|
|
@@ -25,6 +25,8 @@ const router = new VueRouter({
|
|
|
* 路由守卫
|
|
|
*/
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
+ console.log(to, 'beforeEach-to');
|
|
|
+ console.log(from, 'beforeEach-from');
|
|
|
if (!from.path.includes(REDIRECT_PATH)) {
|
|
|
NProgress.start();
|
|
|
}
|
|
|
@@ -52,6 +54,16 @@ router.beforeEach((to, from, next) => {
|
|
|
next();
|
|
|
});
|
|
|
} else {
|
|
|
+ // 判断外链并跳转
|
|
|
+ if (to.meta) {
|
|
|
+ if (to.meta.source && to.meta.source == 2) {
|
|
|
+ next({
|
|
|
+ path: `/page-main-data/source`,
|
|
|
+ query: { link: to.meta.path }
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
// console.log(router.getRoutes(), 'router', routes);
|
|
|
if (routes.length >= router.getRoutes()?.length) {
|
|
|
router.addRoute(
|
|
|
@@ -87,23 +99,35 @@ router.roleChange = async ({ menus, homePath, authoritiesRouter }) => {
|
|
|
const currentUser = JSON.parse(sessionStorage['currentUser']);
|
|
|
|
|
|
if (menus && menus.length > 0) {
|
|
|
- router.addRoute(
|
|
|
- getMenuRoutes([...menus, ...authoritiesRouter], homePath)
|
|
|
- );
|
|
|
+ router.addRoute(getMenuRoutes([...menus, ...authoritiesRouter], homePath));
|
|
|
if (router.currentRoute.path != (menus[0].redirect || menus[0].path)) {
|
|
|
await router.replace({
|
|
|
- path: menus[0].redirect || menus[0].path,
|
|
|
- })
|
|
|
+ path: menus[0].redirect || menus[0].path
|
|
|
+ });
|
|
|
}
|
|
|
-
|
|
|
- const newToken = await changeRole({ groupId: currentUser.currentGroupId, roleId: currentUser.currentRoleId })
|
|
|
- setToken(newToken)
|
|
|
+
|
|
|
+ const newToken = await changeRole({
|
|
|
+ groupId: currentUser.currentGroupId,
|
|
|
+ roleId: currentUser.currentRoleId
|
|
|
+ });
|
|
|
+ setToken(newToken);
|
|
|
setTimeout(() => {
|
|
|
- ['vuex-eos','vuex-wt','vuex-aps','vuex-mes','vuex-eam','vuex-pro','vuex-fm','vuex-main-data','vuex-wms','vuex-qms','vuex-vis'].forEach((key) => {
|
|
|
+ [
|
|
|
+ 'vuex-eos',
|
|
|
+ 'vuex-wt',
|
|
|
+ 'vuex-aps',
|
|
|
+ 'vuex-mes',
|
|
|
+ 'vuex-eam',
|
|
|
+ 'vuex-pro',
|
|
|
+ 'vuex-fm',
|
|
|
+ 'vuex-main-data',
|
|
|
+ 'vuex-wms',
|
|
|
+ 'vuex-qms',
|
|
|
+ 'vuex-vis'
|
|
|
+ ].forEach((key) => {
|
|
|
sessionStorage.removeItem(key);
|
|
|
});
|
|
|
- window.location.reload()
|
|
|
-
|
|
|
+ window.location.reload();
|
|
|
}, 100);
|
|
|
}
|
|
|
|