src/router/guard.ts
@@ -1,10 +1,10 @@
import type { Router } from 'vue-router';
import { LOGIN_PATH } from '../packages/constants/src';
import { $t } from '../packages/locales/src';
import { preferences } from '../packages/preferences/src';
import { useAccessStore, useDictStore, useUserStore } from '../packages/stores/src';
import { startProgress, stopProgress } from '../packages/utils/src';
import { LOGIN_PATH } from '@vben/constants';
import { $t } from '@vben/locales';
import { preferences } from '@vben/preferences';
import { useAccessStore, useDictStore, useUserStore } from '@vben/stores';
import { startProgress, stopProgress } from '@vben/utils';
import { message } from 'ant-design-vue';
@@ -56,12 +56,14 @@
    const dictStore = useDictStore();
    // 基本路由,这些路由不需要进入权限拦截
    if (coreRouteNames.includes(to.name as string)) {
    // Personal settings are available to every signed-in account and still
    // pass through token validation and user/menu initialization below.
    if (to.name === 'Profile') to.meta.fullPathKey = false;
    if (coreRouteNames.includes(to.name as string) && to.name !== 'Profile') {
      if (to.path === LOGIN_PATH && accessStore.accessToken) {
        return decodeURIComponent(
          (to.query?.redirect as string) ||
            userStore.userInfo?.homePath ||
            preferences.app.defaultHomePath,
            '/analytics',
        );
      }
      return true;
@@ -132,7 +134,7 @@
    userStore.setUserRoles(userRoles);
    const redirectPath = (from.query.redirect ??
      (to.path === preferences.app.defaultHomePath
        ? userInfo?.homePath || preferences.app.defaultHomePath
        ? '/analytics'
        : to.fullPath)) as string;
    return {