解决token失效退出登录
This commit is contained in:
parent
ba6c1f3fa6
commit
537690bfb4
|
@ -87,19 +87,19 @@ const req = (method, url, params, responseType) => {
|
|||
|
||||
let http = fetch(url, obj).then(res =>{
|
||||
window.timeshow=res.headers.get('Date-Time');
|
||||
console.log(res);
|
||||
if(res.status==200){
|
||||
return res.json()
|
||||
}else{
|
||||
console.log(res);
|
||||
switch (res.status) {
|
||||
// 401: 未登录
|
||||
case 401:
|
||||
Notify.clear();
|
||||
Notify.error( "当前信息过期请重新登录");
|
||||
Notify.error( "没有权限,用户登录已失效");
|
||||
sessionStorage.clear();
|
||||
setTimeout(() => {
|
||||
window.location.href='/login';
|
||||
}, 3000)
|
||||
}, 2000)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -203,20 +203,20 @@ 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(){
|
||||
window["mydata"].setState({'currentTime':new Date().getTime()});//更新当前时间
|
||||
if( window["mydata"].state.currentTime - window["mydata"].state.lastTime > window["mydata"].state.timeOut){ //判断是否超时
|
||||
window.clearInterval(timerstop)
|
||||
Notify.clear()
|
||||
Notify.warn('登录失效,请重新登录!')
|
||||
sessionStorage.clear();
|
||||
setTimeout(()=>{
|
||||
window["mydata"].props.history.push('/login');
|
||||
},5000);
|
||||
}
|
||||
// timerstop=window.setInterval( window["mydata"].testTime, 1000);
|
||||
}
|
||||
// testTime(){
|
||||
// window["mydata"].setState({'currentTime':new Date().getTime()});//更新当前时间
|
||||
// if( window["mydata"].state.currentTime - window["mydata"].state.lastTime > window["mydata"].state.timeOut){ //判断是否超时
|
||||
// window.clearInterval(timerstop)
|
||||
// Notify.clear()
|
||||
// Notify.warn('登录失效,请重新登录!')
|
||||
// sessionStorage.clear();
|
||||
// setTimeout(()=>{
|
||||
// window["mydata"].props.history.push('/login');
|
||||
// },5000);
|
||||
// }
|
||||
// }
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (this.state.noShowSubMenu.indexOf(nextProps.location.pathname) > -1 ) {
|
||||
console.log("不展示")
|
||||
|
|
|
@ -282,7 +282,7 @@ componentDidUpdate(prevProps,prevState){
|
|||
<p className="accountable dflexj">
|
||||
<Button type="primary" icon="plus" onClick={this.clickFn.bind(this)}>新建账号</Button>
|
||||
{/* <Button type="info">批量操作</Button> */}
|
||||
<Ipt onChange={(e)=>this.setState({search:e})} value={this.state.search} wordSearch={this.iptsureFn.bind(this)} icon="search" placeholder={"请输入手机号、账号查询"} countShow={false} height={'36px'} width={'260px'} onClearItem={(e)=>{this.setState({search:''})}} alignment={'left'}/>
|
||||
<Ipt onChange={(e)=>this.setState({search:e})} value={this.state.search} wordSearch={this.iptsureFn.bind(this)} icon="search" placeholder={"请输入姓名、手机号、账号查询"} countShow={false} height={'36px'} width={'260px'} onClearItem={(e)=>{this.setState({search:''})}} alignment={'left'}/>
|
||||
</p>
|
||||
<div className="table-container">
|
||||
<Grid
|
||||
|
|
Loading…
Reference in New Issue