From 62de921294e5ba699c16c7670eb05b62f38f13f7 Mon Sep 17 00:00:00 2001 From: fan <18706759286@163.com> Date: Wed, 23 Oct 2019 19:00:35 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=AE=E9=A2=98=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/components/Logout.vue | 16 ++++++++-------- src/layout/components/Navbar.vue | 33 ++++++-------------------------- src/permission.js | 13 ++++++++++--- src/router/index.js | 24 +++++++++++------------ src/store/getters.js | 1 + 5 files changed, 37 insertions(+), 50 deletions(-) diff --git a/src/layout/components/Logout.vue b/src/layout/components/Logout.vue index 79b08b345..c212eefcc 100644 --- a/src/layout/components/Logout.vue +++ b/src/layout/components/Logout.vue @@ -34,13 +34,13 @@ export default { data() { return { }; - }, - mounted(){ - }, + }, computed: { username() { return this.$store.state.user.nickname; - }, + } + }, + mounted() { }, methods: { language() { @@ -50,10 +50,10 @@ export default { this.$store.dispatch('LogOut').then(() => { location.reload(); // 为了重新实例化vue-router对象 避免bug }); - }, - selfPermission(){ - this.$router.push({ path: `${UrlConfig.permission.prefix}/manage`}); - } + }, + selfPermission() { + this.$router.push({ path: `${UrlConfig.permission.prefix}/manage`}); + } } }; diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index 6dd8b02eb..54949c87f 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -70,8 +70,7 @@
- -
+
城市轨道交通实训平台 @@ -157,13 +156,13 @@ export default { return true; } return false; - }, - goToTraining(){ - let routeData = this.$router.resolve({ - path: "/", + }, + goToTraining() { + const routeData = this.$router.resolve({ + path: '/' }); window.open(routeData.href, '_blank'); - } + } } }; @@ -202,26 +201,6 @@ export default { display: inline-block; position: relative; margin-right:10px; - // position: absolute; - // right: 35px; - - .avatar-wrapper { - cursor: pointer; - position: relative; - - .user-avatar { - width: 40px; - height: 40px; - border-radius: 10px; - } - - .el-icon-caret-bottom { - position: absolute; - right: -20px; - top: 25px; - font-size: 12px; - } - } } } diff --git a/src/permission.js b/src/permission.js index f26e99c7d..f26236303 100644 --- a/src/permission.js +++ b/src/permission.js @@ -5,9 +5,9 @@ import NProgress from 'nprogress'; // Progress 进度条 import 'nprogress/nprogress.css';// Progress 进度条样式 import { admin, userDesign} from './router'; import { getToken, getScreenToken, getDesignToken} from '@/utils/auth'; // 验权 -// getPlanToken import { LoginParams } from '@/utils/login'; import { getSessionStorage } from '@/utils/auth'; +import localStore from 'storejs'; function hasPermission(roles, permissionRoles) { if (roles.indexOf(admin) >= 0) return true; @@ -29,7 +29,6 @@ function getRouteInfo(to) { let getTokenInfo = () => { }; let clientId = ''; const toRoutePath = to.redirectedFrom || to.path; - if (/^\/dp/.test(toRoutePath) || /^\/display\/dp/.test(toRoutePath)) { loginPath = loginScreenPage; getTokenInfo = getScreenToken; @@ -88,7 +87,15 @@ function handleRoute(to, from, next, routeInfo) { } else { // 除没有动态改变权限的需求可直接next() 删下方权限判断 if (hasPermission(store.getters.roles, to.meta.roles)) { - next(); + if (to.path==='/404' && to.redirectedFrom==='/') { + if (getSessionStorage('design') === 'true') { + next('/design/home'); + } else { + next(localStore.get('trainingPlatformRoute'+store.getters.id) ||'/trainingPlatform'); + } + } else { + next(); + } } else { next({ path: '/401', replace: true, query: { noGoBack: true } }); } diff --git a/src/router/index.js b/src/router/index.js index 5199ad88b..1898707c2 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -153,13 +153,13 @@ export const userPlan = '015'; // 计划系统 export const userDesign='016'; // 设计系统 const isDev = process.env.NODE_ENV === 'development'; -const design = getSessionStorage('design'); -let redirectPath = ''; -if (design === 'true') { - redirectPath = '/design/home'; -} else { - redirectPath = '/trainingPlatform'; -} +// const design = getSessionStorage('design'); +// let redirectPath = ''; +// if (design === 'true') { +// redirectPath = '/design/home'; +// } else { +// redirectPath = '/trainingPlatform'; +// } export const UrlConfig = { display: '/display', @@ -321,11 +321,11 @@ export const constantRoutes = [ component: Jlmap3dedit, hidden: true }, - { - path: '/', - redirect: redirectPath, - hidden: true - }, + // { + // path: '/', + // redirect: redirectPath, + // hidden: true + // }, { path: '/401', component: Error401, diff --git a/src/store/getters.js b/src/store/getters.js index 843d1289b..a1071dd74 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -11,6 +11,7 @@ const getters = { roles: state => state.user.roles, canvasWidth: state => state.config.width, canvasHeight: state => state.config.height, + id: state => state.user.id, permission_routes: state => state.permission.routes }; export default getters;