|
@@ -4,7 +4,7 @@ import { ElMessage } from 'element-plus';
|
|
|
import useMainStore from '@/store/useMainStore';
|
|
|
import { BaseLoginUrl, DA_HUA_URL_PREFIX } from '@/constants/constants';
|
|
|
import { useDaHuaStore } from '@/store';
|
|
|
-
|
|
|
+import { LOGIN_URL, BASE_URL } from '@/constants/constants';
|
|
|
// const baseURL =
|
|
|
// process.env.NODE_ENV === 'production'
|
|
|
// ? 'http://sqpcbg.xt.wenhq.top:8083/api'
|
|
@@ -37,12 +37,17 @@ axios.interceptors.response.use(
|
|
|
// message: `401. 没有权限访问该接口: ${res.config.url}`,
|
|
|
message: `401. 没有权限访问该接口`,
|
|
|
});
|
|
|
- const main = useMainStore();
|
|
|
- main.clearReqToken();
|
|
|
- window.localStorage.setItem('Authorization', '');
|
|
|
- window.location.href = BaseLoginUrl;
|
|
|
+ if (res.data.data.indexOf('Jwt expired') != -1) {
|
|
|
+ debugger
|
|
|
+ window.localStorage.removeItem('userdata');
|
|
|
+ window.location.href = LOGIN_URL;
|
|
|
+ }
|
|
|
+ // const main = useMainStore();
|
|
|
+ // main.clearReqToken();
|
|
|
+ // window.localStorage.setItem('Authorization', '');
|
|
|
+ // window.location.href = BaseLoginUrl;
|
|
|
|
|
|
- throw Error(res.statusText);
|
|
|
+ // throw Error(res.statusText);
|
|
|
}
|
|
|
if (res.data?.code === 404) {
|
|
|
ElMessage.error({ message: '404. 未找到该接口!' });
|
|
@@ -65,6 +70,11 @@ axios.interceptors.response.use(
|
|
|
}
|
|
|
|
|
|
if (res.status >= 500) {
|
|
|
+ if (res.data?.message == 'invalid ticket') {
|
|
|
+ debugger
|
|
|
+ window.localStorage.removeItem('userdata');
|
|
|
+ window.location.href = LOGIN_URL;
|
|
|
+ }
|
|
|
ElMessage.error({ message: '系统异常, 请稍后重试!' });
|
|
|
throw Error(res.statusText);
|
|
|
}
|
|
@@ -94,6 +104,10 @@ export default function request<T>(
|
|
|
method: AxiosRequestConfig['method'] = 'GET',
|
|
|
confifg: AxiosRequestConfig & {},
|
|
|
): Promise<T> {
|
|
|
+ var tokenkjson = window.localStorage.getItem('userdata');
|
|
|
+ tokenkjson = tokenkjson == null ? '{}' : tokenkjson;
|
|
|
+ tokenkjson = tokenkjson == undefined ? '{}' : tokenkjson;
|
|
|
+ tokenkjson = JSON.parse(tokenkjson);
|
|
|
return axios.request({
|
|
|
method,
|
|
|
baseURL,
|
|
@@ -102,8 +116,7 @@ export default function request<T>(
|
|
|
Accept: 'application/json',
|
|
|
'Content-Type': 'application/json',
|
|
|
AppId: '3bcb760743ea456faba29a1dfb247bf4',
|
|
|
- Authorization:
|
|
|
- 'Bearer ' + window.localStorage.getItem('Authorization') ?? '',
|
|
|
+ Authorization: 'Bearer ' + tokenkjson['accessToken'],
|
|
|
...confifg.headers,
|
|
|
},
|
|
|
});
|