| | |
| | | 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') |
| | |
| | | } |
| | | 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() |
| | | } |
| | | |
| | | // 注意:这里不要在 unload 时调用登出(也不要用 sendBeacon 打 /system/auth/logout)。 |
| | | // 后端 logout 会把 refresh token 一并删除,导致页面刷新/关闭后重新打开时无法续期, |
| | | // 只能弹「登录超时,请重新登录」并整页跳转,用户原来打开的页面全部丢失。 |
| | | // 需要离开座位请用页面内的「离座」,需要结束会话请用右上角「退出系统」。 |
| | | </script> |
| | | <template> |
| | | <ConfigGlobal :size="currentSize"> |