兰宝车间质量管理系统-前端
src/permission.ts
@@ -15,11 +15,13 @@
router.beforeEach(async (to, from, next) => {
  NProgress.start();
  if (getToken()) {
    to.meta.title && useSettingsStore().setTitle(to.meta.title as string);
    to.meta.title && useSettingsStore().setTitle(to.meta.title);
    /* has token*/
    if (to.path === '/login') {
      next({ path: '/' });
      NProgress.done();
    } else if (whiteList.indexOf(to.path as string) !== -1) {
      next();
    } else {
      if (useUserStore().roles.length === 0) {
        isRelogin.show = true;
@@ -38,7 +40,7 @@
              router.addRoute(route); // 动态添加可访问路由表
            }
          });
          next({ ...to, replace: true }); // hack方法 确保addRoutes已完成
          next({ path: to.path, replace: true, params: to.params, query: to.query, hash: to.hash, name: to.name as string }); // hack方法 确保addRoutes已完成
        }
      } else {
        next();
@@ -46,7 +48,7 @@
    }
  } else {
    // 没有token
    if (whiteList.indexOf(to.path) !== -1) {
    if (whiteList.indexOf(to.path as string) !== -1) {
      // 在免登录白名单,直接进入
      next();
    } else {