-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtype.d.ts
140 lines (126 loc) · 3.37 KB
/
type.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
* @Author: tackchen
* @Date: 2021-05-02 11:11:35
* @LastEditors: tackchen
* @LastEditTime: 2021-05-12 13:53:26
* @FilePath: \mp-mixin\src\type.d.ts
* @Description: Coding something
*/
export interface IStore {
state: IJson;
__: {
_id: number;
_injectContext (currentContext: IContext, storeTool: IJson): void;
_hitState (setDataAttr: string, value: any, ignoreList: string[], newContext: IContext): boolean;
}
}
export interface IEventReady<T> {
onEventReady(fn: (...args: T[])=>void, ...args: T[]): Function;
eventReady(...args: T[]): void;
removeListener(fn: Function): void;
}
export interface IJson<T = any> {
[prop: string]: T;
}
interface IMixinOption {
data?: IJson;
mixin?: IPageMixin;
}
export interface IPageLifeTimes {
onLoad?(query: any): void | Promise<void>
onShow?(): void | Promise<void>
onReady?(): void | Promise<void>
onHide?(): void | Promise<void>
onUnload?(): void | Promise<void>
onPullDownRefresh?(): void | Promise<void>
onReachBottom?(): void | Promise<void>
onShareAppMessage?(options: {
from: 'button' | 'menu' | string
target: any
webViewUrl?: string
}): {
title?: string
path?: string
imageUrl?: string
} | void
onShareTimeline?(): {
title?: string
query?: string
imageUrl?: string
} | void
onPageScroll?(options: {
scrollTop: number
}): void | Promise<void>
onTabItemTap?(options: {
index: string
pagePath: string
text: string
}): void | Promise<void>
onResize?(options: {
size: {
windowWidth: number
windowHeight: number
}
}): void | Promise<void>
onAddToFavorites?(options: {webviewUrl?: string}): {
title?: string
imageUrl?: string
query?: string
}
}
export interface IPageOption extends IJson, IMixinOption, IPageLifeTimes {
}
interface IComponentLifetimeOptions {
lifetimes?: IComponentLifeTimes; // 仅针对组件有效
pageLifetimes?: IComponentPageLifeTimes; // 仅针对组件有效
}
export interface IComponentOption extends IPageOption, IMixinOption, IComponentLifetimeOptions {
methods?: IJson<Function>;
}
interface IBaseMixin {
data?: IJson;
methods?: IJson<Function>;
}
export interface IPageMixin extends IBaseMixin, IPageLifeTimes {
store?: IStore;
}
export interface IComponentMixin extends IBaseMixin, IComponentLifetimeOptions {
store?: IStore;
}
export interface IGlobalMixin extends IBaseMixin, IPageLifeTimes, IComponentLifetimeOptions {
store?: IStore | IJson;
}
export interface IContext extends IJson {
setData(data: IJson, callbacl?: Function): void;
}
export interface IGlobalMixinFn {
(mixin: IGlobalMixin): void;
}
export interface ICreateStoreFn {
(state: IJson): IStore;
}
export interface IInitGlobalStoreFn {
(state: IJson | IStore): IStore;
}
export interface IComponentLifeTimes {
created?(): void;
attached?(): void;
ready?(): void;
moved?(): void;
detached?(): void;
error?(err: {
name: string;
message: string;
stack?: string;
}): void;
}
export interface IComponentPageLifeTimes {
show?(): void;
hide?(): void;
resize?(size: {
size: {
windowWidth: number;
windowHeight: number;
};
}): void;
}