Commit 867ac68b authored by 晓彤's avatar 晓彤

修改路由跳转问题

parent fde01b8d
...@@ -9448,6 +9448,11 @@ ...@@ -9448,6 +9448,11 @@
"path-key": "^2.0.0" "path-key": "^2.0.0"
} }
}, },
"nprogress": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/nprogress/-/nprogress-0.2.0.tgz",
"integrity": "sha1-y480xTIT2JVyP8urkH6UIq28r7E="
},
"nth-check": { "nth-check": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz", "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz",
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
"echarts": "^4.9.0", "echarts": "^4.9.0",
"element-ui": "^2.13.2", "element-ui": "^2.13.2",
"less": "^3.11.1", "less": "^3.11.1",
"nprogress": "^0.2.0",
"save": "^2.4.0", "save": "^2.4.0",
"sortablejs": "^1.13.0", "sortablejs": "^1.13.0",
"vue": "^2.5.2", "vue": "^2.5.2",
......
import Vue from 'vue' import Vue from 'vue'
// import store from '../store/store'
import Router from 'vue-router' import Router from 'vue-router'
import Login from '../views/login/Login' import Login from '../views/login/Login'
import Main from '../views/Main' import Main from '../views/Main'
...@@ -211,20 +212,27 @@ const router = new Router({ ...@@ -211,20 +212,27 @@ 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) { if (token !== null) {
// if (to.path === '/login') { if (to.path === '/login') {
// // 如果已经登陆,跳转到首页 next('/main')
// console.log('777', to.path) } else if (to.path === '/main') {
next()
// next() } else {
// } else { var menuList = window.sessionStorage.getItem('menuList')
// console.log('888', to.path) if (menuList.indexOf(to.path) > -1) {
// // 如果没有登录,就跳转登录页面 next()
// store.commit('user/RESET_USER') } else {
// next() next('/main')
// } }
// } }
// }) } else {
if (to.path === '/login') {
next()
} else {
next('/login')
}
}
})
export default router export default router
...@@ -106,6 +106,10 @@ export default { ...@@ -106,6 +106,10 @@ export default {
'permissionList', 'permissionList',
resp.data.data.permissionCodeList resp.data.data.permissionCodeList
) )
window.sessionStorage.setItem(
'menuList',
resp.data.data.menuList
)
this.menuList = resp.data.data.menuList this.menuList = resp.data.data.menuList
this.getNav() this.getNav()
}) })
......
...@@ -75,6 +75,7 @@ export default { ...@@ -75,6 +75,7 @@ export default {
logout() logout()
.then((resp) => { .then((resp) => {
this.$store.commit('user/RESET_USER') this.$store.commit('user/RESET_USER')
window.sessionStorage.clear()
this.$router.push('/') this.$router.push('/')
}) })
.catch((error) => { .catch((error) => {
...@@ -148,7 +149,7 @@ p[multiBtn] { ...@@ -148,7 +149,7 @@ p[multiBtn] {
} }
.el-dropdown-link { .el-dropdown-link {
cursor: pointer; cursor: pointer;
color:#606266; color: #606266;
font-size: 16px; font-size: 16px;
} }
.el-icon-arrow-down { .el-icon-arrow-down {
......
...@@ -58,9 +58,13 @@ export default { ...@@ -58,9 +58,13 @@ export default {
// 调取登陆接口 // 调取登陆接口
login(this.loginForm) login(this.loginForm)
.then((resp) => { .then((resp) => {
// 将token放到Application中 if (resp.data.data === false) {
window.sessionStorage.setItem('token', resp.data.data.token) this.$message.error('用户名或密码错误,请重新登陆!')
this.$router.push('/main') } else {
// 将token放到Application中
window.sessionStorage.setItem('token', resp.data.data.token)
this.$router.push('/main')
}
}) })
.catch((error) => { .catch((error) => {
this.$message({ type: 'error', message: error }) this.$message({ type: 'error', message: error })
......
...@@ -121,7 +121,6 @@ export default { ...@@ -121,7 +121,6 @@ export default {
// 获取权限列表 // 获取权限列表
getPermissionList() { getPermissionList() {
getPermissionList().then((resp) => { getPermissionList().then((resp) => {
// console.log('9090', resp.data.data)
this.allPermissionList = resp.data.data this.allPermissionList = resp.data.data
}) })
}, },
......
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