diff --git a/src/hooks/useActivateDebug.ts b/src/hooks/useActivateDebug.ts new file mode 100644 index 0000000..3553cdb --- /dev/null +++ b/src/hooks/useActivateDebug.ts @@ -0,0 +1,37 @@ +import { ElMessageBox } from 'element-plus' +import { useSystemStore } from 'stores/systemStore' +import { ref } from 'vue' + +export const useActivateDebug = () => { + const systemStore = useSystemStore() + const logoClickCount = ref(0) + let clickTimeout: NodeJS.Timeout | null = null + + const handleLogoClick = () => { + if (clickTimeout) { + clearTimeout(clickTimeout) + } + logoClickCount.value++ + if (logoClickCount.value === 10) { + console.log('isDebug', systemStore.isDebug) + ElMessageBox.confirm('确认重新加载?', '提示', { + confirmButtonText: '确认', + cancelButtonText: '取消', + closeOnClickModal: false, + type: 'warning', + }) + .finally(() => { + logoClickCount.value = 0 // 重置计数器 + }) + .then(() => { + location.reload() + }) + } + clickTimeout = setTimeout(() => { + logoClickCount.value = 0 // 重置计数器 + }, 1000) + } + return { + handleLogoClick, + } +} diff --git a/src/layouts/default.vue b/src/layouts/default.vue index a96b7a4..6fef414 100644 --- a/src/layouts/default.vue +++ b/src/layouts/default.vue @@ -4,6 +4,7 @@ import WifiConnSvg from 'assets/images/wifi-conn.svg' import WifiUnconnSvg from 'assets/images/wifi-unconn.svg' import NetReconnection from 'components/system/NetReconnection.vue' import { ElMessageBox } from 'element-plus' +import { useActivateDebug } from 'hooks/useActivateDebug' import { delToken } from 'libs/token' import { formatDateTime } from 'libs/utils' import { authRoutes } from 'router/routes' @@ -20,6 +21,8 @@ import { useSealStore } from '@/stores/sealStore' import { useSystemStore } from '@/stores/systemStore' import SystemLog = System.SystemLog +const { handleLogoClick } = useActivateDebug() + // const routes = generateRoutes() // const childrenRoutes = routes.find(r => r.path === '/')?.children || [] const { locale } = useI18n() @@ -224,7 +227,7 @@ const handleCloseAll = async () => {