|
@@ -15,7 +15,15 @@ http.interceptors.request.use(
|
|
|
config => {
|
|
|
// 所有请求都添加/user-auth前缀,方便接口代理
|
|
|
// config.url = `/user-auth${config.url}`;
|
|
|
- config.url = `${config.url.indexOf('/sc-user-center') == 0 ? '' : '/sc-user-auth'}${config.url}`;
|
|
|
+ if (config.url.indexOf('/sc-user-center') == 0) {
|
|
|
+ config.url = `${config.url}`;
|
|
|
+ } else if (config.url.indexOf('/sc-community') == 0) {
|
|
|
+ config.url = `${config.url}`;
|
|
|
+ } else {
|
|
|
+ config.url = `/sc-user-auth${config.url}`;
|
|
|
+ }
|
|
|
+
|
|
|
+ // config.url = `${config.url.indexOf('/sc-user-center') == 0 ? '' : '/sc-user-auth'}${config.url}`;
|
|
|
config.headers[localStorage.getItem('SC_token') && 'Authorization'] = 'Bearer ' + localStorage.getItem('SC_token');
|
|
|
// 全局添加cancelToken
|
|
|
config.cancelToken = source.token;
|
|
@@ -31,13 +39,13 @@ http.interceptors.response.use(
|
|
|
return Promise.resolve(res.data);
|
|
|
},
|
|
|
err => {
|
|
|
- if (err&&err.response.status == 401) {
|
|
|
+ if (err && err.response.status == 401) {
|
|
|
axios({
|
|
|
- url:'/sc-user-auth/user/getUserStatus?accessToken='+localStorage.getItem('SC_token'),
|
|
|
- method:'get'
|
|
|
- }).then((response)=>{
|
|
|
- if (window.relogin) return false;
|
|
|
- window.relogin = true;
|
|
|
+ url: '/sc-user-auth/user/getUserStatus?accessToken=' + localStorage.getItem('SC_token'),
|
|
|
+ method: 'get'
|
|
|
+ }).then((response) => {
|
|
|
+ if (window.relogin) return false;
|
|
|
+ window.relogin = true;
|
|
|
let data = response.data.data;
|
|
|
if (data == 0) {
|
|
|
ELEMENT.MessageBox('你的登录已超时,请重新登录', '提示', 'warning', {
|
|
@@ -80,9 +88,9 @@ http.interceptors.response.use(
|
|
|
.catch(() => { });
|
|
|
}
|
|
|
})
|
|
|
- return;
|
|
|
+ return;
|
|
|
}
|
|
|
- if (axios.isCancel(err)) return new Promise(() => {}); // 取消请求的情况下,终端Promise调用链
|
|
|
+ if (axios.isCancel(err)) return new Promise(() => { }); // 取消请求的情况下,终端Promise调用链
|
|
|
return Promise.reject(err);
|
|
|
}
|
|
|
);
|