@tarojs/plugin-platform-harmony-ets 3.7.0-alpha.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +160 -0
- package/dist/apis/apis.ts +15 -0
- package/dist/apis/base/index.ts +5 -0
- package/dist/apis/base/system.ts +77 -0
- package/dist/apis/device/accelerometer.ts +76 -0
- package/dist/apis/device/battery.ts +24 -0
- package/dist/apis/device/clipboard.ts +70 -0
- package/dist/apis/device/index.ts +9 -0
- package/dist/apis/device/keyboard.ts +62 -0
- package/dist/apis/device/memory.ts +4 -0
- package/dist/apis/device/network.ts +72 -0
- package/dist/apis/device/phone.ts +43 -0
- package/dist/apis/device/screen.ts +79 -0
- package/dist/apis/device/vibrate.ts +24 -0
- package/dist/apis/files/index.ts +135 -0
- package/dist/apis/files/manager.ts +941 -0
- package/dist/apis/framework/index.ts +32 -0
- package/dist/apis/index.ts +124 -0
- package/dist/apis/location/index.ts +133 -0
- package/dist/apis/media/common.ts +74 -0
- package/dist/apis/media/image.ts +122 -0
- package/dist/apis/media/index.ts +3 -0
- package/dist/apis/media/video.ts +86 -0
- package/dist/apis/navigate/index.ts +8 -0
- package/dist/apis/network/downloadFile.ts +113 -0
- package/dist/apis/network/index.ts +4 -0
- package/dist/apis/network/request.ts +113 -0
- package/dist/apis/network/uploadFile.ts +158 -0
- package/dist/apis/network/webSocket.ts +130 -0
- package/dist/apis/open-api/index.ts +7 -0
- package/dist/apis/open-api/user-info/index.ts +85 -0
- package/dist/apis/page/index.ts +92 -0
- package/dist/apis/route/index.ts +138 -0
- package/dist/apis/storage/index.ts +133 -0
- package/dist/apis/tabbar/index.ts +147 -0
- package/dist/apis/ui/animation.ts +222 -0
- package/dist/apis/ui/background.ts +35 -0
- package/dist/apis/ui/index.ts +14 -0
- package/dist/apis/ui/interaction/index.ts +195 -0
- package/dist/apis/ui/navigation-bar/index.ts +33 -0
- package/dist/apis/ui/pull-down-refresh.ts +41 -0
- package/dist/apis/utils/handler.ts +116 -0
- package/dist/apis/utils/index.ts +85 -0
- package/dist/apis/utils/types.ts +12 -0
- package/dist/apis/utils/validate.ts +87 -0
- package/dist/apis/wxml/IntersectionObserver.ts +119 -0
- package/dist/apis/wxml/index.ts +12 -0
- package/dist/apis/wxml/nodesRef.ts +56 -0
- package/dist/apis/wxml/selectorQuery.ts +287 -0
- package/dist/components/components-react.js +51 -0
- package/dist/components/components-react.js.map +1 -0
- package/dist/components-harmony/button/index.css +109 -0
- package/dist/components-harmony/button/index.hml +31 -0
- package/dist/components-harmony/button/index.js +105 -0
- package/dist/components-harmony/camera/index.hml +6 -0
- package/dist/components-harmony/camera/index.js +12 -0
- package/dist/components-harmony/checkbox/index.hml +11 -0
- package/dist/components-harmony/checkbox/index.js +60 -0
- package/dist/components-harmony/checkbox-group/index.hml +3 -0
- package/dist/components-harmony/checkbox-group/index.js +22 -0
- package/dist/components-harmony/cover-image/index.css +4 -0
- package/dist/components-harmony/cover-image/index.hml +9 -0
- package/dist/components-harmony/cover-image/index.js +15 -0
- package/dist/components-harmony/form/index.hml +10 -0
- package/dist/components-harmony/form/index.js +11 -0
- package/dist/components-harmony/icon/index.css +27 -0
- package/dist/components-harmony/icon/index.hml +54 -0
- package/dist/components-harmony/icon/index.js +17 -0
- package/dist/components-harmony/image/index.css +5 -0
- package/dist/components-harmony/image/index.hml +11 -0
- package/dist/components-harmony/image/index.js +28 -0
- package/dist/components-harmony/input/index.hml +21 -0
- package/dist/components-harmony/input/index.js +98 -0
- package/dist/components-harmony/label/index.hml +3 -0
- package/dist/components-harmony/label/index.js +6 -0
- package/dist/components-harmony/navbar/index.css +56 -0
- package/dist/components-harmony/navbar/index.hml +9 -0
- package/dist/components-harmony/navbar/index.js +30 -0
- package/dist/components-harmony/navigator/index.css +8 -0
- package/dist/components-harmony/navigator/index.hml +9 -0
- package/dist/components-harmony/navigator/index.js +104 -0
- package/dist/components-harmony/picker/index.hml +25 -0
- package/dist/components-harmony/picker/index.js +132 -0
- package/dist/components-harmony/picker-view/index.hml +23 -0
- package/dist/components-harmony/picker-view/index.js +161 -0
- package/dist/components-harmony/picker-view-column/index.hml +3 -0
- package/dist/components-harmony/picker-view-column/index.js +3 -0
- package/dist/components-harmony/progress/index.css +4 -0
- package/dist/components-harmony/progress/index.hml +28 -0
- package/dist/components-harmony/progress/index.js +23 -0
- package/dist/components-harmony/radio/index.hml +11 -0
- package/dist/components-harmony/radio/index.js +41 -0
- package/dist/components-harmony/radio-group/index.hml +3 -0
- package/dist/components-harmony/radio-group/index.js +11 -0
- package/dist/components-harmony/rich-text/index.hml +5 -0
- package/dist/components-harmony/rich-text/index.js +16 -0
- package/dist/components-harmony/scroll-view/index.css +5 -0
- package/dist/components-harmony/scroll-view/index.hml +12 -0
- package/dist/components-harmony/scroll-view/index.js +65 -0
- package/dist/components-harmony/slider/index.hml +16 -0
- package/dist/components-harmony/slider/index.js +53 -0
- package/dist/components-harmony/swiper/index.css +3 -0
- package/dist/components-harmony/swiper/index.hml +14 -0
- package/dist/components-harmony/swiper/index.js +19 -0
- package/dist/components-harmony/switch/index.hml +7 -0
- package/dist/components-harmony/switch/index.js +16 -0
- package/dist/components-harmony/tabbar/index.css +7 -0
- package/dist/components-harmony/tabbar/index.hml +26 -0
- package/dist/components-harmony/tabbar/index.js +42 -0
- package/dist/components-harmony/textarea/index.hml +24 -0
- package/dist/components-harmony/textarea/index.js +92 -0
- package/dist/components-harmony/utils/index.js +41 -0
- package/dist/components-harmony/video/index.hml +7 -0
- package/dist/components-harmony/video/index.js +73 -0
- package/dist/components-harmony/web-view/index.hml +8 -0
- package/dist/components-harmony/web-view/index.js +22 -0
- package/dist/components-harmony-ets/base.ets +63 -0
- package/dist/components-harmony-ets/button.ets +119 -0
- package/dist/components-harmony-ets/checkbox.ets +219 -0
- package/dist/components-harmony-ets/element.ets +223 -0
- package/dist/components-harmony-ets/form.ets +149 -0
- package/dist/components-harmony-ets/icon.ets +84 -0
- package/dist/components-harmony-ets/image.ets +85 -0
- package/dist/components-harmony-ets/index.ts +49 -0
- package/dist/components-harmony-ets/innerHtml.ets +79 -0
- package/dist/components-harmony-ets/input.ets +195 -0
- package/dist/components-harmony-ets/label.ets +111 -0
- package/dist/components-harmony-ets/picker.ets +370 -0
- package/dist/components-harmony-ets/radio.ets +225 -0
- package/dist/components-harmony-ets/richText.ets +97 -0
- package/dist/components-harmony-ets/scrollView.ets +199 -0
- package/dist/components-harmony-ets/slider.ets +159 -0
- package/dist/components-harmony-ets/swiper.ets +204 -0
- package/dist/components-harmony-ets/switch.ets +113 -0
- package/dist/components-harmony-ets/text.ets +97 -0
- package/dist/components-harmony-ets/textArea.ets +169 -0
- package/dist/components-harmony-ets/utils/AttributeManager.ets +250 -0
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +48 -0
- package/dist/components-harmony-ets/utils/constant/event.ets +25 -0
- package/dist/components-harmony-ets/utils/constant/icon.ts +19 -0
- package/dist/components-harmony-ets/utils/constant/style.ets +88 -0
- package/dist/components-harmony-ets/utils/events.ts +24 -0
- package/dist/components-harmony-ets/utils/flexManager.ets +107 -0
- package/dist/components-harmony-ets/utils/helper.ets +99 -0
- package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +103 -0
- package/dist/components-harmony-ets/utils/htmlParser/index.ts +56 -0
- package/dist/components-harmony-ets/utils/index.ts +83 -0
- package/dist/components-harmony-ets/utils/styles.ets +91 -0
- package/dist/components-harmony-ets/video.ets +161 -0
- package/dist/components-harmony-ets/view.ets +79 -0
- package/dist/index.js +1183 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime-ets/bom/document.ts +38 -0
- package/dist/runtime-ets/bom/getComputedStyle.ts +5 -0
- package/dist/runtime-ets/bom/navigator.ts +21 -0
- package/dist/runtime-ets/bom/raf.ts +37 -0
- package/dist/runtime-ets/bom/window.ts +44 -0
- package/dist/runtime-ets/constant.ts +29 -0
- package/dist/runtime-ets/current.ts +16 -0
- package/dist/runtime-ets/dom/class-list.ts +117 -0
- package/dist/runtime-ets/dom/comment.ts +10 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +105 -0
- package/dist/runtime-ets/dom/document.ts +108 -0
- package/dist/runtime-ets/dom/element.ts +457 -0
- package/dist/runtime-ets/dom/event.ts +164 -0
- package/dist/runtime-ets/dom/eventTarget.ts +98 -0
- package/dist/runtime-ets/dom/node.ts +215 -0
- package/dist/runtime-ets/dom/stylesheet/index.ts +687 -0
- package/dist/runtime-ets/dom/stylesheet/type.ts +136 -0
- package/dist/runtime-ets/dom/stylesheet/util.ts +134 -0
- package/dist/runtime-ets/dom/text.ts +19 -0
- package/dist/runtime-ets/index.ts +19 -0
- package/dist/runtime-ets/interface/event.ts +9 -0
- package/dist/runtime-ets/interface/index.ts +1 -0
- package/dist/runtime-ets/utils/bind.ts +35 -0
- package/dist/runtime-ets/utils/index.ts +135 -0
- package/dist/runtime-ets/utils/info.ts +128 -0
- package/dist/runtime-framework/react/app.ts +256 -0
- package/dist/runtime-framework/react/connect.ts +24 -0
- package/dist/runtime-framework/react/constant.ts +5 -0
- package/dist/runtime-framework/react/hooks.ts +101 -0
- package/dist/runtime-framework/react/index.ts +16 -0
- package/dist/runtime-framework/react/page.ts +263 -0
- package/dist/runtime-framework/react/utils/index.ts +25 -0
- package/dist/runtime-framework/react/utils/is.ts +46 -0
- package/dist/runtime-framework/solid/README.md +99 -0
- package/dist/runtime-framework/solid/app.ts +200 -0
- package/dist/runtime-framework/solid/connect.ts +11 -0
- package/dist/runtime-framework/solid/contant.ts +5 -0
- package/dist/runtime-framework/solid/hooks.ts +88 -0
- package/dist/runtime-framework/solid/index.ts +10 -0
- package/dist/runtime-framework/solid/page.ts +202 -0
- package/dist/runtime-framework/solid/reconciler/h.ts +132 -0
- package/dist/runtime-framework/solid/reconciler/index.ts +3 -0
- package/dist/runtime-framework/solid/reconciler/props.ts +151 -0
- package/dist/runtime-framework/solid/reconciler/render.ts +61 -0
- package/dist/runtime-framework/solid/reconciler/use.ts +8 -0
- package/dist/runtime-framework/solid/utils/index.ts +49 -0
- package/dist/runtime-framework/solid/utils/is.ts +46 -0
- package/dist/runtime-utils.js +4149 -0
- package/dist/runtime-utils.js.map +1 -0
- package/dist/runtime.js +4150 -0
- package/dist/runtime.js.map +1 -0
- package/dist/template/container.js +7 -0
- package/index.js +4 -0
- package/package.json +54 -0
- package/types/api.d.ts +4 -0
- package/types/component.d.ts +4 -0
- package/types/harmony.d.ts +11 -0
- package/types/runtime.d.ts +15 -0
- package/types/taro.d.ts +7 -0
- package/types/webpack-sources.d.ts +108 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import matrix4 from '@ohos.matrix4'
|
|
2
|
+
|
|
3
|
+
import { temporarilyNotSupport } from '../utils'
|
|
4
|
+
|
|
5
|
+
import type Taro from '@tarojs/api'
|
|
6
|
+
|
|
7
|
+
interface IAnimationAttr {
|
|
8
|
+
duration: number
|
|
9
|
+
delay: number
|
|
10
|
+
timingFunction: string
|
|
11
|
+
transformOrigin: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type TStep = {
|
|
15
|
+
delay: number
|
|
16
|
+
duration: number
|
|
17
|
+
timingFunction: string
|
|
18
|
+
transformOrigin: string
|
|
19
|
+
rule: TRule
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type TRule = Record<string, any>
|
|
23
|
+
|
|
24
|
+
export class Animation implements Taro.Animation {
|
|
25
|
+
|
|
26
|
+
unit: string
|
|
27
|
+
DEFAULT: IAnimationAttr
|
|
28
|
+
|
|
29
|
+
// 组合动画
|
|
30
|
+
steps: TStep[] = []
|
|
31
|
+
// 属性组合
|
|
32
|
+
rule: TRule = {}
|
|
33
|
+
|
|
34
|
+
constructor({
|
|
35
|
+
duration = 400,
|
|
36
|
+
delay = 0,
|
|
37
|
+
timingFunction = 'linear',
|
|
38
|
+
transformOrigin = '50% 50% 0',
|
|
39
|
+
unit = 'px'
|
|
40
|
+
}: Taro.createAnimation.Option = {}) {
|
|
41
|
+
this.unit = unit
|
|
42
|
+
this.setDefault(duration, delay, timingFunction, transformOrigin)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 设置默认值
|
|
46
|
+
setDefault (duration, delay, timingFunction, transformOrigin) {
|
|
47
|
+
this.DEFAULT = { duration, delay, timingFunction, transformOrigin }
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export (): { actions: any[] } {
|
|
51
|
+
const actions = this.steps.slice()
|
|
52
|
+
this.steps = []
|
|
53
|
+
this.rule = {}
|
|
54
|
+
return {
|
|
55
|
+
actions
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
step (arg: Partial<IAnimationAttr> = {}): Taro.Animation {
|
|
60
|
+
const { DEFAULT } = this
|
|
61
|
+
const {
|
|
62
|
+
duration = DEFAULT.duration,
|
|
63
|
+
delay = DEFAULT.delay,
|
|
64
|
+
timingFunction = DEFAULT.timingFunction,
|
|
65
|
+
transformOrigin = DEFAULT.transformOrigin
|
|
66
|
+
} = arg
|
|
67
|
+
this.steps.push({
|
|
68
|
+
duration,
|
|
69
|
+
delay,
|
|
70
|
+
timingFunction,
|
|
71
|
+
transformOrigin,
|
|
72
|
+
rule: Object.assign({}, this.rule)
|
|
73
|
+
})
|
|
74
|
+
return this
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
matrix (a: number, b: number, c: number, d: number, tx: number, ty: number): Taro.Animation {
|
|
78
|
+
this.rule.transform = matrix4.init([a, b, c, d, tx, ty])
|
|
79
|
+
return this
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
matrix3d (a1: number, b1: number, c1: number, d1: number, a2: number, b2: number, c2: number, d2: number, a3: number, b3: number, c3: number, d3: number, a4: number, b4: number, c4: number, d4: number): Taro.Animation {
|
|
83
|
+
this.rule.transform = matrix4.init([a1, b1, c1, d1, a2, b2, c2, d2, a3, b3, c3, d3, a4, b4, c4, d4])
|
|
84
|
+
return this
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
rotate (angle: number): Taro.Animation {
|
|
88
|
+
this.rule.rotate = { x: 0, y: 0, z: 1, angle }
|
|
89
|
+
return this
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
rotate3d (x: number, y?: number | undefined, z?: number | undefined, angle?: number | undefined): Taro.Animation {
|
|
93
|
+
this.rule.rotate = { x, y, z, angle }
|
|
94
|
+
return this
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
rotateX (angle: number): Taro.Animation {
|
|
98
|
+
this.rule.rotate = { x: 1, y: 0, z: 0, angle }
|
|
99
|
+
return this
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
rotateY (angle: number): Taro.Animation {
|
|
103
|
+
this.rule.rotate = { x: 0, y: 1, z: 0, angle }
|
|
104
|
+
return this
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
rotateZ (angle: number): Taro.Animation {
|
|
108
|
+
this.rule.rotate = { x: 0, y: 0, z: 1, angle }
|
|
109
|
+
return this
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
scale (sx: number, sy?: number | undefined): Taro.Animation {
|
|
113
|
+
this.rule.scale = { x: sx, y: sy }
|
|
114
|
+
return this
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
scale3d (sx: number, sy: number, sz: number): Taro.Animation {
|
|
118
|
+
this.rule.scale = { x: sx, y: sy, z: sz }
|
|
119
|
+
return this
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
scaleX (scale: number): Taro.Animation {
|
|
123
|
+
this.rule.scale = { x: scale }
|
|
124
|
+
return this
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
scaleY (scale: number): Taro.Animation {
|
|
128
|
+
this.rule.scale = { y: scale }
|
|
129
|
+
return this
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
scaleZ (scale: number): Taro.Animation {
|
|
133
|
+
this.rule.scale = { z: scale }
|
|
134
|
+
return this
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
skew (ax: number, ay: number): Taro.Animation {
|
|
138
|
+
this.rule.skew = { x: ax, y: ay }
|
|
139
|
+
return this
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
skewX (angle: number): Taro.Animation {
|
|
143
|
+
this.rule.skew = { x: angle }
|
|
144
|
+
return this
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
skewY (angle: number): Taro.Animation {
|
|
148
|
+
this.rule.skew = { y: angle }
|
|
149
|
+
return this
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
translate (tx?: number | undefined, ty?: number | undefined): Taro.Animation {
|
|
153
|
+
this.rule.translate = { x: tx, y: ty }
|
|
154
|
+
return this
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
translate3d (tx?: number | undefined, ty?: number | undefined, tz?: number | undefined): Taro.Animation {
|
|
158
|
+
this.rule.translate = { x: tx, y: ty, z: tz }
|
|
159
|
+
return this
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
translateX (translation: number): Taro.Animation {
|
|
163
|
+
this.rule.translate = { x: translation }
|
|
164
|
+
return this
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
translateY (translation: number): Taro.Animation {
|
|
168
|
+
this.rule.translate = { y: translation }
|
|
169
|
+
return this
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
translateZ (translation: number): Taro.Animation {
|
|
173
|
+
this.rule.translate = { z: translation }
|
|
174
|
+
return this
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
opacity (value: number): Taro.Animation {
|
|
178
|
+
this.rule.opacity = value
|
|
179
|
+
return this
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
backgroundColor (value: string): Taro.Animation {
|
|
183
|
+
this.rule.backgroundColor = value
|
|
184
|
+
return this
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
width (value: string | number): Taro.Animation {
|
|
188
|
+
this.rule.size = {
|
|
189
|
+
...this.rule.size,
|
|
190
|
+
width: value
|
|
191
|
+
}
|
|
192
|
+
return this
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
height (value: string | number): Taro.Animation {
|
|
196
|
+
this.rule.size = {
|
|
197
|
+
...this.rule.size,
|
|
198
|
+
height: value
|
|
199
|
+
}
|
|
200
|
+
return this
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
left (value: string | number): Taro.Animation {
|
|
204
|
+
temporarilyNotSupport('animation.left:' + value)(value)
|
|
205
|
+
return this
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
right (value: string | number): Taro.Animation {
|
|
209
|
+
temporarilyNotSupport('animation.right:' + value)(value)
|
|
210
|
+
return this
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
top (value: string | number): Taro.Animation {
|
|
214
|
+
temporarilyNotSupport('animation.top:' + value)(value)
|
|
215
|
+
return this
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
bottom (value: string | number): Taro.Animation {
|
|
219
|
+
temporarilyNotSupport('animation.bottom:' + value)(value)
|
|
220
|
+
return this
|
|
221
|
+
}
|
|
222
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// import window from '@ohos.window'
|
|
2
|
+
// import { Current } from '@tarojs/runtime'
|
|
3
|
+
import { eventCenter } from '@tarojs/runtime/dist/runtime.esm'
|
|
4
|
+
|
|
5
|
+
import { MethodHandler } from '../utils/handler'
|
|
6
|
+
|
|
7
|
+
// import { callAsyncFail, callAsyncSuccess } from '../utils'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
// const windowClassPromise = (Current as any).contextPromise
|
|
11
|
+
// .then(context => {
|
|
12
|
+
// return window.getTopWindow(context)
|
|
13
|
+
// })
|
|
14
|
+
|
|
15
|
+
export function setBackgroundColor(options: Taro.setBackgroundColor.Option) {
|
|
16
|
+
const { success, fail, complete } = options || {}
|
|
17
|
+
const handle = new MethodHandler({ name: 'setBackgroundColor', success, fail, complete })
|
|
18
|
+
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
eventCenter.trigger('__taroPageStyle', {
|
|
21
|
+
backgroundColor: options.backgroundColor || options.backgroundColorTop || options.backgroundColorBottom,
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
return handle.success({}, { resolve, reject })
|
|
25
|
+
// windowClassPromise.then(windowClass => {
|
|
26
|
+
// windowClass.setBackgroundColor(color).then(() => {
|
|
27
|
+
// const res = { errMsg: 'setBackgroundColor:ok' }
|
|
28
|
+
// callAsyncSuccess(resolve, res, options)
|
|
29
|
+
// }, (error) => {
|
|
30
|
+
// const res = { errMsg: 'setBackgroundColor:fail' + error }
|
|
31
|
+
// callAsyncFail(reject, res, options)
|
|
32
|
+
// })
|
|
33
|
+
// })
|
|
34
|
+
})
|
|
35
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils'
|
|
2
|
+
import { Animation } from './animation'
|
|
3
|
+
|
|
4
|
+
import type Taro from '@tarojs/api'
|
|
5
|
+
|
|
6
|
+
export const createAnimation = (option: Taro.createAnimation.Option) => {
|
|
7
|
+
return new Animation(option)
|
|
8
|
+
}
|
|
9
|
+
export const getMenuButtonBoundingClientRect = temporarilyNotSupport('getMenuButtonBoundingClientRect')
|
|
10
|
+
|
|
11
|
+
export * from './background'
|
|
12
|
+
export * from './interaction'
|
|
13
|
+
export * from './navigation-bar'
|
|
14
|
+
export * from './pull-down-refresh'
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import prompt from '@ohos.prompt'
|
|
2
|
+
|
|
3
|
+
import { callAsyncFail, callAsyncSuccess, temporarilyNotSupport, validateParams } from '../../utils'
|
|
4
|
+
|
|
5
|
+
const resCallback = (res) => {
|
|
6
|
+
return { errMsg: `${res}:ok` }
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const showToastSchema = {
|
|
10
|
+
title: 'String',
|
|
11
|
+
duration: 'Number',
|
|
12
|
+
bottom: 'String'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function showToast (options) {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
const _default = {
|
|
18
|
+
title: '',
|
|
19
|
+
duration: 1500,
|
|
20
|
+
bottom: '50%'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
options = { ..._default, ...options }
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
validateParams<any>('showToast', options, showToastSchema)
|
|
27
|
+
} catch (error) {
|
|
28
|
+
const res = { errMsg: error.message }
|
|
29
|
+
return callAsyncFail(reject, res, options)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
prompt.showToast({
|
|
33
|
+
message: options.title,
|
|
34
|
+
duration: options.duration,
|
|
35
|
+
bottom: options.bottom
|
|
36
|
+
})
|
|
37
|
+
callAsyncSuccess(resolve, resCallback('showToast'), options)
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function showModal (options) {
|
|
42
|
+
const _default = {
|
|
43
|
+
title: '',
|
|
44
|
+
content: '',
|
|
45
|
+
showCancel: true,
|
|
46
|
+
cancelText: '取消',
|
|
47
|
+
cancelColor: '#000000',
|
|
48
|
+
confirmText: '确定',
|
|
49
|
+
confirmColor: '#3CC51F'
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
options = { ..._default, ...options }
|
|
53
|
+
|
|
54
|
+
const {
|
|
55
|
+
title, content, cancelText, confirmText,
|
|
56
|
+
cancelColor, confirmColor, showCancel
|
|
57
|
+
} = options
|
|
58
|
+
|
|
59
|
+
const buttons: any = []
|
|
60
|
+
|
|
61
|
+
if (cancelText !== '' && showCancel) {
|
|
62
|
+
buttons.push({
|
|
63
|
+
text: cancelText,
|
|
64
|
+
color: cancelColor
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (confirmText !== '') {
|
|
69
|
+
buttons.push({
|
|
70
|
+
text: confirmText,
|
|
71
|
+
color: confirmColor
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return new Promise(resolve => {
|
|
76
|
+
const modalOptions = {
|
|
77
|
+
title,
|
|
78
|
+
message: content,
|
|
79
|
+
buttons: buttons,
|
|
80
|
+
success: (data) => {
|
|
81
|
+
if (data.index === 1 || !showCancel) {
|
|
82
|
+
callAsyncSuccess(
|
|
83
|
+
resolve,
|
|
84
|
+
{
|
|
85
|
+
...resCallback('showModal'),
|
|
86
|
+
confirm: true,
|
|
87
|
+
cancel: false,
|
|
88
|
+
content: null
|
|
89
|
+
},
|
|
90
|
+
options
|
|
91
|
+
)
|
|
92
|
+
} else {
|
|
93
|
+
callAsyncSuccess(
|
|
94
|
+
resolve,
|
|
95
|
+
{
|
|
96
|
+
...resCallback('showModal'),
|
|
97
|
+
confirm: false,
|
|
98
|
+
cancel: true
|
|
99
|
+
},
|
|
100
|
+
options
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
// 鸿蒙没有失败方法,只有取消
|
|
105
|
+
cancel: (_) => {
|
|
106
|
+
callAsyncSuccess(
|
|
107
|
+
resolve,
|
|
108
|
+
{
|
|
109
|
+
...resCallback('showModal'),
|
|
110
|
+
confirm: false,
|
|
111
|
+
cancel: true
|
|
112
|
+
},
|
|
113
|
+
options
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
prompt.showDialog(modalOptions)
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const showActionSheetSchema = {
|
|
123
|
+
title: 'String',
|
|
124
|
+
itemList: 'Array'
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function showActionSheet (options) {
|
|
128
|
+
return new Promise((resolve, reject) => {
|
|
129
|
+
const _default = {
|
|
130
|
+
title: '',
|
|
131
|
+
itemList: [],
|
|
132
|
+
itemColor: '#000000'
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
options = { ..._default, ...options }
|
|
136
|
+
|
|
137
|
+
try {
|
|
138
|
+
validateParams<any>('showActionSheet', options, showActionSheetSchema)
|
|
139
|
+
} catch (error) {
|
|
140
|
+
const res = { errMsg: error.message }
|
|
141
|
+
return callAsyncFail(reject, res, options)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const { title, itemList, itemColor } = options
|
|
145
|
+
|
|
146
|
+
const buttons = itemList.map(res => {
|
|
147
|
+
return {
|
|
148
|
+
text: res,
|
|
149
|
+
color: itemColor
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
const actionSheetOptions = {
|
|
154
|
+
title,
|
|
155
|
+
buttons,
|
|
156
|
+
success: (data) => {
|
|
157
|
+
callAsyncSuccess(
|
|
158
|
+
resolve,
|
|
159
|
+
{
|
|
160
|
+
...data,
|
|
161
|
+
...resCallback('showActionSheet')
|
|
162
|
+
},
|
|
163
|
+
options
|
|
164
|
+
)
|
|
165
|
+
},
|
|
166
|
+
// 取消方法,并非失败
|
|
167
|
+
fail: (data) => {
|
|
168
|
+
callAsyncFail(
|
|
169
|
+
reject,
|
|
170
|
+
{
|
|
171
|
+
...data,
|
|
172
|
+
errMsg: data.errMsg.replace('showActionMenu', 'showActionSheet')
|
|
173
|
+
},
|
|
174
|
+
options
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
prompt.showActionMenu(actionSheetOptions)
|
|
180
|
+
})
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export function hideToast (options) {
|
|
184
|
+
return new Promise(resolve => {
|
|
185
|
+
prompt.showToast({
|
|
186
|
+
message: '关闭中',
|
|
187
|
+
duration: 10,
|
|
188
|
+
bottom: '9999px'
|
|
189
|
+
})
|
|
190
|
+
callAsyncSuccess(resolve, resCallback('hideToast'), options)
|
|
191
|
+
})
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export const showLoading = temporarilyNotSupport('showLoading')
|
|
195
|
+
export const hideLoading = temporarilyNotSupport('hideLoading')
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Current } from '@tarojs/runtime'
|
|
2
|
+
|
|
3
|
+
import { callAsyncSuccess, temporarilyNotSupport } from '../../utils'
|
|
4
|
+
|
|
5
|
+
import type Taro from '@tarojs/api'
|
|
6
|
+
|
|
7
|
+
export const setNavigationBarTitle: typeof Taro.setNavigationBarTitle = function (options) {
|
|
8
|
+
return new Promise(resolve => {
|
|
9
|
+
const taro = (Current as any).taro
|
|
10
|
+
const page = taro.getCurrentInstance().page
|
|
11
|
+
const res = { errMsg: 'setNavigationBarTitle:ok' }
|
|
12
|
+
|
|
13
|
+
page.$set?.('taroNavBar.title', options.title)
|
|
14
|
+
callAsyncSuccess(resolve, res, options)
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const setNavigationBarColor: typeof Taro.setNavigationBarColor = function (options) {
|
|
19
|
+
return new Promise(resolve => {
|
|
20
|
+
const taro = (Current as any).taro
|
|
21
|
+
const page = taro.getCurrentInstance().page
|
|
22
|
+
const { frontColor, backgroundColor } = options
|
|
23
|
+
const res = { errMsg: 'setNavigationBarColor:ok' }
|
|
24
|
+
|
|
25
|
+
page.$set?.('taroNavBar.textStyle', frontColor)
|
|
26
|
+
page.$set?.('taroNavBar.background', backgroundColor)
|
|
27
|
+
callAsyncSuccess(resolve, res, options)
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const showNavigationBarLoading = temporarilyNotSupport('showNavigationBarLoading')
|
|
32
|
+
export const hideNavigationBarLoading = temporarilyNotSupport('hideNavigationBarLoading')
|
|
33
|
+
export const hideHomeButton = temporarilyNotSupport('hideHomeButton')
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Current } from '@tarojs/runtime'
|
|
2
|
+
|
|
3
|
+
import { callAsyncSuccess } from '../utils'
|
|
4
|
+
|
|
5
|
+
import type Taro from '@tarojs/api'
|
|
6
|
+
|
|
7
|
+
export const startPullDownRefresh: typeof Taro.startPullDownRefresh = function (options) {
|
|
8
|
+
return new Promise(resolve => {
|
|
9
|
+
const taro = (Current as any).taro
|
|
10
|
+
const page = taro.getCurrentInstance().page
|
|
11
|
+
|
|
12
|
+
if (page.isRefreshing instanceof Array) {
|
|
13
|
+
const index = page.tabBarCurrentIndex || 0
|
|
14
|
+
page.isRefreshing[index] = true
|
|
15
|
+
} else {
|
|
16
|
+
page.isRefreshing = true
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const res = { errMsg: 'startPullDownRefresh:ok' }
|
|
20
|
+
page.$set?.('isRefreshing', true)
|
|
21
|
+
callAsyncSuccess(resolve, res, options)
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const stopPullDownRefresh: typeof Taro.stopPullDownRefresh = function (options) {
|
|
26
|
+
return new Promise(resolve => {
|
|
27
|
+
const taro = (Current as any).taro
|
|
28
|
+
const page = taro.getCurrentInstance().page
|
|
29
|
+
|
|
30
|
+
if (page.isRefreshing instanceof Array) {
|
|
31
|
+
const index = page.tabBarCurrentIndex || 0
|
|
32
|
+
page.isRefreshing[index] = false
|
|
33
|
+
} else {
|
|
34
|
+
page.isRefreshing = false
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const res = { errMsg: 'stopPullDownRefresh:ok' }
|
|
38
|
+
page.$set?.('isRefreshing', false)
|
|
39
|
+
callAsyncSuccess(resolve, res, options)
|
|
40
|
+
})
|
|
41
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { isFunction } from '@tarojs/shared'
|
|
2
|
+
|
|
3
|
+
export interface ICallbackResult {
|
|
4
|
+
/** 错误信息 */
|
|
5
|
+
errMsg: string
|
|
6
|
+
}
|
|
7
|
+
type TFunc = (...args: any[]) => any
|
|
8
|
+
|
|
9
|
+
type TCallback<T = Partial<ICallbackResult>> = (res: T) => Promise<void> | void
|
|
10
|
+
interface IMethodParam<T = Partial<ICallbackResult>> {
|
|
11
|
+
name: string
|
|
12
|
+
success?: TCallback<T & ICallbackResult>
|
|
13
|
+
fail?: TCallback
|
|
14
|
+
complete?: TCallback
|
|
15
|
+
}
|
|
16
|
+
interface IMockPromise {
|
|
17
|
+
resolve?: typeof Promise.resolve | TFunc
|
|
18
|
+
reject?: typeof Promise.reject | TFunc
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class MethodHandler<T = Partial<ICallbackResult>> {
|
|
22
|
+
methodName: string
|
|
23
|
+
|
|
24
|
+
protected __success?: TCallback<T>
|
|
25
|
+
protected __fail?: TCallback
|
|
26
|
+
protected __complete?: TCallback
|
|
27
|
+
|
|
28
|
+
protected isHandlerError = false
|
|
29
|
+
|
|
30
|
+
constructor ({ name, success, fail, complete }: IMethodParam<T>) {
|
|
31
|
+
this.methodName = name
|
|
32
|
+
this.__success = success
|
|
33
|
+
this.__fail = fail
|
|
34
|
+
this.__complete = complete
|
|
35
|
+
|
|
36
|
+
this.isHandlerError = isFunction(this.__complete) || isFunction(this.__fail)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
success<U = Record<string, unknown>> (res: Partial<T> & Partial<ICallbackResult> = {}, promise: IMockPromise = {}): Promise<T & U & ICallbackResult> {
|
|
40
|
+
if (!res.errMsg) {
|
|
41
|
+
res.errMsg = `${this.methodName}:ok`
|
|
42
|
+
}
|
|
43
|
+
isFunction(this.__success) && this.__success(res as T)
|
|
44
|
+
isFunction(this.__complete) && this.__complete(res)
|
|
45
|
+
|
|
46
|
+
const { resolve = Promise.resolve.bind(Promise) } = promise
|
|
47
|
+
return resolve(res as Required<T & U & ICallbackResult>)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
fail<U = Record<string, unknown>> (res: Partial<T> & Partial<ICallbackResult> = {}, promise: IMockPromise = {}): Promise<T & U & ICallbackResult> {
|
|
51
|
+
if (!res.errMsg) {
|
|
52
|
+
res.errMsg = `${this.methodName}:fail`
|
|
53
|
+
} else {
|
|
54
|
+
res.errMsg = `${this.methodName}:fail ${res.errMsg}`
|
|
55
|
+
}
|
|
56
|
+
isFunction(this.__fail) && this.__fail(res)
|
|
57
|
+
isFunction(this.__complete) && this.__complete(res)
|
|
58
|
+
|
|
59
|
+
const {
|
|
60
|
+
resolve = Promise.resolve.bind(Promise),
|
|
61
|
+
reject = Promise.reject.bind(Promise)
|
|
62
|
+
} = promise
|
|
63
|
+
return this.isHandlerError
|
|
64
|
+
? resolve(res as Required<T & U & ICallbackResult>)
|
|
65
|
+
: reject(res)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
type TCallbackManagerFunc<T extends unknown[] = unknown[]> = (...arr: T) => void
|
|
70
|
+
interface ICallbackManagerOption<T extends unknown[] = unknown[]> {
|
|
71
|
+
callback?: TCallbackManagerFunc<T>
|
|
72
|
+
ctx?: any
|
|
73
|
+
[key: string]: unknown
|
|
74
|
+
}
|
|
75
|
+
type TCallbackManagerUnit<T extends unknown[] = unknown[]> = (TCallbackManagerFunc<T> | ICallbackManagerOption<T>)
|
|
76
|
+
|
|
77
|
+
export class CallbackManager<T extends unknown[] = unknown[]> {
|
|
78
|
+
callbacks: TCallbackManagerUnit<T>[] = []
|
|
79
|
+
|
|
80
|
+
/** 添加回调 */
|
|
81
|
+
add = (opt?: TCallbackManagerUnit<T>) => {
|
|
82
|
+
if (opt) this.callbacks.push(opt)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** 移除回调 */
|
|
86
|
+
remove = (opt?: TCallbackManagerUnit<T>) => {
|
|
87
|
+
if (opt) {
|
|
88
|
+
let pos = -1
|
|
89
|
+
this.callbacks.forEach((callback, k) => {
|
|
90
|
+
if (callback === opt) {
|
|
91
|
+
pos = k
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
if (pos > -1) {
|
|
95
|
+
this.callbacks.splice(pos, 1)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** 获取回调函数数量 */
|
|
101
|
+
count = () => {
|
|
102
|
+
return this.callbacks.length
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** 触发回调 */
|
|
106
|
+
trigger = (...args: T) => {
|
|
107
|
+
this.callbacks.forEach(opt => {
|
|
108
|
+
if (isFunction(opt)) {
|
|
109
|
+
opt(...args)
|
|
110
|
+
} else {
|
|
111
|
+
const { callback, ctx } = opt
|
|
112
|
+
isFunction(callback) && callback.call(ctx, ...args)
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
}
|