feat(types): 更新使用微信官方维护的types
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<p align="center"><img src="./image/logo.png" alt="weRequest" height="160"/></p>
|
||||
<h2 align="center">v1.3.1</h2>
|
||||
<h2 align="center">v1.4.0</h2>
|
||||
<p align="center"><b>解决繁琐的小程序会话管理,一款自带登录态管理的网络请求组件。</b></p>
|
||||
|
||||
|
||||
@@ -306,7 +306,7 @@ weRequest.init({
|
||||
|report|String|否||接口请求成功后将自动执行init()中配置的reportCGI函数,其中的name字段值为这里配置的值|是|
|
||||
|cache|Boolean|否||接口是否启用缓存机制,若为true,将以url为key将结果存储在storage中,下次带cache的请求优先返回缓存内容,success回调中第二个参数对象的isCache值将标识内容是否为缓存|是|
|
||||
|noCacheFlash|Boolean|否||当启用缓存时,决定除了返回缓存内容外,是否还返回接口实时内容,以防止页面多次渲染的抖动|是|
|
||||
|catchError|Boolean|否|false|当使用Promise模式时,开发者是否需要捕获错误(默认不捕获,统一自动处理错误)|否|
|
||||
|catchError|Boolean|否|false|当使用Promise模式时,开发者是否需要捕获错误(默认不捕获,统一自动处理错误)|是|
|
||||
|
||||
#### 示例代码
|
||||
|
||||
@@ -346,7 +346,7 @@ weRequest.request({
|
||||
|complete|Function|否||接口调用结束的回调函数(调用成功、失败都会执行)||
|
||||
|showLoading|Boolean/String|否|false|请求过程页面是否展示全屏的loading,当值为字符串时,将展示相关文案的loading|是|
|
||||
|report|String|否||接口请求成功后将自动执行init()中配置的reportCGI函数,其中的name字段值为这里配置的值|是|
|
||||
|catchError|Boolean|否|false|当使用Promise模式时,开发者是否需要捕获错误(默认不捕获,统一自动处理错误)|否|
|
||||
|catchError|Boolean|否|false|当使用Promise模式时,开发者是否需要捕获错误(默认不捕获,统一自动处理错误)|是|
|
||||
|
||||
#### 示例代码
|
||||
|
||||
|
||||
2
build/api/request.d.ts
vendored
2
build/api/request.d.ts
vendored
@@ -1,3 +1,3 @@
|
||||
import { IRequestOption } from '../interface';
|
||||
declare const _default: (obj: IRequestOption) => any;
|
||||
declare const _default: <TResp>(obj: IRequestOption) => Promise<TResp>;
|
||||
export default _default;
|
||||
|
||||
10
build/interface.d.ts
vendored
10
build/interface.d.ts
vendored
@@ -1,4 +1,6 @@
|
||||
/// <reference types="wx" />
|
||||
/// <reference types="wechat-miniprogram" />
|
||||
export declare type Request = <TResp>(options: IRequestOption) => Promise<TResp>;
|
||||
export declare type IAnyObject = WechatMiniprogram.IAnyObject;
|
||||
export interface IInitOption {
|
||||
codeToSession: ICodeToSessionOptions;
|
||||
sessionName: string;
|
||||
@@ -23,7 +25,7 @@ export interface IInitOption {
|
||||
}
|
||||
export interface ICodeToSessionOptions {
|
||||
url: string;
|
||||
method?: 'OPTIONS' | 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'TRACE' | 'CONNECT' | 'string';
|
||||
method?: 'OPTIONS' | 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'TRACE' | 'CONNECT';
|
||||
codeName?: string;
|
||||
data?: string | Function | IAnyObject | ArrayBuffer;
|
||||
success: Function;
|
||||
@@ -41,7 +43,7 @@ export interface IRequestOption extends IRequestObject {
|
||||
fail?: (res: string | IAnyObject | ArrayBuffer) => void;
|
||||
catchError?: boolean;
|
||||
}
|
||||
export interface IRequestObject extends wx.RequestOption {
|
||||
export interface IRequestObject extends WechatMiniprogram.RequestOption {
|
||||
originUrl?: string;
|
||||
reLoginCount?: number;
|
||||
_reportStartTime?: number;
|
||||
@@ -58,7 +60,7 @@ export interface IUploadFileOption extends IUploadFileObject {
|
||||
fail?: (res: string | IAnyObject | ArrayBuffer) => void;
|
||||
catchError?: boolean;
|
||||
}
|
||||
export interface IUploadFileObject extends wx.UploadFileOption {
|
||||
export interface IUploadFileObject extends WechatMiniprogram.UploadFileOption {
|
||||
originUrl?: string;
|
||||
reLoginCount?: number;
|
||||
_reportStartTime?: number;
|
||||
|
||||
8
build/module/errorHandler.d.ts
vendored
8
build/module/errorHandler.d.ts
vendored
@@ -1,8 +1,8 @@
|
||||
/// <reference types="wx" />
|
||||
/// <reference types="wechat-miniprogram" />
|
||||
import { IRequestOption, IUploadFileOption } from "../interface";
|
||||
declare function systemError(obj: IRequestOption | IUploadFileOption, res: wx.GeneralCallbackResult): void;
|
||||
declare function logicError(obj: IRequestOption | IUploadFileOption, res: wx.RequestSuccessCallbackResult | wx.UploadFileSuccessCallbackResult): void;
|
||||
declare function getErrorMsg(res: wx.RequestSuccessCallbackResult | wx.UploadFileSuccessCallbackResult): {
|
||||
declare function systemError(obj: IRequestOption | IUploadFileOption, res: WechatMiniprogram.GeneralCallbackResult): void;
|
||||
declare function logicError(obj: IRequestOption | IUploadFileOption, res: WechatMiniprogram.RequestSuccessCallbackResult | WechatMiniprogram.UploadFileSuccessCallbackResult): void;
|
||||
declare function getErrorMsg(res: WechatMiniprogram.RequestSuccessCallbackResult | WechatMiniprogram.UploadFileSuccessCallbackResult): {
|
||||
title: string;
|
||||
content: string;
|
||||
};
|
||||
|
||||
2
build/module/requestHandler.d.ts
vendored
2
build/module/requestHandler.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
import { IRequestOption, IUploadFileOption } from "../interface";
|
||||
declare function format(originUrl: string): string;
|
||||
declare function request(obj: IRequestOption): any;
|
||||
declare function request<TResp>(obj: IRequestOption): Promise<TResp>;
|
||||
declare function uploadFile(obj: IUploadFileOption): any;
|
||||
declare const _default: {
|
||||
format: typeof format;
|
||||
|
||||
6
build/module/responseHandler.d.ts
vendored
6
build/module/responseHandler.d.ts
vendored
@@ -1,7 +1,7 @@
|
||||
/// <reference types="wx" />
|
||||
/// <reference types="wechat-miniprogram" />
|
||||
import { IRequestOption, IUploadFileOption } from "../interface";
|
||||
declare function responseForRequest(res: wx.RequestSuccessCallbackResult, obj: IRequestOption): any;
|
||||
declare function responseForUploadFile(res: wx.UploadFileSuccessCallbackResult, obj: IUploadFileOption): any;
|
||||
declare function responseForRequest(res: WechatMiniprogram.RequestSuccessCallbackResult, obj: IRequestOption): any;
|
||||
declare function responseForUploadFile(res: WechatMiniprogram.UploadFileSuccessCallbackResult, obj: IUploadFileOption): any;
|
||||
declare const _default: {
|
||||
responseForRequest: typeof responseForRequest;
|
||||
responseForUploadFile: typeof responseForUploadFile;
|
||||
|
||||
File diff suppressed because one or more lines are too long
4
build/weRequest.min.js
vendored
4
build/weRequest.min.js
vendored
File diff suppressed because one or more lines are too long
11
package.json
11
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "we-request",
|
||||
"version": "1.3.1",
|
||||
"version": "1.4.0",
|
||||
"description": "本工具通过拓展小程序的wx.request,让开发者通过简单的配置,实现自动管理登录态等功能",
|
||||
"keywords": [
|
||||
"登录态",
|
||||
@@ -20,17 +20,16 @@
|
||||
"url": "https://github.com/IvinWu/weRequest.git"
|
||||
},
|
||||
"main": "build/weRequest.js",
|
||||
"typings": [
|
||||
"build/index.d.ts",
|
||||
"typings"
|
||||
],
|
||||
"types": "build/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "webpack --display-error-details",
|
||||
"commit": "git cz",
|
||||
"pub": "npm publish",
|
||||
"test": "jest test"
|
||||
},
|
||||
"dependencies": {},
|
||||
"dependencies": {
|
||||
"@types/wechat-miniprogram": "^3.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.12.9",
|
||||
"@babel/preset-env": "^7.12.7",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import requestHandler from '../module/requestHandler'
|
||||
import { IRequestOption } from '../interface'
|
||||
|
||||
export default (obj: IRequestOption) => {
|
||||
export default <TResp>(obj: IRequestOption): Promise<TResp> => {
|
||||
return requestHandler.request(obj)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
export type Request = <TResp>(options: IRequestOption) => Promise<TResp>;
|
||||
|
||||
export type IAnyObject = WechatMiniprogram.IAnyObject;
|
||||
|
||||
export interface IInitOption {
|
||||
/* 用code换取session的CGI配置 */
|
||||
codeToSession: ICodeToSessionOptions;
|
||||
@@ -51,27 +55,27 @@ export interface IInitOption {
|
||||
}
|
||||
|
||||
export interface ICodeToSessionOptions{
|
||||
/* CGI的url */
|
||||
url: string;
|
||||
/* 调用该CGI的方法 */
|
||||
method?: 'OPTIONS'
|
||||
| 'GET'
|
||||
| 'HEAD'
|
||||
| 'POST'
|
||||
| 'PUT'
|
||||
| 'DELETE'
|
||||
| 'TRACE'
|
||||
| 'CONNECT' | 'string',
|
||||
/* CGI中传参时,存放code的名称 */
|
||||
codeName?: string;
|
||||
/* 登录接口需要的其他参数 */
|
||||
data?: string | Function | IAnyObject | ArrayBuffer;
|
||||
/* 接口返回成功的函数;需要返回session的值 */
|
||||
success: Function;
|
||||
/* code换取session的接口逻辑出错时,执行的函数,若配置了此函数,则不再默认弹窗报错 */
|
||||
fail?: Function;
|
||||
/* codeToSession的上报字段名 */
|
||||
report?: string;
|
||||
/* CGI的url */
|
||||
url: string;
|
||||
/* 调用该CGI的方法 */
|
||||
method?: 'OPTIONS'
|
||||
| 'GET'
|
||||
| 'HEAD'
|
||||
| 'POST'
|
||||
| 'PUT'
|
||||
| 'DELETE'
|
||||
| 'TRACE'
|
||||
| 'CONNECT',
|
||||
/* CGI中传参时,存放code的名称 */
|
||||
codeName?: string;
|
||||
/* 登录接口需要的其他参数 */
|
||||
data?: string | Function | IAnyObject | ArrayBuffer;
|
||||
/* 接口返回成功的函数;需要返回session的值 */
|
||||
success: Function;
|
||||
/* code换取session的接口逻辑出错时,执行的函数,若配置了此函数,则不再默认弹窗报错 */
|
||||
fail?: Function;
|
||||
/* codeToSession的上报字段名 */
|
||||
report?: string;
|
||||
}
|
||||
|
||||
export interface IRequestOption extends IRequestObject {
|
||||
@@ -95,7 +99,7 @@ export interface IRequestOption extends IRequestObject {
|
||||
catchError?: boolean;
|
||||
}
|
||||
|
||||
export interface IRequestObject extends wx.RequestOption{
|
||||
export interface IRequestObject extends WechatMiniprogram.RequestOption{
|
||||
/* 业务请求的原始url */
|
||||
originUrl?: string;
|
||||
/* 重登陆次数 */
|
||||
@@ -127,7 +131,7 @@ export interface IUploadFileOption extends IUploadFileObject {
|
||||
catchError?: boolean;
|
||||
}
|
||||
|
||||
export interface IUploadFileObject extends wx.UploadFileOption {
|
||||
export interface IUploadFileObject extends WechatMiniprogram.UploadFileOption {
|
||||
/* 业务请求的原始url */
|
||||
originUrl?: string;
|
||||
/* 重登陆次数 */
|
||||
|
||||
@@ -2,7 +2,7 @@ import config from '../store/config'
|
||||
import request from '../api/request';
|
||||
import { IRequestOption, IUploadFileOption } from "../interface";
|
||||
|
||||
function systemError(obj: IRequestOption | IUploadFileOption, res: wx.GeneralCallbackResult) {
|
||||
function systemError(obj: IRequestOption | IUploadFileOption, res: WechatMiniprogram.GeneralCallbackResult) {
|
||||
if (typeof obj.fail === "function") {
|
||||
obj.fail(res);
|
||||
} else {
|
||||
@@ -11,7 +11,7 @@ function systemError(obj: IRequestOption | IUploadFileOption, res: wx.GeneralCal
|
||||
}
|
||||
}
|
||||
|
||||
function logicError(obj: IRequestOption | IUploadFileOption, res: wx.RequestSuccessCallbackResult | wx.UploadFileSuccessCallbackResult) {
|
||||
function logicError(obj: IRequestOption | IUploadFileOption, res: WechatMiniprogram.RequestSuccessCallbackResult | WechatMiniprogram.UploadFileSuccessCallbackResult) {
|
||||
if (typeof obj.fail === "function") {
|
||||
obj.fail(res);
|
||||
} else if (typeof config.errorHandler === 'function') {
|
||||
@@ -23,7 +23,7 @@ function logicError(obj: IRequestOption | IUploadFileOption, res: wx.RequestSucc
|
||||
}
|
||||
}
|
||||
|
||||
function getErrorMsg(res: wx.RequestSuccessCallbackResult | wx.UploadFileSuccessCallbackResult) {
|
||||
function getErrorMsg(res: WechatMiniprogram.RequestSuccessCallbackResult | WechatMiniprogram.UploadFileSuccessCallbackResult) {
|
||||
let title = "";
|
||||
if (typeof config.errorTitle === "function") {
|
||||
try {
|
||||
@@ -59,7 +59,7 @@ function doError(title: string, content: string, retry?: () => any) {
|
||||
} : {
|
||||
showCancel: true,
|
||||
confirmText: '重试',
|
||||
success(res: wx.ShowModalSuccessCallbackResult) {
|
||||
success(res: WechatMiniprogram.ShowModalSuccessCallbackResult) {
|
||||
if (res.confirm && typeof retry === "function") retry();
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -149,10 +149,10 @@ function doRequest(obj: IRequestOption) {
|
||||
method: obj.method,
|
||||
header: obj.header || {},
|
||||
dataType: obj.dataType || 'json',
|
||||
success(res: wx.RequestSuccessCallbackResult) {
|
||||
success(res: WechatMiniprogram.RequestSuccessCallbackResult) {
|
||||
return resolve(res);
|
||||
},
|
||||
fail(res: wx.GeneralCallbackResult) {
|
||||
fail(res: WechatMiniprogram.GeneralCallbackResult) {
|
||||
errorHandler.systemError(obj, res);
|
||||
return reject(res);
|
||||
},
|
||||
@@ -176,10 +176,10 @@ function doUploadFile(obj: IUploadFileOption) {
|
||||
filePath: obj.filePath || '',
|
||||
name: obj.name || '',
|
||||
formData: obj.formData,
|
||||
success(res: wx.UploadFileSuccessCallbackResult) {
|
||||
success(res: WechatMiniprogram.UploadFileSuccessCallbackResult) {
|
||||
return resolve(res);
|
||||
},
|
||||
fail(res: wx.GeneralCallbackResult) {
|
||||
fail(res: WechatMiniprogram.GeneralCallbackResult) {
|
||||
errorHandler.systemError(obj, res);
|
||||
return reject(res);
|
||||
},
|
||||
@@ -195,7 +195,7 @@ function doUploadFile(obj: IUploadFileOption) {
|
||||
})
|
||||
}
|
||||
|
||||
function request(obj: IRequestOption): any {
|
||||
function request<TResp>(obj: IRequestOption): Promise<TResp> {
|
||||
return new Promise((resolve, reject) => {
|
||||
obj = preDo(obj, resolve, reject);
|
||||
|
||||
@@ -214,7 +214,7 @@ function request(obj: IRequestOption): any {
|
||||
sessionManager.main(obj).then(() => {
|
||||
return doRequest(obj)
|
||||
}).then((res) => {
|
||||
let response = responseHandler.responseForRequest(res as wx.RequestSuccessCallbackResult, obj);
|
||||
let response = responseHandler.responseForRequest(res as WechatMiniprogram.RequestSuccessCallbackResult, obj);
|
||||
if (response != null) {
|
||||
return resolve(response);
|
||||
}
|
||||
@@ -239,7 +239,7 @@ function uploadFile(obj: IUploadFileOption): any {
|
||||
sessionManager.main(obj).then(() => {
|
||||
return doUploadFile(obj)
|
||||
}).then((res) => {
|
||||
let response = responseHandler.responseForUploadFile(res as wx.UploadFileSuccessCallbackResult, obj);
|
||||
let response = responseHandler.responseForUploadFile(res as WechatMiniprogram.UploadFileSuccessCallbackResult, obj);
|
||||
if (response != null) {
|
||||
return resolve(response);
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@ import errorHandler from './errorHandler'
|
||||
import cacheManager from './cacheManager'
|
||||
import durationReporter from './durationReporter'
|
||||
import sessionManager from './sessionManager'
|
||||
import { IRequestOption, IUploadFileOption } from "../interface";
|
||||
import { IRequestOption, IUploadFileOption, IAnyObject } from "../interface";
|
||||
import jsonSuperset from '../util/jsonSuperset'
|
||||
|
||||
function responseForRequest(
|
||||
res: wx.RequestSuccessCallbackResult,
|
||||
res: WechatMiniprogram.RequestSuccessCallbackResult,
|
||||
obj: IRequestOption
|
||||
): any {
|
||||
if (res.statusCode === 200) {
|
||||
@@ -65,7 +65,7 @@ function responseForRequest(
|
||||
}
|
||||
|
||||
function responseForUploadFile(
|
||||
res: wx.UploadFileSuccessCallbackResult,
|
||||
res: WechatMiniprogram.UploadFileSuccessCallbackResult,
|
||||
obj: IUploadFileOption
|
||||
): any {
|
||||
if (res.statusCode === 200) {
|
||||
|
||||
@@ -153,7 +153,7 @@ function code2Session(code: string) {
|
||||
data,
|
||||
method: config.codeToSession.method || 'GET',
|
||||
header: typeof config.setHeader === 'function' ? config.setHeader(): config.setHeader,
|
||||
success(res: wx.RequestSuccessCallbackResult) {
|
||||
success(res: WechatMiniprogram.RequestSuccessCallbackResult) {
|
||||
if (res.statusCode === 200) {
|
||||
// 耗时上报
|
||||
if (config.codeToSession.report) {
|
||||
@@ -161,13 +161,13 @@ function code2Session(code: string) {
|
||||
durationReporter.report(config.codeToSession.report, start, end)
|
||||
}
|
||||
|
||||
let s = "";
|
||||
let s;
|
||||
try {
|
||||
s = config.codeToSession.success(res.data);
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
if (s) {
|
||||
if (typeof s === 'string') {
|
||||
status.session = s;
|
||||
// 换回来的session,不需要再checkSession
|
||||
config.doNotCheckSession = true;
|
||||
@@ -183,7 +183,7 @@ function code2Session(code: string) {
|
||||
key: config.sessionName,
|
||||
data: status.session
|
||||
});
|
||||
return resolve();
|
||||
return resolve(s);
|
||||
} else {
|
||||
return reject(errorHandler.getErrorMsg(res));
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
"removeComments": true,
|
||||
"pretty": true,
|
||||
"strictPropertyInitialization": true,
|
||||
"typeRoots": ["typings"],
|
||||
"lib": ["es5", "es2015", "dom", "scripthost"],
|
||||
"types": ["wechat-miniprogram"],
|
||||
"lib": ["es5", "es6"],
|
||||
"declaration": true
|
||||
},
|
||||
"include": ["./src/**/*.ts"],
|
||||
|
||||
12
typings/index.d.ts
vendored
12
typings/index.d.ts
vendored
@@ -1,12 +0,0 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) 2018 Tencent, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
***************************************************************************** */
|
||||
|
||||
/// <reference path="./lib.wa.es6.d.ts" />
|
||||
/// <reference path="./wx/index.d.ts" />
|
||||
5819
typings/lib.wa.es6.d.ts
vendored
5819
typings/lib.wa.es6.d.ts
vendored
File diff suppressed because it is too large
Load Diff
63
typings/wx/index.d.ts
vendored
63
typings/wx/index.d.ts
vendored
@@ -1,63 +0,0 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) 2018 Tencent, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
***************************************************************************** */
|
||||
|
||||
/// <reference path="./lib.wx.app.d.ts" />
|
||||
/// <reference path="./lib.wx.page.d.ts" />
|
||||
/// <reference path="./lib.wx.api.d.ts" />
|
||||
/// <reference path="./lib.wx.cloud.d.ts" />
|
||||
|
||||
declare type IAnyObject = Record<string, any>;
|
||||
|
||||
declare type KVInfer<T> = { [K in keyof T]: T[K] };
|
||||
|
||||
declare type Void<T> = T | undefined | null;
|
||||
|
||||
type PartialOptional<T, K extends keyof T> = Partial<Pick<T, K>> &
|
||||
Pick<T, Exclude<keyof T, K>>;
|
||||
|
||||
/**
|
||||
* Make all properties in T required
|
||||
*/
|
||||
// type Required<T> = {
|
||||
// [P in keyof T]-?: T[P];
|
||||
// };
|
||||
|
||||
/**
|
||||
* Exclude from T those types that are assignable to U
|
||||
*/
|
||||
// type Exclude<T, U> = T extends U ? never : T;
|
||||
|
||||
/**
|
||||
* Extract from T those types that are assignable to U
|
||||
*/
|
||||
// type Extract<T, U> = T extends U ? T : never;
|
||||
|
||||
/**
|
||||
* Exclude null and undefined from T
|
||||
*/
|
||||
// type NonNullable<T> = T extends null | undefined ? never : T;
|
||||
|
||||
/**
|
||||
* Obtain the return type of a function type
|
||||
*/
|
||||
// type ReturnType<T extends (...args: any[]) => any> = T extends (...args: any[]) => infer R ? R : any;
|
||||
|
||||
/**
|
||||
* Obtain the return type of a constructor function type
|
||||
*/
|
||||
// type InstanceType<T extends new (...args: any[]) => any> = T extends new (...args: any[]) => infer R ? R : any;
|
||||
|
||||
type Optional<T> = { [K in keyof T]+?: T[K] };
|
||||
|
||||
// 临时解决ts,后续小程序工具会更新
|
||||
declare function Component(...args: any[]): any;
|
||||
declare function requirePlugin(pluginName: string): any;
|
||||
declare function require(pluginName: string): any;
|
||||
type TODO = any;
|
||||
12396
typings/wx/lib.wx.api.d.ts
vendored
12396
typings/wx/lib.wx.api.d.ts
vendored
File diff suppressed because it is too large
Load Diff
250
typings/wx/lib.wx.app.d.ts
vendored
250
typings/wx/lib.wx.app.d.ts
vendored
@@ -1,250 +0,0 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) 2018 Tencent, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
declare namespace App {
|
||||
interface ILaunchOptions {
|
||||
query: number
|
||||
}
|
||||
|
||||
interface IReferrerInfo {
|
||||
/** 来源小程序或公众号或App的 appId
|
||||
*
|
||||
* 以下场景支持返回 referrerInfo.appId:
|
||||
* - 1020(公众号 profile 页相关小程序列表): appId
|
||||
* - 1035(公众号自定义菜单):来源公众号 appId
|
||||
* - 1036(App 分享消息卡片):来源应用 appId
|
||||
* - 1037(小程序打开小程序):来源小程序 appId
|
||||
* - 1038(从另一个小程序返回):来源小程序 appId
|
||||
* - 1043(公众号模板消息):来源公众号 appId
|
||||
*/
|
||||
appId: string
|
||||
/** 来源小程序传过来的数据,scene=1037或1038时支持 */
|
||||
extraData?: any
|
||||
}
|
||||
|
||||
type SceneValues = 1001
|
||||
| 1005
|
||||
| 1006
|
||||
| 1007
|
||||
| 1008
|
||||
| 1011
|
||||
| 1012
|
||||
| 1013
|
||||
| 1014
|
||||
| 1017
|
||||
| 1019
|
||||
| 1020
|
||||
| 1022
|
||||
| 1023
|
||||
| 1024
|
||||
| 1025
|
||||
| 1026
|
||||
| 1027
|
||||
| 1028
|
||||
| 1029
|
||||
| 1030
|
||||
| 1031
|
||||
| 1032
|
||||
| 1034
|
||||
| 1035
|
||||
| 1036
|
||||
| 1037
|
||||
| 1038
|
||||
| 1039
|
||||
| 1042
|
||||
| 1043
|
||||
| 1044
|
||||
| 1045
|
||||
| 1046
|
||||
| 1047
|
||||
| 1048
|
||||
| 1049
|
||||
| 1052
|
||||
| 1053
|
||||
| 1054
|
||||
| 1056
|
||||
| 1057
|
||||
| 1058
|
||||
| 1059
|
||||
| 1064
|
||||
| 1067
|
||||
| 1068
|
||||
| 1069
|
||||
| 1071
|
||||
| 1072
|
||||
| 1073
|
||||
| 1074
|
||||
| 1077
|
||||
| 1078
|
||||
| 1079
|
||||
| 1081
|
||||
| 1082
|
||||
| 1084
|
||||
| 1089
|
||||
| 1090
|
||||
| 1091
|
||||
| 1092
|
||||
| 1095
|
||||
| 1096
|
||||
| 1097
|
||||
| 1099
|
||||
| 1102
|
||||
| 1103
|
||||
| 1104
|
||||
| number
|
||||
|
||||
interface ILaunchShowOption {
|
||||
/** 打开小程序的路径 */
|
||||
path: string
|
||||
/** 打开小程序的query */
|
||||
query: IAnyObject
|
||||
/** 打开小程序的场景值
|
||||
* - 1001: 发现栏小程序主入口,「最近使用」列表(基础库2.2.4版本起包含「我的小程序」列表)
|
||||
* - 1005: 顶部搜索框的搜索结果页
|
||||
* - 1006: 发现栏小程序主入口搜索框的搜索结果页
|
||||
* - 1007: 单人聊天会话中的小程序消息卡片
|
||||
* - 1008: 群聊会话中的小程序消息卡片
|
||||
* - 1011: 扫描二维码
|
||||
* - 1012: 长按图片识别二维码
|
||||
* - 1013: 手机相册选取二维码
|
||||
* - 1014: 小程序模板消息
|
||||
* - 1017: 前往体验版的入口页
|
||||
* - 1019: 微信钱包
|
||||
* - 1020: 公众号 profile 页相关小程序列表
|
||||
* - 1022: 聊天顶部置顶小程序入口
|
||||
* - 1023: 安卓系统桌面图标
|
||||
* - 1024: 小程序 profile 页
|
||||
* - 1025: 扫描一维码
|
||||
* - 1026: 附近小程序列表
|
||||
* - 1027: 顶部搜索框搜索结果页「使用过的小程序」列表
|
||||
* - 1028: 我的卡包
|
||||
* - 1029: 卡券详情页
|
||||
* - 1030: 自动化测试下打开小程序
|
||||
* - 1031: 长按图片识别一维码
|
||||
* - 1032: 手机相册选取一维码
|
||||
* - 1034: 微信支付完成页
|
||||
* - 1035: 公众号自定义菜单
|
||||
* - 1036: App 分享消息卡片
|
||||
* - 1037: 小程序打开小程序
|
||||
* - 1038: 从另一个小程序返回
|
||||
* - 1039: 摇电视
|
||||
* - 1042: 添加好友搜索框的搜索结果页
|
||||
* - 1043: 公众号模板消息
|
||||
* - 1044: 带 shareTicket 的小程序消息卡片 [详情]((转发#获取更多转发信息))
|
||||
* - 1045: 朋友圈广告
|
||||
* - 1046: 朋友圈广告详情页
|
||||
* - 1047: 扫描小程序码
|
||||
* - 1048: 长按图片识别小程序码
|
||||
* - 1049: 手机相册选取小程序码
|
||||
* - 1052: 卡券的适用门店列表
|
||||
* - 1053: 搜一搜的结果页
|
||||
* - 1054: 顶部搜索框小程序快捷入口
|
||||
* - 1056: 音乐播放器菜单
|
||||
* - 1057: 钱包中的银行卡详情页
|
||||
* - 1058: 公众号文章
|
||||
* - 1059: 体验版小程序绑定邀请页
|
||||
* - 1064: 微信连Wi-Fi状态栏
|
||||
* - 1067: 公众号文章广告
|
||||
* - 1068: 附近小程序列表广告
|
||||
* - 1069: 移动应用
|
||||
* - 1071: 钱包中的银行卡列表页
|
||||
* - 1072: 二维码收款页面
|
||||
* - 1073: 客服消息列表下发的小程序消息卡片
|
||||
* - 1074: 公众号会话下发的小程序消息卡片
|
||||
* - 1077: 摇周边
|
||||
* - 1078: 连Wi-Fi成功页
|
||||
* - 1079: 微信游戏中心
|
||||
* - 1081: 客服消息下发的文字链
|
||||
* - 1082: 公众号会话下发的文字链
|
||||
* - 1084: 朋友圈广告原生页
|
||||
* - 1089: 微信聊天主界面下拉,「最近使用」栏(基础库2.2.4版本起包含「我的小程序」栏)
|
||||
* - 1090: 长按小程序右上角菜单唤出最近使用历史
|
||||
* - 1091: 公众号文章商品卡片
|
||||
* - 1092: 城市服务入口
|
||||
* - 1095: 小程序广告组件
|
||||
* - 1096: 聊天记录
|
||||
* - 1097: 微信支付签约页
|
||||
* - 1099: 页面内嵌插件
|
||||
* - 1102: 公众号 profile 页服务预览
|
||||
* - 1103: 发现栏小程序主入口,「我的小程序」列表(基础库2.2.4版本起废弃)
|
||||
* - 1104: 微信聊天主界面下拉,「我的小程序」栏(基础库2.2.4版本起废弃)
|
||||
*/
|
||||
scene: SceneValues
|
||||
/** shareTicket,详见 [获取更多转发信息]((转发#获取更多转发信息)) */
|
||||
shareTicket: string
|
||||
/** 当场景为由从另一个小程序或公众号或App打开时,返回此字段 */
|
||||
referrerInfo?: IReferrerInfo
|
||||
}
|
||||
|
||||
interface IPageNotFoundOption {
|
||||
/** 不存在页面的路径 */
|
||||
path: string
|
||||
/** 打开不存在页面的 query */
|
||||
query: IAnyObject
|
||||
/** 是否本次启动的首个页面(例如从分享等入口进来,首个页面是开发者配置的分享页面) */
|
||||
isEntryPage: boolean
|
||||
}
|
||||
|
||||
interface AppInstance<T extends IAnyObject = {}> {
|
||||
/** 生命周期回调—监听小程序初始化
|
||||
*
|
||||
* 小程序初始化完成时触发,全局只触发一次。
|
||||
*/
|
||||
onLaunch?(options?: ILaunchShowOption): void
|
||||
/** 生命周期回调—监听小程序显示
|
||||
*
|
||||
* 小程序启动,或从后台进入前台显示时
|
||||
*/
|
||||
onShow?(options?: ILaunchShowOption): void
|
||||
/** 生命周期回调—监听小程序隐藏
|
||||
*
|
||||
* 小程序从前台进入后台时
|
||||
*/
|
||||
onHide?(): void
|
||||
/** 错误监听函数
|
||||
*
|
||||
* 小程序发生脚本错误,或者 api
|
||||
*/
|
||||
onError?(/** 错误信息,包含堆栈 */error?: string): void
|
||||
/** 页面不存在监听函数
|
||||
*
|
||||
* 小程序要打开的页面不存在时触发,会带上页面信息回调该函数
|
||||
*
|
||||
* **注意:**
|
||||
* 1. 如果开发者没有添加 `onPageNotFound` 监听,当跳转页面不存在时,将推入微信客户端原生的页面不存在提示页面。
|
||||
* 2. 如果 `onPageNotFound` 回调中又重定向到另一个不存在的页面,将推入微信客户端原生的页面不存在提示页面,并且不再回调 `onPageNotFound`。
|
||||
*
|
||||
* 最低基础库: 1.9.90
|
||||
*/
|
||||
onPageNotFound?(options?: IPageNotFoundOption): void
|
||||
}
|
||||
|
||||
interface AppConstructor {
|
||||
<T extends IAnyObject & AppInstance>(
|
||||
options: AppInstance<T> & T
|
||||
): void
|
||||
}
|
||||
|
||||
interface IGetAppOption {
|
||||
/** 在 `App` 未定义时返回默认实现。当App被调用时,默认实现中定义的属性会被覆盖合并到App中。一般用于独立分包
|
||||
*
|
||||
* 最低基础库: 2.2.4
|
||||
*/
|
||||
allowDefault: boolean
|
||||
}
|
||||
|
||||
interface GetApp {
|
||||
<T extends IAnyObject>(opts?: IGetAppOption): AppInstance<T> & T
|
||||
}
|
||||
}
|
||||
|
||||
declare const App: App.AppConstructor
|
||||
declare const getApp: App.GetApp
|
||||
687
typings/wx/lib.wx.cloud.d.ts
vendored
687
typings/wx/lib.wx.cloud.d.ts
vendored
@@ -1,687 +0,0 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) 2018 Tencent, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
***************************************************************************** */
|
||||
|
||||
/////////////////////
|
||||
///// WX Cloud Apis
|
||||
/////////////////////
|
||||
|
||||
/**
|
||||
* Common interfaces and types
|
||||
*/
|
||||
|
||||
interface IAPIError {
|
||||
errMsg: string,
|
||||
}
|
||||
|
||||
interface IAPIParam<T = any> {
|
||||
config?: ICloudConfig,
|
||||
success?: (res: T) => void,
|
||||
fail?: (err: IAPIError) => void,
|
||||
complete?: (val: T | IAPIError) => void,
|
||||
}
|
||||
|
||||
interface IAPISuccessParam {
|
||||
errMsg: string,
|
||||
}
|
||||
|
||||
type IAPICompleteParam = IAPISuccessParam | IAPIError
|
||||
|
||||
type IAPIFunction<T, P extends IAPIParam<T>> = (param: P) => Promise<T> | any
|
||||
|
||||
interface IInitCloudConfig {
|
||||
env?: string | {
|
||||
database?: string,
|
||||
functions?: string,
|
||||
storage?: string,
|
||||
},
|
||||
traceUser?: boolean,
|
||||
}
|
||||
|
||||
interface ICloudConfig {
|
||||
env?: string,
|
||||
traceUser?: boolean,
|
||||
}
|
||||
|
||||
interface IICloudAPI {
|
||||
init: (config?: IInitCloudConfig) => void,
|
||||
[api: string]: AnyFunction | IAPIFunction<any, any>,
|
||||
}
|
||||
|
||||
interface ICloudService {
|
||||
name: string,
|
||||
|
||||
getAPIs: () => { [name: string]: IAPIFunction<any, any> },
|
||||
}
|
||||
|
||||
interface ICloudServices {
|
||||
[serviceName: string]: ICloudService
|
||||
}
|
||||
|
||||
interface ICloudMetaData {
|
||||
session_id: string,
|
||||
}
|
||||
|
||||
declare class InternalSymbol {
|
||||
|
||||
}
|
||||
|
||||
type AnyObject = {
|
||||
[x: string]: any
|
||||
}
|
||||
|
||||
type AnyArray = any[]
|
||||
|
||||
type AnyFunction = (...args: any[]) => any
|
||||
|
||||
/**
|
||||
* original wx
|
||||
*/
|
||||
|
||||
declare namespace WXNS {
|
||||
|
||||
interface AnyObject {
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
interface IAPIParam<T> {
|
||||
success?: (res: T) => void,
|
||||
fail?: (err: IAPIError) => void,
|
||||
complete?: (val: T | IAPIError) => void,
|
||||
}
|
||||
|
||||
interface CommonAPIResult {
|
||||
errMsg: string,
|
||||
}
|
||||
|
||||
interface IAPIError {
|
||||
errMsg: string,
|
||||
}
|
||||
|
||||
interface IProgressUpdateEvent {
|
||||
progress: number,
|
||||
totalBytesWritten: number,
|
||||
totalBytesExpectedToWrite: number,
|
||||
}
|
||||
|
||||
interface operateWXData {
|
||||
(param: any): void
|
||||
}
|
||||
|
||||
interface uploadFile {
|
||||
/**
|
||||
* upload file
|
||||
* @param param
|
||||
*/
|
||||
(param: IUploadFileParam): IUploadFileTask
|
||||
}
|
||||
|
||||
interface IUploadFileParam extends IAPIParam<IUploadFileSuccessResult> {
|
||||
url: string,
|
||||
filePath: string,
|
||||
name: string,
|
||||
header?: AnyObject,
|
||||
}
|
||||
|
||||
interface IUploadFileSuccessResult extends CommonAPIResult {
|
||||
data: string,
|
||||
statusCode: number,
|
||||
}
|
||||
|
||||
interface IUploadFileTask {
|
||||
onProgressUpdate: (fn: (event: IProgressUpdateEvent) => void) => void,
|
||||
abort: AnyFunction,
|
||||
}
|
||||
|
||||
interface downloadFile {
|
||||
/**
|
||||
* download file
|
||||
* @param param
|
||||
*/
|
||||
(param: IDownloadFileParam): IDownloadFileTask
|
||||
}
|
||||
|
||||
interface IDownloadFileParam extends IAPIParam<IDownloadFileSuccessResult> {
|
||||
url: string,
|
||||
header?: AnyObject,
|
||||
}
|
||||
|
||||
interface IDownloadFileSuccessResult extends CommonAPIResult {
|
||||
tempFilePath: string,
|
||||
statusCode: number,
|
||||
}
|
||||
|
||||
interface IDownloadFileTask {
|
||||
onProgressUpdate: (fn: (event: IProgressUpdateEvent) => void) => void,
|
||||
abort: AnyFunction,
|
||||
}
|
||||
|
||||
interface request {
|
||||
(param: IRequestParam): IRequestTask
|
||||
}
|
||||
|
||||
interface IRequestParam extends IAPIParam<IRequestSuccessResult> {
|
||||
url: string,
|
||||
data?: AnyObject | string | ArrayBuffer,
|
||||
header?: AnyObject,
|
||||
method?: string,
|
||||
dataType?: string,
|
||||
responseType?: string,
|
||||
}
|
||||
|
||||
interface IRequestSuccessResult {
|
||||
data: AnyObject | string | ArrayBuffer,
|
||||
statusCode: number,
|
||||
header: AnyObject,
|
||||
}
|
||||
|
||||
interface IRequestTask {
|
||||
abort: () => void
|
||||
}
|
||||
|
||||
interface getFileInfo {
|
||||
(param: IGetFileInfoParam): void
|
||||
}
|
||||
|
||||
interface IGetFileInfoParam extends IAPIParam<IGetFileInfoSuccessResult> {
|
||||
filePath: string,
|
||||
digestAlgorithm?: string,
|
||||
}
|
||||
|
||||
interface IGetFileInfoSuccessResult {
|
||||
size: number,
|
||||
digest: string,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
declare namespace wx {
|
||||
interface WX {
|
||||
cloud: {
|
||||
init: (config?: ICloudConfig) => void,
|
||||
|
||||
// callFunction: (param: ICloud.CallFunctionParam) => Promise<ICloud.CallFunctionResult> | void,
|
||||
|
||||
// uploadFile: (param: ICloud.UploadFileParam) => Promise<ICloud.UploadFileResult> | WXNS.IUploadFileTask,
|
||||
// downloadFile: (param: ICloud.DownloadFileParam) => Promise<ICloud.DownloadFileResult> | WXNS.IDownloadFileTask,
|
||||
// getTempFileURL: (param: ICloud.GetTempFileURLParam) => Promise<ICloud.GetTempFileURLResult> | void,
|
||||
// deleteFile: (param: ICloud.DeleteFileParam) => Promise<ICloud.DeleteFileResult> | void,
|
||||
|
||||
callFunction(param: OQ<ICloud.CallFunctionParam>): void
|
||||
callFunction(param: RQ<ICloud.CallFunctionParam>): Promise<ICloud.CallFunctionResult>
|
||||
|
||||
uploadFile(param: OQ<ICloud.UploadFileParam>): WXNS.IUploadFileTask
|
||||
uploadFile(param: RQ<ICloud.UploadFileParam>): Promise<ICloud.UploadFileResult>
|
||||
|
||||
downloadFile(param: OQ<ICloud.DownloadFileParam>): WXNS.IDownloadFileTask
|
||||
downloadFile(param: RQ<ICloud.DownloadFileParam>): Promise<ICloud.DownloadFileResult>
|
||||
|
||||
getTempFileURL(param: OQ<ICloud.GetTempFileURLParam>): void,
|
||||
getTempFileURL(param: RQ<ICloud.GetTempFileURLParam>): Promise<ICloud.GetTempFileURLResult>
|
||||
|
||||
deleteFile(param: OQ<ICloud.DeleteFileParam>): void,
|
||||
deleteFile(param: RQ<ICloud.DeleteFileParam>): Promise<ICloud.DeleteFileResult>
|
||||
|
||||
database: (config?: ICloudConfig) => DB.Database,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare namespace ICloud {
|
||||
|
||||
interface ICloudAPIParam<T = any> extends IAPIParam<T> {
|
||||
config?: ICloudConfig
|
||||
}
|
||||
|
||||
// === API: callFunction ===
|
||||
export type CallFunctionData = AnyObject
|
||||
|
||||
export interface CallFunctionResult extends IAPISuccessParam {
|
||||
result: AnyObject | string | undefined,
|
||||
}
|
||||
|
||||
export interface CallFunctionParam extends ICloudAPIParam<CallFunctionResult> {
|
||||
name: string,
|
||||
data?: CallFunctionData,
|
||||
slow?: boolean,
|
||||
}
|
||||
// === end ===
|
||||
|
||||
// === API: uploadFile ===
|
||||
export interface UploadFileResult extends IAPISuccessParam {
|
||||
fileID: string,
|
||||
statusCode: number,
|
||||
}
|
||||
|
||||
export interface UploadFileParam extends ICloudAPIParam<UploadFileResult> {
|
||||
cloudPath: string,
|
||||
filePath: string,
|
||||
header?: AnyObject,
|
||||
}
|
||||
// === end ===
|
||||
|
||||
// === API: downloadFile ===
|
||||
export interface DownloadFileResult extends IAPISuccessParam {
|
||||
tempFilePath: string,
|
||||
statusCode: number,
|
||||
}
|
||||
|
||||
export interface DownloadFileParam extends ICloudAPIParam<DownloadFileResult> {
|
||||
fileID: string,
|
||||
cloudPath?: string,
|
||||
}
|
||||
// === end ===
|
||||
|
||||
// === API: getTempFileURL ===
|
||||
export interface GetTempFileURLResult extends IAPISuccessParam {
|
||||
fileList: GetTempFileURLResultItem[],
|
||||
}
|
||||
|
||||
export interface GetTempFileURLResultItem {
|
||||
fileID: string,
|
||||
tempFileURL: string,
|
||||
maxAge: number,
|
||||
status: number,
|
||||
errMsg: string,
|
||||
}
|
||||
|
||||
export interface GetTempFileURLParam extends ICloudAPIParam<GetTempFileURLResult> {
|
||||
fileList: string[],
|
||||
}
|
||||
// === end ===
|
||||
|
||||
// === API: deleteFile ===
|
||||
interface DeleteFileResult extends IAPISuccessParam {
|
||||
fileList: DeleteFileResultItem[],
|
||||
}
|
||||
|
||||
interface DeleteFileResultItem {
|
||||
fileID: string,
|
||||
status: number,
|
||||
errMsg: string,
|
||||
}
|
||||
|
||||
interface DeleteFileParam extends ICloudAPIParam<DeleteFileResult> {
|
||||
fileList: string[],
|
||||
}
|
||||
// === end ===
|
||||
|
||||
}
|
||||
|
||||
// === Database ===
|
||||
declare namespace DB {
|
||||
/**
|
||||
* The class of all exposed cloud database instances
|
||||
*/
|
||||
export class Database {
|
||||
|
||||
public readonly config: ICloudConfig
|
||||
public readonly command: DatabaseCommand
|
||||
public readonly Geo: Geo
|
||||
public readonly serverDate: () => ServerDate
|
||||
|
||||
private constructor();
|
||||
|
||||
collection(collectionName: string): CollectionReference
|
||||
|
||||
}
|
||||
|
||||
export class CollectionReference extends Query {
|
||||
|
||||
public readonly collectionName: string
|
||||
public readonly database: Database
|
||||
|
||||
private constructor(name: string, database: Database)
|
||||
|
||||
doc(docId: string | number): DocumentReference
|
||||
|
||||
// add(options: IAddDocumentOptions): Promise<IAddResult> | void
|
||||
|
||||
add(options: OQ<IAddDocumentOptions>): void
|
||||
add(options: RQ<IAddDocumentOptions>): Promise<IAddResult>
|
||||
|
||||
}
|
||||
|
||||
export class DocumentReference {
|
||||
|
||||
private constructor(docId: string | number, database: Database)
|
||||
|
||||
field(object: object): this
|
||||
|
||||
// get(options?: IGetDocumentOptions): Promise<IQuerySingleResult> | void
|
||||
|
||||
// set(options?: ISetSingleDocumentOptions): Promise<ISetResult> | void
|
||||
|
||||
// update(options?: IUpdateSingleDocumentOptions): Promise<IUpdateResult> | void
|
||||
|
||||
// remove(options?: IRemoveSingleDocumentOptions): Promise<IRemoveResult> | void
|
||||
|
||||
// get(options?: IGetDocumentOptions): Promise<IQuerySingleResult> | void
|
||||
get(): Promise<IQuerySingleResult>
|
||||
get(options: OQ<IGetDocumentOptions>): void
|
||||
get(options: RQ<IGetDocumentOptions>): Promise<IQuerySingleResult>
|
||||
|
||||
// set(options?: ISetSingleDocumentOptions): Promise<ISetResult> | void
|
||||
set(): Promise<ISetResult>
|
||||
set(options: OQ<ISetSingleDocumentOptions>): void
|
||||
set(options: RQ<ISetSingleDocumentOptions>): Promise<ISetResult>
|
||||
|
||||
// update(options?: IUpdateSingleDocumentOptions): Promise<IUpdateResult> | void
|
||||
update(): Promise<IUpdateResult>
|
||||
update(options: OQ<IUpdateSingleDocumentOptions>): void
|
||||
update(options: RQ<IUpdateSingleDocumentOptions>): Promise<IUpdateResult>
|
||||
|
||||
// remove(options?: IRemoveSingleDocumentOptions): Promise<IRemoveResult> | void
|
||||
remove(): Promise<IRemoveResult>
|
||||
remove(options: OQ<IRemoveSingleDocumentOptions>): void
|
||||
remove(options: RQ<IRemoveSingleDocumentOptions>): Promise<IRemoveResult>
|
||||
|
||||
}
|
||||
|
||||
export class Query {
|
||||
|
||||
where(condition: IQueryCondition): Query
|
||||
|
||||
orderBy(fieldPath: string, order: string): Query
|
||||
|
||||
limit(max: number): Query
|
||||
|
||||
skip(offset: number): Query
|
||||
|
||||
field(object: object): Query
|
||||
|
||||
// get(options?: IGetDocumentOptions): Promise<IQueryResult> | void
|
||||
|
||||
// // update(options?: IUpdateDocumentOptions): Promise<IUpdateResult> | void
|
||||
|
||||
// // remove(options?: IRemoveDocumentOptions): Promise<IRemoveResult> | void
|
||||
|
||||
// count(options?: ICountDocumentOptions): Promise<ICountResult> | void
|
||||
|
||||
// get(options?: IGetDocumentOptions): Promise<IQueryResult> | void
|
||||
get(): Promise<IQueryResult>
|
||||
get(options: OQ<IGetDocumentOptions>): void
|
||||
get(options: RQ<IGetDocumentOptions>): Promise<IQueryResult>
|
||||
|
||||
// update(options?: IUpdateDocumentOptions): Promise<IUpdateResult> | void
|
||||
|
||||
// remove(options?: IRemoveDocumentOptions): Promise<IRemoveResult> | void
|
||||
|
||||
// count(options?: ICountDocumentOptions): Promise<ICountResult> | void
|
||||
count(): Promise<ICountResult>
|
||||
count(options: OQ<ICountDocumentOptions>): void
|
||||
count(options: RQ<ICountDocumentOptions>): Promise<ICountResult>
|
||||
|
||||
}
|
||||
|
||||
export interface DatabaseCommand {
|
||||
|
||||
eq(val: any): DatabaseQueryCommand
|
||||
neq(val: any): DatabaseQueryCommand
|
||||
gt(val: any): DatabaseQueryCommand
|
||||
gte(val: any): DatabaseQueryCommand
|
||||
lt(val: any): DatabaseQueryCommand
|
||||
lte(val: any): DatabaseQueryCommand
|
||||
in(val: any[]): DatabaseQueryCommand
|
||||
nin(val: any[]): DatabaseQueryCommand
|
||||
|
||||
and(...expressions: (DatabaseLogicCommand | IQueryCondition)[]): DatabaseLogicCommand
|
||||
or(...expressions: (DatabaseLogicCommand | IQueryCondition)[]): DatabaseLogicCommand
|
||||
|
||||
set(val: any): DatabaseUpdateCommand
|
||||
remove(): DatabaseUpdateCommand
|
||||
inc(val: number): DatabaseUpdateCommand
|
||||
mul(val: number): DatabaseUpdateCommand
|
||||
|
||||
push(...values: any[]): DatabaseUpdateCommand
|
||||
pop(): DatabaseUpdateCommand
|
||||
shift(): DatabaseUpdateCommand
|
||||
unshift(...values: any[]): DatabaseUpdateCommand
|
||||
|
||||
}
|
||||
|
||||
export enum LOGIC_COMMANDS_LITERAL {
|
||||
AND = 'and',
|
||||
OR = 'or',
|
||||
NOT = 'not',
|
||||
NOR = 'nor',
|
||||
}
|
||||
|
||||
export class DatabaseLogicCommand {
|
||||
|
||||
public fieldName: string | InternalSymbol
|
||||
public operator: LOGIC_COMMANDS_LITERAL | string
|
||||
public operands: any[]
|
||||
|
||||
_setFieldName(fieldName: string): DatabaseLogicCommand
|
||||
|
||||
and(...expressions: (DatabaseLogicCommand | IQueryCondition)[]): DatabaseLogicCommand
|
||||
or(...expressions: (DatabaseLogicCommand | IQueryCondition)[]): DatabaseLogicCommand
|
||||
|
||||
}
|
||||
|
||||
export enum QUERY_COMMANDS_LITERAL {
|
||||
EQ = 'eq',
|
||||
NEQ = 'neq',
|
||||
GT = 'gt',
|
||||
GTE = 'gte',
|
||||
LT = 'lt',
|
||||
LTE = 'lte',
|
||||
IN = 'in',
|
||||
NIN = 'nin',
|
||||
}
|
||||
|
||||
export class DatabaseQueryCommand extends DatabaseLogicCommand {
|
||||
|
||||
public operator: QUERY_COMMANDS_LITERAL | string
|
||||
|
||||
_setFieldName(fieldName: string): DatabaseQueryCommand
|
||||
|
||||
eq(val: any): DatabaseLogicCommand
|
||||
neq(val: any): DatabaseLogicCommand
|
||||
gt(val: any): DatabaseLogicCommand
|
||||
gte(val: any): DatabaseLogicCommand
|
||||
lt(val: any): DatabaseLogicCommand
|
||||
lte(val: any): DatabaseLogicCommand
|
||||
in(val: any[]): DatabaseLogicCommand
|
||||
nin(val: any[]): DatabaseLogicCommand
|
||||
|
||||
}
|
||||
|
||||
export enum UPDATE_COMMANDS_LITERAL {
|
||||
SET = 'set',
|
||||
REMOVE = 'remove',
|
||||
INC = 'inc',
|
||||
MUL = 'mul',
|
||||
PUSH = 'push',
|
||||
POP = 'pop',
|
||||
SHIFT = 'shift',
|
||||
UNSHIFT = 'unshift',
|
||||
}
|
||||
|
||||
export class DatabaseUpdateCommand {
|
||||
|
||||
public fieldName: string | InternalSymbol
|
||||
public operator: UPDATE_COMMANDS_LITERAL
|
||||
public operands: any[]
|
||||
|
||||
constructor(operator: UPDATE_COMMANDS_LITERAL, operands: any[], fieldName?: string | InternalSymbol)
|
||||
|
||||
_setFieldName(fieldName: string): DatabaseUpdateCommand
|
||||
}
|
||||
|
||||
export class Batch {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A contract that all API provider must adhere to
|
||||
*/
|
||||
export class APIBaseContract<PROMISE_RETURN, CALLBACK_RETURN, PARAM extends IAPIParam, CONTEXT = any> {
|
||||
|
||||
getContext(param: PARAM): CONTEXT
|
||||
|
||||
/**
|
||||
* In case of callback-style invocation, this function will be called
|
||||
*/
|
||||
getCallbackReturn(param: PARAM, context: CONTEXT): CALLBACK_RETURN
|
||||
|
||||
getFinalParam<T extends PARAM>(param: PARAM, context: CONTEXT): T
|
||||
|
||||
run<T extends PARAM>(param: T): Promise<PROMISE_RETURN>
|
||||
|
||||
}
|
||||
|
||||
export interface GeoPointConstructor {
|
||||
new (longitude: number, latitide: number): GeoPoint
|
||||
}
|
||||
|
||||
export interface Geo {
|
||||
Point: {
|
||||
new (longitude: number, latitide: number): GeoPoint
|
||||
(longitude: number, latitide: number): GeoPoint
|
||||
}
|
||||
}
|
||||
|
||||
export abstract class GeoPoint {
|
||||
public longitude: number
|
||||
public latitude: number
|
||||
|
||||
constructor(longitude: number, latitude: number)
|
||||
|
||||
toJSON(): object
|
||||
toString(): string
|
||||
}
|
||||
|
||||
export interface IServerDateOptions {
|
||||
offset: number,
|
||||
}
|
||||
|
||||
export abstract class ServerDate {
|
||||
public readonly options: IServerDateOptions
|
||||
constructor(options?: IServerDateOptions)
|
||||
}
|
||||
|
||||
export type DocumentId = string | number
|
||||
|
||||
export interface IDocumentData {
|
||||
_id?: DocumentId,
|
||||
[key: string]: any,
|
||||
}
|
||||
|
||||
export interface IDBAPIParam extends IAPIParam {
|
||||
|
||||
}
|
||||
|
||||
export interface IAddDocumentOptions extends IDBAPIParam {
|
||||
data: IDocumentData,
|
||||
}
|
||||
|
||||
export interface IGetDocumentOptions extends IDBAPIParam {
|
||||
|
||||
}
|
||||
|
||||
export interface ICountDocumentOptions extends IDBAPIParam {
|
||||
|
||||
}
|
||||
|
||||
export interface IUpdateDocumentOptions extends IDBAPIParam {
|
||||
data: IUpdateCondition,
|
||||
}
|
||||
|
||||
export interface IUpdateSingleDocumentOptions extends IDBAPIParam {
|
||||
data: IUpdateCondition,
|
||||
}
|
||||
|
||||
export interface ISetDocumentOptions extends IDBAPIParam {
|
||||
data: IUpdateCondition,
|
||||
}
|
||||
|
||||
export interface ISetSingleDocumentOptions extends IDBAPIParam {
|
||||
data: IUpdateCondition,
|
||||
}
|
||||
|
||||
export interface IRemoveDocumentOptions extends IDBAPIParam {
|
||||
query: IQueryCondition,
|
||||
}
|
||||
|
||||
export interface IRemoveSingleDocumentOptions extends IDBAPIParam {
|
||||
|
||||
}
|
||||
|
||||
export interface IQueryCondition {
|
||||
[key: string]: any,
|
||||
}
|
||||
|
||||
export type IStringQueryCondition = string
|
||||
|
||||
export interface IQueryResult extends IAPISuccessParam {
|
||||
data: IDocumentData[],
|
||||
}
|
||||
|
||||
export interface IQuerySingleResult extends IAPISuccessParam {
|
||||
data: IDocumentData,
|
||||
}
|
||||
|
||||
export interface IUpdateCondition {
|
||||
[key: string]: any,
|
||||
}
|
||||
|
||||
export type IStringUpdateCondition = string
|
||||
|
||||
export interface ISetCondition {
|
||||
|
||||
}
|
||||
|
||||
export interface IAddResult extends IAPISuccessParam {
|
||||
_id: DocumentId,
|
||||
}
|
||||
|
||||
export interface IUpdateResult extends IAPISuccessParam {
|
||||
stats: {
|
||||
updated: number,
|
||||
// created: number,
|
||||
}
|
||||
}
|
||||
|
||||
export interface ISetResult extends IAPISuccessParam {
|
||||
_id: DocumentId,
|
||||
stats: {
|
||||
updated: number,
|
||||
created: number,
|
||||
}
|
||||
}
|
||||
|
||||
export interface IRemoveResult extends IAPISuccessParam {
|
||||
stats: {
|
||||
removed: number,
|
||||
}
|
||||
}
|
||||
|
||||
export interface ICountResult extends IAPISuccessParam {
|
||||
total: number
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Utils
|
||||
*/
|
||||
|
||||
type OQ<T extends Optional<Record<'complete' | 'success' | 'fail', (...args: any[]) => any>>> =
|
||||
(RQ<T> & Required<Pick<T, 'success'>>) |
|
||||
(RQ<T> & Required<Pick<T, 'fail'>>) |
|
||||
(RQ<T> & Required<Pick<T, 'complete'>>) |
|
||||
(RQ<T> & Required<Pick<T, 'success' | 'fail'>>) |
|
||||
(RQ<T> & Required<Pick<T, 'success' | 'complete'>>) |
|
||||
(RQ<T> & Required<Pick<T, 'fail' | 'complete'>>) |
|
||||
(RQ<T> & Required<Pick<T, 'fail' | 'complete' | 'success'>>)
|
||||
|
||||
type RQ<T extends Optional<Record<'complete' | 'success' | 'fail', (...args: any[]) => any>>> = Pick<T, Exclude<keyof T, 'complete' | 'success' | 'fail'>>
|
||||
|
||||
181
typings/wx/lib.wx.page.d.ts
vendored
181
typings/wx/lib.wx.page.d.ts
vendored
@@ -1,181 +0,0 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) 2018 Tencent, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
***************************************************************************** */
|
||||
|
||||
declare namespace Page {
|
||||
|
||||
interface ICustomShareContent {
|
||||
/** 转发标题。默认值:当前小程序名称 */
|
||||
title?: string
|
||||
/** 转发路径,必须是以 / 开头的完整路径。默认值:当前页面 path */
|
||||
path?: string
|
||||
/** 自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径。支持PNG及JPG。显示图片长宽比是 5:4,最低基础库: `1.5.0`。默认值:使用默认截图 */
|
||||
imageUrl?: string
|
||||
}
|
||||
|
||||
interface IPageScrollOption {
|
||||
/** 页面在垂直方向已滚动的距离(单位px) */
|
||||
scrollTop: number
|
||||
}
|
||||
|
||||
interface IShareAppMessageOption {
|
||||
/** 转发事件来源。
|
||||
*
|
||||
* 可选值:
|
||||
* - `button`:页面内转发按钮;
|
||||
* - `menu`:右上角转发菜单。
|
||||
*
|
||||
* 最低基础库: `1.2.4`
|
||||
*/
|
||||
from: 'button' | 'menu' | string
|
||||
/** 如果 `from` 值是 `button`,则 `target` 是触发这次转发事件的 `button`,否则为 `undefined`
|
||||
*
|
||||
* 最低基础库: `1.2.4` */
|
||||
target: any
|
||||
/** 页面中包含`<web-view>`组件时,返回当前`<web-view>`的url
|
||||
*
|
||||
* 最低基础库: `1.6.4`
|
||||
*/
|
||||
webViewUrl?: string
|
||||
}
|
||||
|
||||
interface ITabItemTapOption {
|
||||
/** 被点击tabItem的序号,从0开始,最低基础库: `1.9.0` */
|
||||
index: string
|
||||
/** 被点击tabItem的页面路径,最低基础库: `1.9.0` */
|
||||
pagePath: string
|
||||
/** 被点击tabItem的按钮文字,最低基础库: `1.9.0` */
|
||||
text: string
|
||||
}
|
||||
|
||||
interface PageInstanceBaseProps<D extends IAnyObject = any> {
|
||||
/** 页面的初始数据
|
||||
*
|
||||
* `data` 是页面第一次渲染使用的**初始数据**。
|
||||
*
|
||||
* 页面加载时,`data` 将会以`JSON`字符串的形式由逻辑层传至渲染层,因此`data`中的数据必须是可以转成`JSON`的类型:字符串,数字,布尔值,对象,数组。
|
||||
*
|
||||
* 渲染层可以通过 `WXML` 对数据进行绑定。
|
||||
*/
|
||||
data?: D
|
||||
|
||||
/** `setData` 函数用于将数据从逻辑层发送到视图层(异步),同时改变对应的 `this.data` 的值(同步)。
|
||||
*
|
||||
* **注意:**
|
||||
*
|
||||
* 1. **直接修改 this.data 而不调用 this.setData 是无法改变页面的状态的,还会造成数据不一致**。
|
||||
* 1. 仅支持设置可 JSON 化的数据。
|
||||
* 1. 单次设置的数据不能超过1024kB,请尽量避免一次设置过多的数据。
|
||||
* 1. 请不要把 data 中任何一项的 value 设为 `undefined` ,否则这一项将不被设置并可能遗留一些潜在问题。
|
||||
*/
|
||||
|
||||
setData?<K extends keyof D>(
|
||||
/** 这次要改变的数据
|
||||
*
|
||||
* 以 `key: value` 的形式表示,将 `this.data` 中的 `key` 对应的值改变成 `value`。
|
||||
*
|
||||
* 其中 `key` 可以以数据路径的形式给出,支持改变数组中的某一项或对象的某个属性,如 `array[2].message`,`a.b.c.d`,并且不需要在 this.data 中预先定义。
|
||||
*/
|
||||
data: D | Pick<D, K> | IAnyObject,
|
||||
/** setData引起的界面更新渲染完毕后的回调函数,最低基础库: `1.5.0` */
|
||||
callback?: () => void
|
||||
): void
|
||||
|
||||
/** 到当前页面的路径,类型为`String`。最低基础库: `1.2.0` */
|
||||
route?: string
|
||||
}
|
||||
|
||||
interface PageInstance<D extends IAnyObject = any, T extends IAnyObject = any> extends PageInstanceBaseProps<D> {
|
||||
/** 生命周期回调—监听页面加载
|
||||
*
|
||||
* 页面加载时触发。一个页面只会调用一次,可以在 onLoad 的参数中获取打开当前页面路径中的参数。
|
||||
*/
|
||||
onLoad?(
|
||||
/** 打开当前页面路径中的参数 */
|
||||
query?: { [queryKey: string]: string }
|
||||
): void
|
||||
/** 生命周期回调—监听页面显示
|
||||
*
|
||||
* 页面显示/切入前台时触发。
|
||||
*/
|
||||
onShow?(): void
|
||||
/** 生命周期回调—监听页面初次渲染完成
|
||||
*
|
||||
* 页面初次渲染完成时触发。一个页面只会调用一次,代表页面已经准备妥当,可以和视图层进行交互。
|
||||
*
|
||||
|
||||
* 注意:对界面内容进行设置的 API 如`wx.setNavigationBarTitle`,请在`onReady`之后进行。
|
||||
*/
|
||||
onReady?(): void
|
||||
/** 生命周期回调—监听页面隐藏
|
||||
*
|
||||
* 页面隐藏/切入后台时触发。 如 `navigateTo` 或底部 `tab` 切换到其他页面,小程序切入后台等。
|
||||
*/
|
||||
onHide?(): void
|
||||
/** 生命周期回调—监听页面卸载
|
||||
*
|
||||
* 页面卸载时触发。如`redirectTo`或`navigateBack`到其他页面时。
|
||||
*/
|
||||
onUnload?(): void
|
||||
/** 监听用户下拉动作
|
||||
*
|
||||
* 监听用户下拉刷新事件。
|
||||
* - 需要在`app.json`的`window`选项中或页面配置中开启`enablePullDownRefresh`。
|
||||
* - 可以通过`wx.startPullDownRefresh`触发下拉刷新,调用后触发下拉刷新动画,效果与用户手动下拉刷新一致。
|
||||
* - 当处理完数据刷新后,`wx.stopPullDownRefresh`可以停止当前页面的下拉刷新。
|
||||
*/
|
||||
onPullDownRefresh?(): void
|
||||
/** 页面上拉触底事件的处理函数
|
||||
*
|
||||
* 监听用户上拉触底事件。
|
||||
* - 可以在`app.json`的`window`选项中或页面配置中设置触发距离`onReachBottomDistance`。
|
||||
* - 在触发距离内滑动期间,本事件只会被触发一次。
|
||||
*/
|
||||
onReachBottom?(): void
|
||||
/** 用户点击右上角转发
|
||||
*
|
||||
* 监听用户点击页面内转发按钮(`<button>` 组件 `open-type="share"`)或右上角菜单“转发”按钮的行为,并自定义转发内容。
|
||||
*
|
||||
* **注意:只有定义了此事件处理函数,右上角菜单才会显示“转发”按钮**
|
||||
*
|
||||
* 此事件需要 return 一个 Object,用于自定义转发内容
|
||||
*/
|
||||
onShareAppMessage?(
|
||||
/** 分享发起来源参数 */
|
||||
options?: IShareAppMessageOption
|
||||
): ICustomShareContent
|
||||
/** 页面滚动触发事件的处理函数
|
||||
*
|
||||
* 监听用户滑动页面事件。
|
||||
*/
|
||||
onPageScroll?(
|
||||
/** 页面滚动参数 */
|
||||
options?: IPageScrollOption
|
||||
): void
|
||||
|
||||
/** 当前是 tab 页时,点击 tab 时触发,最低基础库: `1.9.0` */
|
||||
onTabItemTap?(
|
||||
/** tab 点击参数 */
|
||||
options?: ITabItemTapOption
|
||||
): void
|
||||
}
|
||||
|
||||
interface PageConstructor {
|
||||
<D extends IAnyObject, T extends IAnyObject & PageInstance>(
|
||||
options: PageInstance<D, T> & T
|
||||
): void
|
||||
}
|
||||
|
||||
interface GetCurrentPages {
|
||||
<D extends IAnyObject = {}, T extends IAnyObject = {}>(): (PageInstance<D, T> & T)[]
|
||||
}
|
||||
}
|
||||
|
||||
declare const Page: Page.PageConstructor
|
||||
declare const getCurrentPages: Page.GetCurrentPages
|
||||
Reference in New Issue
Block a user