路由判断调整

This commit is contained in:
fan 2019-11-14 11:26:23 +08:00
parent 3f69644b11
commit 25f7b4f0c9

View File

@ -2,7 +2,6 @@ import Vue from 'vue';
import store from '@/store'; import store from '@/store';
import router from './router'; import router from './router';
import NProgress from 'nprogress'; // Progress 进度条 import NProgress from 'nprogress'; // Progress 进度条
// import 'nprogress/nprogress.css';// Progress 进度条样式
import { admin, userDesign} from './router'; import { admin, userDesign} from './router';
import { getToken, getDesignToken} from '@/utils/auth'; // 验权 import { getToken, getDesignToken} from '@/utils/auth'; // 验权
import { LoginParams } from '@/utils/login'; import { LoginParams } from '@/utils/login';
@ -17,6 +16,14 @@ function hasPermission(roles, permissionRoles) {
const whiteList = ['/login', '/design/login', '/xty/login', '/designxty/login']; // 不重定向白名单 const whiteList = ['/login', '/design/login', '/xty/login', '/designxty/login']; // 不重定向白名单
const designPageRegex = [/^\/design/, /^\/scriptDisplay/, /^\/publish/, /^\/orderauthor/, /^\/system/, /^\/display\/record/, /^\/display\/manage/, /^\/apply/, /^\/plan/, /^\/display\/plan/];
function isDesignPage(toRoutePath) {
return designPageRegex.some(item => {
return item.test(toRoutePath);
});
}
const loginPage = whiteList[0]; const loginPage = whiteList[0];
const loginDesignPage = whiteList[1]; const loginDesignPage = whiteList[1];
@ -35,20 +42,10 @@ function getRouteInfo(to) {
loginPath = loginDesignXtyPage; loginPath = loginDesignXtyPage;
getTokenInfo = getDesignToken; getTokenInfo = getDesignToken;
clientId = LoginParams.Design.clientId; clientId = LoginParams.Design.clientId;
} else if (/^\/design/.test(toRoutePath) || /^\/scriptDisplay/.test(toRoutePath) || /^\/publish/.test(toRoutePath) || /^\/orderauthor/.test(toRoutePath) || /^\/system/.test(toRoutePath) || /^\/display\/record/.test(toRoutePath) || /^\/display\/manage/.test(toRoutePath) || /^\/apply/.test(toRoutePath)) { } else if (isDesignPage(toRoutePath)) {
loginPath = getSessionStorage('project') === 'designxty' ? loginDesignXtyPage : loginDesignPage; loginPath = getSessionStorage('project') === 'designxty' ? loginDesignXtyPage : loginDesignPage;
getTokenInfo = getDesignToken; getTokenInfo = getDesignToken;
clientId = LoginParams.Design.clientId; clientId = LoginParams.Design.clientId;
} else if (/^\/plan/.test(toRoutePath) || /^\/display\/plan/.test(toRoutePath)) {
if (getSessionStorage('project').startsWith('design')) {
loginPath = getSessionStorage('project') === 'designxty' ? loginDesignXtyPage : loginDesignPage;
getTokenInfo = getDesignToken;
clientId = LoginParams.Design.clientId;
} else {
loginPath = getSessionStorage('project') === 'xty' ? loginXtyPage : loginPage;
getTokenInfo = getToken;
clientId = null;
}
} else if ( /^\/xty/.test(toRoutePath)) { } else if ( /^\/xty/.test(toRoutePath)) {
loginPath = loginXtyPage; loginPath = loginXtyPage;
getTokenInfo = getToken; getTokenInfo = getToken;
@ -58,7 +55,6 @@ function getRouteInfo(to) {
getTokenInfo = getToken; getTokenInfo = getToken;
clientId = null; clientId = null;
} }
return { clientId, loginPath, getTokenInfo }; return { clientId, loginPath, getTokenInfo };
} }