fix: typing

This commit is contained in:
TENCENT\ivinwu
2019-04-02 20:34:57 +08:00
parent de6f8aaa09
commit 2e05d4289e
6 changed files with 32 additions and 32 deletions

View File

@@ -1,5 +1,5 @@
<p align="center"><img src="./image/logo.png" alt="weRequest" height="160"/></p>
<h2 align="center">v1.2.4</h2>
<h2 align="center">v1.2.5</h2>
<p align="center"><b>解决繁琐的小程序会话管理,一款自带登录态管理的网络请求组件。</b></p>

20
build/interface.d.ts vendored
View File

@@ -5,7 +5,7 @@ export interface IInitOption {
urlPerfix?: string | (() => string);
doNotCheckSession?: boolean;
reLoginLimit?: number;
errorCallback?: null | Function;
errorCallback?: ((obj: IAnyObject, res: string | IAnyObject | ArrayBuffer) => void) | null;
reportCGI?: boolean | ((name: string, startTime: number, endTime: number, request: Function) => void);
mockJson?: any;
globalData?: boolean | object | Function;
@@ -30,7 +30,7 @@ export interface IRequestOption extends IRequestObject {
beforeSend?: Function;
showLoading?: boolean | string;
report?: string;
cache?: boolean | Function;
cache?: boolean | ((res: string | IAnyObject | ArrayBuffer) => boolean);
noCacheFlash?: boolean;
success?: (res: string | IAnyObject | ArrayBuffer, cacheInfo?: object) => void;
complete?: () => void;
@@ -65,12 +65,12 @@ export interface IGetConfigResult {
sessionExpire?: number;
}
export interface weRequest {
init?: (obj: IInitOption) => void;
request?: (option: IRequestOption) => void;
uploadFile?: (option: IUploadFileOption) => void;
getSession?: () => string;
getConfig?: () => IGetConfigResult;
login?: (callback: Function) => void;
setSession?: (x: string) => void;
version?: string;
init: (obj: IInitOption) => void;
request: (option: IRequestOption) => void;
uploadFile: (option: IUploadFileOption) => void;
getSession: () => string;
getConfig: () => IGetConfigResult;
login: (callback: Function) => void;
setSession: (x: string) => void;
version: string;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{
"name": "we-request",
"version": "1.2.4",
"version": "1.2.5",
"description": "本工具通过拓展小程序的wx.request让开发者通过简单的配置实现自动管理登录态等功能",
"keywords": [
"登录态",
@@ -20,7 +20,7 @@
"url": "https://github.com/IvinWu/weRequest.git"
},
"main": "src/index.ts",
"typings": "src/typings/index.d.ts",
"typings": "build/index.d.ts",
"scripts": {
"build": "webpack",
"commit": "git cz"

View File

@@ -10,7 +10,7 @@ export interface IInitOption {
/* 登录重试次数,当连续请求登录接口返回失败次数超过这个次数,将不再重试登录 */
reLoginLimit?: number;
/* 当出现接口逻辑错误时,会执行统一的回调函数,这里可以做统一的错误上报等处理 */
errorCallback?: null | Function;
errorCallback?: ((obj: IAnyObject, res: string | IAnyObject | ArrayBuffer) => void) | null;
/* 接口返回成功之后,会执行统一的回调函数,这里可以做统一的耗时上报等处理 */
reportCGI?: boolean | ((
/* 调用的接口名字可在request接口的report字段配置 */
@@ -74,7 +74,7 @@ export interface IRequestOption extends IRequestObject {
/* 接口请求成功后将自动执行init()中配置的reportCGI函数其中的name字段值为这里配置的值 */
report?: string;
/* 是否需要缓存 */
cache?: boolean | Function;
cache?: boolean | ((res: string | IAnyObject | ArrayBuffer) => boolean);
/* 当启用缓存时,决定除了返回缓存内容外,是否还返回接口实时内容,以防止页面多次渲染的抖动 */
noCacheFlash?: boolean;
/* 接口调用成功的回调函数 */
@@ -138,20 +138,20 @@ export interface IGetConfigResult {
}
export interface weRequest {
/** 小程序账号信息 */
init?: (obj: IInitOption) => void;
/** 插件账号信息(仅在插件中调用时包含这一项) */
request?: (option: IRequestOption) => void;
/** 插件账号信息(仅在插件中调用时包含这一项) */
uploadFile?: (option: IUploadFileOption) => void;
/** 初始化 */
init: (obj: IInitOption) => void;
/** 请求 */
request: (option: IRequestOption) => void;
/** 上传文件 */
uploadFile: (option: IUploadFileOption) => void;
/* 获取本地缓存中用户票据的值 */
getSession?: () => string;
getSession: () => string;
/* 获取weRequest的配置 */
getConfig?: () => IGetConfigResult;
getConfig: () => IGetConfigResult;
/* [不建议使用] 在不发起业务请求的情况下,单独执行登录逻辑 */
login?: (callback: Function) => void;
login: (callback: Function) => void;
/* [不建议使用] 设置用户票据的值 */
setSession?: (x: string) => void;
setSession: (x: string) => void;
/* 获取weRequest版本 */
version?: string;
version: string;
}