From c6648b6c8b4bf83e26c0746cb38f2593f6a5c485 Mon Sep 17 00:00:00 2001 From: paynezhuang Date: Mon, 15 Apr 2024 16:20:30 +0800 Subject: [PATCH] feat(hooks): deleting the route export of useRoutePush, use vue-router --- src/hooks/common/router.ts | 1 - src/store/modules/auth/index.ts | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/hooks/common/router.ts b/src/hooks/common/router.ts index bc5277d7..89374b7f 100644 --- a/src/hooks/common/router.ts +++ b/src/hooks/common/router.ts @@ -92,7 +92,6 @@ export function useRouterPush(inSetup = true) { } return { - route, routerPush, routerBack, routerPushByKey, diff --git a/src/store/modules/auth/index.ts b/src/store/modules/auth/index.ts index 1654bccd..d3ff2b4c 100644 --- a/src/store/modules/auth/index.ts +++ b/src/store/modules/auth/index.ts @@ -1,6 +1,7 @@ import { computed, reactive, ref } from 'vue'; import { defineStore } from 'pinia'; import { useLoading } from '@sa/hooks'; +import { useRoute } from 'vue-router'; import { SetupStoreId } from '@/enum'; import { useRouterPush } from '@/hooks/common/router'; import { fetchGetUserInfo, fetchLogin } from '@/service/api'; @@ -11,9 +12,11 @@ import { clearAuthStorage, getToken, getUserInfo } from './shared'; export const useAuthStore = defineStore(SetupStoreId.Auth, () => { const routeStore = useRouteStore(); - const { route, toLogin, redirectFromLogin } = useRouterPush(false); + const { toLogin, redirectFromLogin } = useRouterPush(false); const { loading: loginLoading, startLoading, endLoading } = useLoading(); + const route = useRoute(); + const token = ref(getToken()); const userInfo: Api.Auth.UserInfo = reactive(getUserInfo()); @@ -36,7 +39,7 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => { authStore.$reset(); - if (!route.value.meta.constant) { + if (!route.meta.constant) { await toLogin(); }