Skip to content

Commit

Permalink
feat(hooks): deleting the route export of useRoutePush, use vue-router
Browse files Browse the repository at this point in the history
  • Loading branch information
paynezhuang committed Apr 15, 2024
1 parent bb74d99 commit c6648b6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/hooks/common/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ export function useRouterPush(inSetup = true) {
}

return {
route,
routerPush,
routerBack,
routerPushByKey,
Expand Down
7 changes: 5 additions & 2 deletions src/store/modules/auth/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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());
Expand All @@ -36,7 +39,7 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {

authStore.$reset();

if (!route.value.meta.constant) {
if (!route.meta.constant) {
await toLogin();
}

Expand Down

0 comments on commit c6648b6

Please sign in to comment.