@tencentcloud/ai-desk-customer-vue 0.1.2 → 0.1.4

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 (225) hide show
  1. package/components/CustomerServiceChat/index-web.vue +7 -14
  2. package/components/CustomerServiceChat/message-input/index-web.vue +17 -16
  3. package/components/CustomerServiceChat/message-input/message-input-editor-web.vue +3 -6
  4. package/components/CustomerServiceChat/message-input/message-input-quote/index.vue +3 -14
  5. package/components/CustomerServiceChat/message-input-toolbar/emoji-dialog-mobile/emoji-dialog-mobile.vue +2 -5
  6. package/components/CustomerServiceChat/message-input-toolbar/emoji-picker/emoji-picker-dialog.vue +8 -15
  7. package/components/CustomerServiceChat/message-input-toolbar/file-upload/index.vue +3 -7
  8. package/components/CustomerServiceChat/message-input-toolbar/image-upload/index.vue +6 -44
  9. package/components/CustomerServiceChat/message-input-toolbar/index-web.vue +1 -14
  10. package/components/CustomerServiceChat/message-input-toolbar/style/uni.scss +0 -56
  11. package/components/CustomerServiceChat/message-input-toolbar/toolbar-item-container/index.vue +4 -7
  12. package/components/CustomerServiceChat/message-input-toolbar/toolbar-item-container/style/index.scss +0 -1
  13. package/components/CustomerServiceChat/message-input-toolbar/video-upload/index.vue +7 -50
  14. package/components/CustomerServiceChat/message-list/index-web.vue +3 -7
  15. package/components/CustomerServiceChat/message-list/message-elements/{plugins/plugin-components → message-desk}/index.ts +1 -1
  16. package/components/{customer-icon.vue → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/customer-icon.vue} +0 -9
  17. package/components/CustomerServiceChat/message-list/message-elements/{plugins/plugin-components/message-customer → message-desk/message-desk-elements}/index.ts +1 -1
  18. package/components/{message-branch.vue → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-branch.vue} +4 -4
  19. package/components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-desk.vue +126 -0
  20. package/components/{message-multi-branch → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-branch}/branch-pc.vue +1 -1
  21. package/components/{message-multi-branch → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-branch}/index.vue +2 -3
  22. 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
  23. 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
  24. 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
  25. 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
  26. 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
  27. package/components/{message-multi-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form}/form-mobile.vue +8 -7
  28. package/components/{message-multi-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form}/form-pc.vue +5 -5
  29. package/components/{message-multi-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form}/index.vue +3 -3
  30. package/components/{message-product-card.vue → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-product-card.vue} +2 -2
  31. package/components/{message-rating → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-rating}/index.vue +4 -4
  32. package/components/{message-rating → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-rating}/message-rating-number.vue +3 -3
  33. package/components/{message-rating → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-rating}/message-rating-star.vue +5 -5
  34. package/components/{message-rich-text.vue → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-rich-text.vue} +5 -17
  35. package/components/{message-robot-welcome.vue → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-robot-welcome.vue} +7 -7
  36. package/components/{message-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-single-form}/form-input.vue +5 -5
  37. package/components/{message-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-single-form}/index.vue +1 -1
  38. package/components/{message-stream.vue → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-stream.vue} +2 -2
  39. package/{styles → components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/styles}/common.scss +1 -1
  40. package/components/CustomerServiceChat/message-list/message-elements/{plugins/plugin-components → message-desk}/message-plugin-layout-web.vue +2 -9
  41. package/components/CustomerServiceChat/message-list/message-elements/{plugins/plugin-components → message-desk}/message-plugin-web.vue +5 -5
  42. package/components/CustomerServiceChat/message-list/message-elements/message-quote/index-web.vue +2 -4
  43. package/components/CustomerServiceChat/message-list/message-elements/message-record/index.vue +3 -6
  44. package/components/CustomerServiceChat/message-list/message-elements/simple-message-list/index.vue +3 -29
  45. package/components/CustomerServiceChat/style/h5.scss +2 -1
  46. package/components/CustomerServiceChat/style/index.scss +0 -2
  47. package/components/common/Avatar/index.vue +2 -23
  48. package/components/common/BottomPopup/index.vue +2 -3
  49. package/components/common/Dialog/index.vue +2 -2
  50. package/components/common/ImagePreviewer/index-web.vue +2 -84
  51. package/components/common/ProgressMessage/index.vue +0 -8
  52. package/index.ts +4 -13
  53. package/index.vue +1 -60
  54. package/package.json +4 -5
  55. package/server.ts +3 -32
  56. package/utils/chatStorage.ts +2 -11
  57. package/utils/index.ts +2 -1
  58. package/assets/audio-before-delete.svg +0 -4
  59. package/assets/audio-blue.png +0 -0
  60. package/assets/audio-bubble-blue.svg +0 -3
  61. package/assets/audio-bubble-red.svg +0 -3
  62. package/assets/audio-delete.svg +0 -10
  63. package/assets/audio.svg +0 -6
  64. package/assets/camera-uni.png +0 -0
  65. package/assets/face-uni.png +0 -0
  66. package/assets/more-uni.png +0 -0
  67. package/assets/translate.svg +0 -12
  68. package/assets/video-uni.png +0 -0
  69. package/components/CustomerServiceChat/message-input-toolbar/toolbar-item-container/style/uni.scss +0 -36
  70. package/components/CustomerServiceChat/message-list/link/index.ts +0 -23
  71. package/components/CustomerServiceChat/message-list/message-elements/plugins/plugin-components/message-customer/message-customer-service.vue +0 -22
  72. package/components/CustomerServiceChat/style/uni.scss +0 -12
  73. package/components/CustomerServiceChat/style/wx.scss +0 -5
  74. package/components/common/RichText/LICENSE +0 -21
  75. package/components/common/RichText/README.md +0 -244
  76. package/components/common/RichText/dist/mp-alipay/index.acss +0 -1
  77. package/components/common/RichText/dist/mp-alipay/index.axml +0 -1
  78. package/components/common/RichText/dist/mp-alipay/index.js +0 -8
  79. package/components/common/RichText/dist/mp-alipay/index.json +0 -1
  80. package/components/common/RichText/dist/mp-alipay/node/node.acss +0 -1
  81. package/components/common/RichText/dist/mp-alipay/node/node.axml +0 -1
  82. package/components/common/RichText/dist/mp-alipay/node/node.js +0 -1
  83. package/components/common/RichText/dist/mp-alipay/node/node.json +0 -1
  84. package/components/common/RichText/dist/mp-alipay/parser.js +0 -1
  85. package/components/common/RichText/dist/mp-baidu/index.css +0 -1
  86. package/components/common/RichText/dist/mp-baidu/index.js +0 -8
  87. package/components/common/RichText/dist/mp-baidu/index.json +0 -1
  88. package/components/common/RichText/dist/mp-baidu/index.swan +0 -1
  89. package/components/common/RichText/dist/mp-baidu/node/node.css +0 -1
  90. package/components/common/RichText/dist/mp-baidu/node/node.js +0 -1
  91. package/components/common/RichText/dist/mp-baidu/node/node.json +0 -1
  92. package/components/common/RichText/dist/mp-baidu/node/node.swan +0 -1
  93. package/components/common/RichText/dist/mp-baidu/parser.js +0 -1
  94. package/components/common/RichText/dist/mp-qq/index.js +0 -8
  95. package/components/common/RichText/dist/mp-qq/index.json +0 -1
  96. package/components/common/RichText/dist/mp-qq/index.qml +0 -1
  97. package/components/common/RichText/dist/mp-qq/index.qss +0 -1
  98. package/components/common/RichText/dist/mp-qq/node/node.js +0 -1
  99. package/components/common/RichText/dist/mp-qq/node/node.json +0 -1
  100. package/components/common/RichText/dist/mp-qq/node/node.qml +0 -1
  101. package/components/common/RichText/dist/mp-qq/node/node.qss +0 -1
  102. package/components/common/RichText/dist/mp-qq/parser.js +0 -1
  103. package/components/common/RichText/dist/mp-toutiao/index.js +0 -8
  104. package/components/common/RichText/dist/mp-toutiao/index.json +0 -1
  105. package/components/common/RichText/dist/mp-toutiao/index.ttml +0 -1
  106. package/components/common/RichText/dist/mp-toutiao/index.ttss +0 -1
  107. package/components/common/RichText/dist/mp-toutiao/node/node.js +0 -1
  108. package/components/common/RichText/dist/mp-toutiao/node/node.json +0 -1
  109. package/components/common/RichText/dist/mp-toutiao/node/node.ttml +0 -1
  110. package/components/common/RichText/dist/mp-toutiao/node/node.ttss +0 -1
  111. package/components/common/RichText/dist/mp-toutiao/parser.js +0 -1
  112. package/components/common/RichText/dist/mp-weixin/index.js +0 -8
  113. package/components/common/RichText/dist/mp-weixin/index.json +0 -1
  114. package/components/common/RichText/dist/mp-weixin/index.wxml +0 -1
  115. package/components/common/RichText/dist/mp-weixin/index.wxss +0 -1
  116. package/components/common/RichText/dist/mp-weixin/node/node.js +0 -1
  117. package/components/common/RichText/dist/mp-weixin/node/node.json +0 -1
  118. package/components/common/RichText/dist/mp-weixin/node/node.wxml +0 -1
  119. package/components/common/RichText/dist/mp-weixin/node/node.wxss +0 -1
  120. package/components/common/RichText/dist/mp-weixin/parser.js +0 -1
  121. package/components/common/RichText/dist/uni-app/components/mp-html/mp-html.vue +0 -498
  122. package/components/common/RichText/dist/uni-app/components/mp-html/node/node.vue +0 -587
  123. package/components/common/RichText/dist/uni-app/components/mp-html/parser.js +0 -1393
  124. package/components/common/RichText/dist/uni-app/static/app-plus/mp-html/js/handler.js +0 -1
  125. package/components/common/RichText/dist/uni-app/static/app-plus/mp-html/js/uni.webview.min.js +0 -1
  126. package/components/common/RichText/dist/uni-app/static/app-plus/mp-html/local.html +0 -1
  127. package/components/common/RichText/docs/.nojekyll +0 -0
  128. package/components/common/RichText/docs/index.html +0 -50
  129. package/components/common/RichText/docs/lib/docsify.min.js +0 -1
  130. package/components/common/RichText/docs/lib/prism-bash.min.js +0 -1
  131. package/components/common/RichText/docs/lib/search.min.js +0 -1
  132. package/components/common/RichText/docs/lib/vue.css +0 -858
  133. package/components/common/RichText/gulpfile.js +0 -113
  134. package/components/common/RichText/lint.js +0 -63
  135. package/components/common/RichText/package.json +0 -74
  136. package/components/common/RichText/plugins/README.md +0 -2
  137. package/components/common/RichText/plugins/audio/README.md +0 -25
  138. package/components/common/RichText/plugins/audio/build.js +0 -11
  139. package/components/common/RichText/plugins/audio/context.js +0 -7
  140. package/components/common/RichText/plugins/audio/index.js +0 -34
  141. package/components/common/RichText/plugins/audio/miniprogram/audio.js +0 -189
  142. package/components/common/RichText/plugins/audio/miniprogram/audio.json +0 -3
  143. package/components/common/RichText/plugins/audio/miniprogram/audio.wxml +0 -17
  144. package/components/common/RichText/plugins/audio/miniprogram/audio.wxss +0 -127
  145. package/components/common/RichText/plugins/audio/miniprogram/build.js +0 -3
  146. package/components/common/RichText/plugins/audio/uni-app/audio.vue +0 -269
  147. package/components/common/RichText/plugins/audio/uni-app/build.js +0 -3
  148. package/components/common/RichText/plugins/card/README.md +0 -30
  149. package/components/common/RichText/plugins/card/build.js +0 -14
  150. package/components/common/RichText/plugins/card/index.js +0 -7
  151. package/components/common/RichText/plugins/card/miniprogram/build.js +0 -3
  152. package/components/common/RichText/plugins/card/miniprogram/card.js +0 -26
  153. package/components/common/RichText/plugins/card/miniprogram/card.json +0 -3
  154. package/components/common/RichText/plugins/card/miniprogram/card.wxml +0 -9
  155. package/components/common/RichText/plugins/card/miniprogram/card.wxss +0 -55
  156. package/components/common/RichText/plugins/card/uni-app/build.js +0 -3
  157. package/components/common/RichText/plugins/card/uni-app/card.vue +0 -122
  158. package/components/common/RichText/plugins/editable/README.md +0 -137
  159. package/components/common/RichText/plugins/editable/config.js +0 -15
  160. package/components/common/RichText/plugins/editable/miniprogram/build.js +0 -813
  161. package/components/common/RichText/plugins/editable/miniprogram/index.js +0 -551
  162. package/components/common/RichText/plugins/editable/uni-app/build.js +0 -744
  163. package/components/common/RichText/plugins/editable/uni-app/index.js +0 -553
  164. package/components/common/RichText/plugins/emoji/README.md +0 -15
  165. package/components/common/RichText/plugins/emoji/index.js +0 -203
  166. package/components/common/RichText/plugins/highlight/README.md +0 -26
  167. package/components/common/RichText/plugins/highlight/config.js +0 -5
  168. package/components/common/RichText/plugins/highlight/index.js +0 -96
  169. package/components/common/RichText/plugins/highlight/miniprogram/build.js +0 -88
  170. package/components/common/RichText/plugins/highlight/prism.css +0 -125
  171. package/components/common/RichText/plugins/highlight/prism.min.js +0 -7
  172. package/components/common/RichText/plugins/highlight/uni-app/build.js +0 -88
  173. package/components/common/RichText/plugins/img-cache/README.md +0 -24
  174. package/components/common/RichText/plugins/img-cache/build.js +0 -16
  175. package/components/common/RichText/plugins/img-cache/index.js +0 -138
  176. package/components/common/RichText/plugins/latex/README.md +0 -16
  177. package/components/common/RichText/plugins/latex/build.js +0 -14
  178. package/components/common/RichText/plugins/latex/index.js +0 -77
  179. package/components/common/RichText/plugins/latex/katex.css +0 -1070
  180. package/components/common/RichText/plugins/latex/katex.min.js +0 -1
  181. package/components/common/RichText/plugins/markdown/README.md +0 -17
  182. package/components/common/RichText/plugins/markdown/index.js +0 -34
  183. package/components/common/RichText/plugins/markdown/marked.min.js +0 -6
  184. package/components/common/RichText/plugins/markdown/miniprogram/build.js +0 -70
  185. package/components/common/RichText/plugins/markdown/uni-app/build.js +0 -68
  186. package/components/common/RichText/plugins/search/README.md +0 -46
  187. package/components/common/RichText/plugins/search/miniprogram/index.js +0 -137
  188. package/components/common/RichText/plugins/search/uni-app/index.js +0 -132
  189. package/components/common/RichText/plugins/style/README.md +0 -30
  190. package/components/common/RichText/plugins/style/index.js +0 -129
  191. package/components/common/RichText/plugins/style/parser.js +0 -175
  192. package/components/common/RichText/plugins/template/README.md +0 -2
  193. package/components/common/RichText/plugins/template/build.js +0 -65
  194. package/components/common/RichText/plugins/template/index.js +0 -67
  195. package/components/common/RichText/plugins/txv-video/README.md +0 -18
  196. package/components/common/RichText/plugins/txv-video/build.js +0 -3
  197. package/components/common/RichText/plugins/txv-video/index.js +0 -46
  198. package/components/common/RichText/plugins/txv-video/miniprogram/build.js +0 -6
  199. package/components/common/RichText/plugins/txv-video/uni-app/build.js +0 -3
  200. package/components/common/RichText/src/miniprogram/index.js +0 -396
  201. package/components/common/RichText/src/miniprogram/index.json +0 -6
  202. package/components/common/RichText/src/miniprogram/index.wxml +0 -7
  203. package/components/common/RichText/src/miniprogram/index.wxss +0 -13
  204. package/components/common/RichText/src/miniprogram/node/node.js +0 -247
  205. package/components/common/RichText/src/miniprogram/node/node.json +0 -6
  206. package/components/common/RichText/src/miniprogram/node/node.wxml +0 -112
  207. package/components/common/RichText/src/miniprogram/node/node.wxss +0 -164
  208. package/components/common/RichText/src/miniprogram/parser.js +0 -1269
  209. package/components/common/RichText/src/uni-app/components/mp-html/mp-html.vue +0 -498
  210. package/components/common/RichText/src/uni-app/components/mp-html/node/node.vue +0 -585
  211. package/components/common/RichText/src/uni-app/components/mp-html/parser.js +0 -1393
  212. package/components/common/RichText/src/uni-app/static/app-plus/mp-html/js/handler.js +0 -254
  213. package/components/common/RichText/src/uni-app/static/app-plus/mp-html/js/uni.webview.min.js +0 -1
  214. package/components/common/RichText/src/uni-app/static/app-plus/mp-html/local.html +0 -33
  215. package/components/common/RichText/tools/config.js +0 -82
  216. package/components/common/RichText/tools/converter.js +0 -205
  217. package/components/common/RichText/tools/ifdef.js +0 -115
  218. package/components/common/RichText/tools/minifier.js +0 -40
  219. package/components/common/RichText/tools/plugin.js +0 -248
  220. package/components/message-customer-service.vue +0 -114
  221. package/script/fileCopy.js +0 -60
  222. package/script/syncVersion.js +0 -35
  223. /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
  224. /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
  225. /package/components/{message-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-single-form}/form-branch.vue +0 -0
