@tarojs/plugin-platform-harmony-ets 3.7.0-alpha.27 → 4.0.0-alpha.10
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/dist/apis/apis.ts +6 -2
- package/dist/apis/base/crypto.ts +4 -0
- package/dist/apis/base/debug.ts +5 -0
- package/dist/apis/base/index.ts +9 -1
- package/dist/apis/base/performance.ts +8 -0
- package/dist/apis/base/system.ts +74 -21
- package/dist/apis/base/update.ts +5 -0
- package/dist/apis/base/weapp/app-event.ts +75 -0
- package/dist/apis/base/weapp/life-cycle.ts +21 -0
- package/dist/apis/canvas/index.ts +27 -0
- package/dist/apis/data-analysis/index.ts +6 -0
- package/dist/apis/device/accelerometer.ts +2 -1
- package/dist/apis/device/accessibility.ts +4 -0
- package/dist/apis/device/battery.ts +2 -2
- package/dist/apis/device/bluetooth-ble.ts +19 -0
- package/dist/apis/device/bluetooth-peripheral.ts +6 -0
- package/dist/apis/device/bluetooth.ts +16 -0
- package/dist/apis/device/calendar.ts +5 -0
- package/dist/apis/device/clipboard.ts +17 -9
- package/dist/apis/device/compass.ts +21 -0
- package/dist/apis/device/contact.ts +5 -0
- package/dist/apis/device/crypto.ts +4 -0
- package/dist/apis/device/gyroscope.ts +7 -0
- package/dist/apis/device/iBeacon.ts +10 -0
- package/dist/apis/device/index.ts +15 -0
- package/dist/apis/device/keyboard.ts +2 -1
- package/dist/apis/device/memory.ts +10 -3
- package/dist/apis/device/motion.ts +6 -0
- package/dist/apis/device/network.ts +26 -9
- package/dist/apis/device/nfc.ts +10 -0
- package/dist/apis/device/phone.ts +2 -1
- package/dist/apis/device/scan.ts +4 -0
- package/dist/apis/device/screen.ts +2 -1
- package/dist/apis/device/sms.ts +4 -0
- package/dist/apis/device/vibrate.ts +19 -11
- package/dist/apis/device/wifi.ts +15 -0
- package/dist/apis/ext/index.ts +5 -0
- package/dist/apis/files/index.ts +2 -1
- package/dist/apis/files/manager.ts +2 -1
- package/dist/apis/framework/index.ts +3 -8
- package/dist/apis/index.ts +27 -17
- package/dist/apis/location/index.ts +61 -68
- package/dist/apis/media/EditorContext.ts +32 -0
- package/dist/apis/media/audio/index.ts +18 -0
- package/dist/apis/media/background-audio/index.ts +16 -0
- package/dist/apis/media/camera.ts +16 -0
- package/dist/apis/media/common.ts +2 -1
- package/dist/apis/media/{image.ts → image/index.ts} +4 -3
- package/dist/apis/media/index.ts +10 -0
- package/dist/apis/media/live.ts +5 -0
- package/dist/apis/media/map.ts +4 -0
- package/dist/apis/media/media-recorder.ts +4 -0
- package/dist/apis/media/recorder.ts +6 -0
- package/dist/apis/media/video/VideoContext.ts +68 -0
- package/dist/apis/media/{video.ts → video/index.ts} +13 -2
- package/dist/apis/media/video-decoder.ts +4 -0
- package/dist/apis/media/video-processing.ts +4 -0
- package/dist/apis/media/voip.ts +19 -0
- package/dist/apis/network/index.ts +3 -0
- package/dist/apis/network/mdns.ts +13 -0
- package/dist/apis/network/request.ts +7 -6
- package/dist/apis/network/tcp.ts +4 -0
- package/dist/apis/network/udp.ts +4 -0
- package/dist/apis/network/webSocket.ts +2 -6
- package/dist/apis/open-api/account.ts +4 -0
- package/dist/apis/open-api/address.ts +4 -0
- package/dist/apis/open-api/authorize.ts +5 -0
- package/dist/apis/open-api/card.ts +5 -0
- package/dist/apis/open-api/channels-live.ts +11 -0
- package/dist/apis/open-api/customer-service.ts +4 -0
- package/dist/apis/open-api/device-voip.ts +5 -0
- package/dist/apis/open-api/facial.ts +7 -0
- package/dist/apis/open-api/favorites.ts +5 -0
- package/dist/apis/open-api/group.ts +4 -0
- package/dist/apis/open-api/index.ts +20 -6
- package/dist/apis/open-api/invoice.ts +5 -0
- package/dist/apis/open-api/license-plate.ts +4 -0
- package/dist/apis/open-api/login.ts +6 -0
- package/dist/apis/open-api/my-miniprogram.ts +4 -0
- package/dist/apis/open-api/privacy.ts +7 -0
- package/dist/apis/open-api/red-package.ts +4 -0
- package/dist/apis/open-api/settings.ts +5 -0
- package/dist/apis/open-api/soter.ts +6 -0
- package/dist/apis/open-api/subscribe-message.ts +6 -0
- package/dist/apis/open-api/{user-info/index.ts → user-info.ts} +1 -16
- package/dist/apis/open-api/werun.ts +5 -0
- package/dist/apis/payment/index.ts +6 -0
- package/dist/apis/route/index.ts +19 -28
- package/dist/apis/share/index.ts +33 -0
- package/dist/apis/storage/background-fetch.ts +7 -0
- package/dist/apis/storage/cache-manager.ts +4 -0
- package/dist/apis/storage/index.ts +158 -88
- package/dist/apis/ui/{animation.ts → animation/animation.ts} +73 -31
- package/dist/apis/ui/animation/index.ts +7 -0
- package/dist/apis/ui/background.ts +4 -19
- package/dist/apis/ui/custom-component.ts +8 -0
- package/dist/apis/ui/fonts.ts +4 -0
- package/dist/apis/ui/index.ts +8 -10
- package/dist/apis/ui/interaction/index.ts +45 -59
- package/dist/apis/ui/menu.ts +4 -0
- package/dist/apis/ui/navigation-bar/index.ts +60 -21
- package/dist/apis/ui/pull-down-refresh.ts +10 -4
- package/dist/apis/{page → ui/scroll}/index.ts +32 -27
- package/dist/apis/ui/sticky.ts +4 -0
- package/dist/apis/{tabbar/index.ts → ui/tab-bar.ts} +6 -8
- package/dist/apis/ui/window.ts +20 -0
- package/dist/apis/utils/handler.ts +4 -4
- package/dist/apis/utils/index.ts +1 -1
- package/dist/apis/worker/index.ts +4 -0
- package/dist/apis/wxml/IntersectionObserver.ts +24 -25
- package/dist/apis/wxml/index.ts +7 -2
- package/dist/apis/wxml/nodesRef.ts +2 -2
- package/dist/apis/wxml/selectorQuery.ts +29 -17
- package/dist/components-harmony-ets/button.ets +106 -80
- package/dist/components-harmony-ets/canvas.ets +51 -0
- package/dist/components-harmony-ets/checkbox.ets +82 -148
- package/dist/components-harmony-ets/form.ets +45 -132
- package/dist/components-harmony-ets/icon.ets +66 -69
- package/dist/components-harmony-ets/image.ets +26 -61
- package/dist/components-harmony-ets/index.ets +92 -0
- package/dist/components-harmony-ets/innerHtml.ets +7 -70
- package/dist/components-harmony-ets/input.ets +60 -146
- package/dist/components-harmony-ets/label.ets +86 -92
- package/dist/components-harmony-ets/listView.ets +26 -0
- package/dist/components-harmony-ets/movableArea.ets +124 -0
- package/dist/components-harmony-ets/movableView.ets +93 -0
- package/dist/components-harmony-ets/navigationBar.ets +65 -0
- package/dist/components-harmony-ets/pageMeta.ets +94 -0
- package/dist/components-harmony-ets/picker.ets +172 -198
- package/dist/components-harmony-ets/progress.ets +52 -0
- package/dist/components-harmony-ets/pseudo.ets +80 -0
- package/dist/components-harmony-ets/radio.ets +85 -155
- package/dist/components-harmony-ets/richText.ets +15 -87
- package/dist/components-harmony-ets/scrollList.ets +94 -0
- package/dist/components-harmony-ets/scrollView.ets +81 -149
- package/dist/components-harmony-ets/slider.ets +47 -94
- package/dist/components-harmony-ets/stickySection.ets +42 -0
- package/dist/components-harmony-ets/style.ets +396 -0
- package/dist/components-harmony-ets/swiper.ets +51 -151
- package/dist/components-harmony-ets/switch.ets +35 -76
- package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
- package/dist/components-harmony-ets/text.ets +131 -76
- package/dist/components-harmony-ets/textArea.ets +64 -140
- package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +4 -13
- package/dist/components-harmony-ets/utils/constant/style.ets +9 -6
- package/dist/components-harmony-ets/utils/flexManager.ets +68 -85
- package/dist/components-harmony-ets/utils/helper.ets +18 -65
- package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
- package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
- package/dist/components-harmony-ets/utils/index.ts +55 -51
- package/dist/components-harmony-ets/utils/styles.ets +177 -65
- package/dist/components-harmony-ets/video.ets +70 -116
- package/dist/components-harmony-ets/view.ets +58 -64
- package/dist/components-harmony-ets/webView.ets +56 -0
- package/dist/index.d.ts +152 -0
- package/dist/index.js +230 -60
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/document.ts +6 -4
- package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
- package/dist/runtime-ets/bom/window.ts +9 -2
- package/dist/runtime-ets/current.ts +3 -0
- package/dist/runtime-ets/dom/bind.ts +96 -0
- package/dist/runtime-ets/dom/class-list.ts +4 -6
- package/dist/runtime-ets/dom/comment.ts +1 -2
- package/dist/runtime-ets/dom/cssNesting.ts +409 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +30 -20
- package/dist/runtime-ets/dom/dataSource.ts +64 -0
- package/dist/runtime-ets/dom/document.ts +36 -51
- package/dist/runtime-ets/dom/element/canvas.ts +136 -0
- package/dist/runtime-ets/dom/element/element.ts +439 -0
- package/dist/runtime-ets/dom/element/form.ts +403 -0
- package/dist/runtime-ets/dom/element/index.ts +120 -0
- package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
- package/dist/runtime-ets/dom/element/movableView.ts +242 -0
- package/dist/runtime-ets/dom/element/normal.ts +103 -0
- package/dist/runtime-ets/dom/element/progress.ts +11 -0
- package/dist/runtime-ets/dom/element/scrollView.ts +15 -0
- package/dist/runtime-ets/dom/element/text.ts +10 -0
- package/dist/runtime-ets/dom/element/video.ts +50 -0
- package/dist/runtime-ets/dom/element/webView.ts +68 -0
- package/dist/runtime-ets/dom/event.ts +26 -5
- package/dist/runtime-ets/dom/eventTarget.ts +3 -3
- package/dist/runtime-ets/dom/node.ts +114 -49
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +805 -0
- package/dist/runtime-ets/dom/stylesheet/index.ts +122 -429
- package/dist/runtime-ets/dom/stylesheet/type.ts +93 -17
- package/dist/runtime-ets/dom/stylesheet/util.ts +145 -17
- package/dist/runtime-ets/index.ts +2 -3
- package/dist/runtime-ets/interface/event.ts +3 -2
- package/dist/runtime-ets/utils/index.ts +87 -17
- package/dist/runtime-ets/utils/info.ts +21 -47
- package/dist/runtime-framework/react/app.ts +20 -28
- package/dist/runtime-framework/react/hooks.ts +3 -4
- package/dist/runtime-framework/react/index.ts +1 -2
- package/dist/runtime-framework/react/native-page.ts +421 -0
- package/dist/runtime-framework/react/page.ts +5 -17
- package/dist/runtime-framework/solid/app.ts +25 -45
- package/dist/runtime-framework/solid/connect.ts +21 -3
- package/dist/runtime-framework/solid/hooks.ts +17 -12
- package/dist/runtime-framework/solid/index.ts +6 -2
- package/dist/runtime-framework/solid/page.ts +84 -36
- package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
- package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
- package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
- package/dist/runtime-framework/solid/utils/index.ts +0 -2
- package/dist/runtime-utils.d.ts +827 -0
- package/dist/runtime-utils.js +1633 -549
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +1633 -549
- package/dist/runtime.js.map +1 -1
- package/index.js +3 -1
- package/package.json +14 -15
- package/static/media/cancel.svg +1 -0
- package/static/media/circle.svg +1 -0
- package/static/media/clear.svg +1 -0
- package/static/media/download.svg +1 -0
- package/static/media/info.svg +1 -0
- package/static/media/info_circle.svg +1 -0
- package/static/media/search.svg +1 -0
- package/static/media/success.svg +1 -0
- package/static/media/success_no_circle.svg +1 -0
- package/static/media/taro_arrow_left.svg +1 -0
- package/static/media/taro_home.svg +1 -0
- package/static/media/waiting.svg +1 -0
- package/static/media/warn.svg +1 -0
- package/types/harmony.d.ts +4 -0
- package/types/index.d.ts +4 -0
- package/types/runtime.d.ts +7 -1
- package/LICENSE +0 -160
- package/dist/components-harmony-ets/base.ets +0 -63
- package/dist/components-harmony-ets/element.ets +0 -223
- package/dist/components-harmony-ets/utils/constant/icon.ts +0 -19
- package/dist/runtime-ets/dom/element.ts +0 -457
- package/dist/runtime-ets/dom/text.ts +0 -19
- package/dist/runtime-ets/utils/bind.ts +0 -35
- package/types/api.d.ts +0 -4
- /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { TaroAny, TaroMovableViewElement, TaroElement } from '@tarojs/runtime'
|
|
2
|
+
|
|
3
|
+
import commonStyleModify, { rowModify, columnModify } from './style'
|
|
4
|
+
|
|
5
|
+
import { FlexManager } from './utils/flexManager'
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@Component
|
|
10
|
+
export default struct TaroMovableView {
|
|
11
|
+
@Builder customBuilder() {}
|
|
12
|
+
@BuilderParam createLazyChildren: (node: TaroMovableViewElement) => void = this.customBuilder
|
|
13
|
+
@ObjectLink node: TaroMovableViewElement
|
|
14
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
15
|
+
|
|
16
|
+
aboutToAppear(): void {
|
|
17
|
+
if (this.node) {
|
|
18
|
+
this.node._instance = this
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
build() {
|
|
24
|
+
Stack() {
|
|
25
|
+
if (FlexManager.useFlexLayout(this.node)) {
|
|
26
|
+
Flex(FlexManager.flexOptions(this.node)) {
|
|
27
|
+
this.createLazyChildren(this.node)
|
|
28
|
+
}
|
|
29
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
30
|
+
} else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
|
|
31
|
+
Row() {
|
|
32
|
+
this.createLazyChildren(this.node)
|
|
33
|
+
}
|
|
34
|
+
.attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
35
|
+
} else {
|
|
36
|
+
Column() {
|
|
37
|
+
this.createLazyChildren(this.node)
|
|
38
|
+
}
|
|
39
|
+
.attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
.translate({ x: this.node.position.x, y: this.node.position.y })
|
|
43
|
+
.scale({ x: this.node.scaleValue, y: this.node.scaleValue })
|
|
44
|
+
.onAreaChange((oldValue: Area, newValue: Area) => {
|
|
45
|
+
if (this.node.selfSize?.w !== Number(newValue.width) || this.node.selfSize?.h !== Number(newValue.height)) {
|
|
46
|
+
this.node.selfSize = { w: Number(newValue.width), h: Number(newValue.height) }
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
.visibility(this.node.visibility)
|
|
50
|
+
.gesture(
|
|
51
|
+
GestureGroup(GestureMode.Parallel,
|
|
52
|
+
PanGesture(getPanOption(this.node)).onActionStart((e: GestureEvent) => {
|
|
53
|
+
|
|
54
|
+
this.node.startMove()
|
|
55
|
+
this.node.callTouchEventFnFromGesture('touchstart', e)
|
|
56
|
+
}).onActionUpdate((e: GestureEvent) => {
|
|
57
|
+
this.node.callTouchEventFnFromGesture('touchmove', e)
|
|
58
|
+
this.node.doMove({
|
|
59
|
+
x: e.offsetX,
|
|
60
|
+
y: e.offsetY
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
}).onActionEnd((e: GestureEvent) => {
|
|
64
|
+
this.node.callTouchEventFnFromGesture('touchend', e)
|
|
65
|
+
this.node.checkPositionBoundary(this.node.position, this.node.scaleValue)
|
|
66
|
+
}),
|
|
67
|
+
PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
|
|
68
|
+
this.node.startScale()
|
|
69
|
+
}).onActionUpdate((event) => {
|
|
70
|
+
this.node.doScale(event.scale)
|
|
71
|
+
})
|
|
72
|
+
)
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
function getPanOption(node: TaroMovableViewElement) {
|
|
79
|
+
const attrDirection = node.getAttribute('direction')
|
|
80
|
+
let panDirection = PanDirection.All
|
|
81
|
+
|
|
82
|
+
if(node.getAttribute('disabled')) {
|
|
83
|
+
panDirection = PanDirection.None
|
|
84
|
+
} else if(attrDirection === 'horizontal') {
|
|
85
|
+
panDirection = PanDirection.Horizontal
|
|
86
|
+
} else if (attrDirection === 'vertical') {
|
|
87
|
+
panDirection = PanDirection.Vertical
|
|
88
|
+
}
|
|
89
|
+
return new PanGestureOptions({
|
|
90
|
+
direction: panDirection,
|
|
91
|
+
fingers: 1
|
|
92
|
+
})
|
|
93
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { eventCenter } from '@tarojs/runtime/dist/runtime.esm'
|
|
2
|
+
|
|
3
|
+
import { isTagFirstChild } from './utils/helper'
|
|
4
|
+
|
|
5
|
+
import type { TaroAny, TaroNavigationBarElement } from '@tarojs/runtime'
|
|
6
|
+
import type { IComponentAttributeUpdateEvents } from './pageMeta'
|
|
7
|
+
|
|
8
|
+
@Component
|
|
9
|
+
export default struct TaroNavigationBar {
|
|
10
|
+
@Builder customBuilder() {}
|
|
11
|
+
@BuilderParam createLazyChildren: (node: TaroNavigationBarElement) => void = this.customBuilder
|
|
12
|
+
@ObjectLink node: TaroNavigationBarElement
|
|
13
|
+
|
|
14
|
+
aboutToAppear(): void {
|
|
15
|
+
if (!isTagFirstChild(this.node, 'page-meta')) {
|
|
16
|
+
console.error('NavigationBar 只能是 PageMeta 内的第一个节点。')
|
|
17
|
+
}
|
|
18
|
+
if (this.node) {
|
|
19
|
+
this.node._instance = this
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// FIXME 在 Harmony 提供 @Watch 文档后,根据 node 实际使用更细粒度的监听
|
|
23
|
+
eventCenter.on('__taroComponentAttributeUpdate', this.handleAttributeUpdate)
|
|
24
|
+
this.handleAttributes(this.node._attrs)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
aboutToDisappear(): void {
|
|
28
|
+
eventCenter.off('__taroComponentAttributeUpdate', this.handleAttributeUpdate)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
handleAttributeUpdate = (opt: IComponentAttributeUpdateEvents) => {
|
|
32
|
+
if (opt.id === this.node._nid && opt.tagName === 'NAVIGATION-BAR') {
|
|
33
|
+
const attrs: Record<string, TaroAny> = {}
|
|
34
|
+
attrs[opt.attribute] = opt.value
|
|
35
|
+
this.handleAttributes(attrs)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
handleAttributes (attrs: Record<string, TaroAny>) {
|
|
40
|
+
const options: Record<string, TaroAny> = {}
|
|
41
|
+
|
|
42
|
+
if (attrs.title) {
|
|
43
|
+
options.title = attrs.title
|
|
44
|
+
}
|
|
45
|
+
if (attrs.loading) {
|
|
46
|
+
options.loading = attrs.loading
|
|
47
|
+
}
|
|
48
|
+
if (attrs.backgroundColor) {
|
|
49
|
+
options.backgroundColor = attrs.backgroundColor
|
|
50
|
+
}
|
|
51
|
+
if (attrs.frontColor) {
|
|
52
|
+
options.frontColor = attrs.frontColor
|
|
53
|
+
}
|
|
54
|
+
eventCenter.trigger('__taroNavigationStyle', options)
|
|
55
|
+
// FIXME: 以下属性暂时不支持
|
|
56
|
+
// attrs.colorAnimationDuration
|
|
57
|
+
// attrs.colorAnimationTimingFunc
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
build() {
|
|
61
|
+
if (true) {
|
|
62
|
+
this.createLazyChildren(this.node)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { APP, eventCenter } from '@tarojs/runtime/dist/runtime.esm'
|
|
2
|
+
import { getCurrentInstance, pageScrollTo } from '@tarojs/taro'
|
|
3
|
+
|
|
4
|
+
import { isTagFirstChild } from './utils/helper'
|
|
5
|
+
|
|
6
|
+
import type { TaroAny, TaroPageMetaElement } from '@tarojs/runtime'
|
|
7
|
+
|
|
8
|
+
export interface IComponentAttributeUpdateEvents {
|
|
9
|
+
id: string
|
|
10
|
+
tagName: string
|
|
11
|
+
attribute: string
|
|
12
|
+
value: TaroAny
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@Component
|
|
16
|
+
export default struct TaroPageMeta {
|
|
17
|
+
@Builder customBuilder() {}
|
|
18
|
+
@BuilderParam createLazyChildren: (node: TaroPageMetaElement) => void = this.customBuilder
|
|
19
|
+
@ObjectLink node: TaroPageMetaElement
|
|
20
|
+
|
|
21
|
+
page: TaroAny = {}
|
|
22
|
+
|
|
23
|
+
aboutToAppear(): void {
|
|
24
|
+
if (!isTagFirstChild(this.node, APP, 2)) {
|
|
25
|
+
// PageMeta 只能是页面内的第一个元素
|
|
26
|
+
console.error('PageMeta 只能是页面内的第一个元素。')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
this.page = getCurrentInstance().page
|
|
30
|
+
if (this.node) {
|
|
31
|
+
this.node._instance = this
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// FIXME 在 Harmony 提供 @Watch 文档后,根据 node 实际使用更细粒度的监听
|
|
35
|
+
eventCenter.on('__taroComponentAttributeUpdate', this.handleAttributeUpdate)
|
|
36
|
+
this.handleAttributes(this.node._attrs)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
aboutToDisappear(): void {
|
|
40
|
+
eventCenter.off('__taroComponentAttributeUpdate', this.handleAttributeUpdate)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
handleAttributeUpdate = (opt: IComponentAttributeUpdateEvents) => {
|
|
44
|
+
if (opt.id === this.node._nid && opt.tagName === 'PAGE-META') {
|
|
45
|
+
const attrs: Record<string, TaroAny> = {}
|
|
46
|
+
attrs[opt.attribute] = opt.value
|
|
47
|
+
this.handleAttributes(attrs)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
handleAttributes (attrs: Record<string, TaroAny>) {
|
|
52
|
+
const options: Record<string, TaroAny> = {}
|
|
53
|
+
let triggerStyleEvent = false
|
|
54
|
+
|
|
55
|
+
// FIXME 更新类型支持度
|
|
56
|
+
if (attrs.backgroundColorTop || attrs.rootBackgroundColor || attrs.backgroundColor) {
|
|
57
|
+
options.backgroundColorContext = attrs.backgroundColorTop || attrs.rootBackgroundColor || attrs.backgroundColor
|
|
58
|
+
triggerStyleEvent = true
|
|
59
|
+
}
|
|
60
|
+
if (attrs.backgroundColorBottom || attrs.backgroundColor) {
|
|
61
|
+
options.backgroundColor = attrs.backgroundColorBottom || attrs.backgroundColor
|
|
62
|
+
triggerStyleEvent = true
|
|
63
|
+
}
|
|
64
|
+
if (attrs.backgroundTextStyle) {
|
|
65
|
+
options.backgroundTextStyle = attrs.backgroundTextStyle
|
|
66
|
+
triggerStyleEvent = true
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (this.page === getCurrentInstance().page) {
|
|
70
|
+
if (attrs.scrollTop || attrs.scrollDuration) {
|
|
71
|
+
pageScrollTo({
|
|
72
|
+
scrollTop: attrs.scrollTop || this.node._attrs.scrollTop,
|
|
73
|
+
duration: attrs.scrollDuration || this.node._attrs.scrollDuration,
|
|
74
|
+
} as TaroAny)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// pageStyle
|
|
78
|
+
// rootFontSize
|
|
79
|
+
// pageFontSize
|
|
80
|
+
// pageOrientation
|
|
81
|
+
if (triggerStyleEvent) {
|
|
82
|
+
eventCenter.trigger('__taroPageStyle', options)
|
|
83
|
+
}
|
|
84
|
+
// onResize
|
|
85
|
+
// onScroll
|
|
86
|
+
// onScrollDone
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
build() {
|
|
90
|
+
if (true) {
|
|
91
|
+
this.createLazyChildren(this.node)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|