fix: closes #2443
This commit is contained in:
parent
9c01fd3814
commit
c22a593396
@ -15,6 +15,14 @@ import projectConfig from './config';
|
||||
import $ from 'jquery';
|
||||
import { Message } from '@alifd/next';
|
||||
|
||||
function goLogin() {
|
||||
const url = window.location.href;
|
||||
localStorage.removeItem('token');
|
||||
const base_url = url.split('#')[0];
|
||||
console.log('base_url', base_url);
|
||||
window.location = `${base_url}#/login`;
|
||||
}
|
||||
|
||||
const global = window;
|
||||
|
||||
/**
|
||||
@ -484,9 +492,10 @@ const request = (function(_global) {
|
||||
config = handleMiddleWare.apply(this, [config, ...args, middlewareBackList]);
|
||||
let token = {};
|
||||
try {
|
||||
token = JSON.parse(localStorage.token || '{}');
|
||||
token = JSON.parse(localStorage.token);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
console.log('Token Erro', localStorage.token, e);
|
||||
goLogin();
|
||||
}
|
||||
const { accessToken = '' } = token;
|
||||
const [url, paramsStr = ''] = config.url.split('?');
|
||||
|
@ -7,6 +7,13 @@ import { isPlainObject } from './nacosutil';
|
||||
|
||||
const API_GENERAL_ERROR_MESSAGE = 'Request error, please try again later!';
|
||||
|
||||
function goLogin() {
|
||||
const url = window.location.href;
|
||||
localStorage.removeItem('token');
|
||||
const base_url = url.split('#')[0];
|
||||
window.location.href = `${base_url}#/login`;
|
||||
}
|
||||
|
||||
const request = () => {
|
||||
const instance = axios.create();
|
||||
|
||||
@ -19,9 +26,10 @@ const request = () => {
|
||||
if (!url.includes('auth/users/login')) {
|
||||
let token = {};
|
||||
try {
|
||||
token = JSON.parse(localStorage.token || '{}');
|
||||
token = JSON.parse(localStorage.token);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
goLogin();
|
||||
}
|
||||
const { accessToken = '' } = token;
|
||||
config.params.accessToken = accessToken;
|
||||
|
Loading…
Reference in New Issue
Block a user