chore
This commit is contained in:
@@ -1,18 +1,9 @@
|
||||
import type {
|
||||
AxiosError,
|
||||
AxiosInstance,
|
||||
AxiosRequestConfig,
|
||||
AxiosResponse,
|
||||
CreateAxiosDefaults,
|
||||
InternalAxiosRequestConfig,
|
||||
} from 'axios';
|
||||
import type { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse, CreateAxiosDefaults, InternalAxiosRequestConfig } from 'axios';
|
||||
|
||||
import axios from 'axios';
|
||||
|
||||
import type { Result } from '@/axios';
|
||||
|
||||
import { getAppEnvConfig } from './env';
|
||||
|
||||
export type Response<T> = [err: AxiosError | null, data: T | null, resp: Result<T> | null];
|
||||
|
||||
export interface RequestOptions extends CreateAxiosDefaults {
|
||||
@@ -42,18 +33,6 @@ export class Request {
|
||||
this.lastAbortController = this.abortController;
|
||||
this.abortController = new AbortController();
|
||||
return config;
|
||||
|
||||
// 业务登录所需headers
|
||||
// const { lampAuthorization, lampClientId, lampClientSecret } = getAppEnvConfig();
|
||||
// const newAuthorization = window.btoa(`${lampClientId}:${lampClientSecret}`);
|
||||
// const authorization = lampAuthorization.trim() !== '' ? lampAuthorization : newAuthorization;
|
||||
// config.headers.set('accept-language', 'zh-CN,zh;q=0.9');
|
||||
// config.headers.set('accept', 'application/json, text/plain, */*');
|
||||
// config.headers.set('Applicationid', '')
|
||||
// config.headers.set('Tenantid', '1');
|
||||
// config.headers.set('Authorization', authorization);
|
||||
// config.headers.set('token', this.extraInfo?.token ?? '')
|
||||
// return config;
|
||||
});
|
||||
|
||||
const requestInterceptor = config?.requestInterceptor ?? Request.defaultRequestInterceptor;
|
||||
@@ -76,14 +55,16 @@ export class Request {
|
||||
private static defaultResponseErrorInterceptor(error: any) {
|
||||
const err = error as AxiosError;
|
||||
if (err.status === 401) {
|
||||
//
|
||||
}
|
||||
if (err.status === 404) {
|
||||
//
|
||||
}
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
public get requestInstance(): AxiosInstance {
|
||||
return this.instance;
|
||||
}
|
||||
|
||||
get<T>(url: string, option?: AxiosRequestConfig & { uniq?: boolean }): Promise<Response<T>> {
|
||||
const { uniq, ...reqConfig } = option ?? {};
|
||||
this.uniq = !!uniq;
|
||||
|
||||
Reference in New Issue
Block a user