|
|
@@ -35,6 +35,8 @@ const transform: AxiosTransform = {
|
|
|
* @description: 处理请求数据
|
|
|
*/
|
|
|
transformRequestData: (res: AxiosResponse<Result>, options: RequestOptions) => {
|
|
|
+ const userStore = useUserStoreWidthOut();
|
|
|
+
|
|
|
const {
|
|
|
isShowMessage = true,
|
|
|
isShowErrorMessage = true,
|
|
|
@@ -106,42 +108,27 @@ const transform: AxiosTransform = {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- switch (code) {
|
|
|
- // 请求失败
|
|
|
- // case ResultEnum.ERROR:
|
|
|
- // ElMessage.error(errorMsg);
|
|
|
- // break;
|
|
|
- // 没有权限
|
|
|
- // case 502:
|
|
|
- // ElMessage.error(errorMsg);
|
|
|
- // break;
|
|
|
- // 参数错误
|
|
|
- // case 405:
|
|
|
- // ElMessage.error(errorMsg);
|
|
|
- // break;
|
|
|
- // 登录超时
|
|
|
- case ResultEnum.TIMEOUT:
|
|
|
- case ResultEnum.EXPIRED:
|
|
|
- const LoginName = PageEnum.BASE_LOGIN_NAME;
|
|
|
- const LoginPath = PageEnum.BASE_LOGIN;
|
|
|
- if (router.currentRoute.value?.name === LoginName) return;
|
|
|
- // 到登录页
|
|
|
- errorMsg = '登录超时,请重新登录!';
|
|
|
- ElMessageBox.confirm('登录身份已失效,请重新登录!', '提示', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- showCancelButton: false,
|
|
|
- type: 'warning',
|
|
|
- })
|
|
|
- .then(() => {
|
|
|
- storage.clear();
|
|
|
- window.location.href = getRedirectUrl();
|
|
|
- // window.location.reload();
|
|
|
- })
|
|
|
- .catch(() => {});
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
+ // switch (code) {
|
|
|
+ // // 请求失败
|
|
|
+ // // case ResultEnum.ERROR:
|
|
|
+ // // ElMessage.error(errorMsg);
|
|
|
+ // // break;
|
|
|
+ // // 没有权限
|
|
|
+ // // case 502:
|
|
|
+ // // ElMessage.error(errorMsg);
|
|
|
+ // // break;
|
|
|
+ // // 参数错误
|
|
|
+ // // case 405:
|
|
|
+ // // ElMessage.error(errorMsg);
|
|
|
+ // // break;
|
|
|
+ // // 登录超时
|
|
|
+ // case ResultEnum.TIMEOUT:
|
|
|
+ // case ResultEnum.EXPIRED:
|
|
|
+ // // userStore.showLogin = true;
|
|
|
+ // break;
|
|
|
+ // default:
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
throw new Error(errorMsg);
|
|
|
},
|
|
|
|
|
|
@@ -186,10 +173,7 @@ const transform: AxiosTransform = {
|
|
|
config.params = undefined;
|
|
|
}
|
|
|
if (joinParamsToUrl) {
|
|
|
- config.url = setObjToUrlParams(
|
|
|
- config.url as string,
|
|
|
- Object.assign({}, config.params, config.data),
|
|
|
- );
|
|
|
+ config.url = setObjToUrlParams(config.url as string, Object.assign({}, config.params, config.data));
|
|
|
}
|
|
|
} else {
|
|
|
// 兼容restful风格
|
|
|
@@ -234,8 +218,7 @@ const transform: AxiosTransform = {
|
|
|
responseInterceptorsCatch: (error: any) => {
|
|
|
const { response, code, message } = error || {};
|
|
|
// TODO 此处要根据后端接口返回格式修改
|
|
|
- const msg: string =
|
|
|
- response && response.data && response.data.message ? response.data.message : '';
|
|
|
+ const msg: string = response && response.data && response.data.message ? response.data.message : '';
|
|
|
const err: string = error.toString();
|
|
|
try {
|
|
|
if (code === 'ECONNABORTED' && message.indexOf('timeout') !== -1) {
|