@tencentcloud/ai-desk-customer-vue 0.1.3 → 0.1.5
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/components/CustomerServiceChat/index-web.vue +6 -14
- package/components/CustomerServiceChat/message-input/message-input-quote/index.vue +3 -14
- package/components/CustomerServiceChat/message-input-toolbar/emoji-dialog-mobile/emoji-dialog-mobile.vue +2 -5
- package/components/CustomerServiceChat/message-input-toolbar/emoji-picker/emoji-picker-dialog.vue +8 -15
- package/components/CustomerServiceChat/message-input-toolbar/file-upload/index.vue +3 -7
- package/components/CustomerServiceChat/message-input-toolbar/image-upload/index.vue +6 -44
- package/components/CustomerServiceChat/message-input-toolbar/index-web.vue +1 -14
- package/components/CustomerServiceChat/message-input-toolbar/style/uni.scss +0 -56
- package/components/CustomerServiceChat/message-input-toolbar/toolbar-item-container/index.vue +4 -7
- package/components/CustomerServiceChat/message-input-toolbar/toolbar-item-container/style/index.scss +0 -1
- package/components/CustomerServiceChat/message-input-toolbar/video-upload/index.vue +7 -50
- package/components/CustomerServiceChat/message-list/index-web.vue +3 -7
- package/components/CustomerServiceChat/message-list/message-elements/{plugins/plugin-components → message-desk}/index.ts +1 -1
- package/components/{customer-icon.vue → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/customer-icon.vue} +0 -9
- package/components/CustomerServiceChat/message-list/message-elements/{plugins/plugin-components/message-customer → message-desk/message-desk-elements}/index.ts +1 -1
- package/components/{message-branch.vue → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-branch.vue} +4 -4
- package/components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-desk.vue +126 -0
- package/components/{message-multi-branch → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-branch}/branch-pc.vue +1 -1
- package/components/{message-multi-branch → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-branch}/index.vue +2 -3
- package/components/{message-multi-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form}/component-mobile/form-popup.vue +2 -3
- package/components/{message-multi-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form}/component-mobile/input-mobile.vue +1 -1
- package/components/{message-multi-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form}/component-mobile/radios-mobile.vue +7 -7
- package/components/{message-multi-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form}/component-pc/input-pc.vue +1 -1
- package/components/{message-multi-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form}/component-pc/radio-pc.vue +4 -5
- package/components/{message-multi-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form}/form-mobile.vue +8 -7
- package/components/{message-multi-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form}/form-pc.vue +5 -5
- package/components/{message-multi-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form}/index.vue +3 -3
- package/components/{message-product-card.vue → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-product-card.vue} +2 -2
- package/components/{message-rating → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-rating}/index.vue +4 -4
- package/components/{message-rating → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-rating}/message-rating-number.vue +3 -3
- package/components/{message-rating → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-rating}/message-rating-star.vue +5 -5
- package/components/{message-rich-text.vue → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-rich-text.vue} +5 -17
- package/components/{message-robot-welcome.vue → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-robot-welcome.vue} +7 -7
- package/components/{message-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-single-form}/form-input.vue +5 -5
- package/components/{message-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-single-form}/index.vue +1 -1
- package/components/{message-stream.vue → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-stream.vue} +2 -2
- package/{styles → components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/styles}/common.scss +1 -1
- package/components/CustomerServiceChat/message-list/message-elements/{plugins/plugin-components → message-desk}/message-plugin-layout-web.vue +2 -9
- package/components/CustomerServiceChat/message-list/message-elements/{plugins/plugin-components → message-desk}/message-plugin-web.vue +5 -5
- package/components/CustomerServiceChat/message-list/message-elements/message-quote/index-web.vue +2 -4
- package/components/CustomerServiceChat/message-list/message-elements/message-record/index.vue +3 -6
- package/components/CustomerServiceChat/message-list/message-elements/simple-message-list/index.vue +3 -29
- package/components/CustomerServiceChat/style/index.scss +0 -2
- package/components/common/Avatar/index.vue +2 -23
- package/components/common/BottomPopup/index.vue +2 -3
- package/components/common/Dialog/index.vue +2 -2
- package/components/common/ImagePreviewer/index-web.vue +2 -84
- package/components/common/ProgressMessage/index.vue +0 -8
- package/excluded-list.txt +3 -4
- package/index.ts +4 -13
- package/index.vue +1 -60
- package/package.json +9 -19
- package/server.ts +2 -12
- package/utils/chatStorage.ts +2 -11
- package/utils/index.ts +2 -1
- package/assets/audio-before-delete.svg +0 -4
- package/assets/audio-blue.png +0 -0
- package/assets/audio-bubble-blue.svg +0 -3
- package/assets/audio-bubble-red.svg +0 -3
- package/assets/audio-delete.svg +0 -10
- package/assets/audio.svg +0 -6
- package/assets/camera-uni.png +0 -0
- package/assets/face-uni.png +0 -0
- package/assets/more-uni.png +0 -0
- package/assets/translate.svg +0 -12
- package/assets/video-uni.png +0 -0
- package/components/CustomerServiceChat/message-input-toolbar/toolbar-item-container/style/uni.scss +0 -36
- package/components/CustomerServiceChat/message-list/link/index.ts +0 -23
- package/components/CustomerServiceChat/message-list/message-elements/plugins/plugin-components/message-customer/message-customer-service.vue +0 -22
- package/components/CustomerServiceChat/style/uni.scss +0 -12
- package/components/CustomerServiceChat/style/wx.scss +0 -5
- package/components/common/RichText/LICENSE +0 -21
- package/components/common/RichText/README.md +0 -244
- package/components/common/RichText/dist/mp-alipay/index.acss +0 -1
- package/components/common/RichText/dist/mp-alipay/index.axml +0 -1
- package/components/common/RichText/dist/mp-alipay/index.js +0 -8
- package/components/common/RichText/dist/mp-alipay/index.json +0 -1
- package/components/common/RichText/dist/mp-alipay/node/node.acss +0 -1
- package/components/common/RichText/dist/mp-alipay/node/node.axml +0 -1
- package/components/common/RichText/dist/mp-alipay/node/node.js +0 -1
- package/components/common/RichText/dist/mp-alipay/node/node.json +0 -1
- package/components/common/RichText/dist/mp-alipay/parser.js +0 -1
- package/components/common/RichText/dist/mp-baidu/index.css +0 -1
- package/components/common/RichText/dist/mp-baidu/index.js +0 -8
- package/components/common/RichText/dist/mp-baidu/index.json +0 -1
- package/components/common/RichText/dist/mp-baidu/index.swan +0 -1
- package/components/common/RichText/dist/mp-baidu/node/node.css +0 -1
- package/components/common/RichText/dist/mp-baidu/node/node.js +0 -1
- package/components/common/RichText/dist/mp-baidu/node/node.json +0 -1
- package/components/common/RichText/dist/mp-baidu/node/node.swan +0 -1
- package/components/common/RichText/dist/mp-baidu/parser.js +0 -1
- package/components/common/RichText/dist/mp-qq/index.js +0 -8
- package/components/common/RichText/dist/mp-qq/index.json +0 -1
- package/components/common/RichText/dist/mp-qq/index.qml +0 -1
- package/components/common/RichText/dist/mp-qq/index.qss +0 -1
- package/components/common/RichText/dist/mp-qq/node/node.js +0 -1
- package/components/common/RichText/dist/mp-qq/node/node.json +0 -1
- package/components/common/RichText/dist/mp-qq/node/node.qml +0 -1
- package/components/common/RichText/dist/mp-qq/node/node.qss +0 -1
- package/components/common/RichText/dist/mp-qq/parser.js +0 -1
- package/components/common/RichText/dist/mp-toutiao/index.js +0 -8
- package/components/common/RichText/dist/mp-toutiao/index.json +0 -1
- package/components/common/RichText/dist/mp-toutiao/index.ttml +0 -1
- package/components/common/RichText/dist/mp-toutiao/index.ttss +0 -1
- package/components/common/RichText/dist/mp-toutiao/node/node.js +0 -1
- package/components/common/RichText/dist/mp-toutiao/node/node.json +0 -1
- package/components/common/RichText/dist/mp-toutiao/node/node.ttml +0 -1
- package/components/common/RichText/dist/mp-toutiao/node/node.ttss +0 -1
- package/components/common/RichText/dist/mp-toutiao/parser.js +0 -1
- package/components/common/RichText/dist/mp-weixin/index.js +0 -8
- package/components/common/RichText/dist/mp-weixin/index.json +0 -1
- package/components/common/RichText/dist/mp-weixin/index.wxml +0 -1
- package/components/common/RichText/dist/mp-weixin/index.wxss +0 -1
- package/components/common/RichText/dist/mp-weixin/node/node.js +0 -1
- package/components/common/RichText/dist/mp-weixin/node/node.json +0 -1
- package/components/common/RichText/dist/mp-weixin/node/node.wxml +0 -1
- package/components/common/RichText/dist/mp-weixin/node/node.wxss +0 -1
- package/components/common/RichText/dist/mp-weixin/parser.js +0 -1
- package/components/common/RichText/dist/uni-app/components/mp-html/mp-html.vue +0 -498
- package/components/common/RichText/dist/uni-app/components/mp-html/node/node.vue +0 -587
- package/components/common/RichText/dist/uni-app/components/mp-html/parser.js +0 -1393
- package/components/common/RichText/dist/uni-app/static/app-plus/mp-html/js/handler.js +0 -1
- package/components/common/RichText/dist/uni-app/static/app-plus/mp-html/js/uni.webview.min.js +0 -1
- package/components/common/RichText/dist/uni-app/static/app-plus/mp-html/local.html +0 -1
- package/components/common/RichText/docs/.nojekyll +0 -0
- package/components/common/RichText/docs/index.html +0 -50
- package/components/common/RichText/docs/lib/docsify.min.js +0 -1
- package/components/common/RichText/docs/lib/prism-bash.min.js +0 -1
- package/components/common/RichText/docs/lib/search.min.js +0 -1
- package/components/common/RichText/docs/lib/vue.css +0 -858
- package/components/common/RichText/gulpfile.js +0 -113
- package/components/common/RichText/lint.js +0 -63
- package/components/common/RichText/package.json +0 -74
- package/components/common/RichText/plugins/README.md +0 -2
- package/components/common/RichText/plugins/audio/README.md +0 -25
- package/components/common/RichText/plugins/audio/build.js +0 -11
- package/components/common/RichText/plugins/audio/context.js +0 -7
- package/components/common/RichText/plugins/audio/index.js +0 -34
- package/components/common/RichText/plugins/audio/miniprogram/audio.js +0 -189
- package/components/common/RichText/plugins/audio/miniprogram/audio.json +0 -3
- package/components/common/RichText/plugins/audio/miniprogram/audio.wxml +0 -17
- package/components/common/RichText/plugins/audio/miniprogram/audio.wxss +0 -127
- package/components/common/RichText/plugins/audio/miniprogram/build.js +0 -3
- package/components/common/RichText/plugins/audio/uni-app/audio.vue +0 -269
- package/components/common/RichText/plugins/audio/uni-app/build.js +0 -3
- package/components/common/RichText/plugins/card/README.md +0 -30
- package/components/common/RichText/plugins/card/build.js +0 -14
- package/components/common/RichText/plugins/card/index.js +0 -7
- package/components/common/RichText/plugins/card/miniprogram/build.js +0 -3
- package/components/common/RichText/plugins/card/miniprogram/card.js +0 -26
- package/components/common/RichText/plugins/card/miniprogram/card.json +0 -3
- package/components/common/RichText/plugins/card/miniprogram/card.wxml +0 -9
- package/components/common/RichText/plugins/card/miniprogram/card.wxss +0 -55
- package/components/common/RichText/plugins/card/uni-app/build.js +0 -3
- package/components/common/RichText/plugins/card/uni-app/card.vue +0 -122
- package/components/common/RichText/plugins/editable/README.md +0 -137
- package/components/common/RichText/plugins/editable/config.js +0 -15
- package/components/common/RichText/plugins/editable/miniprogram/build.js +0 -813
- package/components/common/RichText/plugins/editable/miniprogram/index.js +0 -551
- package/components/common/RichText/plugins/editable/uni-app/build.js +0 -744
- package/components/common/RichText/plugins/editable/uni-app/index.js +0 -553
- package/components/common/RichText/plugins/emoji/README.md +0 -15
- package/components/common/RichText/plugins/emoji/index.js +0 -203
- package/components/common/RichText/plugins/highlight/README.md +0 -26
- package/components/common/RichText/plugins/highlight/config.js +0 -5
- package/components/common/RichText/plugins/highlight/index.js +0 -96
- package/components/common/RichText/plugins/highlight/miniprogram/build.js +0 -88
- package/components/common/RichText/plugins/highlight/prism.css +0 -125
- package/components/common/RichText/plugins/highlight/prism.min.js +0 -7
- package/components/common/RichText/plugins/highlight/uni-app/build.js +0 -88
- package/components/common/RichText/plugins/img-cache/README.md +0 -24
- package/components/common/RichText/plugins/img-cache/build.js +0 -16
- package/components/common/RichText/plugins/img-cache/index.js +0 -138
- package/components/common/RichText/plugins/latex/README.md +0 -16
- package/components/common/RichText/plugins/latex/build.js +0 -14
- package/components/common/RichText/plugins/latex/index.js +0 -77
- package/components/common/RichText/plugins/latex/katex.css +0 -1070
- package/components/common/RichText/plugins/latex/katex.min.js +0 -1
- package/components/common/RichText/plugins/markdown/README.md +0 -17
- package/components/common/RichText/plugins/markdown/index.js +0 -34
- package/components/common/RichText/plugins/markdown/marked.min.js +0 -6
- package/components/common/RichText/plugins/markdown/miniprogram/build.js +0 -70
- package/components/common/RichText/plugins/markdown/uni-app/build.js +0 -68
- package/components/common/RichText/plugins/search/README.md +0 -46
- package/components/common/RichText/plugins/search/miniprogram/index.js +0 -137
- package/components/common/RichText/plugins/search/uni-app/index.js +0 -132
- package/components/common/RichText/plugins/style/README.md +0 -30
- package/components/common/RichText/plugins/style/index.js +0 -129
- package/components/common/RichText/plugins/style/parser.js +0 -175
- package/components/common/RichText/plugins/template/README.md +0 -2
- package/components/common/RichText/plugins/template/build.js +0 -65
- package/components/common/RichText/plugins/template/index.js +0 -67
- package/components/common/RichText/plugins/txv-video/README.md +0 -18
- package/components/common/RichText/plugins/txv-video/build.js +0 -3
- package/components/common/RichText/plugins/txv-video/index.js +0 -46
- package/components/common/RichText/plugins/txv-video/miniprogram/build.js +0 -6
- package/components/common/RichText/plugins/txv-video/uni-app/build.js +0 -3
- package/components/common/RichText/src/miniprogram/index.js +0 -396
- package/components/common/RichText/src/miniprogram/index.json +0 -6
- package/components/common/RichText/src/miniprogram/index.wxml +0 -7
- package/components/common/RichText/src/miniprogram/index.wxss +0 -13
- package/components/common/RichText/src/miniprogram/node/node.js +0 -247
- package/components/common/RichText/src/miniprogram/node/node.json +0 -6
- package/components/common/RichText/src/miniprogram/node/node.wxml +0 -112
- package/components/common/RichText/src/miniprogram/node/node.wxss +0 -164
- package/components/common/RichText/src/miniprogram/parser.js +0 -1269
- package/components/common/RichText/src/uni-app/components/mp-html/mp-html.vue +0 -498
- package/components/common/RichText/src/uni-app/components/mp-html/node/node.vue +0 -585
- package/components/common/RichText/src/uni-app/components/mp-html/parser.js +0 -1393
- package/components/common/RichText/src/uni-app/static/app-plus/mp-html/js/handler.js +0 -254
- package/components/common/RichText/src/uni-app/static/app-plus/mp-html/js/uni.webview.min.js +0 -1
- package/components/common/RichText/src/uni-app/static/app-plus/mp-html/local.html +0 -33
- package/components/common/RichText/tools/config.js +0 -82
- package/components/common/RichText/tools/converter.js +0 -205
- package/components/common/RichText/tools/ifdef.js +0 -115
- package/components/common/RichText/tools/minifier.js +0 -40
- package/components/common/RichText/tools/plugin.js +0 -248
- package/components/message-customer-service.vue +0 -114
- package/script/fileCopy.js +0 -60
- package/script/syncVersion.js +0 -35
- /package/components/{message-multi-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form}/component-mobile/label-mobile.vue +0 -0
- /package/components/{message-multi-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form}/component-pc/label-pc.vue +0 -0
- /package/components/{message-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-single-form}/form-branch.vue +0 -0
|
@@ -1,396 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* mp-html v2.5.0
|
|
3
|
-
* https://github.com/jin-yufeng/mp-html
|
|
4
|
-
*
|
|
5
|
-
* Released under the MIT license
|
|
6
|
-
* Author: Jin Yufeng
|
|
7
|
-
*/
|
|
8
|
-
const Parser = require('./parser')
|
|
9
|
-
const plugins = []
|
|
10
|
-
|
|
11
|
-
Component({
|
|
12
|
-
data: {
|
|
13
|
-
nodes: []
|
|
14
|
-
},
|
|
15
|
-
properties: {
|
|
16
|
-
/**
|
|
17
|
-
* @description 容器的样式
|
|
18
|
-
* @type {String}
|
|
19
|
-
*/
|
|
20
|
-
containerStyle: String,
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @description 用于渲染的 html 字符串
|
|
24
|
-
* @type {String}
|
|
25
|
-
*/
|
|
26
|
-
content: {
|
|
27
|
-
type: String,
|
|
28
|
-
value: '',
|
|
29
|
-
observer (content) {
|
|
30
|
-
this.setContent(content)
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @description 是否允许外部链接被点击时自动复制
|
|
36
|
-
* @type {Boolean}
|
|
37
|
-
* @default true
|
|
38
|
-
*/
|
|
39
|
-
copyLink: {
|
|
40
|
-
type: Boolean,
|
|
41
|
-
value: true
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @description 主域名,用于拼接链接
|
|
46
|
-
* @type {String}
|
|
47
|
-
*/
|
|
48
|
-
domain: String,
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* @description 图片出错时的占位图链接
|
|
52
|
-
* @type {String}
|
|
53
|
-
*/
|
|
54
|
-
errorImg: String,
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* @description 是否开启图片懒加载
|
|
58
|
-
* @type {Boolean}
|
|
59
|
-
* @default false
|
|
60
|
-
*/
|
|
61
|
-
lazyLoad: Boolean,
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* @description 图片加载过程中的占位图链接
|
|
65
|
-
* @type {String}
|
|
66
|
-
*/
|
|
67
|
-
loadingImg: String,
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* @description 是否在播放一个视频时自动暂停其他视频
|
|
71
|
-
* @type {Boolean}
|
|
72
|
-
* @default true
|
|
73
|
-
*/
|
|
74
|
-
pauseVideo: {
|
|
75
|
-
type: Boolean,
|
|
76
|
-
value: true
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* @description 是否允许图片被点击时自动预览
|
|
81
|
-
* @type {Boolean | String}
|
|
82
|
-
* @default true
|
|
83
|
-
*/
|
|
84
|
-
previewImg: {
|
|
85
|
-
type: null,
|
|
86
|
-
value: true
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* @description 是否给每个表格添加一个滚动层使其能单独横向滚动
|
|
91
|
-
* @type {Boolean}
|
|
92
|
-
* @default false
|
|
93
|
-
*/
|
|
94
|
-
scrollTable: Boolean,
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* @description 是否开启长按复制
|
|
98
|
-
* @type {Boolean | String}
|
|
99
|
-
* @default false
|
|
100
|
-
*/
|
|
101
|
-
selectable: null,
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* @description 是否将 title 标签的内容设置到页面标题
|
|
105
|
-
* @type {Boolean}
|
|
106
|
-
* @default true
|
|
107
|
-
*/
|
|
108
|
-
setTitle: {
|
|
109
|
-
type: Boolean,
|
|
110
|
-
value: true
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* @description 是否允许图片被长按时显示菜单
|
|
115
|
-
* @type {Boolean}
|
|
116
|
-
* @default true
|
|
117
|
-
*/
|
|
118
|
-
showImgMenu: {
|
|
119
|
-
type: Boolean,
|
|
120
|
-
value: true
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* @description 标签的默认样式
|
|
125
|
-
* @type {Object}
|
|
126
|
-
*/
|
|
127
|
-
tagStyle: Object,
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* @description 是否使用锚点链接
|
|
131
|
-
* @type {Boolean | Number}
|
|
132
|
-
* @default false
|
|
133
|
-
*/
|
|
134
|
-
useAnchor: null
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
created () {
|
|
138
|
-
this.plugins = []
|
|
139
|
-
for (let i = plugins.length; i--;) {
|
|
140
|
-
this.plugins.push(new plugins[i](this))
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// #ifdef MP-ALIPAY
|
|
144
|
-
if (this.properties.content) {
|
|
145
|
-
this.setContent(this.properties.content)
|
|
146
|
-
}
|
|
147
|
-
// #endif
|
|
148
|
-
},
|
|
149
|
-
|
|
150
|
-
// #ifdef MP-ALIPAY
|
|
151
|
-
didUpdate (e) {
|
|
152
|
-
if (e.content !== this.properties.content) {
|
|
153
|
-
this.setContent(this.properties.content)
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
// #endif
|
|
157
|
-
|
|
158
|
-
detached () {
|
|
159
|
-
// 注销插件
|
|
160
|
-
this._hook('onDetached')
|
|
161
|
-
},
|
|
162
|
-
|
|
163
|
-
methods: {
|
|
164
|
-
/**
|
|
165
|
-
* @description 将锚点跳转的范围限定在一个 scroll-view 内
|
|
166
|
-
* @param {Object} page scroll-view 所在页面的示例
|
|
167
|
-
* @param {String} selector scroll-view 的选择器
|
|
168
|
-
* @param {String} scrollTop scroll-view scroll-top 属性绑定的变量名
|
|
169
|
-
*/
|
|
170
|
-
in (page, selector, scrollTop) {
|
|
171
|
-
if (page && selector && scrollTop) {
|
|
172
|
-
this._in = {
|
|
173
|
-
page,
|
|
174
|
-
selector,
|
|
175
|
-
scrollTop
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* @description 锚点跳转
|
|
182
|
-
* @param {String} id 要跳转的锚点 id
|
|
183
|
-
* @param {Number} offset 跳转位置的偏移量
|
|
184
|
-
* @returns {Promise}
|
|
185
|
-
*/
|
|
186
|
-
navigateTo (id, offset) {
|
|
187
|
-
return new Promise((resolve, reject) => {
|
|
188
|
-
if (!this.properties.useAnchor) {
|
|
189
|
-
reject(Error('Anchor is disabled'))
|
|
190
|
-
return
|
|
191
|
-
}
|
|
192
|
-
// 跨组件选择器
|
|
193
|
-
const deep =
|
|
194
|
-
// #ifdef MP-WEIXIN || MP-QQ || MP-TOUTIAO
|
|
195
|
-
'>>>'
|
|
196
|
-
// #endif
|
|
197
|
-
// #ifdef MP-BAIDU || MP-ALIPAY
|
|
198
|
-
' ' // eslint-disable-line
|
|
199
|
-
// #endif
|
|
200
|
-
const selector = wx.createSelectorQuery()
|
|
201
|
-
// #ifndef MP-ALIPAY
|
|
202
|
-
.in(this._in ? this._in.page : this)
|
|
203
|
-
// #endif
|
|
204
|
-
.select((this._in ? this._in.selector : '._root') + (id ? `${deep}#${id}` : '')).boundingClientRect()
|
|
205
|
-
if (this._in) {
|
|
206
|
-
selector.select(this._in.selector).scrollOffset()
|
|
207
|
-
.select(this._in.selector).boundingClientRect()
|
|
208
|
-
} else {
|
|
209
|
-
// 获取 scroll-view 的位置和滚动距离
|
|
210
|
-
selector.selectViewport().scrollOffset() // 获取窗口的滚动距离
|
|
211
|
-
}
|
|
212
|
-
selector.exec(res => {
|
|
213
|
-
if (!res[0]) {
|
|
214
|
-
reject(Error('Label not found'))
|
|
215
|
-
return
|
|
216
|
-
}
|
|
217
|
-
const scrollTop = res[1].scrollTop + res[0].top - (res[2] ? res[2].top : 0) + (offset || parseInt(this.properties.useAnchor) || 0)
|
|
218
|
-
if (this._in) {
|
|
219
|
-
// scroll-view 跳转
|
|
220
|
-
this._in.page.setData({
|
|
221
|
-
[this._in.scrollTop]: scrollTop
|
|
222
|
-
})
|
|
223
|
-
} else {
|
|
224
|
-
// 页面跳转
|
|
225
|
-
wx.pageScrollTo({
|
|
226
|
-
scrollTop,
|
|
227
|
-
duration: 300
|
|
228
|
-
})
|
|
229
|
-
}
|
|
230
|
-
resolve()
|
|
231
|
-
})
|
|
232
|
-
})
|
|
233
|
-
},
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* @description 获取文本内容
|
|
237
|
-
* @returns {String}
|
|
238
|
-
*/
|
|
239
|
-
getText (nodes) {
|
|
240
|
-
let text = '';
|
|
241
|
-
(function traversal (nodes) {
|
|
242
|
-
for (let i = 0; i < nodes.length; i++) {
|
|
243
|
-
const node = nodes[i]
|
|
244
|
-
if (node.type === 'text') {
|
|
245
|
-
text += node.text.replace(/&/g, '&')
|
|
246
|
-
} else if (node.name === 'br') {
|
|
247
|
-
text += '\n'
|
|
248
|
-
} else {
|
|
249
|
-
// 块级标签前后加换行
|
|
250
|
-
const isBlock = node.name === 'p' || node.name === 'div' || node.name === 'tr' || node.name === 'li' || (node.name[0] === 'h' && node.name[1] > '0' && node.name[1] < '7')
|
|
251
|
-
if (isBlock && text && text[text.length - 1] !== '\n') {
|
|
252
|
-
text += '\n'
|
|
253
|
-
}
|
|
254
|
-
// 递归获取子节点的文本
|
|
255
|
-
if (node.children) {
|
|
256
|
-
traversal(node.children)
|
|
257
|
-
}
|
|
258
|
-
if (isBlock && text[text.length - 1] !== '\n') {
|
|
259
|
-
text += '\n'
|
|
260
|
-
} else if (node.name === 'td' || node.name === 'th') {
|
|
261
|
-
text += '\t'
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
})(nodes || this.data.nodes)
|
|
266
|
-
return text
|
|
267
|
-
},
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* @description 获取内容大小
|
|
271
|
-
* @returns {Promise}
|
|
272
|
-
*/
|
|
273
|
-
getRect () {
|
|
274
|
-
return new Promise((resolve, reject) => {
|
|
275
|
-
wx.createSelectorQuery()
|
|
276
|
-
// #ifndef MP-ALIPAY
|
|
277
|
-
.in(this)
|
|
278
|
-
// #endif
|
|
279
|
-
.select('._root').boundingClientRect().exec(res => res[0] ? resolve(res[0]) : reject(Error('Root label not found')))
|
|
280
|
-
})
|
|
281
|
-
},
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* @description 暂停播放媒体
|
|
285
|
-
*/
|
|
286
|
-
pauseMedia () {
|
|
287
|
-
for (let i = (this._videos || []).length; i--;) {
|
|
288
|
-
this._videos[i].pause()
|
|
289
|
-
}
|
|
290
|
-
},
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* @description 设置媒体播放速率
|
|
294
|
-
* @param {Number} rate 播放速率
|
|
295
|
-
*/
|
|
296
|
-
setPlaybackRate (rate) {
|
|
297
|
-
this.playbackRate = rate
|
|
298
|
-
for (let i = (this._videos || []).length; i--;) {
|
|
299
|
-
this._videos[i].playbackRate(rate)
|
|
300
|
-
}
|
|
301
|
-
},
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* @description 设置富文本内容
|
|
305
|
-
* @param {string} content 要渲染的 html 字符串
|
|
306
|
-
* @param {boolean} append 是否在尾部追加
|
|
307
|
-
*/
|
|
308
|
-
setContent (content, append) {
|
|
309
|
-
if (!this.imgList || !append) {
|
|
310
|
-
this.imgList = []
|
|
311
|
-
}
|
|
312
|
-
this._videos = []
|
|
313
|
-
|
|
314
|
-
const data = {}
|
|
315
|
-
const nodes = new Parser(this).parse(content)
|
|
316
|
-
// 尾部追加内容
|
|
317
|
-
if (append) {
|
|
318
|
-
for (let i = this.data.nodes.length, j = nodes.length; j--;) {
|
|
319
|
-
data[`nodes[${i + j}]`] = nodes[j]
|
|
320
|
-
}
|
|
321
|
-
} else {
|
|
322
|
-
data.nodes = nodes
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
this.setData(data,
|
|
326
|
-
// #ifndef MP-TOUTIAO
|
|
327
|
-
() => {
|
|
328
|
-
this._hook('onLoad')
|
|
329
|
-
this.triggerEvent('load')
|
|
330
|
-
}
|
|
331
|
-
// #endif
|
|
332
|
-
)
|
|
333
|
-
|
|
334
|
-
// #ifdef MP-TOUTIAO
|
|
335
|
-
this.selectComponent('#_root', child => {
|
|
336
|
-
child.root = this
|
|
337
|
-
this._hook('onLoad')
|
|
338
|
-
this.triggerEvent('load')
|
|
339
|
-
})
|
|
340
|
-
// #endif
|
|
341
|
-
|
|
342
|
-
if (this.properties.lazyLoad || this.imgList._unloadimgs < this.imgList.length / 2) {
|
|
343
|
-
// 设置懒加载,每 350ms 获取高度,不变则认为加载完毕
|
|
344
|
-
let height = 0
|
|
345
|
-
const callback = rect => {
|
|
346
|
-
if (!rect || !rect.height) rect = {}
|
|
347
|
-
// 350ms 总高度无变化就触发 ready 事件
|
|
348
|
-
if (rect.height === height) {
|
|
349
|
-
this.triggerEvent('ready', rect)
|
|
350
|
-
} else {
|
|
351
|
-
height = rect.height
|
|
352
|
-
setTimeout(() => {
|
|
353
|
-
this.getRect().then(callback).catch(callback)
|
|
354
|
-
}, 350)
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
this.getRect().then(callback).catch(callback)
|
|
358
|
-
} else {
|
|
359
|
-
// 未设置懒加载,等待所有图片加载完毕
|
|
360
|
-
if (!this.imgList._unloadimgs) {
|
|
361
|
-
this.getRect().then(rect => {
|
|
362
|
-
this.triggerEvent('ready', rect)
|
|
363
|
-
}).catch(() => {
|
|
364
|
-
this.triggerEvent('ready', {})
|
|
365
|
-
})
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
},
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* @description 调用插件的钩子函数
|
|
372
|
-
* @private
|
|
373
|
-
*/
|
|
374
|
-
_hook (name) {
|
|
375
|
-
for (let i = plugins.length; i--;) {
|
|
376
|
-
if (this.plugins[i][name]) {
|
|
377
|
-
this.plugins[i][name]()
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
},
|
|
381
|
-
|
|
382
|
-
// #ifndef MP-TOUTIAO
|
|
383
|
-
/**
|
|
384
|
-
* @description 添加子组件
|
|
385
|
-
* @private
|
|
386
|
-
*/
|
|
387
|
-
_add (e) {
|
|
388
|
-
e
|
|
389
|
-
// #ifndef MP-ALIPAY
|
|
390
|
-
.detail
|
|
391
|
-
// #endif
|
|
392
|
-
.root = this
|
|
393
|
-
}
|
|
394
|
-
// #endif
|
|
395
|
-
}
|
|
396
|
-
})
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
<!-- 主组件 -->
|
|
2
|
-
<view class="_root {{selectable?'_select':''}}" style="{{containerStyle}}">
|
|
3
|
-
<!-- 加载完成前显示自定义 loading -->
|
|
4
|
-
<slot wx:if="{{!nodes[0]}}" />
|
|
5
|
-
<!-- 节点树 -->
|
|
6
|
-
<node id="_root" childs="{{nodes}}" opts="{{[lazyLoad,loadingImg,errorImg,showImgMenu,selectable]}}" mp-weixin:mp-qq:mp-baidu:catchadd="_add" mp-alipay:onAdd="_add" />
|
|
7
|
-
</view>
|
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview 递归子组件,用于显示节点树
|
|
3
|
-
*/
|
|
4
|
-
Component({
|
|
5
|
-
data: {
|
|
6
|
-
ctrl: {}, // 控制信号
|
|
7
|
-
// #ifdef MP-WEIXIN
|
|
8
|
-
isiOS: wx.getSystemInfoSync().system.includes('iOS')
|
|
9
|
-
// #endif
|
|
10
|
-
},
|
|
11
|
-
properties: {
|
|
12
|
-
childs: Array, // 子节点列表
|
|
13
|
-
opts: Array // 设置 [是否开启懒加载, 加载中占位图, 错误占位图, 是否使用长按菜单]
|
|
14
|
-
},
|
|
15
|
-
options: {
|
|
16
|
-
addGlobalClass: true
|
|
17
|
-
},
|
|
18
|
-
// #ifndef MP-TOUTIAO
|
|
19
|
-
attached () {
|
|
20
|
-
// #ifndef MP-ALIPAY
|
|
21
|
-
this.triggerEvent('add', this, {
|
|
22
|
-
bubbles: true,
|
|
23
|
-
composed: true
|
|
24
|
-
})
|
|
25
|
-
// #endif
|
|
26
|
-
// #ifdef MP-ALIPAY
|
|
27
|
-
this.props.onAdd(this)
|
|
28
|
-
// #endif
|
|
29
|
-
},
|
|
30
|
-
// #endif
|
|
31
|
-
methods: {
|
|
32
|
-
noop () { },
|
|
33
|
-
/**
|
|
34
|
-
* @description 获取标签
|
|
35
|
-
* @param {String} path 路径
|
|
36
|
-
*/
|
|
37
|
-
getNode (path) {
|
|
38
|
-
try {
|
|
39
|
-
const nums = path.split('_')
|
|
40
|
-
let node = this.properties.childs[nums[0]]
|
|
41
|
-
for (let i = 1; i < nums.length; i++) {
|
|
42
|
-
node = node.children[nums[i]]
|
|
43
|
-
}
|
|
44
|
-
return node
|
|
45
|
-
} catch {
|
|
46
|
-
return {
|
|
47
|
-
text: '',
|
|
48
|
-
attrs: {},
|
|
49
|
-
children: []
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
/**
|
|
54
|
-
* @description 播放视频事件
|
|
55
|
-
* @param {Event} e
|
|
56
|
-
*/
|
|
57
|
-
play (e) {
|
|
58
|
-
const i = e.target.dataset.i
|
|
59
|
-
const node = this.getNode(i)
|
|
60
|
-
this.root.triggerEvent('play', {
|
|
61
|
-
source: node.name,
|
|
62
|
-
attrs: {
|
|
63
|
-
...node.attrs,
|
|
64
|
-
src: node.src[this.data.ctrl[i] || 0]
|
|
65
|
-
}
|
|
66
|
-
})
|
|
67
|
-
if (this.root.properties.pauseVideo) {
|
|
68
|
-
let flag = false
|
|
69
|
-
const id = e.target.id
|
|
70
|
-
for (let i = this.root._videos.length; i--;) {
|
|
71
|
-
if (this.root._videos[i].id === id) {
|
|
72
|
-
flag = true
|
|
73
|
-
} else {
|
|
74
|
-
this.root._videos[i].pause() // 自动暂停其他视频
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
// 将自己加入列表
|
|
78
|
-
if (!flag) {
|
|
79
|
-
const ctx = wx.createVideoContext(id
|
|
80
|
-
// #ifndef MP-BAIDU
|
|
81
|
-
, this
|
|
82
|
-
// #endif
|
|
83
|
-
)
|
|
84
|
-
ctx.id = id
|
|
85
|
-
if (this.root.playbackRate) {
|
|
86
|
-
ctx.playbackRate(this.root.playbackRate)
|
|
87
|
-
}
|
|
88
|
-
this.root._videos.push(ctx)
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* @description 图片点击事件
|
|
95
|
-
* @param {Event} e
|
|
96
|
-
*/
|
|
97
|
-
imgTap (e) {
|
|
98
|
-
const node = this.getNode(e.target.dataset.i)
|
|
99
|
-
// 父级中有链接
|
|
100
|
-
if (node.a) return this.linkTap(node.a)
|
|
101
|
-
if (node.attrs.ignore) return
|
|
102
|
-
this.root.triggerEvent('imgtap', node.attrs)
|
|
103
|
-
if (this.root.properties.previewImg) {
|
|
104
|
-
const current =
|
|
105
|
-
// #ifndef MP-ALIPAY
|
|
106
|
-
this.root.imgList[node.i]
|
|
107
|
-
// #endif
|
|
108
|
-
// #ifdef MP-ALIPAY
|
|
109
|
-
node.i // eslint-disable-line
|
|
110
|
-
// #endif
|
|
111
|
-
// 自动预览图片
|
|
112
|
-
wx.previewImage({
|
|
113
|
-
// #ifdef MP-WEIXIN
|
|
114
|
-
showmenu: this.root.properties.showImgMenu,
|
|
115
|
-
// #endif
|
|
116
|
-
// #ifdef MP-ALIPAY
|
|
117
|
-
enablesavephoto: this.root.properties.showImgMenu,
|
|
118
|
-
enableShowPhotoDownload: this.root.properties.showImgMenu,
|
|
119
|
-
// #endif
|
|
120
|
-
current,
|
|
121
|
-
urls: this.root.imgList
|
|
122
|
-
})
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* @description 图片加载完成事件
|
|
128
|
-
* @param {Event} e
|
|
129
|
-
*/
|
|
130
|
-
imgLoad (e) {
|
|
131
|
-
const i = e.target.dataset.i
|
|
132
|
-
const node = this.getNode(i)
|
|
133
|
-
let val
|
|
134
|
-
if (!node.w) {
|
|
135
|
-
val = e.detail.width
|
|
136
|
-
} else if ((this.properties.opts[1] && !this.data.ctrl[i]) || this.data.ctrl[i] === -1) {
|
|
137
|
-
// 加载完毕,取消加载中占位图
|
|
138
|
-
val = 1
|
|
139
|
-
}
|
|
140
|
-
if (val
|
|
141
|
-
// #ifdef MP-TOUTIAO
|
|
142
|
-
&& val !== this.data.ctrl[i] // eslint-disable-line
|
|
143
|
-
// #endif
|
|
144
|
-
) {
|
|
145
|
-
this.setData({
|
|
146
|
-
['ctrl.' + i]: val
|
|
147
|
-
})
|
|
148
|
-
}
|
|
149
|
-
this.checkReady()
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* @description 检查是否所有图片加载完毕
|
|
154
|
-
*/
|
|
155
|
-
checkReady () {
|
|
156
|
-
if (!this.root.properties.lazyLoad) {
|
|
157
|
-
this.root.imgList._unloadimgs -= 1
|
|
158
|
-
if (!this.root.imgList._unloadimgs) {
|
|
159
|
-
setTimeout(() => {
|
|
160
|
-
this.root.getRect().then(rect => {
|
|
161
|
-
this.root.triggerEvent('ready', rect)
|
|
162
|
-
}).catch(() => {
|
|
163
|
-
this.root.triggerEvent('ready', {})
|
|
164
|
-
})
|
|
165
|
-
}, 350)
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* @description 链接点击事件
|
|
172
|
-
* @param {Event} e
|
|
173
|
-
*/
|
|
174
|
-
linkTap (e) {
|
|
175
|
-
const node = e.currentTarget ? this.getNode(e.currentTarget.dataset.i) : {}
|
|
176
|
-
const attrs = node.attrs || e
|
|
177
|
-
const href = attrs.href
|
|
178
|
-
this.root.triggerEvent('linktap', Object.assign({
|
|
179
|
-
innerText: this.root.getText(node.children || []) // 链接内的文本内容
|
|
180
|
-
}, attrs))
|
|
181
|
-
if (href) {
|
|
182
|
-
if (href[0] === '#') {
|
|
183
|
-
// 跳转锚点
|
|
184
|
-
this.root.navigateTo(href.substring(1)).catch(() => { })
|
|
185
|
-
} else if (href.split('?')[0].includes('://')) {
|
|
186
|
-
// 复制外部链接
|
|
187
|
-
if (this.root.properties.copyLink) {
|
|
188
|
-
wx.setClipboardData({
|
|
189
|
-
data: href,
|
|
190
|
-
success: () =>
|
|
191
|
-
wx.showToast({
|
|
192
|
-
title: '链接已复制'
|
|
193
|
-
})
|
|
194
|
-
})
|
|
195
|
-
}
|
|
196
|
-
} else {
|
|
197
|
-
// 跳转页面
|
|
198
|
-
wx.navigateTo({
|
|
199
|
-
url: href,
|
|
200
|
-
fail () {
|
|
201
|
-
wx.switchTab({
|
|
202
|
-
url: href,
|
|
203
|
-
fail () { }
|
|
204
|
-
})
|
|
205
|
-
}
|
|
206
|
-
})
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
},
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* @description 错误事件
|
|
213
|
-
* @param {Event} e
|
|
214
|
-
*/
|
|
215
|
-
mediaError (e) {
|
|
216
|
-
const i = e.target.dataset.i
|
|
217
|
-
const node = this.getNode(i)
|
|
218
|
-
if (node.name === 'video' || node.name === 'audio') {
|
|
219
|
-
// 加载其他源
|
|
220
|
-
let index = (this.data.ctrl[i] || 0) + 1
|
|
221
|
-
if (index > node.src.length) {
|
|
222
|
-
index = 0
|
|
223
|
-
}
|
|
224
|
-
if (index < node.src.length) {
|
|
225
|
-
return this.setData({
|
|
226
|
-
['ctrl.' + i]: index
|
|
227
|
-
})
|
|
228
|
-
}
|
|
229
|
-
} else if (node.name === 'img') {
|
|
230
|
-
// 显示错误占位图
|
|
231
|
-
if (this.properties.opts[2]) {
|
|
232
|
-
this.setData({
|
|
233
|
-
['ctrl.' + i]: -1
|
|
234
|
-
})
|
|
235
|
-
}
|
|
236
|
-
this.checkReady()
|
|
237
|
-
}
|
|
238
|
-
if (this.root) {
|
|
239
|
-
this.root.triggerEvent('error', {
|
|
240
|
-
source: node.name,
|
|
241
|
-
attrs: node.attrs,
|
|
242
|
-
errMsg: e.detail.errMsg
|
|
243
|
-
})
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
})
|