菜单栏调整

This commit is contained in:
joylink_cuiweidong 2019-09-23 17:47:54 +08:00
parent dc5edddde0
commit 5ba93805c1
8 changed files with 184 additions and 40 deletions

View File

@ -7,6 +7,9 @@
<i class="el-icon-caret-bottom" style="color: #909399;" />
</div>
<el-dropdown-menu slot="dropdown" class="user-dropdown">
<el-dropdown-item v-if="isHavePermission">
<span style="display:block;" @click="selfPermission">{{ $t('router.selfPermission') }}</span>
</el-dropdown-item>
<el-dropdown-item>
<span style="display:block;" @click="language">{{ $t('global.language') }}</span>
</el-dropdown-item>
@ -19,8 +22,9 @@
</template>
<script>
import { getSessionStorage } from '@/utils/auth';
import Language from './Language';
import { UrlConfig } from '@/router/index';
export default {
name: 'Logout',
components: {
@ -28,12 +32,21 @@ export default {
},
data() {
return {
isHavePermission:false,
};
},
},
mounted(){
if(getSessionStorage('design')){
this.isHavePermission=false;
}
else{
this.isHavePermission=true;
}
},
computed: {
username() {
return this.$store.state.user.nickname;
}
},
},
methods: {
language() {
@ -43,7 +56,10 @@ export default {
this.$store.dispatch('LogOut').then(() => {
location.reload(); // vue-router bug
});
}
},
selfPermission(){
this.$router.push({ path: `${UrlConfig.permission.prefix}/manage`});
}
}
};
</script>

View File

