From 1cf70e6bb4e80bab839ab6318063682f9d82a8a9 Mon Sep 17 00:00:00 2001 From: ivamp Date: Wed, 6 Nov 2024 18:11:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=20Token=20=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/auto-imports.d.ts | 5 ----- src/plugins/httpInterceptors.ts | 9 ++++++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/auto-imports.d.ts b/src/auto-imports.d.ts index 39054c1..e8f788b 100644 --- a/src/auto-imports.d.ts +++ b/src/auto-imports.d.ts @@ -3,7 +3,6 @@ // @ts-nocheck // noinspection JSUnusedGlobalSymbols // Generated by unplugin-auto-import -// biome-ignore lint: disable export {} declare global { const EffectScope: typeof import('vue')['EffectScope'] @@ -106,7 +105,6 @@ declare module 'vue' { readonly onServerPrefetch: UnwrapRef readonly onUnmounted: UnwrapRef readonly onUpdated: UnwrapRef - readonly onWatcherCleanup: UnwrapRef readonly provide: UnwrapRef readonly reactive: UnwrapRef readonly readonly: UnwrapRef @@ -124,12 +122,9 @@ declare module 'vue' { readonly useAttrs: UnwrapRef readonly useCssModule: UnwrapRef readonly useCssVars: UnwrapRef - readonly useId: UnwrapRef - readonly useModel: UnwrapRef readonly useRoute: UnwrapRef readonly useRouter: UnwrapRef readonly useSlots: UnwrapRef - readonly useTemplateRef: UnwrapRef readonly watch: UnwrapRef readonly watchEffect: UnwrapRef readonly watchPostEffect: UnwrapRef diff --git a/src/plugins/httpInterceptors.ts b/src/plugins/httpInterceptors.ts index 162bf5d..ccc6906 100644 --- a/src/plugins/httpInterceptors.ts +++ b/src/plugins/httpInterceptors.ts @@ -5,6 +5,7 @@ import error401 from "@/pages/errors/401.vue"; import error404 from "@/pages/errors/404.vue"; import error400 from "@/pages/errors/400.vue"; import error500 from "@/pages/errors/500.vue"; +import { useUserStore } from "@/stores/user"; const osThemeRef = useOsTheme(); @@ -19,13 +20,19 @@ const { dialog, loadingBar } = createDiscreteApi( ); const request = { - onFulfilled: (config: any) => { + onFulfilled: async (config: any) => { if (config.headers === undefined) { config.headers = {}; } loadingBar.start(); + const userStore = useUserStore(); + + if (userStore.logined) { + userStore.checkAndRefresh(); + } + return Promise.resolve(config); }, onRejected: (error: any) => {