Skip to content

Commit c6648b6

Browse files
committed
feat(hooks): deleting the route export of useRoutePush, use vue-router
1 parent bb74d99 commit c6648b6

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/hooks/common/router.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ export function useRouterPush(inSetup = true) {
9292
}
9393

9494
return {
95-
route,
9695
routerPush,
9796
routerBack,
9897
routerPushByKey,

src/store/modules/auth/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { computed, reactive, ref } from 'vue';
22
import { defineStore } from 'pinia';
33
import { useLoading } from '@sa/hooks';
4+
import { useRoute } from 'vue-router';
45
import { SetupStoreId } from '@/enum';
56
import { useRouterPush } from '@/hooks/common/router';
67
import { fetchGetUserInfo, fetchLogin } from '@/service/api';
@@ -11,9 +12,11 @@ import { clearAuthStorage, getToken, getUserInfo } from './shared';
1112

1213
export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
1314
const routeStore = useRouteStore();
14-
const { route, toLogin, redirectFromLogin } = useRouterPush(false);
15+
const { toLogin, redirectFromLogin } = useRouterPush(false);
1516
const { loading: loginLoading, startLoading, endLoading } = useLoading();
1617

18+
const route = useRoute();
19+
1720
const token = ref(getToken());
1821

1922
const userInfo: Api.Auth.UserInfo = reactive(getUserInfo());
@@ -36,7 +39,7 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
3639

3740
authStore.$reset();
3841

39-
if (!route.value.meta.constant) {
42+
if (!route.meta.constant) {
4043
await toLogin();
4144
}
4245

0 commit comments

Comments
 (0)