hy-app 0.6.4 → 0.6.6

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.
Files changed (106) hide show
  1. package/attributes.json +1 -1
  2. package/components/hy-address-picker/hy-address-picker.vue +249 -249
  3. package/components/hy-address-picker/props.ts +103 -103
  4. package/components/hy-button/hy-button.vue +320 -289
  5. package/components/hy-button/props.ts +143 -143
  6. package/components/hy-button/typing.d.ts +43 -35
  7. package/components/hy-calendar/header.vue +58 -58
  8. package/components/hy-calendar/hy-calendar.vue +8 -6
  9. package/components/hy-calendar/month.vue +402 -402
  10. package/components/hy-calendar/props.ts +169 -169
  11. package/components/hy-calendar/typing.d.ts +47 -45
  12. package/components/hy-cell-item/hy-cell-item.vue +161 -161
  13. package/components/hy-cell-item/props.ts +59 -59
  14. package/components/hy-check-button/hy-check-button.vue +135 -135
  15. package/components/hy-code-input/hy-code-input.vue +231 -231
  16. package/components/hy-code-input/props.ts +90 -90
  17. package/components/hy-config-provider/hy-config-provider.vue +53 -53
  18. package/components/hy-config-provider/props.ts +30 -30
  19. package/components/hy-coupon/hy-coupon.vue +183 -183
  20. package/components/hy-coupon/props.ts +108 -108
  21. package/components/hy-datetime-picker/hy-datetime-picker.vue +41 -55
  22. package/components/hy-datetime-picker/props.ts +144 -144
  23. package/components/hy-datetime-picker/typing.d.ts +2 -0
  24. package/components/hy-divider/props.ts +83 -83
  25. package/components/hy-empty/icon.ts +72 -72
  26. package/components/hy-folding-panel/hy-folding-panel-group.vue +162 -162
  27. package/components/hy-form/hy-form.vue +220 -220
  28. package/components/hy-icon/hy-icon.vue +112 -112
  29. package/components/hy-index-bar/hy-index-bar.vue +185 -185
  30. package/components/hy-index-bar/index.scss +64 -64
  31. package/components/hy-index-bar/props.ts +94 -94
  32. package/components/hy-index-bar/typing.d.ts +36 -36
  33. package/components/hy-input/hy-input.vue +333 -333
  34. package/components/hy-input/props.ts +186 -186
  35. package/components/hy-modal/hy-modal.vue +211 -211
  36. package/components/hy-modal/props.ts +94 -94
  37. package/components/hy-modal/typing.d.ts +16 -16
  38. package/components/hy-notice-bar/hy-row-notice.vue +121 -121
  39. package/components/hy-notify/hy-notify.vue +174 -174
  40. package/components/hy-number-step/hy-number-step.vue +367 -367
  41. package/components/hy-overlay/hy-overlay.vue +61 -61
  42. package/components/hy-overlay/props.ts +38 -38
  43. package/components/hy-pagination/hy-pagination.vue +136 -136
  44. package/components/hy-pagination/props.ts +58 -58
  45. package/components/hy-parse/hy-parse.vue +550 -550
  46. package/components/hy-parse/node/node.vue +781 -781
  47. package/components/hy-parse/parser.js +1455 -1455
  48. package/components/hy-parse/props.ts +19 -19
  49. package/components/hy-parse/typing.d.ts +68 -68
  50. package/components/hy-picker/hy-picker.vue +435 -435
  51. package/components/hy-picker/props.ts +122 -122
  52. package/components/hy-picker/typing.d.ts +38 -38
  53. package/components/hy-qrcode/props.ts +72 -72
  54. package/components/hy-qrcode/qrcode.js.bak +1433 -1433
  55. package/components/hy-radio/props.ts +97 -97
  56. package/components/hy-read-more/props.ts +48 -48
  57. package/components/hy-search/props.ts +133 -133
  58. package/components/hy-signature/canvasHelper.ts +51 -51
  59. package/components/hy-signature/props.ts +121 -121
  60. package/components/hy-skeleton/hy-skeleton.vue +142 -142
  61. package/components/hy-skeleton/props.ts +46 -46
  62. package/components/hy-skeleton/typing.d.ts +31 -31
  63. package/components/hy-steps/hy-steps.vue +275 -275
  64. package/components/hy-steps/typing.d.ts +25 -25
  65. package/components/hy-swiper/hy-swiper.vue +3 -3
  66. package/components/hy-swiper/index.scss +5 -5
  67. package/components/hy-swiper/props.ts +0 -1
  68. package/components/hy-table/hy-table.vue +630 -630
  69. package/components/hy-table/props.ts +62 -62
  70. package/components/hy-table/typing.d.ts +29 -29
  71. package/components/hy-tabs/hy-tabs.vue +336 -335
  72. package/components/hy-tabs/props.ts +84 -77
  73. package/components/hy-tag/hy-tag.vue +173 -173
  74. package/components/hy-tag/props.ts +89 -89
  75. package/components/hy-text/hy-text.vue +237 -237
  76. package/components/hy-text/props.ts +115 -115
  77. package/components/hy-textarea/hy-textarea.vue +198 -198
  78. package/components/hy-toast/hy-toast.vue +200 -200
  79. package/components/hy-toast/props.ts +3 -3
  80. package/components/hy-transition/hy-transition.vue +157 -157
  81. package/components/hy-transition/props.ts +32 -32
  82. package/components/hy-upload/hy-upload.vue +384 -384
  83. package/components/hy-watermark/hy-watermark.vue +1058 -1058
  84. package/components/hy-watermark/props.ts +109 -109
  85. package/global.d.ts +94 -94
  86. package/libs/api/http.ts +119 -119
  87. package/libs/composables/index.ts +8 -8
  88. package/libs/composables/useMessage.ts +149 -149
  89. package/libs/composables/useToast.ts +45 -45
  90. package/libs/composables/useTranslate.ts +10 -10
  91. package/libs/css/_config.scss +5 -5
  92. package/libs/index.ts +8 -8
  93. package/libs/locale/index.ts +32 -32
  94. package/libs/locale/lang/en-US.ts +84 -84
  95. package/libs/locale/lang/zh-CN.ts +87 -87
  96. package/libs/typing/index.ts +2 -2
  97. package/libs/typing/modules/common.d.ts +139 -139
  98. package/libs/typing/modules/form.ts +176 -176
  99. package/libs/typing/modules/http.d.ts +19 -19
  100. package/libs/typing/modules/index.d.ts +12 -12
  101. package/libs/utils/inside.ts +340 -340
  102. package/libs/utils/inspect.ts +140 -140
  103. package/libs/utils/utils.ts +525 -525
  104. package/package.json +81 -81
  105. package/tags.json +1 -1
  106. package/web-types.json +1 -1
@@ -1,781 +1,781 @@
1
- <template>
2
- <view :id="attrs.id" :class="'_block _' + name + ' ' + attrs.class" :style="attrs.style">
3
- <block v-for="(n, i) in childs" v-bind:key="i">
4
- <!-- 图片 -->
5
- <!-- 占位图 -->
6
- <image
7
- v-if="n.name === 'img' && !n.t && ((opts[1] && !ctrl[i]) || ctrl[i] < 0)"
8
- class="_img"
9
- :style="n.attrs.style"
10
- :src="ctrl[i] < 0 ? opts[2] : opts[1]"
11
- mode="widthFix"
12
- />
13
- <!-- 显示图片 -->
14
- <!-- #ifdef H5 || (APP-PLUS && VUE2) -->
15
- <img
16
- v-if="n.name === 'img'"
17
- :id="n.attrs.id"
18
- :class="'_img ' + n.attrs.class"
19
- :style="(ctrl[i] === -1 ? 'display:none;' : '') + n.attrs.style"
20
- :src="n.attrs.src || (ctrl.load ? n.attrs['data-src'] : '')"
21
- :data-i="i"
22
- @load="imgLoad"
23
- @error="mediaError"
24
- @tap.stop="imgTap"
25
- @longpress="imgLongTap"
26
- />
27
- <!-- #endif -->
28
- <!-- #ifndef H5 || (APP-PLUS && VUE2) -->
29
- <!-- 表格中的图片,使用 rich-test 防止大小不正确 -->
30
- <rich-text
31
- v-if="n.name === 'img' && n.t"
32
- :style="'display:' + n.t"
33
- :nodes="
34
- '<img class=\'_img\' style=\'' +
35
- n.attrs.style +
36
- '\' src=\'' +
37
- n.attrs.src +
38
- '\'>'
39
- "
40
- :data-i="i"
41
- @tap.stop="imgTap"
42
- />
43
- <!-- #endif -->
44
- <!-- #ifndef H5 || APP-PLUS -->
45
- <image
46
- v-else-if="n.name === 'img'"
47
- :id="n.attrs.id"
48
- :class="'_img ' + n.attrs.class"
49
- :style="
50
- (ctrl[i] === -1 ? 'display:none;' : '') +
51
- 'width:' +
52
- (ctrl[i] || 1) +
53
- 'px;height:1px;' +
54
- n.attrs.style
55
- "
56
- :src="n.attrs.src"
57
- :mode="!n.h ? 'widthFix' : !n.w ? 'heightFix' : ''"
58
- :lazy-load="opts[0]"
59
- :webp="n.webp"
60
- :show-menu-by-longpress="opts[3] && !n.attrs.ignore"
61
- :image-menu-prevent="!opts[3] || n.attrs.ignore"
62
- :data-i="i"
63
- @load="imgLoad"
64
- @error="mediaError"
65
- @tap.stop="imgTap"
66
- @longpress="imgLongTap"
67
- />
68
- <!-- #endif -->
69
- <!-- #ifdef APP-PLUS && VUE3 -->
70
- <image
71
- v-else-if="n.name === 'img'"
72
- :id="n.attrs.id"
73
- :class="'_img ' + n.attrs.class"
74
- :style="
75
- (ctrl[i] === -1 ? 'display:none;' : '') +
76
- 'width:' +
77
- (ctrl[i] || 1) +
78
- 'px;' +
79
- n.attrs.style
80
- "
81
- :src="n.attrs.src || (ctrl.load ? n.attrs['data-src'] : '')"
82
- :mode="!n.h ? 'widthFix' : !n.w ? 'heightFix' : ''"
83
- :data-i="i"
84
- @load="imgLoad"
85
- @error="mediaError"
86
- @tap.stop="imgTap"
87
- @longpress="imgLongTap"
88
- />
89
- <!-- #endif -->
90
- <!-- 文本 -->
91
- <!-- #ifdef MP-WEIXIN -->
92
- <text v-else-if="n.text" :user-select="opts[4] == 'force' && isiOS" decode>{{
93
- n.text
94
- }}</text>
95
- <!-- #endif -->
96
- <!-- #ifndef MP-WEIXIN || MP-BAIDU || MP-ALIPAY || MP-TOUTIAO -->
97
- <text v-else-if="n.text" decode>{{ n.text }}</text>
98
- <!-- #endif -->
99
- <text v-else-if="n.name === 'br'">\n</text>
100
- <!-- 链接 -->
101
- <view
102
- v-else-if="n.name === 'a'"
103
- :id="n.attrs.id"
104
- :class="(n.attrs.href ? '_a ' : '') + n.attrs.class"
105
- hover-class="_hover"
106
- :style="'display:inline;' + n.attrs.style"
107
- :data-i="i"
108
- @tap.stop="linkTap"
109
- >
110
- <node name="span" :childs="n.children" :opts="opts" style="display: inherit" />
111
- </view>
112
- <!-- 视频 -->
113
- <!-- #ifdef APP-PLUS -->
114
- <view
115
- v-else-if="n.html"
116
- :id="n.attrs.id"
117
- :class="'_video ' + n.attrs.class"
118
- :style="n.attrs.style"
119
- v-html="n.html"
120
- @vplay.stop="play"
121
- />
122
- <!-- #endif -->
123
- <!-- #ifndef APP-PLUS -->
124
- <video
125
- v-else-if="n.name === 'video'"
126
- :id="n.attrs.id"
127
- :class="n.attrs.class"
128
- :style="n.attrs.style"
129
- :autoplay="n.attrs.autoplay"
130
- :controls="n.attrs.controls"
131
- :loop="n.attrs.loop"
132
- :muted="n.attrs.muted"
133
- :object-fit="n.attrs['object-fit']"
134
- :poster="n.attrs.poster"
135
- :src="n.src[ctrl[i] || 0]"
136
- :data-i="i"
137
- @play="play"
138
- @error="mediaError"
139
- />
140
- <!-- #endif -->
141
- <!-- #ifdef H5 || APP-PLUS -->
142
- <iframe
143
- v-else-if="n.name === 'iframe'"
144
- :style="n.attrs.style"
145
- :allowfullscreen="n.attrs.allowfullscreen"
146
- :frameborder="n.attrs.frameborder"
147
- :src="n.attrs.src"
148
- />
149
- <embed v-else-if="n.name === 'embed'" :style="n.attrs.style" :src="n.attrs.src" />
150
- <!-- #endif -->
151
- <!-- #ifndef MP-TOUTIAO || ((H5 || APP-PLUS) && VUE3) -->
152
- <!-- 音频 -->
153
- <audio
154
- v-else-if="n.name === 'audio'"
155
- :id="n.attrs.id"
156
- :class="n.attrs.class"
157
- :style="n.attrs.style"
158
- :author="n.attrs.author"
159
- :controls="n.attrs.controls"
160
- :loop="n.attrs.loop"
161
- :name="n.attrs.name"
162
- :poster="n.attrs.poster"
163
- :src="n.src[ctrl[i] || 0]"
164
- :data-i="i"
165
- @play="play"
166
- @error="mediaError"
167
- />
168
- <!-- #endif -->
169
- <view
170
- v-else-if="(n.name === 'table' && n.c) || n.name === 'li'"
171
- :id="n.attrs.id"
172
- :class="'_' + n.name + ' ' + n.attrs.class"
173
- :style="n.attrs.style"
174
- >
175
- <node v-if="n.name === 'li'" :childs="n.children" :opts="opts" />
176
- <view
177
- v-else
178
- v-for="(tbody, x) in n.children"
179
- v-bind:key="x"
180
- :class="'_' + tbody.name + ' ' + tbody.attrs.class"
181
- :style="tbody.attrs.style"
182
- >
183
- <node
184
- v-if="tbody.name === 'td' || tbody.name === 'th'"
185
- :childs="tbody.children"
186
- :opts="opts"
187
- />
188
- <block v-else v-for="(tr, y) in tbody.children" v-bind:key="y">
189
- <view
190
- v-if="tr.name === 'td' || tr.name === 'th'"
191
- :class="'_' + tr.name + ' ' + tr.attrs.class"
192
- :style="tr.attrs.style"
193
- >
194
- <node :childs="tr.children" :opts="opts" />
195
- </view>
196
- <view
197
- v-else
198
- :class="'_' + tr.name + ' ' + tr.attrs.class"
199
- :style="tr.attrs.style"
200
- >
201
- <view
202
- v-for="(td, z) in tr.children"
203
- v-bind:key="z"
204
- :class="'_' + td.name + ' ' + td.attrs.class"
205
- :style="td.attrs.style"
206
- >
207
- <node :childs="td.children" :opts="opts" />
208
- </view>
209
- </view>
210
- </block>
211
- </view>
212
- </view>
213
-
214
- <!-- 富文本 -->
215
- <!-- #ifdef H5 || ((MP-WEIXIN || MP-QQ || APP-PLUS || MP-360) && VUE2) -->
216
- <rich-text
217
- v-else-if="!n.c && !handler.isInline(n.name, n.attrs.style)"
218
- :id="n.attrs.id"
219
- :style="n.f"
220
- :user-select="opts[4]"
221
- :nodes="[n]"
222
- />
223
- <!-- #endif -->
224
- <!-- #ifndef H5 || ((MP-WEIXIN || MP-QQ || APP-PLUS || MP-360) && VUE2) -->
225
- <rich-text
226
- v-else-if="!n.c"
227
- :id="n.attrs.id"
228
- :style="n.f + ';display:inline'"
229
- :preview="false"
230
- :selectable="opts[4]"
231
- :user-select="opts[4]"
232
- :nodes="[n]"
233
- />
234
- <!-- #endif -->
235
- <!-- 继续递归 -->
236
- <view
237
- v-else-if="n.c === 2"
238
- :id="n.attrs.id"
239
- :class="'_block _' + n.name + ' ' + n.attrs.class"
240
- :style="n.f + ';' + n.attrs.style"
241
- >
242
- <node
243
- v-for="(n2, j) in n.children"
244
- v-bind:key="j"
245
- :style="n2.f"
246
- :name="n2.name"
247
- :attrs="n2.attrs"
248
- :childs="n2.children"
249
- :opts="opts"
250
- />
251
- </view>
252
- <node
253
- v-else
254
- :style="n.f"
255
- :name="n.name"
256
- :attrs="n.attrs"
257
- :childs="n.children"
258
- :opts="opts"
259
- />
260
- </block>
261
- </view>
262
- </template>
263
- <script module="handler" lang="wxs">
264
- // 行内标签列表
265
- var inlineTags = {
266
- abbr: true,
267
- b: true,
268
- big: true,
269
- code: true,
270
- del: true,
271
- em: true,
272
- i: true,
273
- ins: true,
274
- label: true,
275
- q: true,
276
- small: true,
277
- span: true,
278
- strong: true,
279
- sub: true,
280
- sup: true
281
- }
282
- /**
283
- * @description 判断是否为行内标签
284
- */
285
- module.exports = {
286
- isInline: function (tagName, style) {
287
- return inlineTags[tagName] || (style || '').indexOf('display:inline') !== -1
288
- }
289
- }
290
- </script>
291
- <script>
292
- import node from './node'
293
- export default {
294
- name: 'node',
295
- options: {
296
- // #ifdef MP-WEIXIN
297
- virtualHost: true,
298
- // #endif
299
- // #ifdef MP-TOUTIAO
300
- addGlobalClass: false
301
- // #endif
302
- },
303
- data() {
304
- return {
305
- ctrl: {},
306
- // #ifdef MP-WEIXIN
307
- isiOS: uni.getDeviceInfo().system.includes('iOS')
308
- // #endif
309
- }
310
- },
311
- props: {
312
- name: String,
313
- attrs: {
314
- type: Object,
315
- default() {
316
- return {}
317
- }
318
- },
319
- childs: Array,
320
- opts: Array
321
- },
322
- components: {
323
- // #ifndef (H5 || APP-PLUS) && VUE3
324
- node
325
- // #endif
326
- },
327
- mounted() {
328
- this.$nextTick(() => {
329
- for (
330
- this.root = this.$parent;
331
- this.root.$options.name !== 'hy-parse';
332
- this.root = this.root.$parent
333
- );
334
- })
335
- // #ifdef H5 || APP-PLUS
336
- if (this.opts[0]) {
337
- let i
338
- for (i = this.childs.length; i--; ) {
339
- if (this.childs[i].name === 'img') break
340
- }
341
- if (i !== -1) {
342
- this.observer = uni.createIntersectionObserver(this).relativeToViewport({
343
- top: 500,
344
- bottom: 500
345
- })
346
- this.observer.observe('._img', (res) => {
347
- if (res.intersectionRatio) {
348
- this.$set(this.ctrl, 'load', 1)
349
- this.observer.disconnect()
350
- }
351
- })
352
- }
353
- }
354
- // #endif
355
- },
356
- beforeUnmount() {
357
- // #ifdef H5 || APP-PLUS
358
- if (this.observer) {
359
- this.observer.disconnect()
360
- }
361
- // #endif
362
- },
363
- methods: {
364
- // #ifdef MP-WEIXIN
365
- toJSON() {
366
- return this
367
- },
368
- // #endif
369
- /**
370
- * @description 播放视频事件
371
- * @param {Event} e
372
- */
373
- play(e) {
374
- this.root.$emit('play')
375
- // #ifndef APP-PLUS
376
- if (this.root.pauseVideo) {
377
- let flag = false
378
- const id = e.target.id
379
- for (let i = this.root._videos.length; i--; ) {
380
- if (this.root._videos[i].id === id) {
381
- flag = true
382
- } else {
383
- this.root._videos[i].pause() // 自动暂停其他视频
384
- }
385
- }
386
- // 将自己加入列表
387
- if (!flag) {
388
- const ctx = uni.createVideoContext(
389
- id,
390
- // #ifndef MP-BAIDU
391
- this
392
- // #endif
393
- )
394
- ctx.id = id
395
- if (this.root.playbackRate) {
396
- ctx.playbackRate(this.root.playbackRate)
397
- }
398
- this.root._videos.push(ctx)
399
- }
400
- }
401
- // #endif
402
- },
403
-
404
- /**
405
- * @description 图片点击事件
406
- * @param {Event} e
407
- */
408
- imgTap(e) {
409
- const node = this.childs[e.currentTarget.dataset.i]
410
- if (node.a) {
411
- this.linkTap(node.a)
412
- return
413
- }
414
- if (node.attrs.ignore) return
415
- // #ifdef H5 || APP-PLUS
416
- node.attrs.src = node.attrs.src || node.attrs['data-src']
417
- // #endif
418
- this.root.$emit('imgTap', node.attrs)
419
- // 自动预览图片
420
- if (this.root.previewImg) {
421
- uni.previewImage({
422
- // #ifdef MP-WEIXIN
423
- showmenu: this.root.showImgMenu,
424
- // #endif
425
- // #ifdef MP-ALIPAY
426
- enablesavephoto: this.root.showImgMenu,
427
- enableShowPhotoDownload: this.root.showImgMenu,
428
- // #endif
429
- current: parseInt(node.attrs.i),
430
- urls: this.root.imgList
431
- })
432
- }
433
- },
434
-
435
- /**
436
- * @description 图片长按
437
- */
438
- imgLongTap(e) {
439
- // #ifdef APP-PLUS
440
- const attrs = this.childs[e.currentTarget.dataset.i].attrs
441
- if (this.opts[3] && !attrs.ignore) {
442
- uni.showActionSheet({
443
- itemList: ['保存图片'],
444
- success: () => {
445
- const save = (path) => {
446
- uni.saveImageToPhotosAlbum({
447
- filePath: path,
448
- success() {
449
- uni.showToast({
450
- title: '保存成功'
451
- })
452
- }
453
- })
454
- }
455
- if (this.root.imgList[attrs.i].startsWith('http')) {
456
- uni.downloadFile({
457
- url: this.root.imgList[attrs.i],
458
- success: (res) => save(res.tempFilePath)
459
- })
460
- } else {
461
- save(this.root.imgList[attrs.i])
462
- }
463
- }
464
- })
465
- }
466
- // #endif
467
- },
468
-
469
- /**
470
- * @description 图片加载完成事件
471
- * @param {Event} e
472
- */
473
- imgLoad(e) {
474
- const i = e.currentTarget.dataset.i
475
- /* #ifndef H5 || (APP-PLUS && VUE2) */
476
- if (!this.childs[i].w) {
477
- // 设置原宽度
478
- this.$set(this.ctrl, i, e.detail.width)
479
- } else if ((this.opts[1] && !this.ctrl[i]) || this.ctrl[i] === -1) {
480
- /* #endif */ // 加载完毕,取消加载中占位图
481
- this.$set(this.ctrl, i, 1)
482
- }
483
- this.checkReady()
484
- },
485
-
486
- /**
487
- * @description 检查是否所有图片加载完毕
488
- */
489
- checkReady() {
490
- if (!this.root.lazyLoad) {
491
- this.root._unloadimgs -= 1
492
- if (!this.root._unloadimgs) {
493
- setTimeout(() => {
494
- this.root
495
- .getRect()
496
- .then((rect) => {
497
- this.root.$emit('ready', rect)
498
- })
499
- .catch(() => {
500
- this.root.$emit('ready', {})
501
- })
502
- }, 350)
503
- }
504
- }
505
- },
506
-
507
- /**
508
- * @description 链接点击事件
509
- * @param {Event} e
510
- */
511
- linkTap(e) {
512
- const node = e.currentTarget ? this.childs[e.currentTarget.dataset.i] : {}
513
- const attrs = node.attrs || e
514
- const href = attrs.href
515
- this.root.$emit(
516
- 'linkTap',
517
- Object.assign(
518
- {
519
- innerText: this.root.getText(node.children || []) // 链接内的文本内容
520
- },
521
- attrs
522
- )
523
- )
524
- if (href) {
525
- if (href[0] === '#') {
526
- // 跳转锚点
527
- this.root.navigateTo(href.substring(1)).catch(() => {})
528
- } else if (href.split('?')[0].includes('://')) {
529
- // 复制外部链接
530
- if (this.root.copyLink) {
531
- // #ifdef H5
532
- window.open(href)
533
- // #endif
534
- // #ifdef MP
535
- uni.setClipboardData({
536
- data: href,
537
- success: () =>
538
- uni.showToast({
539
- title: '链接已复制'
540
- })
541
- })
542
- // #endif
543
- // #ifdef APP-PLUS
544
- plus.runtime.openWeb(href)
545
- // #endif
546
- }
547
- } else {
548
- // 跳转页面
549
- uni.navigateTo({
550
- url: href,
551
- fail() {
552
- uni.switchTab({
553
- url: href,
554
- fail() {}
555
- })
556
- }
557
- })
558
- }
559
- }
560
- },
561
-
562
- /**
563
- * @description 错误事件
564
- * @param {Event} e
565
- */
566
- mediaError(e) {
567
- const i = e.currentTarget.dataset.i
568
- const node = this.childs[i]
569
- // 加载其他源
570
- if (node.name === 'video' || node.name === 'audio') {
571
- let index = (this.ctrl[i] || 0) + 1
572
- if (index > node.src.length) {
573
- index = 0
574
- }
575
- if (index < node.src.length) {
576
- this.$set(this.ctrl, i, index)
577
- return
578
- }
579
- } else if (node.name === 'img') {
580
- // #ifdef H5 && VUE3
581
- if (this.opts[0] && !this.ctrl.load) return
582
- // #endif
583
- // 显示错误占位图
584
- if (this.opts[2]) {
585
- this.$set(this.ctrl, i, -1)
586
- }
587
- this.checkReady()
588
- }
589
- if (this.root) {
590
- this.root.$emit('error', {
591
- source: node.name,
592
- attrs: node.attrs,
593
- // #ifndef H5 && VUE3
594
- errMsg: e.detail.errMsg
595
- // #endif
596
- })
597
- }
598
- }
599
- }
600
- }
601
- </script>
602
- <style>
603
- /* a 标签默认效果 */
604
- ._a {
605
- padding: 1.5px 0 1.5px 0;
606
- color: #366092;
607
- /* #ifndef APP-NVUE */
608
- word-break: break-all;
609
- /* #endif */
610
- }
611
-
612
- /* a 标签点击态效果 */
613
- ._hover {
614
- text-decoration: underline;
615
- opacity: 0.7;
616
- }
617
-
618
- /* 图片默认效果 */
619
- ._img {
620
- max-width: 100%;
621
- -webkit-touch-callout: none;
622
- }
623
-
624
- /* 内部样式 */
625
-
626
- ._block {
627
- /* #ifndef APP-NVUE */
628
- display: block;
629
- /* #endif */
630
- }
631
-
632
- ._b,
633
- ._strong {
634
- font-weight: bold;
635
- }
636
-
637
- ._code {
638
- font-family: monospace;
639
- }
640
-
641
- ._del {
642
- text-decoration: line-through;
643
- }
644
-
645
- ._em,
646
- ._i {
647
- font-style: italic;
648
- }
649
-
650
- ._h1 {
651
- font-size: 2em;
652
- }
653
-
654
- ._h2 {
655
- font-size: 1.5em;
656
- }
657
-
658
- ._h3 {
659
- font-size: 1.17em;
660
- }
661
-
662
- ._h5 {
663
- font-size: 0.83em;
664
- }
665
-
666
- ._h6 {
667
- font-size: 0.67em;
668
- }
669
-
670
- ._h1,
671
- ._h2,
672
- ._h3,
673
- ._h4,
674
- ._h5,
675
- ._h6 {
676
- /* #ifndef APP-NVUE */
677
- display: block;
678
- /* #endif */
679
- font-weight: bold;
680
- }
681
-
682
- ._image {
683
- height: 1px;
684
- }
685
-
686
- ._ins {
687
- text-decoration: underline;
688
- }
689
-
690
- ._li {
691
- display: list-item;
692
- }
693
-
694
- ._ol {
695
- list-style-type: decimal;
696
- }
697
-
698
- ._ol,
699
- ._ul {
700
- /* #ifndef APP-NVUE */
701
- display: block;
702
- /* #endif */
703
- padding-left: 40px;
704
- margin: 1em 0;
705
- }
706
-
707
- ._q::before {
708
- content: '"';
709
- }
710
-
711
- ._q::after {
712
- content: '"';
713
- }
714
-
715
- ._sub {
716
- font-size: smaller;
717
- vertical-align: sub;
718
- }
719
-
720
- ._sup {
721
- font-size: smaller;
722
- vertical-align: super;
723
- }
724
-
725
- ._thead,
726
- ._tbody,
727
- ._tfoot {
728
- display: table-row-group;
729
- }
730
-
731
- ._tr {
732
- display: table-row;
733
- }
734
-
735
- ._td,
736
- ._th {
737
- display: table-cell;
738
- vertical-align: middle;
739
- }
740
-
741
- ._th {
742
- font-weight: bold;
743
- text-align: center;
744
- }
745
-
746
- ._ul {
747
- list-style-type: disc;
748
- }
749
-
750
- ._ul ._ul {
751
- margin: 0;
752
- list-style-type: circle;
753
- }
754
-
755
- ._ul ._ul ._ul {
756
- list-style-type: square;
757
- }
758
-
759
- ._abbr,
760
- ._b,
761
- ._code,
762
- ._del,
763
- ._em,
764
- ._i,
765
- ._ins,
766
- ._label,
767
- ._q,
768
- ._span,
769
- ._strong,
770
- ._sub,
771
- ._sup {
772
- display: inline;
773
- }
774
-
775
- /* #ifdef APP-PLUS */
776
- ._video {
777
- width: 300px;
778
- height: 225px;
779
- }
780
- /* #endif */
781
- </style>
1
+ <template>
2
+ <view :id="attrs.id" :class="'_block _' + name + ' ' + attrs.class" :style="attrs.style">
3
+ <block v-for="(n, i) in childs" v-bind:key="i">
4
+ <!-- 图片 -->
5
+ <!-- 占位图 -->
6
+ <image
7
+ v-if="n.name === 'img' && !n.t && ((opts[1] && !ctrl[i]) || ctrl[i] < 0)"
8
+ class="_img"
9
+ :style="n.attrs.style"
10
+ :src="ctrl[i] < 0 ? opts[2] : opts[1]"
11
+ mode="widthFix"
12
+ />
13
+ <!-- 显示图片 -->
14
+ <!-- #ifdef H5 || (APP-PLUS && VUE2) -->
15
+ <img
16
+ v-if="n.name === 'img'"
17
+ :id="n.attrs.id"
18
+ :class="'_img ' + n.attrs.class"
19
+ :style="(ctrl[i] === -1 ? 'display:none;' : '') + n.attrs.style"
20
+ :src="n.attrs.src || (ctrl.load ? n.attrs['data-src'] : '')"
21
+ :data-i="i"
22
+ @load="imgLoad"
23
+ @error="mediaError"
24
+ @tap.stop="imgTap"
25
+ @longpress="imgLongTap"
26
+ />
27
+ <!-- #endif -->
28
+ <!-- #ifndef H5 || (APP-PLUS && VUE2) -->
29
+ <!-- 表格中的图片,使用 rich-test 防止大小不正确 -->
30
+ <rich-text
31
+ v-if="n.name === 'img' && n.t"
32
+ :style="'display:' + n.t"
33
+ :nodes="
34
+ '<img class=\'_img\' style=\'' +
35
+ n.attrs.style +
36
+ '\' src=\'' +
37
+ n.attrs.src +
38
+ '\'>'
39
+ "
40
+ :data-i="i"
41
+ @tap.stop="imgTap"
42
+ />
43
+ <!-- #endif -->
44
+ <!-- #ifndef H5 || APP-PLUS -->
45
+ <image
46
+ v-else-if="n.name === 'img'"
47
+ :id="n.attrs.id"
48
+ :class="'_img ' + n.attrs.class"
49
+ :style="
50
+ (ctrl[i] === -1 ? 'display:none;' : '') +
51
+ 'width:' +
52
+ (ctrl[i] || 1) +
53
+ 'px;height:1px;' +
54
+ n.attrs.style
55
+ "
56
+ :src="n.attrs.src"
57
+ :mode="!n.h ? 'widthFix' : !n.w ? 'heightFix' : ''"
58
+ :lazy-load="opts[0]"
59
+ :webp="n.webp"
60
+ :show-menu-by-longpress="opts[3] && !n.attrs.ignore"
61
+ :image-menu-prevent="!opts[3] || n.attrs.ignore"
62
+ :data-i="i"
63
+ @load="imgLoad"
64
+ @error="mediaError"
65
+ @tap.stop="imgTap"
66
+ @longpress="imgLongTap"
67
+ />
68
+ <!-- #endif -->
69
+ <!-- #ifdef APP-PLUS && VUE3 -->
70
+ <image
71
+ v-else-if="n.name === 'img'"
72
+ :id="n.attrs.id"
73
+ :class="'_img ' + n.attrs.class"
74
+ :style="
75
+ (ctrl[i] === -1 ? 'display:none;' : '') +
76
+ 'width:' +
77
+ (ctrl[i] || 1) +
78
+ 'px;' +
79
+ n.attrs.style
80
+ "
81
+ :src="n.attrs.src || (ctrl.load ? n.attrs['data-src'] : '')"
82
+ :mode="!n.h ? 'widthFix' : !n.w ? 'heightFix' : ''"
83
+ :data-i="i"
84
+ @load="imgLoad"
85
+ @error="mediaError"
86
+ @tap.stop="imgTap"
87
+ @longpress="imgLongTap"
88
+ />
89
+ <!-- #endif -->
90
+ <!-- 文本 -->
91
+ <!-- #ifdef MP-WEIXIN -->
92
+ <text v-else-if="n.text" :user-select="opts[4] == 'force' && isiOS" decode>{{
93
+ n.text
94
+ }}</text>
95
+ <!-- #endif -->
96
+ <!-- #ifndef MP-WEIXIN || MP-BAIDU || MP-ALIPAY || MP-TOUTIAO -->
97
+ <text v-else-if="n.text" decode>{{ n.text }}</text>
98
+ <!-- #endif -->
99
+ <text v-else-if="n.name === 'br'">\n</text>
100
+ <!-- 链接 -->
101
+ <view
102
+ v-else-if="n.name === 'a'"
103
+ :id="n.attrs.id"
104
+ :class="(n.attrs.href ? '_a ' : '') + n.attrs.class"
105
+ hover-class="_hover"
106
+ :style="'display:inline;' + n.attrs.style"
107
+ :data-i="i"
108
+ @tap.stop="linkTap"
109
+ >
110
+ <node name="span" :childs="n.children" :opts="opts" style="display: inherit" />
111
+ </view>
112
+ <!-- 视频 -->
113
+ <!-- #ifdef APP-PLUS -->
114
+ <view
115
+ v-else-if="n.html"
116
+ :id="n.attrs.id"
117
+ :class="'_video ' + n.attrs.class"
118
+ :style="n.attrs.style"
119
+ v-html="n.html"
120
+ @vplay.stop="play"
121
+ />
122
+ <!-- #endif -->
123
+ <!-- #ifndef APP-PLUS -->
124
+ <video
125
+ v-else-if="n.name === 'video'"
126
+ :id="n.attrs.id"
127
+ :class="n.attrs.class"
128
+ :style="n.attrs.style"
129
+ :autoplay="n.attrs.autoplay"
130
+ :controls="n.attrs.controls"
131
+ :loop="n.attrs.loop"
132
+ :muted="n.attrs.muted"
133
+ :object-fit="n.attrs['object-fit']"
134
+ :poster="n.attrs.poster"
135
+ :src="n.src[ctrl[i] || 0]"
136
+ :data-i="i"
137
+ @play="play"
138
+ @error="mediaError"
139
+ />
140
+ <!-- #endif -->
141
+ <!-- #ifdef H5 || APP-PLUS -->
142
+ <iframe
143
+ v-else-if="n.name === 'iframe'"
144
+ :style="n.attrs.style"
145
+ :allowfullscreen="n.attrs.allowfullscreen"
146
+ :frameborder="n.attrs.frameborder"
147
+ :src="n.attrs.src"
148
+ />
149
+ <embed v-else-if="n.name === 'embed'" :style="n.attrs.style" :src="n.attrs.src" />
150
+ <!-- #endif -->
151
+ <!-- #ifndef MP-TOUTIAO || ((H5 || APP-PLUS) && VUE3) -->
152
+ <!-- 音频 -->
153
+ <audio
154
+ v-else-if="n.name === 'audio'"
155
+ :id="n.attrs.id"
156
+ :class="n.attrs.class"
157
+ :style="n.attrs.style"
158
+ :author="n.attrs.author"
159
+ :controls="n.attrs.controls"
160
+ :loop="n.attrs.loop"
161
+ :name="n.attrs.name"
162
+ :poster="n.attrs.poster"
163
+ :src="n.src[ctrl[i] || 0]"
164
+ :data-i="i"
165
+ @play="play"
166
+ @error="mediaError"
167
+ />
168
+ <!-- #endif -->
169
+ <view
170
+ v-else-if="(n.name === 'table' && n.c) || n.name === 'li'"
171
+ :id="n.attrs.id"
172
+ :class="'_' + n.name + ' ' + n.attrs.class"
173
+ :style="n.attrs.style"
174
+ >
175
+ <node v-if="n.name === 'li'" :childs="n.children" :opts="opts" />
176
+ <view
177
+ v-else
178
+ v-for="(tbody, x) in n.children"
179
+ v-bind:key="x"
180
+ :class="'_' + tbody.name + ' ' + tbody.attrs.class"
181
+ :style="tbody.attrs.style"
182
+ >
183
+ <node
184
+ v-if="tbody.name === 'td' || tbody.name === 'th'"
185
+ :childs="tbody.children"
186
+ :opts="opts"
187
+ />
188
+ <block v-else v-for="(tr, y) in tbody.children" v-bind:key="y">
189
+ <view
190
+ v-if="tr.name === 'td' || tr.name === 'th'"
191
+ :class="'_' + tr.name + ' ' + tr.attrs.class"
192
+ :style="tr.attrs.style"
193
+ >
194
+ <node :childs="tr.children" :opts="opts" />
195
+ </view>
196
+ <view
197
+ v-else
198
+ :class="'_' + tr.name + ' ' + tr.attrs.class"
199
+ :style="tr.attrs.style"
200
+ >
201
+ <view
202
+ v-for="(td, z) in tr.children"
203
+ v-bind:key="z"
204
+ :class="'_' + td.name + ' ' + td.attrs.class"
205
+ :style="td.attrs.style"
206
+ >
207
+ <node :childs="td.children" :opts="opts" />
208
+ </view>
209
+ </view>
210
+ </block>
211
+ </view>
212
+ </view>
213
+
214
+ <!-- 富文本 -->
215
+ <!-- #ifdef H5 || ((MP-WEIXIN || MP-QQ || APP-PLUS || MP-360) && VUE2) -->
216
+ <rich-text
217
+ v-else-if="!n.c && !handler.isInline(n.name, n.attrs.style)"
218
+ :id="n.attrs.id"
219
+ :style="n.f"
220
+ :user-select="opts[4]"
221
+ :nodes="[n]"
222
+ />
223
+ <!-- #endif -->
224
+ <!-- #ifndef H5 || ((MP-WEIXIN || MP-QQ || APP-PLUS || MP-360) && VUE2) -->
225
+ <rich-text
226
+ v-else-if="!n.c"
227
+ :id="n.attrs.id"
228
+ :style="n.f + ';display:inline'"
229
+ :preview="false"
230
+ :selectable="opts[4]"
231
+ :user-select="opts[4]"
232
+ :nodes="[n]"
233
+ />
234
+ <!-- #endif -->
235
+ <!-- 继续递归 -->
236
+ <view
237
+ v-else-if="n.c === 2"
238
+ :id="n.attrs.id"
239
+ :class="'_block _' + n.name + ' ' + n.attrs.class"
240
+ :style="n.f + ';' + n.attrs.style"
241
+ >
242
+ <node
243
+ v-for="(n2, j) in n.children"
244
+ v-bind:key="j"
245
+ :style="n2.f"
246
+ :name="n2.name"
247
+ :attrs="n2.attrs"
248
+ :childs="n2.children"
249
+ :opts="opts"
250
+ />
251
+ </view>
252
+ <node
253
+ v-else
254
+ :style="n.f"
255
+ :name="n.name"
256
+ :attrs="n.attrs"
257
+ :childs="n.children"
258
+ :opts="opts"
259
+ />
260
+ </block>
261
+ </view>
262
+ </template>
263
+ <script module="handler" lang="wxs">
264
+ // 行内标签列表
265
+ var inlineTags = {
266
+ abbr: true,
267
+ b: true,
268
+ big: true,
269
+ code: true,
270
+ del: true,
271
+ em: true,
272
+ i: true,
273
+ ins: true,
274
+ label: true,
275
+ q: true,
276
+ small: true,
277
+ span: true,
278
+ strong: true,
279
+ sub: true,
280
+ sup: true
281
+ }
282
+ /**
283
+ * @description 判断是否为行内标签
284
+ */
285
+ module.exports = {
286
+ isInline: function (tagName, style) {
287
+ return inlineTags[tagName] || (style || '').indexOf('display:inline') !== -1
288
+ }
289
+ }
290
+ </script>
291
+ <script>
292
+ import node from './node'
293
+ export default {
294
+ name: 'node',
295
+ options: {
296
+ // #ifdef MP-WEIXIN
297
+ virtualHost: true,
298
+ // #endif
299
+ // #ifdef MP-TOUTIAO
300
+ addGlobalClass: false
301
+ // #endif
302
+ },
303
+ data() {
304
+ return {
305
+ ctrl: {},
306
+ // #ifdef MP-WEIXIN
307
+ isiOS: uni.getDeviceInfo().system.includes('iOS')
308
+ // #endif
309
+ }
310
+ },
311
+ props: {
312
+ name: String,
313
+ attrs: {
314
+ type: Object,
315
+ default() {
316
+ return {}
317
+ }
318
+ },
319
+ childs: Array,
320
+ opts: Array
321
+ },
322
+ components: {
323
+ // #ifndef (H5 || APP-PLUS) && VUE3
324
+ node
325
+ // #endif
326
+ },
327
+ mounted() {
328
+ this.$nextTick(() => {
329
+ for (
330
+ this.root = this.$parent;
331
+ this.root.$options.name !== 'hy-parse';
332
+ this.root = this.root.$parent
333
+ );
334
+ })
335
+ // #ifdef H5 || APP-PLUS
336
+ if (this.opts[0]) {
337
+ let i
338
+ for (i = this.childs.length; i--; ) {
339
+ if (this.childs[i].name === 'img') break
340
+ }
341
+ if (i !== -1) {
342
+ this.observer = uni.createIntersectionObserver(this).relativeToViewport({
343
+ top: 500,
344
+ bottom: 500
345
+ })
346
+ this.observer.observe('._img', (res) => {
347
+ if (res.intersectionRatio) {
348
+ this.$set(this.ctrl, 'load', 1)
349
+ this.observer.disconnect()
350
+ }
351
+ })
352
+ }
353
+ }
354
+ // #endif
355
+ },
356
+ beforeUnmount() {
357
+ // #ifdef H5 || APP-PLUS
358
+ if (this.observer) {
359
+ this.observer.disconnect()
360
+ }
361
+ // #endif
362
+ },
363
+ methods: {
364
+ // #ifdef MP-WEIXIN
365
+ toJSON() {
366
+ return this
367
+ },
368
+ // #endif
369
+ /**
370
+ * @description 播放视频事件
371
+ * @param {Event} e
372
+ */
373
+ play(e) {
374
+ this.root.$emit('play')
375
+ // #ifndef APP-PLUS
376
+ if (this.root.pauseVideo) {
377
+ let flag = false
378
+ const id = e.target.id
379
+ for (let i = this.root._videos.length; i--; ) {
380
+ if (this.root._videos[i].id === id) {
381
+ flag = true
382
+ } else {
383
+ this.root._videos[i].pause() // 自动暂停其他视频
384
+ }
385
+ }
386
+ // 将自己加入列表
387
+ if (!flag) {
388
+ const ctx = uni.createVideoContext(
389
+ id,
390
+ // #ifndef MP-BAIDU
391
+ this
392
+ // #endif
393
+ )
394
+ ctx.id = id
395
+ if (this.root.playbackRate) {
396
+ ctx.playbackRate(this.root.playbackRate)
397
+ }
398
+ this.root._videos.push(ctx)
399
+ }
400
+ }
401
+ // #endif
402
+ },
403
+
404
+ /**
405
+ * @description 图片点击事件
406
+ * @param {Event} e
407
+ */
408
+ imgTap(e) {
409
+ const node = this.childs[e.currentTarget.dataset.i]
410
+ if (node.a) {
411
+ this.linkTap(node.a)
412
+ return
413
+ }
414
+ if (node.attrs.ignore) return
415
+ // #ifdef H5 || APP-PLUS
416
+ node.attrs.src = node.attrs.src || node.attrs['data-src']
417
+ // #endif
418
+ this.root.$emit('imgTap', node.attrs)
419
+ // 自动预览图片
420
+ if (this.root.previewImg) {
421
+ uni.previewImage({
422
+ // #ifdef MP-WEIXIN
423
+ showmenu: this.root.showImgMenu,
424
+ // #endif
425
+ // #ifdef MP-ALIPAY
426
+ enablesavephoto: this.root.showImgMenu,
427
+ enableShowPhotoDownload: this.root.showImgMenu,
428
+ // #endif
429
+ current: parseInt(node.attrs.i),
430
+ urls: this.root.imgList
431
+ })
432
+ }
433
+ },
434
+
435
+ /**
436
+ * @description 图片长按
437
+ */
438
+ imgLongTap(e) {
439
+ // #ifdef APP-PLUS
440
+ const attrs = this.childs[e.currentTarget.dataset.i].attrs
441
+ if (this.opts[3] && !attrs.ignore) {
442
+ uni.showActionSheet({
443
+ itemList: ['保存图片'],
444
+ success: () => {
445
+ const save = (path) => {
446
+ uni.saveImageToPhotosAlbum({
447
+ filePath: path,
448
+ success() {
449
+ uni.showToast({
450
+ title: '保存成功'
451
+ })
452
+ }
453
+ })
454
+ }
455
+ if (this.root.imgList[attrs.i].startsWith('http')) {
456
+ uni.downloadFile({
457
+ url: this.root.imgList[attrs.i],
458
+ success: (res) => save(res.tempFilePath)
459
+ })
460
+ } else {
461
+ save(this.root.imgList[attrs.i])
462
+ }
463
+ }
464
+ })
465
+ }
466
+ // #endif
467
+ },
468
+
469
+ /**
470
+ * @description 图片加载完成事件
471
+ * @param {Event} e
472
+ */
473
+ imgLoad(e) {
474
+ const i = e.currentTarget.dataset.i
475
+ /* #ifndef H5 || (APP-PLUS && VUE2) */
476
+ if (!this.childs[i].w) {
477
+ // 设置原宽度
478
+ this.$set(this.ctrl, i, e.detail.width)
479
+ } else if ((this.opts[1] && !this.ctrl[i]) || this.ctrl[i] === -1) {
480
+ /* #endif */ // 加载完毕,取消加载中占位图
481
+ this.$set(this.ctrl, i, 1)
482
+ }
483
+ this.checkReady()
484
+ },
485
+
486
+ /**
487
+ * @description 检查是否所有图片加载完毕
488
+ */
489
+ checkReady() {
490
+ if (!this.root.lazyLoad) {
491
+ this.root._unloadimgs -= 1
492
+ if (!this.root._unloadimgs) {
493
+ setTimeout(() => {
494
+ this.root
495
+ .getRect()
496
+ .then((rect) => {
497
+ this.root.$emit('ready', rect)
498
+ })
499
+ .catch(() => {
500
+ this.root.$emit('ready', {})
501
+ })
502
+ }, 350)
503
+ }
504
+ }
505
+ },
506
+
507
+ /**
508
+ * @description 链接点击事件
509
+ * @param {Event} e
510
+ */
511
+ linkTap(e) {
512
+ const node = e.currentTarget ? this.childs[e.currentTarget.dataset.i] : {}
513
+ const attrs = node.attrs || e
514
+ const href = attrs.href
515
+ this.root.$emit(
516
+ 'linkTap',
517
+ Object.assign(
518
+ {
519
+ innerText: this.root.getText(node.children || []) // 链接内的文本内容
520
+ },
521
+ attrs
522
+ )
523
+ )
524
+ if (href) {
525
+ if (href[0] === '#') {
526
+ // 跳转锚点
527
+ this.root.navigateTo(href.substring(1)).catch(() => {})
528
+ } else if (href.split('?')[0].includes('://')) {
529
+ // 复制外部链接
530
+ if (this.root.copyLink) {
531
+ // #ifdef H5
532
+ window.open(href)
533
+ // #endif
534
+ // #ifdef MP
535
+ uni.setClipboardData({
536
+ data: href,
537
+ success: () =>
538
+ uni.showToast({
539
+ title: '链接已复制'
540
+ })
541
+ })
542
+ // #endif
543
+ // #ifdef APP-PLUS
544
+ plus.runtime.openWeb(href)
545
+ // #endif
546
+ }
547
+ } else {
548
+ // 跳转页面
549
+ uni.navigateTo({
550
+ url: href,
551
+ fail() {
552
+ uni.switchTab({
553
+ url: href,
554
+ fail() {}
555
+ })
556
+ }
557
+ })
558
+ }
559
+ }
560
+ },
561
+
562
+ /**
563
+ * @description 错误事件
564
+ * @param {Event} e
565
+ */
566
+ mediaError(e) {
567
+ const i = e.currentTarget.dataset.i
568
+ const node = this.childs[i]
569
+ // 加载其他源
570
+ if (node.name === 'video' || node.name === 'audio') {
571
+ let index = (this.ctrl[i] || 0) + 1
572
+ if (index > node.src.length) {
573
+ index = 0
574
+ }
575
+ if (index < node.src.length) {
576
+ this.$set(this.ctrl, i, index)
577
+ return
578
+ }
579
+ } else if (node.name === 'img') {
580
+ // #ifdef H5 && VUE3
581
+ if (this.opts[0] && !this.ctrl.load) return
582
+ // #endif
583
+ // 显示错误占位图
584
+ if (this.opts[2]) {
585
+ this.$set(this.ctrl, i, -1)
586
+ }
587
+ this.checkReady()
588
+ }
589
+ if (this.root) {
590
+ this.root.$emit('error', {
591
+ source: node.name,
592
+ attrs: node.attrs,
593
+ // #ifndef H5 && VUE3
594
+ errMsg: e.detail.errMsg
595
+ // #endif
596
+ })
597
+ }
598
+ }
599
+ }
600
+ }
601
+ </script>
602
+ <style>
603
+ /* a 标签默认效果 */
604
+ ._a {
605
+ padding: 1.5px 0 1.5px 0;
606
+ color: #366092;
607
+ /* #ifndef APP-NVUE */
608
+ word-break: break-all;
609
+ /* #endif */
610
+ }
611
+
612
+ /* a 标签点击态效果 */
613
+ ._hover {
614
+ text-decoration: underline;
615
+ opacity: 0.7;
616
+ }
617
+
618
+ /* 图片默认效果 */
619
+ ._img {
620
+ max-width: 100%;
621
+ -webkit-touch-callout: none;
622
+ }
623
+
624
+ /* 内部样式 */
625
+
626
+ ._block {
627
+ /* #ifndef APP-NVUE */
628
+ display: block;
629
+ /* #endif */
630
+ }
631
+
632
+ ._b,
633
+ ._strong {
634
+ font-weight: bold;
635
+ }
636
+
637
+ ._code {
638
+ font-family: monospace;
639
+ }
640
+
641
+ ._del {
642
+ text-decoration: line-through;
643
+ }
644
+
645
+ ._em,
646
+ ._i {
647
+ font-style: italic;
648
+ }
649
+
650
+ ._h1 {
651
+ font-size: 2em;
652
+ }
653
+
654
+ ._h2 {
655
+ font-size: 1.5em;
656
+ }
657
+
658
+ ._h3 {
659
+ font-size: 1.17em;
660
+ }
661
+
662
+ ._h5 {
663
+ font-size: 0.83em;
664
+ }
665
+
666
+ ._h6 {
667
+ font-size: 0.67em;
668
+ }
669
+
670
+ ._h1,
671
+ ._h2,
672
+ ._h3,
673
+ ._h4,
674
+ ._h5,
675
+ ._h6 {
676
+ /* #ifndef APP-NVUE */
677
+ display: block;
678
+ /* #endif */
679
+ font-weight: bold;
680
+ }
681
+
682
+ ._image {
683
+ height: 1px;
684
+ }
685
+
686
+ ._ins {
687
+ text-decoration: underline;
688
+ }
689
+
690
+ ._li {
691
+ display: list-item;
692
+ }
693
+
694
+ ._ol {
695
+ list-style-type: decimal;
696
+ }
697
+
698
+ ._ol,
699
+ ._ul {
700
+ /* #ifndef APP-NVUE */
701
+ display: block;
702
+ /* #endif */
703
+ padding-left: 40px;
704
+ margin: 1em 0;
705
+ }
706
+
707
+ ._q::before {
708
+ content: '"';
709
+ }
710
+
711
+ ._q::after {
712
+ content: '"';
713
+ }
714
+
715
+ ._sub {
716
+ font-size: smaller;
717
+ vertical-align: sub;
718
+ }
719
+
720
+ ._sup {
721
+ font-size: smaller;
722
+ vertical-align: super;
723
+ }
724
+
725
+ ._thead,
726
+ ._tbody,
727
+ ._tfoot {
728
+ display: table-row-group;
729
+ }
730
+
731
+ ._tr {
732
+ display: table-row;
733
+ }
734
+
735
+ ._td,
736
+ ._th {
737
+ display: table-cell;
738
+ vertical-align: middle;
739
+ }
740
+
741
+ ._th {
742
+ font-weight: bold;
743
+ text-align: center;
744
+ }
745
+
746
+ ._ul {
747
+ list-style-type: disc;
748
+ }
749
+
750
+ ._ul ._ul {
751
+ margin: 0;
752
+ list-style-type: circle;
753
+ }
754
+
755
+ ._ul ._ul ._ul {
756
+ list-style-type: square;
757
+ }
758
+
759
+ ._abbr,
760
+ ._b,
761
+ ._code,
762
+ ._del,
763
+ ._em,
764
+ ._i,
765
+ ._ins,
766
+ ._label,
767
+ ._q,
768
+ ._span,
769
+ ._strong,
770
+ ._sub,
771
+ ._sup {
772
+ display: inline;
773
+ }
774
+
775
+ /* #ifdef APP-PLUS */
776
+ ._video {
777
+ width: 300px;
778
+ height: 225px;
779
+ }
780
+ /* #endif */
781
+ </style>