Browse Source

fix: 点击logo10次触发重新加载

master
guoapeng 1 week ago
parent
commit
936069d5d9
  1. 37
      src/hooks/useActivateDebug.ts
  2. 5
      src/layouts/default.vue

37
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,
}
}

5
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 () => {
<template>
<el-container class="main">
<el-header class="header">
<div class="logo">
<div class="logo" @click="handleLogoClick">
<img src="../assets/images/logo.svg" alt="">
</div>
<div class="header-menu">

Loading…
Cancel
Save