eight
2025-04-11 e89834c34e8f987cd59a167aa8c8369a731ef44c
src/App.vue
@@ -4,8 +4,15 @@
import { useDesign } from '@/hooks/web/useDesign'
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
import routerSearch from '@/components/RouterSearch/index.vue'
import {useUserStore} from "@/store/modules/user";
import {useTagsViewStore} from "@/store/modules/tagsView";
import {getAccessToken} from "@/utils/auth";
defineOptions({ name: 'APP' })
const userStore = useUserStore()
const tagsViewStore = useTagsViewStore()
const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('app')
@@ -23,6 +30,26 @@
  appStore.setIsDark(isDarkTheme)
}
setDefaultTheme()
/** 初始化 **/
onMounted(() => {
  window.addEventListener('unload', handleUnload);
})
onBeforeUnmount(() => {
  window.removeEventListener('unload', handleUnload);
})
const handleUnload = async () => {
  //await userStore.loginOut()
  if (getAccessToken()) {
    const loginouturl = import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL + '/system/auth/logout' + '?token=' + getAccessToken()
    navigator.sendBeacon(loginouturl, JSON.stringify(""))
  }
  tagsViewStore.delAllViews()
}
</script>
<template>
  <ConfigGlobal :size="currentSize">