@@ -1,254 +0,0 @@
1
- // 等待初始化完毕
2
- document.addEventListener('UniAppJSBridgeReady', () => {
3
- document.body.onclick = () =>
4
- uni.postMessage({
5
- data: {
6
- action: 'onClick'
7
- }
8
- })
9
- uni.postMessage({
10
- data: {
11
- action: 'onJSBridgeReady'
12
- }
13
- })
14
- })
15
-
16
- let options
17
- let medias = []
18
-
19
- /**
20
- * @description 获取标签的所有属性
21
- * @param {Element} ele
22
- */
23
- function getAttrs (ele) {
24
- const attrs = Object.create(null)
25
- for (let i = ele.attributes.length; i--;) {
26
- attrs[ele.attributes[i].name] = ele.attributes[i].value
27
- }
28
- return attrs
29
- }
30
-
31
- /**
32
- * @description 图片加载出错
33
- */
34
- function onImgError () {
35
- if (options[1]) {
36
- this.src = options[1]
37
- this.onerror = null
38
- }
39
- // 取消监听点击
40
- this.onclick = null
41
- this.ontouchstart = null
42
- uni.postMessage({
43
- data: {
44
- action: 'onError',
45
- source: 'img',
46
- attrs: getAttrs(this)
47
- }
48
- })
49
- }
50
-
51
- /**
52
- * @description 检查是否所有图片加载完毕
53
- */
54
- function checkReady () {
55
- window.unloadimgs -= 1
56
- if (window.unloadimgs === 0) {
57
- // 所有图片加载完毕
58
- uni.postMessage({
59
- data: {
60
- action: 'onReady'
61
- }
62
- })
63
- }
64
- }
65
-
66
- /**
67
- * @description 创建 dom 结构
68
- * @param {object[]} nodes 节点数组
69
- * @param {Element} parent 父节点
70
- * @param {string} namespace 命名空间
71
- */
72
- function createDom (nodes, parent, namespace) {
73
- for (let i = 0; i < nodes.length; i++) {
74
- const node = nodes[i]
75
- let ele
76
- if (!node.type || node.type === 'node') {
77
- let name = node.name
78
- // svg 需要设置 namespace
79
- if (name === 'svg') {
80
- namespace = 'http://www.w3.org/2000/svg'
81
- }
82
- if (name === 'html' || name === 'body') {
83
- name = 'div'
84
- }
85
- // 创建标签
86
- if (!namespace) {
87
- ele = document.createElement(name)
88
- } else {
89
- ele = document.createElementNS(namespace, name)
90
- }
91
- // 设置属性
92
- for (const item in node.attrs) {
93
- ele.setAttribute(item, node.attrs[item])
94
- }
95
- // 递归创建子节点
96
- if (node.children) {
97
- createDom(node.children, ele, namespace)
98
- }
99
-
100
- // 处理图片
101
- if (name === 'img') {
102
- window.unloadimgs += 1
103
- ele.onload = checkReady
104
- ele.onerror = checkReady
105
- if (!ele.src && ele.getAttribute('data-src')) {
106
- ele.src = ele.getAttribute('data-src')
107
- }
108
- if (!node.attrs.ignore) {
109
- // 监听图片点击事件
110
- ele.onclick = function (e) {
111
- e.stopPropagation()
112
- uni.postMessage({
113
- data: {
114
- action: 'onImgTap',
115
- attrs: getAttrs(this)
116
- }
117
- })
118
- }
119
- }
120
- if (options[2]) {
121
- const image = new Image()
122
- image.src = ele.src
123
- ele.src = options[2]
124
- image.onload = function () {
125
- ele.src = this.src
126
- }
127
- image.onerror = function () {
128
- ele.onerror()
129
- }
130
- }
131
- ele.onerror = onImgError
132
- } else if (name === 'a') {
133
- // 处理链接
134
- ele.addEventListener('click', function (e) {
135
- e.stopPropagation()
136
- e.preventDefault() // 阻止默认跳转
137
- const href = this.getAttribute('href')
138
- let offset
139
- if (href && href[0] === '#') {
140
- offset = (document.getElementById(href.substr(1)) || {}).offsetTop
141
- }
142
- uni.postMessage({
143
- data: {
144
- action: 'onLinkTap',
145
- attrs: getAttrs(this),
146
- offset
147
- }
148
- })
149
- }, true)
150
- } else if (name === 'video' || name === 'audio') {
151
- // 处理音视频
152
- medias.push(ele)
153
- if (!node.attrs.autoplay && !node.attrs.controls) {
154
- ele.setAttribute('controls', 'true')
155
- }
156
- ele.onplay = function () {
157
- uni.postMessage({
158
- data: {
159
- action: 'onPlay'
160
- }
161
- })
162
- if (options[3]) {
163
- for (let i = 0; i < medias.length; i++) {
164
- if (medias[i] !== this) {
165
- medias[i].pause()
166
- }
167
- }
168
- }
169
- }
170
- ele.onerror = function () {
171
- uni.postMessage({
172
- data: {
173
- action: 'onError',
174
- source: name,
175
- attrs: getAttrs(this)
176
- }
177
- })
178
- }
179
- } else if (name === 'table' && options[4] && !ele.style.cssText.includes('inline')) {
180
- // 处理表格
181
- const div = document.createElement('div')
182
- div.style.overflow = 'auto'
183
- div.appendChild(ele)
184
- ele = div
185
- } else if (name === 'svg') {
186
- namespace = undefined
187
- }
188
- } else {
189
- ele = document.createTextNode(node.text.replace(/&amp;/g, '&'))
190
- }
191
- parent.appendChild(ele)
192
- }
193
- }
194
-
195
- // 设置 html 内容
196
- window.setContent = function (nodes, opts, append) {
197
- const ele = document.getElementById('content')
198
-
199
- // 容器样式
200
- if (opts[0]) {
201
- document.body.style.cssText = opts[0]
202
- }
203
-
204
- // 长按复制
205
- if (!opts[5]) {
206
- ele.style.userSelect = 'none'
207
- }
208
-
209
- if (!append) {
210
- ele.innerHTML = '' // 不追加则先清空
211
- medias = []
212
- }
213
-
214
- options = opts
215
- window.unloadimgs = 0
216
- const fragment = document.createDocumentFragment()
217
- createDom(nodes, fragment)
218
- ele.appendChild(fragment)
219
-
220
- // 触发事件
221
- let height = ele.scrollHeight
222
- uni.postMessage({
223
- data: {
224
- action: 'onLoad',
225
- height
226
- }
227
- })
228
- if (!window.unloadimgs) {
229
- uni.postMessage({
230
- data: {
231
- action: 'onReady',
232
- height
233
- }
234
- })
235
- }
236
-
237
- clearInterval(window.timer)
238
- window.timer = setInterval(() => {
239
- if (ele.scrollHeight !== height) {
240
- height = ele.scrollHeight
241
- uni.postMessage({
242
- data: {
243
- action: 'onHeightChange',
244
- height: height
245
- }
246
- })
247
- }
248
- }, 350)
249
- }
250
-
251
- // 回收计时器
252
- window.onunload = function () {
253
- clearInterval(window.timer)
254
- }
@@ -1 +0,0 @@
1
- !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).uni=n()}(this,(function(){"use strict";try{var e={};Object.defineProperty(e,"passive",{get:function(){!0}}),window.addEventListener("test-passive",null,e)}catch(e){}var n=Object.prototype.hasOwnProperty;function t(e,t){return n.call(e,t)}var i=[],a=function(e,n){var t={options:{timestamp:+new Date},name:e,arg:n};if(window.__dcloud_weex_postMessage||window.__dcloud_weex_){if("postMessage"===e){var a={data:[n]};return window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessage(a):window.__dcloud_weex_.postMessage(JSON.stringify(a))}var o={type:"WEB_INVOKE_APPSERVICE",args:{data:t,webviewIds:i}};window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessageToService(o):window.__dcloud_weex_.postMessageToService(JSON.stringify(o))}if(!window.plus)return window.parent.postMessage({type:"WEB_INVOKE_APPSERVICE",data:t,pageId:""},"*");if(0===i.length){var r=plus.webview.currentWebview();if(!r)throw new Error("plus.webview.currentWebview() is undefined");var d=r.parent(),s="";s=d?d.id:r.id,i.push(s)}if(plus.webview.getWebviewById("__uniapp__service"))plus.webview.postMessageToUniNView({type:"WEB_INVOKE_APPSERVICE",args:{data:t,webviewIds:i}},"__uniapp__service");else{var w=JSON.stringify(t);plus.webview.getLaunchWebview().evalJS('UniPlusBridge.subscribeHandler("'.concat("WEB_INVOKE_APPSERVICE",'",').concat(w,",").concat(JSON.stringify(i),");"))}},o={navigateTo:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;a("navigateTo",{url:encodeURI(n)})},navigateBack:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.delta;a("navigateBack",{delta:parseInt(n)||1})},switchTab:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;a("switchTab",{url:encodeURI(n)})},reLaunch:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;a("reLaunch",{url:encodeURI(n)})},redirectTo:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;a("redirectTo",{url:encodeURI(n)})},getEnv:function(e){window.plus?e({plus:!0}):e({h5:!0})},postMessage:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a("postMessage",e.data||{})}},r=/uni-app/i.test(navigator.userAgent),d=/Html5Plus/i.test(navigator.userAgent),s=/complete|loaded|interactive/;var w=window.my&&navigator.userAgent.indexOf("AlipayClient")>-1;var u=window.swan&&window.swan.webView&&/swan/i.test(navigator.userAgent);var c=window.qq&&window.qq.miniProgram&&/QQ/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);var g=window.tt&&window.tt.miniProgram&&/toutiaomicroapp/i.test(navigator.userAgent);var v=window.wx&&window.wx.miniProgram&&/micromessenger/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);var p=window.qa&&/quickapp/i.test(navigator.userAgent);for(var l,_=function(){window.UniAppJSBridge=!0,document.dispatchEvent(new CustomEvent("UniAppJSBridgeReady",{bubbles:!0,cancelable:!0}))},f=[function(e){if(r||d)return window.__dcloud_weex_postMessage||window.__dcloud_weex_?document.addEventListener("DOMContentLoaded",e):window.plus&&s.test(document.readyState)?setTimeout(e,0):document.addEventListener("plusready",e),o},function(e){if(v)return window.WeixinJSBridge&&window.WeixinJSBridge.invoke?setTimeout(e,0):document.addEventListener("WeixinJSBridgeReady",e),window.wx.miniProgram},function(e){if(c)return window.QQJSBridge&&window.QQJSBridge.invoke?setTimeout(e,0):document.addEventListener("QQJSBridgeReady",e),window.qq.miniProgram},function(e){if(w){document.addEventListener("DOMContentLoaded",e);var n=window.my;return{navigateTo:n.navigateTo,navigateBack:n.navigateBack,switchTab:n.switchTab,reLaunch:n.reLaunch,redirectTo:n.redirectTo,postMessage:n.postMessage,getEnv:n.getEnv}}},function(e){if(u)return document.addEventListener("DOMContentLoaded",e),window.swan.webView},function(e){if(g)return document.addEventListener("DOMContentLoaded",e),window.tt.miniProgram},function(e){if(p){window.QaJSBridge&&window.QaJSBridge.invoke?setTimeout(e,0):document.addEventListener("QaJSBridgeReady",e);var n=window.qa;return{navigateTo:n.navigateTo,navigateBack:n.navigateBack,switchTab:n.switchTab,reLaunch:n.reLaunch,redirectTo:n.redirectTo,postMessage:n.postMessage,getEnv:n.getEnv}}},function(e){return document.addEventListener("DOMContentLoaded",e),o}],m=0;m<f.length&&!(l=f[m](_));m++);l||(l={});var E="undefined"!=typeof uni?uni:{};if(!E.navigateTo)for(var b in l)t(l,b)&&(E[b]=l[b]);return E.webView=l,E}));
@@ -1,33 +0,0 @@
1
- <head>
2
- <meta charset="utf-8">
3
- <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
4
- <style>
5
- html,
6
- body {
7
- width: 100%;
8
- height: 100%;
9
- overflow-x: scroll;
10
- overflow-y: hidden;
11
- }
12
-
13
- body {
14
- margin: 0;
15
- }
16
-
17
- video {
18
- width: 300px;
19
- height: 225px;
20
- }
21
-
22
- img {
23
- max-width: 100%;
24
- -webkit-touch-callout: none;
25
- }
26
- </style>
27
- </head>
28
-
29
- <body>
30
- <div id="content" style="overflow: hidden;"></div>
31
- <script type="text/javascript" src="./js/uni.webview.min.js"></script>
32
- <script type="text/javascript" src="./js/handler.js"></script>
33
- </body>
@@ -1,82 +0,0 @@
1
- /**
2
- * @fileoverview 配置文件
3
- */
4
- module.exports = {
5
- /**
6
- * @description 需要的插件列表
7
- */
8
- plugins: [
9
- // 按需打开注释即可
10
- // 'audio', // 音乐播放器
11
- // 'editable', // 内容编辑
12
- // 'emoji', // 小表情
13
- // 'highlight', // 代码高亮
14
- // 'markdown', // 解析 md
15
- // 'latex', // 解析 latex
16
- // 'search', // 关键词搜索
17
- // 'style', // 解析 style 标签
18
- // 'txv-video', // 使用腾讯视频
19
- // 'img-cache' // 图片缓存
20
- // 'card', // 卡片展示
21
- ],
22
-
23
- /**
24
- * @description 要引入到组件中的外部样式(css)
25
- * 仅支持标签名和 class 选择器
26
- */
27
- externStyle: '',
28
-
29
- /**
30
- * @description 要引入到模板中的自定义标签(ad 等)
31
- * 每个标签为一个 object,包含 name(标签名,必要)、attrs(属性列表,非必要)、platforms(需要添加的平台,非必要)
32
- */
33
- customElements: [
34
- /*
35
- // 需要使用广告标签则打开此注释
36
- {
37
- name: 'ad',
38
- attrs: ['unit-id']
39
- }
40
- */
41
- ],
42
-
43
- /**
44
- * @description babel 配置(es6 转 es5)
45
- * @tutorial https://babeljs.io/docs/usage/options/
46
- */
47
- babel: {
48
- presets: ['@babel/env']
49
- },
50
-
51
- /**
52
- * @description js 压缩配置
53
- * @tutorial https://www.npmjs.com/package/uglify-js#minify-options
54
- */
55
- uglify: {
56
- mangle: {
57
- toplevel: true
58
- },
59
- output: {
60
- comments: /^!/
61
- }
62
- },
63
-
64
- /**
65
- * @description html 压缩配置
66
- * @tutorial https://github.com/kangax/html-minifier#options-quick-reference
67
- */
68
- htmlmin: {
69
- caseSensitive: true,
70
- collapseWhitespace: true,
71
- removeComments: true,
72
- keepClosingSlash: true
73
- },
74
-
75
- /**
76
- * @description css 压缩配置
77
- * @tutorial https://github.com/jakubpawlowicz/clean-css#constructor-options
78
- */
79
- cleanCss: {
80
-
81
- }
82
- }
@@ -1,205 +0,0 @@
1
- /**
2
- * @fileoverview 将微信端的代码转换到各个平台
3
- */
4
- const through2 = require('through2')
5
-
6
- // api 前缀
7
- const prefix = {
8
- weixin: {
9
- wxml: 'wx:',
10
- js: 'wx.'
11
- },
12
- qq: {
13
- wxml: 'qq:',
14
- js: 'qq.'
15
- },
16
- baidu: {
17
- wxml: 's-',
18
- js: 'swan.'
19
- },
20
- alipay: {
21
- wxml: 'a:',
22
- js: 'my.'
23
- },
24
- toutiao: {
25
- wxml: 'tt:',
26
- js: 'tt.'
27
- }
28
- }
29
- // 文件名后缀
30
- const suffix = {
31
- weixin: {
32
- wxml: '.wxml',
33
- wxss: '.wxss'
34
- },
35
- qq: {
36
- wxml: '.qml',
37
- wxss: '.qss'
38
- },
39
- baidu: {
40
- wxml: '.swan',
41
- wxss: '.css'
42
- },
43
- alipay: {
44
- wxml: '.axml',
45
- wxss: '.acss'
46
- },
47
- toutiao: {
48
- wxml: '.ttml',
49
- wxss: '.ttss'
50
- }
51
- }
52
-
53
- /**
54
- * @description 取出两个括号之间的内容
55
- * @param {string} content 总内容
56
- * @param {number} i 开始位置
57
- */
58
- function getSection (content, i) {
59
- let j = i + 1
60
- let num = 1
61
- const start = content[i]
62
- const end = start === '(' ? ')' : '}'
63
- while (num) {
64
- if (content[j] === start) {
65
- num++
66
- } else if (content[j] === end) {
67
- num--
68
- }
69
- j++
70
- }
71
- return content.substring(i, j)
72
- }
73
-
74
- /**
75
- * @description 处理不同小程序平台间的差异
76
- * @param {string} platform 使用平台
77
- */
78
- module.exports = function (platform) {
79
- if (platform !== 'uni-app') {
80
- platform = platform.split('-')[1]
81
- }
82
- return through2.obj(function (file, _, callback) {
83
- if (file.isBuffer()) {
84
- let content = file.contents.toString()
85
- if (platform === 'uni-app') {
86
- if (file.extname === '.js') {
87
- content = content.replace(/\.properties/g, '')
88
- }
89
- } else {
90
- // wxml 文件处理
91
- if (file.extname === '.wxml') {
92
- content = content.replace(/wx:/g, prefix[platform].wxml) // 替换 api 前缀
93
- file.extname = suffix[platform].wxml // 修改后缀名
94
- if (platform === 'qq') {
95
- // wxs 转为 qs
96
- content = content.replace(/<wxs/g, '<qs').replace(/<\/wxs/g, '</qs')
97
- } else if (platform === 'baidu') {
98
- content = content.replace(/s-if=['"]{{(\S+)}}['"]/g, 's-if="$1"') // s-if 和 s-for 后不加 {{}}
99
- .replace(/s-for=['"]{{(\S+)}}['"]/g, 's-for="$1"')
100
- .replace(/data="(.*?)"/g, 'data="{$1}"')
101
- } else if (platform === 'alipay') {
102
- content = content.replace('block-size', 'handle-size')
103
- .replace(/longpress/g, 'longTap')
104
- .replace(/bind([\S])/g, (_, $1) => { // bindevent 转为 onEvent
105
- return 'on' + $1.toUpperCase()
106
- }).replace(/catch([\S])/g, (_, $1) => { // catchevent 转为 catchEvent
107
- return 'catch' + $1.toUpperCase()
108
- })
109
- }
110
- } else if (file.extname === '.js') {
111
- // js 文件处理
112
- // 替换 api 前缀
113
- content = content.replace(/wx\./g, prefix[platform].js)
114
-
115
- // 支付宝格式转换
116
- if (platform === 'alipay') {
117
- // 将 aa.triggerEvent('bb', cc) 替换为 aa.props.onBb && aa.props.onBb(cc)
118
- content = content.replace(/([a-zA-Z0-9._]+).triggerEvent\(['"](\S+?)['"],*/g, function (_, $1, $2) {
119
- const method = `${$1}.props.on${$2[0].toUpperCase()}${$2.slice(1)}`
120
- return `${method}&&${method}(`
121
- })
122
-
123
- // 转换 showToast
124
- let i = content.indexOf('.showToast')
125
- while (i !== -1) {
126
- i += 10
127
- const section = getSection(content, i)
128
- content = content.substr(0, i) + section.replace('title', 'content') + content.substr(i + section.length)
129
- i = content.indexOf('.showToast', i)
130
- }
131
- // 转换 showActionSheet
132
- i = content.indexOf('.showActionSheet')
133
- while (i !== -1) {
134
- i += 16
135
- const section = getSection(content, i)
136
- content = content.substr(0, i) + section.replace('itemList', 'items') + content.substr(i + section.length)
137
- i = content.indexOf('.showActionSheet', i)
138
- }
139
- // 转换 setClipboardData
140
- i = content.indexOf('.setClipboardData')
141
- while (i !== -1) {
142
- i += 17
143
- const section = getSection(content, i)
144
- content = content.substr(0, i - 4) + section.replace('data', 'text') + content.substr(i + section.length)
145
- i = content.indexOf('.setClipboardData', i)
146
- }
147
- // 组件格式转换
148
- if (content.includes('Component({')) {
149
- // 替换生命周期
150
- content = content.replace('created:', 'didMount:')
151
- .replace('attached:', 'didMount:')
152
- .replace('detached:', 'didUnmount:')
153
- // 将 properties 字段转为 props 格式
154
- i = content.indexOf('{', content.indexOf('properties:'))
155
- let props
156
- let propsStr = '{'
157
- const objStr = getSection(content, i)
158
- // 取出整个 properties 字段
159
- eval('props = ' + objStr) // eslint-disable-line
160
- for (const item in props) {
161
- if (!props[item]) continue
162
- propsStr += item + ':'
163
- if (props[item].value) {
164
- // 设置了默认值
165
- if (typeof props[item].value === 'boolean') {
166
- propsStr += props[item].value ? '!0' : '!1'
167
- } else {
168
- propsStr += props[item].value
169
- }
170
- } else {
171
- // 没有设置默认值
172
- const type = props[item].type || props[item]
173
- if (type === String) {
174
- propsStr += '""'
175
- } else if (type === Boolean) {
176
- propsStr += '!1'
177
- } else if (type === Number) {
178
- propsStr += '0'
179
- } else if (type === Object) {
180
- propsStr += '{}'
181
- } else if (type === Array) {
182
- propsStr += '[]'
183
- }
184
- }
185
- propsStr += ','
186
- }
187
- content = content.substr(0, i) + propsStr.substring(0, propsStr.length - 1) + '}' + content.substr(i + objStr.length)
188
- }
189
-
190
- content = content.replace(/properties/g, 'props')
191
- .replace(/\.setNavigationBarTitle/g, '.setNavigationBar')
192
- } else {
193
- content = content.replace(/\.properties/g, '.data')
194
- }
195
- } else if (file.extname === '.wxss') {
196
- // wxss 文件处理
197
- file.extname = suffix[platform].wxss // 修改后缀名
198
- }
199
- }
200
- file.contents = Buffer.from(content)
201
- }
202
- this.push(file)
203
- callback()
204
- })
205
- }
@@ -1,115 +0,0 @@
1
- /**
2
- * @fileoverview 条件编译
3
- */
4
- const through2 = require('through2')
5
-
6
- /**
7
- * @description 条件编译
8
- * @param {string} platform 平台
9
- */
10
- module.exports = function (platform) {
11
- return through2.obj(function (file, _, callback) {
12
- if (file.isBuffer()) {
13
- // 文件夹级别的处理
14
- if (file.relative.includes('miniprogram')) {
15
- if (platform !== 'uni-app') {
16
- // 去掉这一层
17
- file.path = file.path.replace(/(.*)[/\\]miniprogram/, '$1')
18
- } else {
19
- // 不用于本平台的文件
20
- callback()
21
- return
22
- }
23
- } else if (file.relative.includes('uni-app')) {
24
- if (platform === 'uni-app') {
25
- file.path = file.path.replace(/(.*)[/\\]uni-app/, '$1')
26
- } else {
27
- callback()
28
- return
29
- }
30
- }
31
- if (platform === 'uni-app') {
32
- // uni-app 平台 vue3 要求使用 es6 模块
33
- let content = file.contents.toString()
34
- if (file.basename === 'prism.min.js') {
35
- content = content.replace('"undefined"!=typeof module&&module.exports&&(module.exports=Prism),', 'export default Prism;')
36
- } else if (file.extname === '.js' && !file.relative.includes('static')) {
37
- content = content.replace(/module.exports\s*=\s*/, 'export default ')
38
- .replace(/const\s+([^\s=]+)\s*=\s*require\(([^)]+)\)/g, 'import $1 from $2')
39
- }
40
- file.contents = Buffer.from(content)
41
- } else {
42
- // 小程序平台进行进一步处理
43
- let content = file.contents.toString()
44
- /**
45
- * 方式1:
46
- * 在注释 #if(n)def xxx 和 #endif 之间的内容会根据是否定义 xxx 决定是否保留
47
- */
48
- const commentReg = /\/\*[\s\S]*?\*\/|\/\/[^\n]*|<!--[\s\S]*?-->/g // 提取所有注释
49
- const copy = content // 拷贝一个副本用于搜索
50
- let match = commentReg.exec(copy)
51
- const stack = []
52
- while (match) {
53
- if (match[0].includes('#if')) {
54
- stack.push([match[0], match.index])
55
- } else if (match[0].includes('#endif')) {
56
- const item = stack.pop()
57
- if (!item) {
58
- throw Error('条件编译错误:存在多余的 #endif,path:' + file.path + ',content: ' + content.substr(match.index, 100))
59
- }
60
- const def = item[0].match(/MP-[A-Z]+/gi) || [] // 取出定义条件
61
- let hit = false
62
- for (let i = 0; i < def.length; i++) {
63
- if (def[i] && platform === def[i].toLowerCase()) {
64
- hit = true // 命中
65
- break
66
- }
67
- }
68
- // 不匹配
69
- if ((item[0].includes('#ifdef') && !hit) || (item[0].includes('#ifndef') && hit)) {
70
- let fill = ''
71
- // 用空格填充
72
- for (let j = item[1] + item[0].length; j < match.index; j++) {
73
- if (content[j] === '\n') {
74
- fill += '\n'
75
- } else {
76
- fill += ' '
77
- }
78
- }
79
- content = content.substr(0, item[1] + item[0].length) + fill + content.substr(match.index)
80
- }
81
- }
82
- match = commentReg.exec(copy)
83
- }
84
- if (stack.length) {
85
- throw Error('条件编译错误:存在未闭合的 #ifdef,path:' + file.path + ',content: ' + content.substr(stack[0][1], 100))
86
- }
87
-
88
- /**
89
- * 方式2:
90
- * wxml 中属性前加平台名将仅编译到该平台,如 mp-weixin:attr
91
- */
92
- if (file.extname === '.wxml') {
93
- content = content.replace(/([^:\s]+:[^=\s]+)\s*=\s*"(.*?)"/g, ($, $1, $2) => {
94
- const platforms = $1.split(':')
95
- let name = platforms.pop()
96
- const last = platforms[platforms.length - 1]
97
- if (last && !last.includes('mp')) {
98
- name = platforms.pop() + ':' + name
99
- }
100
- if (!platforms.length) return $
101
- let i
102
- for (i = platforms.length; i--;) {
103
- if (platform === platforms[i].toLowerCase()) break
104
- }
105
- if (i >= 0) return `${name}="${$2}"`
106
- return ''
107
- })
108
- }
109
- file.contents = Buffer.from(content)
110
- }
111
- }
112
- this.push(file)
113
- callback()
114
- })
115
- }