0203
This commit is contained in:
parent
e28f557d45
commit
0d533ea8fb
|
@ -66,7 +66,6 @@
|
|||
"vue/multi-word-component-names": 0,
|
||||
"no-debugger": "off",
|
||||
"no-console": "off",
|
||||
"drop_debugger":true,
|
||||
"no-trailing-spaces": "off"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -27,18 +27,6 @@
|
|||
// ]
|
||||
|
||||
const routes = [
|
||||
{
|
||||
"path": "/bigScreen",
|
||||
"name": "bigScreen",
|
||||
"meta": {
|
||||
"title": "驾驶舱",
|
||||
"icon": "el-icon-position",
|
||||
"perms": ["bigScreen"],
|
||||
"fullpage": true,
|
||||
"type": "link",
|
||||
},
|
||||
"component": "bigScreen"
|
||||
},
|
||||
{
|
||||
"name": "home",
|
||||
"path": "/home",
|
||||
|
@ -68,7 +56,6 @@ const routes = [
|
|||
"icon": "el-icon-position",
|
||||
"perms": ["bigScreen"],
|
||||
"fullpage": true,
|
||||
"type": "link",
|
||||
},
|
||||
"component": "bigScreen"
|
||||
},
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
</el-menu-item>
|
||||
<el-sub-menu v-else :index="navMenu.path">
|
||||
<template #title>
|
||||
<a v-if="navMenu.meta.type=='link'" href="javascript:void(0)" @click="blankPageClick(navMenu.path)"></a>
|
||||
<el-icon v-if="navMenu.meta&&navMenu.meta.icon"><component :is="navMenu.meta.icon || 'el-icon-menu'"/></el-icon>
|
||||
<span>{{navMenu.meta.title}}</span>
|
||||
</template>
|
||||
|
@ -38,9 +37,9 @@
|
|||
blankPageClick(path){
|
||||
// console.log(window.location);
|
||||
// console.log(path);
|
||||
// let linkUrl = window.location.origin+"/#"+path;
|
||||
// console.log(linkUrl)
|
||||
// debugger;
|
||||
let linkUrl = window.location.origin+"/#"+path;
|
||||
console.log(linkUrl)
|
||||
debugger;
|
||||
|
||||
|
||||
let routeUrl = this.$router.resolve({path: path});
|
||||
|
|
|
@ -40,44 +40,44 @@ axios.interceptors.response.use(
|
|||
if (error.response) {
|
||||
if (error.response.status == 401) {
|
||||
if(error.response.data.err_code == 'no_active_account'){
|
||||
// ElNotification.warning({
|
||||
// title: '请求失败',
|
||||
// message: "账户密码错误或已禁用"
|
||||
// });
|
||||
if (!isRefreshing) {
|
||||
isRefreshing = true;
|
||||
axios({
|
||||
method: 'post',
|
||||
url: sysConfig.API_URL+'/auth/token/refresh/',
|
||||
headers: {
|
||||
Authorization: `Bearer ${tool.cookie.get("TOKEN")}`,
|
||||
},
|
||||
data:{refresh:tool.cookie.get("TOKEN_REFRESH")}
|
||||
}).then(res=>{
|
||||
debugger;
|
||||
console.log(res.data.access);
|
||||
// 替换本地的token
|
||||
tool.cookie.set("TOKEN", res.data.access);
|
||||
tool.data.set("TOKEN_TIME", new Date().getTime());
|
||||
error.config.headers[sysConfig.TOKEN_NAME] = sysConfig.TOKEN_PREFIX + res.data.access;
|
||||
isRefreshing = false;
|
||||
requests.forEach(cb => cb())
|
||||
//发起后将requests置空
|
||||
requests=[];
|
||||
return axios(error.config)
|
||||
}).catch(()=>{
|
||||
// refresh_token 有值 , 但是过期了, 请求失败
|
||||
router.push('/login')
|
||||
})
|
||||
ElNotification.warning({
|
||||
title: '请求失败',
|
||||
message: "账户密码错误或已禁用"
|
||||
});
|
||||
// if (!isRefreshing) {
|
||||
// isRefreshing = true;
|
||||
// axios({
|
||||
// method: 'post',
|
||||
// url: sysConfig.API_URL+'/auth/token/refresh/',
|
||||
// headers: {
|
||||
// Authorization: `Bearer ${tool.cookie.get("TOKEN")}`,
|
||||
// },
|
||||
// data:{refresh:tool.cookie.get("TOKEN_REFRESH")}
|
||||
// }).then(res=>{
|
||||
// debugger;
|
||||
// console.log(res.data.access);
|
||||
// // 替换本地的token
|
||||
// tool.cookie.set("TOKEN", res.data.access);
|
||||
// tool.data.set("TOKEN_TIME", new Date().getTime());
|
||||
// error.config.headers[sysConfig.TOKEN_NAME] = sysConfig.TOKEN_PREFIX + res.data.access;
|
||||
// isRefreshing = false;
|
||||
// requests.forEach(cb => cb())
|
||||
// //发起后将requests置空
|
||||
// requests=[];
|
||||
// return axios(error.config)
|
||||
// }).catch(()=>{
|
||||
// // refresh_token 有值 , 但是过期了, 请求失败
|
||||
// router.push('/login')
|
||||
// })
|
||||
|
||||
}else{
|
||||
//如果正在刷新token,将发起的请求暂存在requests中
|
||||
return new Promise((resolve)=>{
|
||||
requests.push(()=>{
|
||||
resolve(axios(error.config));
|
||||
})
|
||||
})
|
||||
}
|
||||
// }else{
|
||||
// //如果正在刷新token,将发起的请求暂存在requests中
|
||||
// return new Promise((resolve)=>{
|
||||
// requests.push(()=>{
|
||||
// resolve(axios(error.config));
|
||||
// })
|
||||
// })
|
||||
// }
|
||||
}else{
|
||||
// ElMessageBox.confirm('当前用户已被登出或无权限访问当前资源,请尝试重新登录后再操作。', '无权限访问', {
|
||||
// type: 'error',
|
||||
|
|
Loading…
Reference in New Issue