Commit 127e03dd authored by 晓彤's avatar 晓彤

修改权限登陆问题

parent 0e6583f5
...@@ -212,19 +212,20 @@ const router = new Router({ ...@@ -212,19 +212,20 @@ const router = new Router({
] ]
}) })
// 判断用户是否登陆到系统 // 判断用户是否登陆到系统
router.beforeEach(function (to, from, next) { router.beforeEach(function(to, from, next) {
var token = window.sessionStorage.getItem('token') var token = window.sessionStorage.getItem('token')
if (token !== null) { if (token !== null) {
if (to.path === '/login') { if (to.path === '/login') {
next('/main') next('/main')
} else if (to.path === '/main') {
next()
} else { } else {
// var menuList = window.sessionStorage.getItem('menuList') var menuList = window.sessionStorage.getItem('menuList')
// if (menuList.indexOf(to.path) > -1) { if (menuList.indexOf(to.path) > -1) {
// next()
// } else {
// next('/main')
// }
next() next()
} else {
next('/main')
}
} }
} else { } else {
if (to.path === '/login') { if (to.path === '/login') {
......
...@@ -97,7 +97,11 @@ export default { ...@@ -97,7 +97,11 @@ export default {
// this.$store.dispatch('user/userMsg', { // this.$store.dispatch('user/userMsg', {
// userInfo: resp.data.data // userInfo: resp.data.data
// }) // })
if (resp.data.data === false) {
this.$message.error(resp.data.msg)
window.sessionStorage.clear()
this.$router.push('/login')
}
// 同步赋值mutations // 同步赋值mutations
this.$store.commit('user/SET_USER', resp.data.data) this.$store.commit('user/SET_USER', resp.data.data)
...@@ -106,10 +110,7 @@ export default { ...@@ -106,10 +110,7 @@ export default {
'permissionList', 'permissionList',
resp.data.data.permissionCodeList resp.data.data.permissionCodeList
) )
window.sessionStorage.setItem( window.sessionStorage.setItem('menuList', resp.data.data.menuList)
'menuList',
resp.data.data.menuList
)
this.menuList = resp.data.data.menuList this.menuList = resp.data.data.menuList
this.getNav() this.getNav()
}) })
......
<template> <template>
<div class="main"> <div class="main">
<div class="container"> <div class="container" >
<h3 class="title">测试平台</h3> <h3 class="title">测试平台</h3>
<el-form style="margin-left:50px" :model="loginForm" :rules="loginRules" ref="loginFormRef"> <el-form style="margin-left:50px" :model="loginForm" :rules="loginRules" ref="loginFormRef">
<el-form-item prop="username" class="input-style"> <el-form-item prop="username" class="input-style">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment