@tarojs/plugin-platform-harmony-ets 4.0.0-beta.12 → 4.0.0-beta.13

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.
@@ -1,5 +1,3 @@
1
- import { Current } from '@tarojs/runtime'
2
-
3
1
  import { temporarilyNotSupport } from '../utils'
4
2
 
5
3
  export const ENV_TYPE = {
@@ -19,12 +17,10 @@ export function getEnv () {
19
17
  return ENV_TYPE.HARMONY
20
18
  }
21
19
 
22
- export { Current }
23
-
24
20
  // TODO
25
21
  export const getCurrentPages = () => []
26
22
 
27
- export const getCurrentInstance = () => Current
23
+ export { Current, getCurrentInstance } from '@tarojs/runtime'
28
24
 
29
25
  export const requirePlugin = temporarilyNotSupport('requirePlugin')
30
26
 
@@ -33,7 +33,7 @@ const defaultUnitPrecision = 5
33
33
  const defaultTargetUnit = 'vp'
34
34
 
35
35
  export function getApp () {
36
- return Current.app
36
+ return Current.app || {}
37
37
  }
38
38
 
39
39
  export function initPxTransform ({
@@ -0,0 +1,72 @@
1
+ import { getFontAttributes, getStyle } from './utils/helper'
2
+ import { pseudoModify } from './style'
3
+ import { createLazyChildren } from './render'
4
+
5
+ import type { TaroViewElement, TaroStyleType, TaroTextStyleType } from '@tarojs/runtime'
6
+
7
+ @Extend(Stack)
8
+ function stackAttrs (style: TaroStyleType) {
9
+ .constraintSize({
10
+ minWidth: style.minWidth,
11
+ maxWidth: style.maxWidth,
12
+ minHeight: style.minHeight || style.height,
13
+ maxHeight: style.maxHeight
14
+ })
15
+ }
16
+
17
+
18
+ @Extend(Text)
19
+ function textNormalFontStyle (style: TaroStyleType) {
20
+ .id(style.id)
21
+ .key(style.id)
22
+ .opacity(style.opacity)
23
+ .fontColor(style.color)
24
+ .fontSize(style.fontSize)
25
+ .fontWeight(style.fontWeight)
26
+ .fontStyle(style.fontStyle)
27
+ .fontFamily(style.fontFamily)
28
+ .lineHeight(style.lineHeight)
29
+ .decoration({
30
+ type: style.textDecoration,
31
+ color: style.color
32
+ })
33
+ }
34
+
35
+ @Extend(Text)
36
+ function textSpecialFontStyle(attr: TaroTextStyleType) {
37
+ .textAlign(attr.textAlign)
38
+ .textOverflow(attr.textOverflow)
39
+ .maxLines(attr.WebkitLineClamp)
40
+ .letterSpacing(attr.letterSpacing)
41
+ }
42
+
43
+ @Builder
44
+ export default function PseduoChildren (node: TaroViewElement) {
45
+ // 伪类::Before
46
+ if (node.pseudo_before) {
47
+ if (node.pseudo_before.content) {
48
+ Text(node.pseudo_before.content)
49
+ .attributeModifier(pseudoModify.setStyle(node.pseudo_before))
50
+ .textNormalFontStyle(getStyle(node.pseudo_before || {}))
51
+ .textSpecialFontStyle(getFontAttributes(node))
52
+ } else {
53
+ Stack() {}
54
+ .attributeModifier(pseudoModify.setStyle(node.pseudo_before || {}))
55
+ .stackAttrs(getStyle(node.pseudo_before || {}))
56
+ }
57
+ }
58
+ createLazyChildren(node)
59
+ // 伪类::After
60
+ if (node.pseudo_after) {
61
+ if (node.pseudo_after.content) {
62
+ Text(node.pseudo_after.content)
63
+ .attributeModifier(pseudoModify.setStyle(node.pseudo_after))
64
+ .textNormalFontStyle(getStyle(node.pseudo_after || {}))
65
+ .textSpecialFontStyle(getFontAttributes(node))
66
+ } else {
67
+ Stack() {}
68
+ .attributeModifier(pseudoModify.setStyle(node.pseudo_after || {}))
69
+ .stackAttrs(getStyle(node.pseudo_after || {}))
70
+ }
71
+ }
72
+ }
@@ -1,8 +1,8 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
2
2
 
3
3
  import commonStyleModify from './style'
4
- import { createLazyChildren } from './render'
5
- import { FlexManager } from './utils/flexManager'
4
+ import PseduoChildren from './pseudo'
5
+ import { FlexManager } from './utils/FlexManager'
6
6
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
7
7
  import { getNodeThresholds, getNormalAttributes, shouldBindEvent } from './utils/helper'
8
8
 
@@ -85,7 +85,7 @@ export default struct TaroScrollView {
85
85
  Scroll(this.node.scroller) {
86
86
  if (this.node._attrs.scrollX) {
87
87
  Row() {
88
- createLazyChildren(this.node)
88
+ PseduoChildren(this.node)
89
89
  }
90
90
  .attributeModifier(commonStyleModify.setNode(this.node))
91
91
  .rowAttrs(getNormalAttributes(this.node))
@@ -98,7 +98,7 @@ export default struct TaroScrollView {
98
98
  .flexGrow(0).flexShrink(0)
99
99
  } else {
100
100
  Column() {
101
- createLazyChildren(this.node)
101
+ PseduoChildren(this.node)
102
102
  }
103
103
  .attributeModifier(commonStyleModify.setNode(this.node))
104
104
  .columnAttrs(getNormalAttributes(this.node))
@@ -1,6 +1,6 @@
1
- import type { TaroElement, TaroStyleType } from '@tarojs/runtime'
1
+ import type { HarmonyStyle, TaroElement, TaroStyleType } from '@tarojs/runtime'
2
2
  import { isUndefined } from '../shared'
3
- import { getNormalAttributes } from './utils/helper'
3
+ import { getNormalAttributes, getStyle } from './utils/helper'
4
4
 
5
5
  function getTop (node: TaroElement): Length | number {
6
6
  return node?.hmStyle?.top || 0
@@ -23,132 +23,153 @@ class CommonStyleModify implements AttributeModifier<CommonAttribute> {
23
23
 
24
24
  applyNormalAttribute(instance: CommonAttribute): void {
25
25
  if (this.node && this.style) {
26
+ setNormalAttributeIntoInstance(instance, this.style)
27
+ }
28
+ }
29
+ }
30
+
31
+ class PseudoStyleModify implements AttributeModifier<CommonAttribute> {
32
+ style: TaroStyleType | null = null
26
33
 
27
- if (!isUndefined(this.style.id)) {
28
- instance.id(this.style.id)
29
- instance.key(this.style.id)
30
- }
31
- if (!isUndefined(this.style.flexGrow)) {
32
- instance.flexGrow(this.style.flexGrow)
33
- }
34
- if (!isUndefined(this.style.flexShrink)) {
35
- instance.flexShrink(this.style.flexShrink)
36
- }
37
- if (!isUndefined(this.style.flexBasis)) {
38
- instance.flexBasis(this.style.flexBasis)
39
- }
40
- if (!isUndefined(this.style.alignSelf)) {
41
- instance.alignSelf(this.style.alignSelf)
42
- }
43
- if (!isUndefined(this.style.paddingTop) || !isUndefined(this.style.paddingRight) || !isUndefined(this.style.paddingBottom) || !isUndefined(this.style.paddingLeft)) {
44
- instance.padding({
45
- top: this.style.paddingTop,
46
- right: this.style.paddingRight,
47
- bottom: this.style.paddingBottom,
48
- left: this.style.paddingLeft
49
- })
50
- }
51
- if (!isUndefined(this.style.marginTop) || !isUndefined(this.style.marginRight) || !isUndefined(this.style.marginBottom) || !isUndefined(this.style.marginLeft)) {
52
- instance.margin({
53
- top: this.style.marginTop,
54
- right: this.style.marginRight,
55
- bottom: this.style.marginBottom,
56
- left: this.style.marginLeft
57
- })
58
- }
59
- if (!isUndefined(this.style.width)) {
60
- instance.width(this.style.width)
61
- }
62
- if (!isUndefined(this.style.height)) {
63
- instance.height(this.style.height)
64
- }
65
- if (!isUndefined(this.style.minWidth) || !isUndefined(this.style.maxWidth) || !isUndefined(this.style.minHeight) || !isUndefined(this.style.maxHeight)) {
66
- instance.constraintSize({
67
- minWidth: this.style.minWidth,
68
- maxWidth: this.style.maxWidth,
69
- minHeight: this.style.minHeight,
70
- maxHeight: this.style.maxHeight
71
- })
72
- }
73
- if (!isUndefined(this.style.backgroundColor)) {
74
- instance.backgroundColor(this.style.backgroundColor)
75
- }
76
- if (!isUndefined(this.style.backgroundImage)) {
77
- instance.backgroundImage(this.style.backgroundImage?.src, this.style.backgroundRepeat)
78
- }
79
- if (!isUndefined(this.style.backgroundSize)) {
80
- instance.backgroundImageSize(this.style.backgroundSize)
81
- }
82
- if (!isUndefined(this.style.backgroundPosition)) {
83
- instance.backgroundImagePosition(this.style.backgroundPosition)
84
- }
85
- if (!isUndefined(this.style.borderTopStyle) || !isUndefined(this.style.borderRightStyle) || !isUndefined(this.style.borderBottomStyle) || !isUndefined(this.style.borderLeftStyle)) {
86
- instance.borderStyle({
87
- top: this.style.borderTopStyle,
88
- right: this.style.borderRightStyle,
89
- bottom: this.style.borderBottomStyle,
90
- left: this.style.borderLeftStyle
91
- })
92
- }
93
- if (!isUndefined(this.style.borderTopWidth) || !isUndefined(this.style.borderRightWidth) || !isUndefined(this.style.borderBottomWidth) || !isUndefined(this.style.borderLeftWidth)) {
94
- instance.borderWidth({
95
- top: this.style.borderTopWidth,
96
- right: this.style.borderRightWidth,
97
- bottom: this.style.borderBottomWidth,
98
- left: this.style.borderLeftWidth
99
- })
100
- }
101
- if (!isUndefined(this.style.borderTopColor) || !isUndefined(this.style.borderRightColor) || !isUndefined(this.style.borderBottomColor) || !isUndefined(this.style.borderLeftColor)) {
102
- instance.borderColor({
103
- top: this.style.borderTopColor,
104
- right: this.style.borderRightColor,
105
- bottom: this.style.borderBottomColor,
106
- left: this.style.borderLeftColor
107
- })
108
- }
109
- if (!isUndefined(this.style.borderTopLeftRadius) || !isUndefined(this.style.borderTopRightRadius) || !isUndefined(this.style.borderBottomLeftRadius) || !isUndefined(this.style.borderBottomRightRadius)) {
110
- instance.borderRadius({
111
- topLeft: this.style.borderTopLeftRadius,
112
- topRight: this.style.borderTopRightRadius,
113
- bottomLeft: this.style.borderBottomLeftRadius,
114
- bottomRight: this.style.borderBottomRightRadius
115
- })
116
- }
117
- if (!isUndefined(this.style.zIndex)) {
118
- instance.zIndex(this.style.zIndex)
119
- }
120
- if (!isUndefined(this.style.opacity)) {
121
- instance.opacity(this.style.opacity)
122
- }
123
- if (!isUndefined(this.style.linearGradient)) {
124
- instance.linearGradient(this.style.linearGradient)
125
- }
126
- if (!isUndefined(this.style.overflow)) {
127
- instance.clip(this.style.overflow)
128
- }
129
- if (!isUndefined(this.style.transformOrigin)) {
130
- instance.rotate({ centerX: this.style.transformOrigin.x, centerY: this.style.transformOrigin.y, angle: 0 })
131
- instance.scale({ centerX: this.style.transformOrigin.x, centerY: this.style.transformOrigin.y })
132
- }
133
- if (!isUndefined(this.style.transform)) {
134
- instance.transform(this.style.transform)
135
- }
136
- if (this.node.hmStyle?.position === 'absolute' || this.node.hmStyle?.position === 'fixed') {
137
- instance.position({
138
- x: getLeft(this.node),
139
- y: getTop(this.node)
140
- })
141
- }
142
- if (this.node.hmStyle?.position === 'relative') {
143
- instance.offset({
144
- x: getLeft(this.node),
145
- y: getTop(this.node)
146
- })
147
- }
34
+ setStyle (style: HarmonyStyle) {
35
+ this.style = getStyle(style)
36
+ return this
37
+ }
38
+
39
+ applyNormalAttribute(instance: CommonAttribute): void {
40
+ if (this.style) {
41
+ setNormalAttributeIntoInstance(instance, this.style)
148
42
  }
149
43
  }
150
44
  }
151
45
 
46
+
47
+ function setNormalAttributeIntoInstance(instance: CommonAttribute, style: TaroStyleType) {
48
+ if (!isUndefined(style.id)) {
49
+ instance.id(style.id)
50
+ instance.key(style.id)
51
+ }
52
+ if (!isUndefined(style.flexGrow)) {
53
+ instance.flexGrow(style.flexGrow)
54
+ }
55
+ if (!isUndefined(style.flexShrink)) {
56
+ instance.flexShrink(style.flexShrink)
57
+ }
58
+ if (!isUndefined(style.flexBasis)) {
59
+ instance.flexBasis(style.flexBasis)
60
+ }
61
+ if (!isUndefined(style.alignSelf)) {
62
+ instance.alignSelf(style.alignSelf)
63
+ }
64
+ if (!isUndefined(style.paddingTop) || !isUndefined(style.paddingRight) || !isUndefined(style.paddingBottom) || !isUndefined(style.paddingLeft)) {
65
+ instance.padding({
66
+ top: style.paddingTop,
67
+ right: style.paddingRight,
68
+ bottom: style.paddingBottom,
69
+ left: style.paddingLeft
70
+ })
71
+ }
72
+ if (!isUndefined(style.marginTop) || !isUndefined(style.marginRight) || !isUndefined(style.marginBottom) || !isUndefined(style.marginLeft)) {
73
+ instance.margin({
74
+ top: style.marginTop,
75
+ right: style.marginRight,
76
+ bottom: style.marginBottom,
77
+ left: style.marginLeft
78
+ })
79
+ }
80
+ if (!isUndefined(style.width)) {
81
+ instance.width(style.width)
82
+ }
83
+ if (!isUndefined(style.height)) {
84
+ instance.height(style.height)
85
+ }
86
+ if (!isUndefined(style.minWidth) || !isUndefined(style.maxWidth) || !isUndefined(style.minHeight) || !isUndefined(style.maxHeight)) {
87
+ instance.constraintSize({
88
+ minWidth: style.minWidth,
89
+ maxWidth: style.maxWidth,
90
+ minHeight: style.minHeight,
91
+ maxHeight: style.maxHeight
92
+ })
93
+ }
94
+ if (!isUndefined(style.backgroundColor)) {
95
+ instance.backgroundColor(style.backgroundColor)
96
+ }
97
+ if (!isUndefined(style.backgroundImage)) {
98
+ instance.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
99
+ }
100
+ if (!isUndefined(style.backgroundSize)) {
101
+ instance.backgroundImageSize(style.backgroundSize)
102
+ }
103
+ if (!isUndefined(style.backgroundPosition)) {
104
+ instance.backgroundImagePosition(style.backgroundPosition)
105
+ }
106
+ if (!isUndefined(style.borderTopStyle) || !isUndefined(style.borderRightStyle) || !isUndefined(style.borderBottomStyle) || !isUndefined(style.borderLeftStyle)) {
107
+ instance.borderStyle({
108
+ top: style.borderTopStyle,
109
+ right: style.borderRightStyle,
110
+ bottom: style.borderBottomStyle,
111
+ left: style.borderLeftStyle
112
+ })
113
+ }
114
+ if (!isUndefined(style.borderTopWidth) || !isUndefined(style.borderRightWidth) || !isUndefined(style.borderBottomWidth) || !isUndefined(style.borderLeftWidth)) {
115
+ instance.borderWidth({
116
+ top: style.borderTopWidth,
117
+ right: style.borderRightWidth,
118
+ bottom: style.borderBottomWidth,
119
+ left: style.borderLeftWidth
120
+ })
121
+ }
122
+ if (!isUndefined(style.borderTopColor) || !isUndefined(style.borderRightColor) || !isUndefined(style.borderBottomColor) || !isUndefined(style.borderLeftColor)) {
123
+ instance.borderColor({
124
+ top: style.borderTopColor,
125
+ right: style.borderRightColor,
126
+ bottom: style.borderBottomColor,
127
+ left: style.borderLeftColor
128
+ })
129
+ }
130
+ if (!isUndefined(style.borderTopLeftRadius) || !isUndefined(style.borderTopRightRadius) || !isUndefined(style.borderBottomLeftRadius) || !isUndefined(style.borderBottomRightRadius)) {
131
+ instance.borderRadius({
132
+ topLeft: style.borderTopLeftRadius,
133
+ topRight: style.borderTopRightRadius,
134
+ bottomLeft: style.borderBottomLeftRadius,
135
+ bottomRight: style.borderBottomRightRadius
136
+ })
137
+ }
138
+ if (!isUndefined(style.zIndex)) {
139
+ instance.zIndex(style.zIndex)
140
+ }
141
+ if (!isUndefined(style.opacity)) {
142
+ instance.opacity(style.opacity)
143
+ }
144
+ if (!isUndefined(style.linearGradient)) {
145
+ instance.linearGradient(style.linearGradient)
146
+ }
147
+ if (!isUndefined(style.overflow)) {
148
+ instance.clip(style.overflow)
149
+ }
150
+ if (!isUndefined(style.transformOrigin)) {
151
+ instance.rotate({ centerX: style.transformOrigin.x, centerY: style.transformOrigin.y, angle: 0 })
152
+ instance.scale({ centerX: style.transformOrigin.x, centerY: style.transformOrigin.y })
153
+ }
154
+ if (!isUndefined(style.transform)) {
155
+ instance.transform(style.transform)
156
+ }
157
+ if (style.position === 'absolute' || style.position === 'fixed') {
158
+ instance.position({
159
+ x: style.left || 0,
160
+ y: style.top || 0,
161
+ })
162
+ }
163
+ if (style.position === 'relative') {
164
+ instance.offset({
165
+ x: style.left || 0,
166
+ y: style.top || 0,
167
+ })
168
+ }
169
+ }
170
+
152
171
  const modify = new CommonStyleModify()
153
172
 
173
+ export const pseudoModify = new PseudoStyleModify()
174
+
154
175
  export default modify
@@ -18,21 +18,21 @@ class FlexManager {
18
18
  static convertFlexAlignItemsToColumnOrRow (direction: FlexDirection, alignItems: ItemAlign | undefined): VerticalAlign | HorizontalAlign {
19
19
  if (direction === FlexDirection.Column) {
20
20
  switch (alignItems) {
21
- case ItemAlign.Start:
22
- return HorizontalAlign.Start
21
+ case ItemAlign.Center:
22
+ return HorizontalAlign.Center
23
23
  case ItemAlign.End:
24
24
  return HorizontalAlign.End
25
25
  default:
26
- return HorizontalAlign.Center
26
+ return HorizontalAlign.Start
27
27
  }
28
28
  } else {
29
29
  switch (alignItems) {
30
- case ItemAlign.Start:
31
- return VerticalAlign.Top
30
+ case ItemAlign.Center:
31
+ return VerticalAlign.Center
32
32
  case ItemAlign.End:
33
33
  return VerticalAlign.Bottom
34
34
  default:
35
- return VerticalAlign.Center
35
+ return VerticalAlign.Top
36
36
  }
37
37
  }
38
38
  }
@@ -1,4 +1,4 @@
1
- import { getNormalAttributes, getFontAttributes } from './styles'
1
+ import { getNormalAttributes, getStyle, getFontAttributes } from './styles'
2
2
 
3
3
  import type { TFunc } from '@tarojs/runtime/dist/runtime.esm'
4
4
  import type { TaroElement } from '@tarojs/runtime'
@@ -36,4 +36,4 @@ export function getNodeThresholds (node: TaroElement): number[] | null {
36
36
  return node?._nodeInfo.thresholds || null
37
37
  }
38
38
 
39
- export { getNormalAttributes, getFontAttributes }
39
+ export { getNormalAttributes, getStyle, getFontAttributes }
@@ -42,6 +42,30 @@ export function getNormalAttributes (node: TaroElement): TaroStyleType {
42
42
  linearGradient = hmStyle.backgroundImage
43
43
  }
44
44
 
45
+ let normalAttributes = getStyle(hmStyle)
46
+
47
+ normalAttributes.width = isMaxWidthView(node) && isUndefined(hmStyle.width) ? '100%' : hmStyle.width
48
+ normalAttributes.id = _attrs.id || _nid
49
+
50
+ // taro_page 等写死在运行时里的节点,没有 _nodeInfo
51
+ if (node._nodeInfo) {
52
+ const overwriteStyle: TaroStyleType = node._nodeInfo?.overwriteStyle
53
+
54
+ // 处理覆盖属性:如动画的覆盖
55
+ if (overwriteStyle) {
56
+ normalAttributes = ObjectAssign(normalAttributes, overwriteStyle)
57
+ }
58
+ }
59
+ return normalAttributes
60
+ }
61
+
62
+ export function getStyle(hmStyle: HarmonyStyle): TaroStyleType {
63
+ let linearGradient: HarmonyType.LinearGradient | undefined = undefined
64
+ // 渐变
65
+ if (hmStyle.backgroundImage?.colors) {
66
+ linearGradient = hmStyle.backgroundImage
67
+ }
68
+
45
69
  let normalAttributes: HarmonyStyle = {
46
70
  // Flex相关
47
71
  flexBasis: hmStyle.flexBasis,
@@ -49,7 +73,7 @@ export function getNormalAttributes (node: TaroElement): TaroStyleType {
49
73
  flexShrink: hmStyle.flexShrink,
50
74
  alignSelf: hmStyle.alignSelf,
51
75
  // 尺寸相关
52
- width: isMaxWidthView(node) && isUndefined(hmStyle.width) ? '100%' : hmStyle.width,
76
+ width: hmStyle.width,
53
77
  height: hmStyle.height,
54
78
  minHeight: hmStyle.minHeight,
55
79
  maxHeight: hmStyle.maxHeight,
@@ -107,20 +131,13 @@ export function getNormalAttributes (node: TaroElement): TaroStyleType {
107
131
  textDecoration: hmStyle.textDecoration,
108
132
  // 其他
109
133
  overflow: hmStyle.overflow,
110
- id: _attrs.id || _nid,
111
134
  opacity: hmStyle.opacity,
112
- zIndex: hmStyle.zIndex
113
- // focus: _attrs.focus || false,
135
+ zIndex: hmStyle.zIndex,
136
+ // 定位
137
+ position: hmStyle.position,
138
+ top: hmStyle.top,
139
+ left: hmStyle.left,
114
140
  }
115
141
 
116
- // taro_page 等写死在运行时里的节点,没有 _nodeInfo
117
- if (node._nodeInfo) {
118
- const overwriteStyle: TaroStyleType = node._nodeInfo?.overwriteStyle
119
-
120
- // 处理覆盖属性:如动画的覆盖
121
- if (overwriteStyle) {
122
- normalAttributes = ObjectAssign(normalAttributes, overwriteStyle)
123
- }
124
- }
125
142
  return normalAttributes
126
- }
143
+ }
@@ -1,7 +1,7 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
2
 
3
3
  import commonStyleModify from './style'
4
- import { createLazyChildren } from './render'
4
+ import PseduoChildren from './pseudo'
5
5
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
6
6
  import { FlexManager } from './utils/flexManager'
7
7
  import { getNodeThresholds, getNormalAttributes, shouldBindEvent } from './utils/helper'
@@ -35,7 +35,7 @@ export default struct TaroView {
35
35
  build () {
36
36
  if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
37
37
  Row() {
38
- createLazyChildren(this.node)
38
+ PseduoChildren(this.node)
39
39
  }
40
40
  .attributeModifier(commonStyleModify.setNode(this.node))
41
41
  .rowAttrs(getNormalAttributes(this.node))
@@ -49,7 +49,7 @@ export default struct TaroView {
49
49
  .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
50
50
  } else {
51
51
  Column() {
52
- createLazyChildren(this.node)
52
+ PseduoChildren(this.node)
53
53
  }
54
54
  .attributeModifier(commonStyleModify.setNode(this.node))
55
55
  .columnAttrs(getNormalAttributes(this.node))
@@ -3,6 +3,7 @@ import { History, Location } from '@tarojs/runtime/dist/runtime.esm'
3
3
 
4
4
  import { TaroEventTarget } from '../dom/eventTarget'
5
5
  import { getComputedStyle } from './getComputedStyle'
6
+ import { nav } from './navigator'
6
7
 
7
8
  import type { TaroDocument } from '../dom/document'
8
9
 
@@ -13,6 +14,7 @@ class Window extends TaroEventTarget {
13
14
 
14
15
  public location: any
15
16
  public history: any
17
+ public navigator = nav
16
18
  public getComputedStyle = getComputedStyle
17
19
 
18
20
  constructor () {
@@ -14,3 +14,5 @@ export const Current: any = {
14
14
  }),
15
15
  createHarmonyElement: null
16
16
  }
17
+
18
+ export const getCurrentInstance = () => Current
@@ -6,7 +6,7 @@ import { initComponentNodeInfo, triggerAttributesCallback } from '../../utils/in
6
6
  import { bindAnimation } from '../bind'
7
7
  import { ClassList } from '../class-list'
8
8
  import { NodeType, TaroNode } from '../node'
9
- import StyleSheet from '../stylesheet'
9
+ import StyleSheet, { HarmonyStyle } from '../stylesheet'
10
10
 
11
11
  import type { StandardProps } from '@tarojs/components/types'
12
12
  import type { TaroAny } from '../../utils'
@@ -156,4 +156,44 @@ export class TaroElement<T extends StandardProps = StandardProps> extends TaroNo
156
156
  public get style (): ICSSStyleDeclaration | null {
157
157
  return this._style
158
158
  }
159
+
160
+ // 伪类,不存在style动态设置,均已被转换为鸿蒙样式
161
+ // TODO:可根据实际情况,迁移到具体的组件中,如View、ScrollView中,Text\Image其实是不需要的
162
+ public _pseudo_before: StyleSheet | null
163
+
164
+ public get pseudo_before () {
165
+ return this._pseudo_before?.hmStyle
166
+ }
167
+
168
+ public set_pseudo_before (value: HarmonyStyle | null) {
169
+ if (value) {
170
+ if (!this._pseudo_before) {
171
+ this._pseudo_before = new StyleSheet()
172
+ }
173
+ Object.keys(value).forEach(key => {
174
+ this._pseudo_before![key] = value[key]
175
+ })
176
+ } else {
177
+ this._pseudo_before = null
178
+ }
179
+ }
180
+
181
+ public _pseudo_after: StyleSheet | null
182
+
183
+ public get pseudo_after () {
184
+ return this._pseudo_after?.hmStyle
185
+ }
186
+
187
+ public set_pseudo_after (value: HarmonyStyle | null) {
188
+ if (value) {
189
+ if (!this._pseudo_after) {
190
+ this._pseudo_after = new StyleSheet()
191
+ }
192
+ Object.keys(value).forEach(key => {
193
+ this._pseudo_after![key] = value[key]
194
+ })
195
+ } else {
196
+ this._pseudo_after = null
197
+ }
198
+ }
159
199
  }