@ -3,9 +3,10 @@ import store from '@/store';
import router from './router';
import NProgress from 'nprogress'; // Progress 进度条
import 'nprogress/nprogress.css';// Progress 进度条样式
import { admin } from './router';
import { admin, userDesign} from './router';
import { getToken, getScreenToken, getPlanToken } from '@/utils/auth'; // 验权
import { LoginParams } from '@/utils/login';
import { getSessionStorage } from '@/utils/auth';
function hasPermission(roles, permissionRoles) {
if (roles.indexOf(admin) >= 0) return true;
@ -15,7 +16,7 @@ function hasPermission(roles, permissionRoles) {
const isDev = process.env.NODE_ENV === 'development';
const whiteList = ['/login', '/login1', '/dp/login', '/dp/login1', '/plan/login', '/plan/login1']; // 不重定向白名单
const whiteList = ['/login', '/login1', '/dp/login', '/dp/login1', '/plan/login', '/plan/login1', '/design/login1']; // 不重定向白名单
const loginPage = isDev ? whiteList[1] : whiteList[0];
@ -52,11 +53,15 @@ function handleRoute(to, from, next, routeInfo) {
// 拉取用户信息
store.dispatch('GetInfo', routeInfo.getTokenInfo).then(res => {
// 根据roles权限生成可访问的路由表
// debugger;
const roles = res.roles;
if (getSessionStorage('design')) {
roles.push(userDesign);
}
store.dispatch('GenerateRoutes', { roles, clientId: routeInfo.clientId }).then(() => {
// 动态添加可访问路由表
router.addRoutes(store.getters.addRouters);
// router.addRoutes(asyncRouter1);
if (to.redirectedFrom) {
next({ path: to.redirectedFrom, replace: true });
} else {

View File

@ -11,6 +11,7 @@ import LoginNewScreen from '@/views/login/loginNewScreen';
import LoginScreen from '@/views/login/loginScreen';
import LoginNewPlan from '@/views/login/loginNewPlan';
import LoginPlan from '@/views/login/loginPlan';
import LoginDesign from '@/views/login/loginDesign';
import Jlmap3dedit from '@/views/jlmap3d/edit/jlmap3dedit';
import Jlmap3d from '@/views/jlmap3d/drive/jl3ddrive';
@ -70,6 +71,9 @@ import PlanMonitor from '@/views/planMonitor/index';
import PlanMonitorHome from '@/views/planMonitor/home';
import PlanMonitorDetail from '@/views/planMonitor/detail';
// import DesignPlatform from '@/views/designPlatform/index';
import DesignPlatformHome from '@/views/designPlatform/home';
import Replay from '@/views/replay/index';
import Package from '@/views/package/index';
import PackageDraft from '@/views/package/draft/ruleForm';
@ -142,6 +146,7 @@ export const userLesson = '012'; // 教学系统
export const userSimulation = '013'; // 仿真系统
export const userScreen = '014'; // 大屏系统
export const userPlan = '015'; // 计划系统
export const userDesign='016'; // 设计系统
export const UrlConfig = {
display: '/display',
@ -193,6 +198,12 @@ export const UrlConfig = {
detail: '/plan/detail',
pay: '/plan/pay'
},
design: {
prefix: '/design'
// tool: '/design/tool',
// detail: '/plan/detail',
// pay: '/plan/pay'
},
replay: {
prefix: '/replay'
},
@ -277,6 +288,12 @@ export const constantRoutes = [
component: LoginPlan,
hidden: true
},
// 密码登录
{
path: '/design/login1',
component: LoginDesign,
hidden: true
},
{
path: '/jlmap3d/edit',
component: Jlmap3dedit,
@ -294,19 +311,22 @@ export const constantRoutes = [
hidden: true
},
{
path: '/',
component: Layout,
redirect: '/dashboard',
children: [{
path: 'dashboard',
component: Dashboard,
meta: {
i18n: 'router.homePage',
icon: 'dashboard'
}
}]
},
// {
// path: '/',
// component: Layout,
// redirect: '/dashboard',
// meta: {
// roles: [admin, user]
// },
// children: [{
// path: 'dashboard',
// component: Dashboard,
// meta: {
// i18n: 'router.homePage',
// icon: 'dashboard'
// }
// }]
// },
{ path: '*', redirect: '/404', hidden: true }
];
@ -317,13 +337,54 @@ export const asyncRouter = [
component: Layout,
redirect: '/dashboard',
hidden: true,
meta: {
roles: [admin, user]
},
children: [
{
path: 'dashboard',
component: Dashboard1
component: Dashboard,
meta: {
i18n: 'router.homePage',
icon: 'dashboard'
}
}
]
},
{
path: '/design/home',
redirect: '/design/home/index',
component: Layout,
meta: {
roles: [admin, user, userDesign]
},
children: [
{
path: 'index',
component: DesignPlatformHome,
meta: {
i18n: 'router.homePage',
icon: 'design'
}
}
]
},
// {
// path: '/',
// component: Layout,
// redirect: '/dashboard',
// meta: {
// roles: [admin, user]
// },
// children: [{
// path: 'dashboard',
// component: Dashboard,
// meta: {
// i18n: 'router.homePage',
// icon: 'dashboard'
// }
// }]
// },
{
path: '/display/:mode',
component: Display,
@ -361,7 +422,7 @@ export const asyncRouter = [
path: '/map',
meta: {
i18n: 'router.mapManage',
roles: [admin, mapCreater]
roles: [admin, mapCreater, userDesign]
},
component: Layout,
children: [
@ -426,7 +487,7 @@ export const asyncRouter = [
component: Layout,
meta: {
i18n: 'router.lessaonManage',
roles: [admin, lessonCreater]
roles: [admin, lessonCreater, userDesign]
},
children: [
{
@ -485,7 +546,7 @@ export const asyncRouter = [
path: '/script',
component: Layout,
meta: {
roles: [admin, lessonCreater, user]
roles: [admin, lessonCreater, user, userDesign]
},
children: [
{
@ -515,6 +576,7 @@ export const asyncRouter = [
{
path: '/teach',
component: Layout,
hidden: true,
meta: {
roles: [admin, userLesson, user]
},
@ -561,6 +623,7 @@ export const asyncRouter = [
{
path: '/exam',
component: Layout,
hidden: true,
meta: {
roles: [admin, userExam, user]
},
@ -622,6 +685,7 @@ export const asyncRouter = [
},
{
path: '/demonstration',
hidden: true,
component: Layout,
meta: {
roles: [admin, userSimulation, user]
@ -658,6 +722,7 @@ export const asyncRouter = [
},
{
path: '/dp',
hidden: true,
redirect: '/dp/home',
component: ScreenMonitor,
meta: {
@ -696,7 +761,7 @@ export const asyncRouter = [
redirect: '/plan/home',
component: PlanMonitor,
meta: {
roles: [admin, user]
roles: [admin, user, userDesign]
},
children: [
{
@ -723,7 +788,7 @@ export const asyncRouter = [
path: '/replay',
component: Layout,
meta: {
roles: [admin]
roles: [admin, userDesign]
},
children: [
{
@ -741,6 +806,7 @@ export const asyncRouter = [
meta: {
roles: [admin, user]
},
hidden: true,
children: [
{
path: 'manage',
@ -766,7 +832,7 @@ export const asyncRouter = [
component: Layout,
meta: {
i18n: 'router.pulishManage',
roles: [admin]
roles: [admin, userDesign]
},
children: [
{
@ -857,7 +923,7 @@ export const asyncRouter = [
component: Layout,
meta: {
i18n: 'router.orderAuthorityManage',
roles: [admin]
roles: [admin, userDesign]
},
children: [
{
@ -949,7 +1015,7 @@ export const asyncRouter = [
component: Layout,
meta: {
i18n: 'router.systemManage',
roles: [admin]
roles: [admin, userDesign]
},
children: [
{
@ -1011,6 +1077,26 @@ export const asyncRouter = [
}
]
}
// ,
// {
// path: '/design',
// redirect: '/design/home',
// component: Layout,
// hidden: true,
// meta: {
// roles: [admin, user]
// },
// children: [
// {
// path: 'home',
// component: DesignPlatformHome,
// meta: {
// i18n: 'router.homePage',
// icon: 'design'
// }
// }
// ]
// }
];
const createRouter = () => new Router({

View File

@ -1,6 +1,7 @@
import { asyncRouter, constantRoutes, user, userLesson, userExam, userSimulation, userScreen, userPlan, superAdmin, admin } from '@/router';
import { asyncRouter, constantRoutes, user, userLesson, userExam, userSimulation, userScreen, userPlan, superAdmin, admin, userDesign } from '@/router';
import { PermissionType } from '@/utils/PermissionType';
import { UrlConfig } from '@/router/index';
import { getSessionStorage } from '@/utils/auth';
function setHonePagePath(route, roles) {
if (roles && roles.length === 2 && roles.indexOf(user) >= 0 && (route.path === '/' || route.path === 'dashboard')) {
@ -26,7 +27,16 @@ function setHonePagePath(route, roles) {
function hasPermission(roles, route, parentsRoles) {
setHonePagePath(route, roles);
if (route.meta && route.meta.roles) {
// debugger;
// 如果存在本级路由则使用自己的roles过滤
if (getSessionStorage('design')&& route.meta.roles.indexOf(userDesign)===-1 ) {
route.hidden = true;
} else {
// debugger;
if (!getSessionStorage('design')&&route.meta.roles.indexOf(userDesign)>0) {
route.hidden = true;
}
}
return roles.some(role => route.meta.roles.indexOf(role) >= 0);
} else if (parentsRoles) {
// 如果没有本级路由,有父级路由,则使用父级路由过滤
@ -91,13 +101,15 @@ const permission = {
// 生成其他权限路由
GenerateRoutes({ commit }, data) {
return new Promise(resolve => {
// debugger;
const { roles } = convertRouterRoles(data);
let accessedRouters;
if (roles.indexOf(superAdmin) >= 0) {
accessedRouters = asyncRouter;
} else {
accessedRouters = filterAsyncRouter(asyncRouter, roles);
}
// if (roles.indexOf(superAdmin) >= 0) {
// accessedRouters = asyncRouter;
// } else {
// eslint-disable-next-line prefer-const
accessedRouters = filterAsyncRouter(asyncRouter, roles);
// }
commit('SET_ROUTERS', accessedRouters);
resolve();

View File

@ -1,6 +1,6 @@
import { setSessionStorage } from '@/utils/auth';
import { setSessionStorage, removeSessionStorage } from '@/utils/auth';
import { login, logout, getInfo } from '@/api/login';
import { getToken, setToken, removeToken, removeScreenToken, setScreenToken, getScreenToken, setPlanToken, getPlanToken, removePlanToken, handleToken, handleRemoveToken } from '@/utils/auth';
import { getToken, setToken, removeToken, removeScreenToken, setScreenToken, getScreenToken, setPlanToken, setDesignToken, getPlanToken, removePlanToken, handleToken, handleRemoveToken } from '@/utils/auth';
import { getUserConfigInfo } from '@/api/management/user';
import { LoginParams } from '@/utils/login';
import { creatSubscribe, perpetualTopic } from '@/utils/stomp';
@ -77,6 +77,14 @@ const user = {
const header = { group: '', 'X-Token': getPlanToken() };
creatSubscribe(perpetualTopic, header);
};
} else if (userInfo.type == 'design') {
params = Object.assign({ account: username, password }, LoginParams.Design);
execFc = (token) => {
setDesignToken(token);
commit('SET_TOKENPLAN', token);
const header = { group: '', 'X-Token': getPlanToken() };
creatSubscribe(perpetualTopic, header);
};
} else {
params = Object.assign({ account: username, password }, LoginParams.LianKeTang);
execFc = (token) => {
@ -170,6 +178,7 @@ const user = {
commit('SET_TOKEN', '');
commit('SET_ROLES', []);
commit('SET_ID', '');
removeSessionStorage('design');
handleRemoveToken();
resolve();
}).catch(error => {

View File

@ -7,6 +7,8 @@ const TokenScreenKey = 'Screen-Token';
const TokenPlanKey = 'Plan-Token';
const TokenDesignKey='Admin-Token';
// 设置教学实训仿真系统token
export function getToken() {
return SessionStorage.getItem(TokenKey);
@ -28,6 +30,17 @@ export function removeScreenToken() {
return SessionStorage.removeItem(TokenScreenKey);
}
// 设置城市轨道交通设计平台token
export function getDesignToken() {
return SessionStorage.getItem(TokenDesignKey);
}
export function setDesignToken(token) {
return SessionStorage.setItem(TokenDesignKey, token);
}
export function removeDesignToken() {
return SessionStorage.removeItem(TokenDesignKey);
}
// 设置琏计划token
export function getPlanToken() {
return SessionStorage.getItem(TokenPlanKey);

View File

@ -4,5 +4,6 @@ export const LoginParams = {
LianKeTang: { clientId: '1', secret: 'joylink' }, // "琏课堂"
DaPing: { clientId: '2', secret: 'bigscreen' }, // "大屏系统"
LianJiHua: { clientId: '3', secret: 'linkplan' }, // "琏计划"
Assistant: { clientId: '4', secret: 'linkassistant' } // "琏课堂助手"
Assistant: { clientId: '4', secret: 'linkassistant' }, // "琏课堂助手"
Design: { clientId: '1', secret: 'joylink' } // "城市轨道交通设计平台"
};

View File

@ -33,7 +33,8 @@
</el-form-item>
<el-form-item>
<span class="svg-container" />
<el-radio>琏课堂</el-radio>
<!-- <el-radio>琏课堂</el-radio> -->
<el-radio>城市轨道交通实训平台</el-radio>
</el-form-item>
<div class="tip-message">{{ tipsMsg }}</div>
<el-form-item>
@ -80,7 +81,8 @@ export default {
};
},
mounted() {
document.title = '琏课堂';
// document.title = '';
document.title = '城市轨道交通实训平台';
},
methods: {
showPwd() {