77 lines
2.4 KiB
TypeScript
77 lines
2.4 KiB
TypeScript
import * as axios from 'axios';
|
|
import * as Request from 'ff-request';
|
|
import Request__default from 'ff-request';
|
|
import MockAdapter from 'axios-mock-adapter';
|
|
import React from 'react';
|
|
|
|
declare const _default$3: any;
|
|
|
|
declare const _default$2: Http & Request__default;
|
|
|
|
/**
|
|
* 应用统一的 HTTP 客户端单例;自身只实现 init/driver/headers/mock/unmock,
|
|
* 其余属性通过 Proxy 代理到内部的 ff-request 实例(HttpRequest),
|
|
* 所以 get/post/del 等请求方法可以直接在这个单例上调用
|
|
*/
|
|
declare class Http {
|
|
static "__#private@#instance": any;
|
|
static "__#private@#core": any;
|
|
/** @returns {Http & import('ff-request').default} 单例实例 */
|
|
static getInstance: () => Http & Request.default;
|
|
appUrl: string;
|
|
/**
|
|
* 初始化(设置请求 baseURL/超时,并初始化内部 ff-request 实例)
|
|
* @param {string} appKey
|
|
* @param {string} appSecret
|
|
* @param {string} appUrl 接口请求的 baseURL
|
|
*/
|
|
init(appKey: string, appSecret: string, appUrl: string): void;
|
|
get driver(): axios.AxiosStatic;
|
|
get headers(): Readonly<{
|
|
Platform: "web";
|
|
SaaS: string;
|
|
Authorization: `Bearer ${string} `;
|
|
}>;
|
|
/**
|
|
* 开启请求 mock(基于 axios-mock-adapter),未匹配的请求会透传到真实接口
|
|
* @param {Object} [opt] 传给 MockAdapter 的选项
|
|
* @returns {MockAdapter} mock 适配器实例,用于注册具体的 mock 规则
|
|
*/
|
|
mock(opt?: any): MockAdapter;
|
|
/** 关闭并清除 mock */
|
|
unmock(): void;
|
|
#private;
|
|
}
|
|
|
|
declare class Cache {
|
|
constructor(target: any, fn: any);
|
|
get: (...args: any[]) => Promise<any>;
|
|
#private;
|
|
}
|
|
|
|
declare const _default$1: any;
|
|
|
|
declare const pipe: any;
|
|
|
|
declare const _default: any;
|
|
|
|
declare const AppContext: React.Context<{
|
|
user: {};
|
|
initUser: () => void;
|
|
initUserComplete: boolean;
|
|
}>;
|
|
declare const AppGlobalParamsContext: React.Context<{
|
|
set: () => void;
|
|
get: () => void;
|
|
assign: () => void;
|
|
currentRoute: () => void;
|
|
}>;
|
|
|
|
/**
|
|
* 判断是否是 React 组件, 大写字母开头的函数则判断为组件
|
|
*/
|
|
declare function isReactComponent(component: any): boolean;
|
|
declare function insertStyle(css: any, id: any): any;
|
|
|
|
export { AppContext, AppGlobalParamsContext, Cache as cache, _default$1 as configure, _default$3 as default, pipe as func, _default$2 as http, insertStyle, isReactComponent, _default as route };
|