From 49ac7ba919346bdc3f293109a705d7c132adf8b5 Mon Sep 17 00:00:00 2001 From: zyy <1787816799@qq.com> Date: Thu, 9 Jul 2020 10:16:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=B7=AF=E7=94=B1=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E6=9D=83=E9=99=90=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/permission.js | 61 ++++++++++++------------ src/router/index_Common.js | 2 +- src/scripts/ProjectConfig.js | 90 ++++++++++++++++++------------------ 3 files changed, 76 insertions(+), 77 deletions(-) diff --git a/src/permission.js b/src/permission.js index 6eab0fc57..1bf6726f0 100644 --- a/src/permission.js +++ b/src/permission.js @@ -4,10 +4,8 @@ import router from './router/index_APP_TARGET'; import {PermissionParam} from '@/scripts/ProjectConfig'; import NProgress from 'nprogress'; import 'nprogress/nprogress.css'; -import { admin} from './router/index_APP_TARGET'; -import { getToken, removeToken} from '@/utils/auth'; -// import { LoginParams } from '@/utils/login'; -import { getSessionStorage } from '@/utils/auth'; +import { admin } from './router/index_APP_TARGET'; +import { getToken, removeToken, getSessionStorage } from '@/utils/auth'; import localStore from 'storejs'; import { loginInfo } from '@/scripts/ProjectConfig'; @@ -19,18 +17,18 @@ function hasPermission(roles, permissionRoles) { const whiteList = ['/login', '/design/login', '/gzzbxy/relay']; // 不重定向白名单 -const designPageRegex = [/^\/design/, /^\/scriptDisplay/, /^\/publish/, /^\/orderauthor/, /^\/system/, /^\/iscs/, /^\/display\/record/, /^\/display\/manage/, /^\/apply/, /^\/plan/, /^\/display\/plan/, /^\/displayNew\/record/, /^\/displayNew\/manage/, /^\/displayNew\/plan/, /^\/practiceDisplayNew/, /^\/bigSplitScreen/]; +// const designPageRegex = [/^\/design/, /^\/scriptDisplay/, /^\/publish/, /^\/orderauthor/, /^\/system/, /^\/iscs/, /^\/display\/record/, /^\/display\/manage/, /^\/apply/, /^\/plan/, /^\/display\/plan/, /^\/displayNew\/record/, /^\/displayNew\/manage/, /^\/displayNew\/plan/, /^\/practiceDisplayNew/, /^\/bigSplitScreen/]; -function isDesignPage(toRoutePath) { - return designPageRegex.some(item => item.test(toRoutePath) ); -} +// function isDesignPage(toRoutePath) { +// return designPageRegex.some(item => item.test(toRoutePath) ); +// } for (const val in PermissionParam) { - if (PermissionParam[val].whitePage) { + if (PermissionParam[val].whitePage && !whiteList.includes(PermissionParam[val].whitePage)) { whiteList.push(PermissionParam[val].whitePage); } } -const loginPage = whiteList[0]; -const loginDesignPage = whiteList[1]; +// const loginPage = whiteList[0]; +// const loginDesignPage = whiteList[1]; // 获取路径数据 function getRouteInfo(to) { @@ -41,25 +39,26 @@ function getRouteInfo(to) { removeToken(); } - if (isDesignPage(toRoutePath)) { - const whitePage = PermissionParam[current_session] ? PermissionParam[current_session].whitePage : ''; - loginPath = whitePage || loginDesignPage; - } else { - const whitePage = PermissionParam[current_session] ? PermissionParam[current_session].whitePage : ''; - loginPath = whitePage || loginPage; - if (to.query.projectDevice && to.query.type) { - loginPath = `${loginPath}&projectDevice=${to.query.projectDevice}&type=${to.query.type}`; - } - if (current_session && current_session == 'jsxt' || current_session && current_session == 'refereeJsxt') { - const raceId = getSessionStorage('raceId'); // 登陆时候保存 竞赛id - loginPath = `${loginPath}?raceId=${raceId}`; - } + // if (isDesignPage(toRoutePath)) { + // const whitePage = PermissionParam[current_session] ? PermissionParam[current_session].whitePage : ''; + // loginPath = whitePage || loginDesignPage; + // } else { + // const whitePage = PermissionParam[current_session] ? PermissionParam[current_session].whitePage : ''; + // loginPath = whitePage || loginPage; + // } + loginPath = PermissionParam[current_session] ? PermissionParam[current_session].whitePage : whiteList[0]; + if (to.query.projectDevice && to.query.type) { + loginPath = `${loginPath}&projectDevice=${to.query.projectDevice}&type=${to.query.type}`; + } + if (current_session && current_session == 'jsxt' || current_session && current_session == 'refereeJsxt') { + const raceId = getSessionStorage('raceId'); // 登陆时候保存 竞赛id + loginPath = `${loginPath}?raceId=${raceId}`; } - return { loginPath }; + return loginPath; } -function handleRoute(to, next, routeInfo) { +function handleRoute(to, next, loginPath) { if (store.getters.roles.length === 0) { store.dispatch('GetInfo', getToken()).then(res => { // 根据roles权限生成可访问的路由表 @@ -76,7 +75,7 @@ function handleRoute(to, next, routeInfo) { }).catch(() => { store.dispatch('FedLogOut').then(() => { Vue.prototype.$messageBox('验证失败,请重新登录!'); - next({ path: routeInfo.loginPath }); + next({ path: loginPath }); }); }); } else { @@ -99,14 +98,14 @@ router.beforeEach((to, from, next) => { document.title = loginInfo[project || 'login'].browserTitle || loginInfo[project || 'login'].title; NProgress.start(); - const routeInfo = getRouteInfo(to); + const loginPath = getRouteInfo(to); if (getToken()) { - if (to.path === routeInfo.loginPath) { + if (to.path === loginPath) { // 登录页面不拦截 next(); } else { // 进入系统重新计算路由 - handleRoute(to, next, routeInfo); + handleRoute(to, next, loginPath); } } else { if (whiteList.indexOf(to.path) !== -1) { @@ -118,7 +117,7 @@ router.beforeEach((to, from, next) => { next(); } else { // 否则全部重定向到登录页 - next(routeInfo.loginPath); + next(loginPath); } } }); diff --git a/src/router/index_Common.js b/src/router/index_Common.js index f3723208a..70e873759 100644 --- a/src/router/index_Common.js +++ b/src/router/index_Common.js @@ -227,7 +227,7 @@ export const constantRoutes = [ hidden: true }, { - path: '/gzzbxy/relay/:deviceid', + path: '/gzzbxy/relay/:deviceid', // 贵阳 继电器 component: Jlmap3dTrain, hidden: true }, diff --git a/src/scripts/ProjectConfig.js b/src/scripts/ProjectConfig.js index 4350b5d43..deb3dc888 100644 --- a/src/scripts/ProjectConfig.js +++ b/src/scripts/ProjectConfig.js @@ -8,7 +8,7 @@ import FaviconJyd from '@/assets/icon/favicon_jyd.png'; import Bottom_Jyd from '@/assets/icon/bottom_jyd.png'; import Link_Jyd from '@/assets/icon/link_jyd.png'; import FaviconTky from '@/assets/icon/favicon_tky.png'; -import { LoginParams } from '@/utils/login'; +// import { LoginParams } from '@/utils/login'; // title:页面title; loginPath:退出登录跳转路径; loginParam:登录接口参数project;loginTitle:登录页左上角title;logoWidth:登录页左上角logo宽度; // homeTitle:导航栏title(没有采用title); browserTitle:浏览器窗口title;bottomColumn:底部栏描述;bottomIcon:底部栏Icon;linkIcon:浏览器窗口icon(没有采用ProjectIcon) @@ -224,96 +224,96 @@ export const goOtherPlatformMenu = { // 导航栏快速切换平台 }; export const PermissionParam = { // 路径权限处理所需参数配置(跳转白名单&路径正则匹配&clientId) hyd: { - // systemType: '011' whitePage: '/login?project=hyd', - reg: /^\/hyd/, - systemType: '011', - clientId: null + // reg: /^\/hyd/, + systemType: '011' + // clientId: null }, designhyd: { - // systemType: '011' whitePage: '/design/login?project=hyd', - reg: /^\/designhyd/, - systemType: '011', - clientId: LoginParams.Design.clientId + // reg: /^\/designhyd/, + systemType: '011' + // clientId: LoginParams.Design.clientId }, login: { + whitePage: '/login', systemType: '011' }, design: { + whitePage: '/design/login', systemType: '011' }, designxty: { whitePage: '/design/login?project=xty', - reg: /^\/designxty/, - systemType: '013', - clientId: LoginParams.Design.clientId + // reg: /^\/designxty/, + systemType: '013' + // clientId: LoginParams.Design.clientId }, designgzb: { whitePage: '/design/login?project=gzb', - reg: /^\/designgzb/, - systemType: '014', - clientId: LoginParams.Design.clientId + // reg: /^\/designgzb/, + systemType: '014' + // clientId: LoginParams.Design.clientId }, designxadt: { whitePage: '/design/login?project=xadt', - reg: /^\/designxadt/, - systemType: '012', - clientId: LoginParams.Design.clientId + // reg: /^\/designxadt/, + systemType: '012' + // clientId: LoginParams.Design.clientId }, designjyd: { whitePage: '/design/login?project=jyd', - reg: /^\/designjyd/, - systemType: '017', - clientId: LoginParams.Design.clientId + // reg: /^\/designjyd/, + systemType: '017' + // clientId: LoginParams.Design.clientId }, designtky: { whitePage: '/design/login?project=tky', - reg: /^\/designtky/, - systemType: '018', - clientId: LoginParams.Design.clientId + // reg: /^\/designtky/, + systemType: '018' + // clientId: LoginParams.Design.clientId }, xty: { whitePage: '/login?project=xty', - reg: /^\/xty/, - systemType: '013', - clientId: null + // reg: /^\/xty/, + systemType: '013' + // clientId: null }, gzb: { whitePage: '/login?project=gzb', - reg: /^\/gzb/, - systemType: '014', - clientId: null + // reg: /^\/gzb/, + systemType: '014' + // clientId: null }, xadt: { whitePage: '/login?project=xadt', - reg: /^\/xadt/, - systemType: '012', - clientId: null + // reg: /^\/xadt/, + systemType: '012' + // clientId: null }, jyd: { whitePage: '/login?project=jyd', - reg: /^\/jyd/, - systemType: '017', - clientId: null + // reg: /^\/jyd/, + systemType: '017' + // clientId: null }, tky: { whitePage: '/login?project=tky', - reg: /^\/tky/, - systemType: '018', - clientId: null + // reg: /^\/tky/, + systemType: '018' + // clientId: null }, jsxt: { whitePage: '/jsxt/login', - reg: /^\/jsxt/, - systemType: '015', - clientId: null + // reg: /^\/jsxt/, + systemType: '015' + // clientId: null }, refereeJsxt: { whitePage: '/refereeJsxt/login', - reg: /^\/refereeJsxt/, - systemType: '015', - clientId: LoginParams.Design.clientId + // reg: /^\/refereeJsxt/, + systemType: '015' + // clientId: LoginParams.Design.clientId } }; export const ProjectList = [