From 25f7b4f0c96f74000774deaffc9aa6f9b20948e3 Mon Sep 17 00:00:00 2001 From: fan <18706759286@163.com> Date: Thu, 14 Nov 2019 11:26:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=AF=E7=94=B1=E5=88=A4=E6=96=AD=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/permission.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/permission.js b/src/permission.js index a321cc4fb..6d9573c38 100644 --- a/src/permission.js +++ b/src/permission.js @@ -2,7 +2,6 @@ import Vue from 'vue'; import store from '@/store'; import router from './router'; import NProgress from 'nprogress'; // Progress 进度条 -// import 'nprogress/nprogress.css';// Progress 进度条样式 import { admin, userDesign} from './router'; import { getToken, getDesignToken} from '@/utils/auth'; // 验权 import { LoginParams } from '@/utils/login'; @@ -17,6 +16,14 @@ function hasPermission(roles, permissionRoles) { 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 loginDesignPage = whiteList[1]; @@ -35,20 +42,10 @@ function getRouteInfo(to) { loginPath = loginDesignXtyPage; getTokenInfo = getDesignToken; 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; getTokenInfo = getDesignToken; 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)) { loginPath = loginXtyPage; getTokenInfo = getToken; @@ -58,7 +55,6 @@ function getRouteInfo(to) { getTokenInfo = getToken; clientId = null; } - return { clientId, loginPath, getTokenInfo }; }