odc.xiaohui
2023-11-06 fb6fb889fa31e7ba3e28683e53641cd9a4d480f6
src/permission.ts
@@ -10,17 +10,19 @@
import usePermissionStore from '@/store/modules/permission';
NProgress.configure({ showSpinner: false });
const whiteList = ['/login', '/register', '/social-callback'];
const whiteList = ['/login', '/register', '/social-callback','/index'];
router.beforeEach(async (to, from, next) => {
  NProgress.start();
  if (getToken()) {
    console.log('有token',to.path);
    to.meta.title && useSettingsStore().setTitle(to.meta.title as string);
    /* has token*/
    if (to.path === '/login') {
      next({ path: '/' });
      NProgress.done();
    } else {
      console.log(useUserStore().roles);
      if (useUserStore().roles.length === 0) {
        isRelogin.show = true;
        // 判断当前用户是否已拉取完user_info信息
@@ -50,7 +52,8 @@
      // 在免登录白名单,直接进入
      next();
    } else {
      next(`/login?redirect=${to.fullPath}`); // 否则全部重定向到登录页
      // next(`/login?redirect=${to.fullPath}`); // 否则全部重定向到登录页
      next(`/index`); // 否则全部重定向到登录页
      NProgress.done();
    }
  }