解决token失效

This commit is contained in:
red-deng-deng 2021-11-29 14:27:44 +08:00
parent 04e5560342
commit c9827f238b
3 changed files with 19 additions and 16 deletions

View File

@ -90,20 +90,23 @@ const req = (method, url, params, responseType) => {
if(res.status==200){
return res.json()
}else{
console.log(res);
switch (res.status) {
// 401: 未登录
case 401:
res.json().then(response =>{
if(response.code==403){
Notify.clear();
Notify.error( "没有权限");
break;
case 403:
Notify.clear();
Notify.error( "用户登录已失效,请重新登录");
sessionStorage.clear();
Notify.error(response.message);
setTimeout(() => {
window.location.href='/login';
}, 2000)
}else if(response.code==401){
Notify.clear();
Notify.error(response.message);
}
}
).catch();
break;
}
}

View File

@ -203,6 +203,8 @@ export default class App extends Component {
window.document.addEventListener('mouseover',function(){
window["mydata"].setState({lastTime:new Date().getTime()}); //更新操作时间
});
//根据权限菜单进行匹配
// timerstop=window.setInterval( window["mydata"].testTime, 1000);
}
// testTime(){
@ -247,7 +249,7 @@ export default class App extends Component {
<Link to="/extension" className={this.state.pathname=='/extension'?'active':''} onClick={()=>this.setState({pathname:'/extension'})}>推广</Link> */}
<Subnav listnav={this.state.navlist} time={window.time}/>
</div>
<div> <Icon type="help-circle" /> <a href="https://www.baidu.com/" target="_blank" className="help">帮助中心</a></div>
<div> <Icon type="help-circle" /> <a href="https://shimo.im/docs/wV3VVQP5W6I1nz3y/" target="_blank" className="help">帮助中心</a></div>
{/* 用户头像信息 */}
<div className="userImg dflexa">

View File

@ -40,10 +40,8 @@ function FormDom(props) {
items:[{path:'/home/plan-list',name:'营销计划管理'}]
}]
sessionStorage.setItem('menulinklist',JSON.stringify(arr));
let {authorization}=response;
sessionStorage.setItem('authorization',authorization);
sessionStorage.setItem('activeMenu',"营销计划管理");
sessionStorage.setItem('linkshowname',"营销计划管理");
setTimeout(()=>{
props.history.push('/home/plan-list')
},1000);