UNPKG

@auraxy/invoice-services

Version:

发票前端 http ajax,mqtt,localStorage,cookie 再封装

72 lines (66 loc) 1.55 kB
import { Http, Mqtt } from '@auraxy/services' import { AxiosError } from 'axios' declare enum ResCode { SUCCESS = 0, PARAM_ERROR_CODE = -1, AUTH_FAILED = -2, SYS_ERROR_CODE = -3, TIMEOUT_ERROR_CODE = -4, SHOW_SYS_ERROR = -1000, } declare interface APIResult<T = any> { code: ResCode message?: string data?: T } declare interface APIResultOld<T = any> { status: boolean | number responseCode: number entry?: T message?: string total?: number } declare interface APIError<CodeType, T = any> extends AxiosError<T> { resCode?: CodeType } interface InvoiceInterceptorParams { getToken?(): string responseCallback?(res: any): void } interface ProxyHttpOptions extends InvoiceInterceptorParams { errorHandler?: (err: Error) => void } declare type BaseURL = 'prod' | 'test' declare type AppName = 'LITE_APP' | 'KAIPIAO_APP' declare function ProxyHttp( baseUrl: BaseURL | string, options?: ProxyHttpOptions, ): Http<APIError<ResCode, any>> declare function OperateProxyHttp( baseUrl: BaseURL | string, options?: ProxyHttpOptions, ): Http<APIError<ResCode, any>> interface MqttInitOptions { http: Http | (() => Http) parentTopic?: BaseURL | string appName?: AppName /** * 配置信息的保存在缓存中的键 * */ getKey(): string } declare function invoiceMqtt(options: MqttInitOptions): Mqtt export { APIError, APIResult, APIResultOld, AppName, BaseURL, InvoiceInterceptorParams, MqttInitOptions, OperateProxyHttp, ProxyHttp, ProxyHttpOptions, ResCode, invoiceMqtt, }