From eafc031e3e6e48778d22b5455358273714944012 Mon Sep 17 00:00:00 2001
From: Your Name <123456>
Date: 星期一, 05 九月 2022 09:53:16 +0800
Subject: [PATCH] Merge branch 'master' of https://sinanoaq.cn:8888/r/gtqt
---
src/router/index.ts | 45 +++++++++++++++++++++++++--------------------
1 files changed, 25 insertions(+), 20 deletions(-)
diff --git a/src/router/index.ts b/src/router/index.ts
index 5fe7e90..11ec534 100644
--- a/src/router/index.ts
+++ b/src/router/index.ts
@@ -11,6 +11,7 @@
import { initFrontEndControlRoutes } from '/@/router/frontEnd';
import { initBackEndControlRoutes } from '/@/router/backEnd';
import { useUserInfo } from '/@/stores/userInfo';
+import { nextTick } from 'vue';
// 读取 `/src/stores/themeConfig.ts` 是否开启后端控制路由配置
const storesThemeConfig = useThemeConfig(pinia);
@@ -65,31 +66,35 @@
// 路由加载前
router.beforeEach(async (to, from, next) => {
- NProgress.configure({ showSpinner: false });
- if (to.meta.title) NProgress.start();
- const token = Session.get('token');
- if (to.path === '/login' && !token) {
+ if (to.path === '/intelligentLine') {
next();
- NProgress.done();
} else {
- if (!token) {
- next(`/login?redirect=${to.path}¶ms=${JSON.stringify(to.query ? to.query : to.params)}`);
- Session.clear();
- NProgress.done();
- } else if (token && to.path === '/login') {
- next('/homeMenu');
+ NProgress.configure({ showSpinner: false });
+ if (to.meta.title) NProgress.start();
+ const token = Session.get('token');
+ if (to.path === '/login' && !token) {
+ next();
NProgress.done();
} else {
- const storesRoutesList = useRoutesList(pinia);
- const { routesList } = storeToRefs(storesRoutesList);
- if (routesList.value.length === 0) {
- // 后端控制路由:路由数据初始化,防止刷新时丢失
- await initBackEndControlRoutes();
- // 动态添加路由:防止非首页刷新时跳转回首页的问题
- // 确保 addRoute() 时动态添加的路由已经被完全加载上去
- next({ ...to, replace: true });
+ if (!token) {
+ next(`/login?redirect=${to.path}¶ms=${JSON.stringify(to.query ? to.query : to.params)}`);
+ Session.clear();
+ NProgress.done();
+ } else if (token && to.path === '/login') {
+ next('/homeMenu');
+ NProgress.done();
} else {
- next();
+ const storesRoutesList = useRoutesList(pinia);
+ const { routesList } = storeToRefs(storesRoutesList);
+ if (routesList.value.length === 0) {
+ // 后端控制路由:路由数据初始化,防止刷新时丢失
+ await initBackEndControlRoutes();
+ // 动态添加路由:防止非首页刷新时跳转回首页的问题
+ // 确保 addRoute() 时动态添加的路由已经被完全加载上去
+ next({ ...to, replace: true });
+ } else {
+ next();
+ }
}
}
}
--
Gitblit v1.9.2