@pisell/pisellos
Version:
一个可扩展的前端模块化SDK框架,支持插件系统
42 lines (41 loc) • 1.21 kB
TypeScript
import { CreateAxiosDefaults } from "axios";
import { CacheType } from './cache';
export interface RequestConfig {
interceptorsRequest?: ((value: any) => any | Promise<any>) | null;
interceptorsRequestError?: ((error: any) => any) | null;
interceptorsResponse?: any;
interceptorsResponseError?: ((error: any) => any) | null;
axiosConfig?: CreateAxiosDefaults;
storage?: any;
getToken?: () => string | null;
setToken?: (token: string) => void;
getLocale?: () => string | null;
getUrl?: (config: any) => string;
requestCallbacks?: {
200?: (data: any) => void;
401?: (data: any) => void;
403?: (data: any) => void;
other?: (data: any) => void;
[key: string]: any;
};
}
export interface CacheProps {
key?: string;
type?: CacheType;
updateCache?: boolean;
cacheUpdateChange?: (data: any) => void;
}
export interface RequestSetting {
abort?: boolean;
headers?: any;
cache?: CacheProps;
signal?: any;
token?: string;
[key: string]: any;
}
export interface RequestWrapperProps {
url: string;
method: 'get' | 'post' | 'remove' | 'put';
data?: any;
config?: RequestSetting;
}