【修改】增加登陆持久
This commit is contained in:
+1
-1
@@ -22,10 +22,10 @@
|
|||||||
"quill-image-drop-module": "^1.0.3",
|
"quill-image-drop-module": "^1.0.3",
|
||||||
"quill-image-extend-module": "^1.1.2",
|
"quill-image-extend-module": "^1.1.2",
|
||||||
"quill-image-resize-module": "^3.0.0",
|
"quill-image-resize-module": "^3.0.0",
|
||||||
"svg-sprite-loader": "^6.0.11",
|
|
||||||
"uuid": "^3.4.0",
|
"uuid": "^3.4.0",
|
||||||
"vue": "^2.6.11",
|
"vue": "^2.6.11",
|
||||||
"vue-axios": "^3.4.0",
|
"vue-axios": "^3.4.0",
|
||||||
|
"vue-cookies": "^1.8.3",
|
||||||
"vue-echarts": "^6.0.0",
|
"vue-echarts": "^6.0.0",
|
||||||
"vue-quill-editor": "^3.0.6",
|
"vue-quill-editor": "^3.0.6",
|
||||||
"vue-router": "^3.2.0",
|
"vue-router": "^3.2.0",
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import router from './router/index'
|
||||||
|
// import { getToken } from '@utils/auth'
|
||||||
|
import store from './store'
|
||||||
|
import vue from 'vue'
|
||||||
|
const whiteList = ['/loginout','/login','/checkPage']
|
||||||
|
|
||||||
|
router.beforeEach(async (to, from, next) => {
|
||||||
|
// 判断用户是否登录
|
||||||
|
const hasToken =store.getters.userInfo
|
||||||
|
// 如果已经登录了
|
||||||
|
if (localStorage.getItem('cookie')) {
|
||||||
|
// console.log( this.$cookies.get('JSESSIONID'),"getCookiegetCookiegetCookiegetCookiegetCookiegetCookie")
|
||||||
|
vue.prototype.$cookies.set("JSESSIONID", localStorage.getItem('cookie'), {expires: "7D"});
|
||||||
|
// 不能再去登录页面
|
||||||
|
if (to.path === '/login' ||to.path === '/loginout' ||to.path === '/checkPage') {
|
||||||
|
|
||||||
|
next({ path: store.getters.pathUrl })
|
||||||
|
} else {
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 否则如果没登录
|
||||||
|
else {
|
||||||
|
// 去白名单路由页面
|
||||||
|
if (whiteList.indexOf(to.path) !== -1) {
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
// 否则必须登录
|
||||||
|
else {
|
||||||
|
next('/login')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
router.afterEach(() => {})
|
||||||
Reference in New Issue
Block a user