改进 Token 刷新
All checks were successful
Build / build (push) Successful in 3m45s

This commit is contained in:
ivamp 2024-11-06 18:11:39 +08:00
parent b0f52ca420
commit 1cf70e6bb4
2 changed files with 8 additions and 6 deletions

View File

@ -3,7 +3,6 @@
// @ts-nocheck // @ts-nocheck
// noinspection JSUnusedGlobalSymbols // noinspection JSUnusedGlobalSymbols
// Generated by unplugin-auto-import // Generated by unplugin-auto-import
// biome-ignore lint: disable
export {} export {}
declare global { declare global {
const EffectScope: typeof import('vue')['EffectScope'] const EffectScope: typeof import('vue')['EffectScope']
@ -106,7 +105,6 @@ declare module 'vue' {
readonly onServerPrefetch: UnwrapRef<typeof import('vue')['onServerPrefetch']> readonly onServerPrefetch: UnwrapRef<typeof import('vue')['onServerPrefetch']>
readonly onUnmounted: UnwrapRef<typeof import('vue')['onUnmounted']> readonly onUnmounted: UnwrapRef<typeof import('vue')['onUnmounted']>
readonly onUpdated: UnwrapRef<typeof import('vue')['onUpdated']> readonly onUpdated: UnwrapRef<typeof import('vue')['onUpdated']>
readonly onWatcherCleanup: UnwrapRef<typeof import('vue')['onWatcherCleanup']>
readonly provide: UnwrapRef<typeof import('vue')['provide']> readonly provide: UnwrapRef<typeof import('vue')['provide']>
readonly reactive: UnwrapRef<typeof import('vue')['reactive']> readonly reactive: UnwrapRef<typeof import('vue')['reactive']>
readonly readonly: UnwrapRef<typeof import('vue')['readonly']> readonly readonly: UnwrapRef<typeof import('vue')['readonly']>
@ -124,12 +122,9 @@ declare module 'vue' {
readonly useAttrs: UnwrapRef<typeof import('vue')['useAttrs']> readonly useAttrs: UnwrapRef<typeof import('vue')['useAttrs']>
readonly useCssModule: UnwrapRef<typeof import('vue')['useCssModule']> readonly useCssModule: UnwrapRef<typeof import('vue')['useCssModule']>
readonly useCssVars: UnwrapRef<typeof import('vue')['useCssVars']> readonly useCssVars: UnwrapRef<typeof import('vue')['useCssVars']>
readonly useId: UnwrapRef<typeof import('vue')['useId']>
readonly useModel: UnwrapRef<typeof import('vue')['useModel']>
readonly useRoute: UnwrapRef<typeof import('vue-router/auto')['useRoute']> readonly useRoute: UnwrapRef<typeof import('vue-router/auto')['useRoute']>
readonly useRouter: UnwrapRef<typeof import('vue-router/auto')['useRouter']> readonly useRouter: UnwrapRef<typeof import('vue-router/auto')['useRouter']>
readonly useSlots: UnwrapRef<typeof import('vue')['useSlots']> readonly useSlots: UnwrapRef<typeof import('vue')['useSlots']>
readonly useTemplateRef: UnwrapRef<typeof import('vue')['useTemplateRef']>
readonly watch: UnwrapRef<typeof import('vue')['watch']> readonly watch: UnwrapRef<typeof import('vue')['watch']>
readonly watchEffect: UnwrapRef<typeof import('vue')['watchEffect']> readonly watchEffect: UnwrapRef<typeof import('vue')['watchEffect']>
readonly watchPostEffect: UnwrapRef<typeof import('vue')['watchPostEffect']> readonly watchPostEffect: UnwrapRef<typeof import('vue')['watchPostEffect']>

View File

@ -5,6 +5,7 @@ import error401 from "@/pages/errors/401.vue";
import error404 from "@/pages/errors/404.vue"; import error404 from "@/pages/errors/404.vue";
import error400 from "@/pages/errors/400.vue"; import error400 from "@/pages/errors/400.vue";
import error500 from "@/pages/errors/500.vue"; import error500 from "@/pages/errors/500.vue";
import { useUserStore } from "@/stores/user";
const osThemeRef = useOsTheme(); const osThemeRef = useOsTheme();
@ -19,13 +20,19 @@ const { dialog, loadingBar } = createDiscreteApi(
); );
const request = { const request = {
onFulfilled: (config: any) => { onFulfilled: async (config: any) => {
if (config.headers === undefined) { if (config.headers === undefined) {
config.headers = {}; config.headers = {};
} }
loadingBar.start(); loadingBar.start();
const userStore = useUserStore();
if (userStore.logined) {
userStore.checkAndRefresh();
}
return Promise.resolve(config); return Promise.resolve(config);
}, },
onRejected: (error: any) => { onRejected: (error: any) => {