token
This commit is contained in:
parent
ac45999554
commit
b08226ed26
@ -38,7 +38,7 @@ router.beforeEach(async (to, from, next) => {
|
|||||||
NProgress.start()
|
NProgress.start()
|
||||||
//动态标题
|
//动态标题
|
||||||
document.title = to.meta.title ? `${to.meta.title} - ${config.APP_NAME}` : `${config.APP_NAME}`
|
document.title = to.meta.title ? `${to.meta.title} - ${config.APP_NAME}` : `${config.APP_NAME}`
|
||||||
let token = tool.cookie.get("TOKEN");
|
let token = tool.cookie.get("token");
|
||||||
if (to.path === "/login") {
|
if (to.path === "/login") {
|
||||||
//删除路由(替换当前layout路由)
|
//删除路由(替换当前layout路由)
|
||||||
router.addRoute(routes[0])
|
router.addRoute(routes[0])
|
||||||
|
@ -11,7 +11,7 @@ axios.defaults.timeout = sysConfig.TIMEOUT
|
|||||||
// HTTP request 拦截器
|
// HTTP request 拦截器
|
||||||
axios.interceptors.request.use(
|
axios.interceptors.request.use(
|
||||||
(config) => {
|
(config) => {
|
||||||
let token = tool.cookie.get("TOKEN");
|
let token = tool.cookie.get("token");
|
||||||
if(token){
|
if(token){
|
||||||
config.headers[sysConfig.TOKEN_NAME] = sysConfig.TOKEN_PREFIX + token
|
config.headers[sysConfig.TOKEN_NAME] = sysConfig.TOKEN_PREFIX + token
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@
|
|||||||
//获取token
|
//获取token
|
||||||
var user = await this.$api.auth.token.post(data)
|
var user = await this.$api.auth.token.post(data)
|
||||||
if(user.code == 200){
|
if(user.code == 200){
|
||||||
this.$tool.cookie.set("TOKEN", user.data.token, {
|
this.$tool.cookie.set("token", user.data.token, {
|
||||||
expires: 86400*360
|
expires: 86400*360
|
||||||
})
|
})
|
||||||
}else{
|
}else{
|
||||||
@ -95,7 +95,7 @@
|
|||||||
})
|
})
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
this.$tool.data.set("MENU", menu.data.menu)
|
this.$tool.data.set("menu", menu.data.menu)
|
||||||
this.$tool.data.set("userinfo", menu.data.user)
|
this.$tool.data.set("userinfo", menu.data.user)
|
||||||
this.$tool.data.set("permissions", menu.data.permissions)
|
this.$tool.data.set("permissions", menu.data.permissions)
|
||||||
this.$tool.data.set("dashboardgrid", menu.data.dashboardGrid)
|
this.$tool.data.set("dashboardgrid", menu.data.dashboardGrid)
|
||||||
|
@ -106,7 +106,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: function() {
|
created: function() {
|
||||||
this.$tool.cookie.remove("TOKEN")
|
this.$tool.cookie.remove("token")
|
||||||
this.$tool.data.remove("userinfo")
|
this.$tool.data.remove("userinfo")
|
||||||
this.$tool.data.remove("menu")
|
this.$tool.data.remove("menu")
|
||||||
this.$tool.data.remove("permissions")
|
this.$tool.data.remove("permissions")
|
||||||
|
Loading…
Reference in New Issue
Block a user