mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 14:56:07 +08:00
25 lines
617 B
TypeScript
25 lines
617 B
TypeScript
import { history } from 'umi';
|
|
import { request } from '@/utils/http';
|
|
import config from '@/utils/config';
|
|
|
|
export function render(oldRender: any) {
|
|
request
|
|
.get(`${config.apiPrefix}user`)
|
|
.then((data) => {
|
|
if (data.data && data.data.username) {
|
|
return oldRender();
|
|
}
|
|
localStorage.removeItem(config.authKey);
|
|
history.push('/login');
|
|
oldRender();
|
|
})
|
|
.catch((e) => {
|
|
console.log(e);
|
|
if (e.response && e.response.status === 401) {
|
|
localStorage.removeItem(config.authKey);
|
|
history.push('/login');
|
|
oldRender();
|
|
}
|
|
});
|
|
}
|