2023年10月10日 修复部分不应该跳转的内容
This commit is contained in:
parent
88380a8f22
commit
f796d2f69c
|
@ -141,7 +141,7 @@ export const transform: AxiosTransform = {
|
||||||
requestInterceptors: (config: Recordable, options) => {
|
requestInterceptors: (config: Recordable, options) => {
|
||||||
// 请求之前处理config
|
// 请求之前处理config
|
||||||
const token = getToken();
|
const token = getToken();
|
||||||
let tenantid = getTenantId();
|
let tenantid:any = getTenantId();
|
||||||
if (token && (config as Recordable)?.requestOptions?.withToken !== false) {
|
if (token && (config as Recordable)?.requestOptions?.withToken !== false) {
|
||||||
// jwt token
|
// jwt token
|
||||||
config.headers.Authorization = options.authenticationScheme ? `${options.authenticationScheme} ${token}` : token;
|
config.headers.Authorization = options.authenticationScheme ? `${options.authenticationScheme} ${token}` : token;
|
||||||
|
@ -193,7 +193,12 @@ export const transform: AxiosTransform = {
|
||||||
* @description: 响应错误处理
|
* @description: 响应错误处理
|
||||||
*/
|
*/
|
||||||
responseInterceptorsCatch: (error: any) => {
|
responseInterceptorsCatch: (error: any) => {
|
||||||
//console.log('报错了!',error);
|
//console.log('报错了!',error,error.config,error.request,error.response,error.isAxiosError,error.toJSON(),);
|
||||||
|
|
||||||
|
if (!error?.response?.status) {//找不到返回值,也找不到状态码,则认为是重定向后跨域了,
|
||||||
|
window.location.href = error?.config?.url || window.location.href;
|
||||||
|
}
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const errorLogStore = useErrorLogStoreWithOut();
|
const errorLogStore = useErrorLogStoreWithOut();
|
||||||
errorLogStore.addAjaxErrorInfo(error);
|
errorLogStore.addAjaxErrorInfo(error);
|
||||||
|
@ -216,7 +221,7 @@ export const transform: AxiosTransform = {
|
||||||
errMessage = t('sys.api.networkExceptionMsg');
|
errMessage = t('sys.api.networkExceptionMsg');
|
||||||
//errMessage = '请刷新';
|
//errMessage = '请刷新';
|
||||||
//刷新页面
|
//刷新页面
|
||||||
window.location.href = config?.url || window.location.href;
|
//window.location.href = config?.url || window.location.href;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errMessage) {
|
if (errMessage) {
|
||||||
|
@ -227,7 +232,7 @@ export const transform: AxiosTransform = {
|
||||||
}
|
}
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error:any) {
|
||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,10 +241,27 @@ export const transform: AxiosTransform = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// .onerror = function handleError() {
|
||||||
|
// // Real errors are hidden from us by the browser
|
||||||
|
// // onerror should only fire if it's a network error
|
||||||
|
// reject(createError('Network Error', config, null, request));
|
||||||
|
|
||||||
|
// // Clean up request
|
||||||
|
// request = null;
|
||||||
|
// };
|
||||||
|
|
||||||
function createAxios(opt?: Partial<CreateAxiosOptions>) {
|
function createAxios(opt?: Partial<CreateAxiosOptions>) {
|
||||||
return new VAxios(
|
return new VAxios(
|
||||||
deepMerge(
|
deepMerge(
|
||||||
{
|
{
|
||||||
|
// transformResponse: (res,conf) => {
|
||||||
|
|
||||||
|
// console.log(`🚀 ---------------------------------------------------🚀`);
|
||||||
|
// console.log(`🚀 ~ file: index.ts:259 ~ createAxios ~ ...d:`, res,conf);
|
||||||
|
// console.log(`🚀 ---------------------------------------------------🚀`);
|
||||||
|
// return res
|
||||||
|
|
||||||
|
// },
|
||||||
// See https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication#authentication_schemes
|
// See https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication#authentication_schemes
|
||||||
// authentication schemes,e.g: Bearer
|
// authentication schemes,e.g: Bearer
|
||||||
// authenticationScheme: 'Bearer',
|
// authenticationScheme: 'Bearer',
|
||||||
|
|
|
@ -32,6 +32,7 @@ export interface Result<T = any> {
|
||||||
type: 'success' | 'error' | 'warning';
|
type: 'success' | 'error' | 'warning';
|
||||||
message: string;
|
message: string;
|
||||||
result: T;
|
result: T;
|
||||||
|
success: T;
|
||||||
}
|
}
|
||||||
|
|
||||||
//文件上传参数
|
//文件上传参数
|
||||||
|
|
Loading…
Reference in New Issue