@gmcb/uv-ui 0.2.26

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 (285) hide show
  1. package/CHANGELOG.md +295 -0
  2. package/LICENSE +21 -0
  3. package/README.md +164 -0
  4. package/components/uv-action-sheet/props.js +50 -0
  5. package/components/uv-action-sheet/uv-action-sheet.vue +280 -0
  6. package/components/uv-album/uv-album.vue +312 -0
  7. package/components/uv-alert/props.js +45 -0
  8. package/components/uv-alert/uv-alert.vue +246 -0
  9. package/components/uv-avatar/props.js +85 -0
  10. package/components/uv-avatar/uv-avatar.vue +182 -0
  11. package/components/uv-avatar-group/props.js +53 -0
  12. package/components/uv-avatar-group/uv-avatar-group.vue +106 -0
  13. package/components/uv-back-top/props.js +58 -0
  14. package/components/uv-back-top/uv-back-top.vue +116 -0
  15. package/components/uv-badge/props.js +73 -0
  16. package/components/uv-badge/uv-badge.vue +176 -0
  17. package/components/uv-button/nvue.scss +46 -0
  18. package/components/uv-button/props.js +163 -0
  19. package/components/uv-button/uv-button.vue +529 -0
  20. package/components/uv-button/vue.scss +93 -0
  21. package/components/uv-calendar/calendar.js +546 -0
  22. package/components/uv-calendar/header.vue +104 -0
  23. package/components/uv-calendar/month.vue +616 -0
  24. package/components/uv-calendar/props.js +145 -0
  25. package/components/uv-calendar/uv-calendar.vue +390 -0
  26. package/components/uv-calendars/calendar-body.vue +376 -0
  27. package/components/uv-calendars/calendar-item.vue +248 -0
  28. package/components/uv-calendars/calendar.js +546 -0
  29. package/components/uv-calendars/i18n/en.json +12 -0
  30. package/components/uv-calendars/i18n/index.js +8 -0
  31. package/components/uv-calendars/i18n/zh-Hans.json +12 -0
  32. package/components/uv-calendars/i18n/zh-Hant.json +12 -0
  33. package/components/uv-calendars/util.js +435 -0
  34. package/components/uv-calendars/uv-calendars.vue +452 -0
  35. package/components/uv-cell/props.js +116 -0
  36. package/components/uv-cell/uv-cell.vue +209 -0
  37. package/components/uv-cell-group/props.js +15 -0
  38. package/components/uv-cell-group/uv-cell-group.vue +63 -0
  39. package/components/uv-checkbox/props.js +70 -0
  40. package/components/uv-checkbox/uv-checkbox.vue +371 -0
  41. package/components/uv-checkbox-group/props.js +84 -0
  42. package/components/uv-checkbox-group/uv-checkbox-group.vue +119 -0
  43. package/components/uv-code/props.js +35 -0
  44. package/components/uv-code/uv-code.vue +136 -0
  45. package/components/uv-code-input/props.js +83 -0
  46. package/components/uv-code-input/uv-code-input.vue +272 -0
  47. package/components/uv-col/props.js +30 -0
  48. package/components/uv-col/uv-col.vue +165 -0
  49. package/components/uv-collapse/props.js +20 -0
  50. package/components/uv-collapse/uv-collapse.vue +86 -0
  51. package/components/uv-collapse-item/props.js +60 -0
  52. package/components/uv-collapse-item/uv-collapse-item.vue +228 -0
  53. package/components/uv-column-notice/props.js +61 -0
  54. package/components/uv-column-notice/uv-column-notice.vue +176 -0
  55. package/components/uv-count-down/props.js +25 -0
  56. package/components/uv-count-down/utils.js +62 -0
  57. package/components/uv-count-down/uv-count-down.vue +169 -0
  58. package/components/uv-count-to/props.js +60 -0
  59. package/components/uv-count-to/uv-count-to.vue +187 -0
  60. package/components/uv-datetime-picker/props.js +130 -0
  61. package/components/uv-datetime-picker/uv-datetime-picker.vue +355 -0
  62. package/components/uv-divider/props.js +45 -0
  63. package/components/uv-divider/uv-divider.vue +113 -0
  64. package/components/uv-drop-down/uv-drop-down.vue +135 -0
  65. package/components/uv-drop-down-item/uv-drop-down-item.vue +169 -0
  66. package/components/uv-drop-down-popup/uv-drop-down-popup.vue +242 -0
  67. package/components/uv-empty/props.js +60 -0
  68. package/components/uv-empty/uv-empty.vue +126 -0
  69. package/components/uv-form/props.js +46 -0
  70. package/components/uv-form/uv-form.vue +209 -0
  71. package/components/uv-form/valid.js +1343 -0
  72. package/components/uv-form-item/props.js +49 -0
  73. package/components/uv-form-item/uv-form-item.vue +226 -0
  74. package/components/uv-gap/props.js +25 -0
  75. package/components/uv-gap/uv-gap.vue +36 -0
  76. package/components/uv-grid/props.js +20 -0
  77. package/components/uv-grid/uv-grid.vue +100 -0
  78. package/components/uv-grid-item/props.js +15 -0
  79. package/components/uv-grid-item/uv-grid-item.vue +223 -0
  80. package/components/uv-icon/icons.js +160 -0
  81. package/components/uv-icon/props.js +90 -0
  82. package/components/uv-icon/uv-icon.vue +226 -0
  83. package/components/uv-icon/uvicons.ttf +0 -0
  84. package/components/uv-image/props.js +100 -0
  85. package/components/uv-image/uv-image.vue +296 -0
  86. package/components/uv-index-anchor/props.js +30 -0
  87. package/components/uv-index-anchor/uv-index-anchor.vue +98 -0
  88. package/components/uv-index-item/uv-index-item.vue +87 -0
  89. package/components/uv-index-list/props.js +30 -0
  90. package/components/uv-index-list/uv-index-list.vue +461 -0
  91. package/components/uv-input/props.js +175 -0
  92. package/components/uv-input/uv-input.vue +348 -0
  93. package/components/uv-keyboard/props.js +95 -0
  94. package/components/uv-keyboard/uv-keyboard.vue +180 -0
  95. package/components/uv-keyboard-car/props.js +24 -0
  96. package/components/uv-keyboard-car/uv-keyboard-car.vue +347 -0
  97. package/components/uv-keyboard-number/props.js +19 -0
  98. package/components/uv-keyboard-number/uv-keyboard-number.vue +201 -0
  99. package/components/uv-line/props.js +34 -0
  100. package/components/uv-line/uv-line.vue +60 -0
  101. package/components/uv-line-progress/props.js +29 -0
  102. package/components/uv-line-progress/uv-line-progress.vue +146 -0
  103. package/components/uv-link/props.js +40 -0
  104. package/components/uv-link/uv-link.vue +83 -0
  105. package/components/uv-list/uv-list.vue +147 -0
  106. package/components/uv-list-item/uv-list-item.vue +535 -0
  107. package/components/uv-load-more/props.js +95 -0
  108. package/components/uv-load-more/uv-load-more.vue +152 -0
  109. package/components/uv-loading-icon/props.js +67 -0
  110. package/components/uv-loading-icon/uv-loading-icon.vue +347 -0
  111. package/components/uv-loading-page/props.js +55 -0
  112. package/components/uv-loading-page/uv-loading-page.vue +96 -0
  113. package/components/uv-modal/props.js +90 -0
  114. package/components/uv-modal/uv-modal.vue +245 -0
  115. package/components/uv-navbar/props.js +89 -0
  116. package/components/uv-navbar/uv-navbar.vue +245 -0
  117. package/components/uv-no-network/props.js +20 -0
  118. package/components/uv-no-network/uv-no-network.vue +222 -0
  119. package/components/uv-notice-bar/props.js +76 -0
  120. package/components/uv-notice-bar/uv-notice-bar.vue +110 -0
  121. package/components/uv-notify/props.js +45 -0
  122. package/components/uv-notify/uv-notify.vue +220 -0
  123. package/components/uv-number-box/props.js +118 -0
  124. package/components/uv-number-box/uv-number-box.vue +397 -0
  125. package/components/uv-overlay/props.js +25 -0
  126. package/components/uv-overlay/uv-overlay.vue +85 -0
  127. package/components/uv-parse/node/node.vue +576 -0
  128. package/components/uv-parse/parser.js +1335 -0
  129. package/components/uv-parse/uv-parse.vue +498 -0
  130. package/components/uv-pick-color/colors.js +217 -0
  131. package/components/uv-pick-color/props.js +47 -0
  132. package/components/uv-pick-color/uv-pick-color.vue +551 -0
  133. package/components/uv-picker/props.js +95 -0
  134. package/components/uv-picker/uv-picker.vue +329 -0
  135. package/components/uv-popup/keypress.js +45 -0
  136. package/components/uv-popup/uv-popup.vue +537 -0
  137. package/components/uv-preview-video/uv-preview-video.vue +52 -0
  138. package/components/uv-qrcode/cache.js +1 -0
  139. package/components/uv-qrcode/gcanvas/bridge/bridge-weex.js +241 -0
  140. package/components/uv-qrcode/gcanvas/context-2d/FillStyleLinearGradient.js +18 -0
  141. package/components/uv-qrcode/gcanvas/context-2d/FillStylePattern.js +8 -0
  142. package/components/uv-qrcode/gcanvas/context-2d/FillStyleRadialGradient.js +17 -0
  143. package/components/uv-qrcode/gcanvas/context-2d/RenderingContext.js +666 -0
  144. package/components/uv-qrcode/gcanvas/context-webgl/ActiveInfo.js +11 -0
  145. package/components/uv-qrcode/gcanvas/context-webgl/Buffer.js +21 -0
  146. package/components/uv-qrcode/gcanvas/context-webgl/Framebuffer.js +21 -0
  147. package/components/uv-qrcode/gcanvas/context-webgl/GLenum.js +298 -0
  148. package/components/uv-qrcode/gcanvas/context-webgl/GLmethod.js +142 -0
  149. package/components/uv-qrcode/gcanvas/context-webgl/GLtype.js +23 -0
  150. package/components/uv-qrcode/gcanvas/context-webgl/Program.js +21 -0
  151. package/components/uv-qrcode/gcanvas/context-webgl/Renderbuffer.js +21 -0
  152. package/components/uv-qrcode/gcanvas/context-webgl/RenderingContext.js +1191 -0
  153. package/components/uv-qrcode/gcanvas/context-webgl/Shader.js +22 -0
  154. package/components/uv-qrcode/gcanvas/context-webgl/ShaderPrecisionFormat.js +11 -0
  155. package/components/uv-qrcode/gcanvas/context-webgl/Texture.js +22 -0
  156. package/components/uv-qrcode/gcanvas/context-webgl/UniformLocation.js +22 -0
  157. package/components/uv-qrcode/gcanvas/context-webgl/classUtils.js +3 -0
  158. package/components/uv-qrcode/gcanvas/env/canvas.js +74 -0
  159. package/components/uv-qrcode/gcanvas/env/image.js +96 -0
  160. package/components/uv-qrcode/gcanvas/env/tool.js +24 -0
  161. package/components/uv-qrcode/gcanvas/index.js +39 -0
  162. package/components/uv-qrcode/props.js +85 -0
  163. package/components/uv-qrcode/qrcode.js +34 -0
  164. package/components/uv-qrcode/queue.js +41 -0
  165. package/components/uv-qrcode/uv-qrcode.vue +1038 -0
  166. package/components/uv-radio/props.js +65 -0
  167. package/components/uv-radio/uv-radio.vue +349 -0
  168. package/components/uv-radio-group/props.js +89 -0
  169. package/components/uv-radio-group/uv-radio-group.vue +115 -0
  170. package/components/uv-rate/props.js +73 -0
  171. package/components/uv-rate/uv-rate.vue +274 -0
  172. package/components/uv-read-more/props.js +62 -0
  173. package/components/uv-read-more/uv-read-more.vue +162 -0
  174. package/components/uv-row/props.js +20 -0
  175. package/components/uv-row/uv-row.vue +95 -0
  176. package/components/uv-row-notice/props.js +40 -0
  177. package/components/uv-row-notice/uv-row-notice.vue +341 -0
  178. package/components/uv-safe-bottom/uv-safe-bottom.vue +67 -0
  179. package/components/uv-scroll-list/nvue.js +29 -0
  180. package/components/uv-scroll-list/props.js +35 -0
  181. package/components/uv-scroll-list/scrollWxs.wxs +51 -0
  182. package/components/uv-scroll-list/uv-scroll-list.vue +218 -0
  183. package/components/uv-search/props.js +127 -0
  184. package/components/uv-search/uv-search.vue +311 -0
  185. package/components/uv-skeleton/props.js +65 -0
  186. package/components/uv-skeleton/uv-skeleton.vue +250 -0
  187. package/components/uv-skeletons/uv-skeletons.vue +247 -0
  188. package/components/uv-slider/props.js +58 -0
  189. package/components/uv-slider/uv-slider.vue +58 -0
  190. package/components/uv-status-bar/props.js +8 -0
  191. package/components/uv-status-bar/uv-status-bar.vue +54 -0
  192. package/components/uv-steps/props.js +40 -0
  193. package/components/uv-steps/uv-steps.vue +83 -0
  194. package/components/uv-steps-item/props.js +25 -0
  195. package/components/uv-steps-item/uv-steps-item.vue +347 -0
  196. package/components/uv-sticky/props.js +41 -0
  197. package/components/uv-sticky/uv-sticky.vue +223 -0
  198. package/components/uv-subsection/props.js +54 -0
  199. package/components/uv-subsection/uv-subsection.vue +269 -0
  200. package/components/uv-swipe-action/props.js +10 -0
  201. package/components/uv-swipe-action/uv-swipe-action.vue +65 -0
  202. package/components/uv-swipe-action-item/index - backup.wxs +256 -0
  203. package/components/uv-swipe-action-item/index.wxs +225 -0
  204. package/components/uv-swipe-action-item/nvue - backup.js +264 -0
  205. package/components/uv-swipe-action-item/nvue.js +182 -0
  206. package/components/uv-swipe-action-item/props.js +40 -0
  207. package/components/uv-swipe-action-item/uv-swipe-action-item.vue +200 -0
  208. package/components/uv-swipe-action-item/wxs.js +15 -0
  209. package/components/uv-swiper/props.js +136 -0
  210. package/components/uv-swiper/uv-swiper.vue +263 -0
  211. package/components/uv-swiper-indicator/props.js +30 -0
  212. package/components/uv-swiper-indicator/uv-swiper-indicator.vue +112 -0
  213. package/components/uv-switch/props.js +58 -0
  214. package/components/uv-switch/uv-switch.vue +182 -0
  215. package/components/uv-tabbar/props.js +50 -0
  216. package/components/uv-tabbar/uv-tabbar.vue +146 -0
  217. package/components/uv-tabbar-item/props.js +40 -0
  218. package/components/uv-tabbar-item/uv-tabbar-item.vue +146 -0
  219. package/components/uv-tabs/props.js +71 -0
  220. package/components/uv-tabs/uv-tabs.vue +391 -0
  221. package/components/uv-tags/props.js +104 -0
  222. package/components/uv-tags/uv-tags.vue +379 -0
  223. package/components/uv-text/props.js +113 -0
  224. package/components/uv-text/uv-text.vue +218 -0
  225. package/components/uv-text/value.js +87 -0
  226. package/components/uv-textarea/props.js +138 -0
  227. package/components/uv-textarea/uv-textarea.vue +238 -0
  228. package/components/uv-toast/uv-toast.vue +292 -0
  229. package/components/uv-toolbar/props.js +40 -0
  230. package/components/uv-toolbar/uv-toolbar.vue +109 -0
  231. package/components/uv-tooltip/props.js +60 -0
  232. package/components/uv-tooltip/uv-tooltip.vue +372 -0
  233. package/components/uv-transition/createAnimation.js +131 -0
  234. package/components/uv-transition/props.js +31 -0
  235. package/components/uv-transition/uv-transition.vue +320 -0
  236. package/components/uv-upload/mixin.js +22 -0
  237. package/components/uv-upload/props.js +130 -0
  238. package/components/uv-upload/utils.js +151 -0
  239. package/components/uv-upload/uv-upload.vue +488 -0
  240. package/components/uv-vtabs/props.js +79 -0
  241. package/components/uv-vtabs/uv-vtabs.vue +438 -0
  242. package/components/uv-vtabs-item/uv-vtabs-item.vue +68 -0
  243. package/components/uv-waterfall/props.js +69 -0
  244. package/components/uv-waterfall/uv-waterfall.vue +265 -0
  245. package/index.js +82 -0
  246. package/index.scss +7 -0
  247. package/libs/config/config.js +34 -0
  248. package/libs/css/color.scss +32 -0
  249. package/libs/css/common.scss +100 -0
  250. package/libs/css/components.scss +23 -0
  251. package/libs/css/variable.scss +111 -0
  252. package/libs/css/vue.scss +40 -0
  253. package/libs/function/colorGradient.js +134 -0
  254. package/libs/function/compress.js +27 -0
  255. package/libs/function/debounce.js +29 -0
  256. package/libs/function/digit.js +167 -0
  257. package/libs/function/index.js +734 -0
  258. package/libs/function/platform.js +75 -0
  259. package/libs/function/test.js +287 -0
  260. package/libs/function/throttle.js +30 -0
  261. package/libs/luch-request/adapters/index.js +132 -0
  262. package/libs/luch-request/core/InterceptorManager.js +51 -0
  263. package/libs/luch-request/core/Request.js +201 -0
  264. package/libs/luch-request/core/buildFullPath.js +20 -0
  265. package/libs/luch-request/core/defaults.js +33 -0
  266. package/libs/luch-request/core/dispatchRequest.js +6 -0
  267. package/libs/luch-request/core/mergeConfig.js +126 -0
  268. package/libs/luch-request/core/settle.js +16 -0
  269. package/libs/luch-request/helpers/buildURL.js +64 -0
  270. package/libs/luch-request/helpers/combineURLs.js +14 -0
  271. package/libs/luch-request/helpers/isAbsoluteURL.js +14 -0
  272. package/libs/luch-request/index.d.ts +197 -0
  273. package/libs/luch-request/index.js +2 -0
  274. package/libs/luch-request/utils/clone.js +264 -0
  275. package/libs/luch-request/utils.js +135 -0
  276. package/libs/mixin/button.js +13 -0
  277. package/libs/mixin/mixin.js +172 -0
  278. package/libs/mixin/mpMixin.js +8 -0
  279. package/libs/mixin/mpShare.js +13 -0
  280. package/libs/mixin/openType.js +47 -0
  281. package/libs/mixin/touch.js +59 -0
  282. package/libs/util/dayjs.js +216 -0
  283. package/libs/util/route.js +126 -0
  284. package/package.json +28 -0
  285. package/theme.scss +43 -0
@@ -0,0 +1,498 @@
1
+ <template>
2
+ <view id="_root" :class="(selectable?'_select ':'')+'_root'" :style="containerStyle">
3
+ <slot v-if="!nodes[0]" />
4
+ <!-- #ifndef APP-PLUS-NVUE -->
5
+ <node v-else :childs="nodes" :opts="[lazyLoad,loadingImg,errorImg,showImgMenu,selectable]" name="span" />
6
+ <!-- #endif -->
7
+ <!-- #ifdef APP-PLUS-NVUE -->
8
+ <web-view ref="web" src="/static/app-plus/uv-parse/local.html" :style="'margin-top:-2px;height:' + height + 'px'" @onPostMessage="_onMessage" />
9
+ <!-- #endif -->
10
+ </view>
11
+ </template>
12
+
13
+ <script>
14
+ /**
15
+ * uv-parse v1.0.3
16
+ * @description 富文本组件
17
+ * @tutorial https://www.uvui.cn/components/parse.html
18
+ * @property {String} container-style 容器的样式
19
+ * @property {String} content 用于渲染的 html 字符串
20
+ * @property {Boolean} copy-link 是否允许外部链接被点击时自动复制
21
+ * @property {String} domain 主域名,用于拼接链接
22
+ * @property {String} error-img 图片出错时的占位图链接
23
+ * @property {Boolean} lazy-load 是否开启图片懒加载
24
+ * @property {string} loading-img 图片加载过程中的占位图链接
25
+ * @property {Boolean} pause-video 是否在播放一个视频时自动暂停其他视频
26
+ * @property {Boolean} preview-img 是否允许图片被点击时自动预览
27
+ * @property {Boolean} scroll-table 是否给每个表格添加一个滚动层使其能单独横向滚动
28
+ * @property {Boolean | String} selectable 是否开启长按复制
29
+ * @property {Boolean} set-title 是否将 title 标签的内容设置到页面标题
30
+ * @property {Boolean} show-img-menu 是否允许图片被长按时显示菜单
31
+ * @property {Object} tag-style 标签的默认样式
32
+ * @property {Boolean | Number} use-anchor 是否使用锚点链接
33
+ * @event {Function} load dom 结构加载完毕时触发
34
+ * @event {Function} ready 所有图片加载完毕时触发
35
+ * @event {Function} imgtap 图片被点击时触发
36
+ * @event {Function} linktap 链接被点击时触发
37
+ * @event {Function} play 音视频播放时触发
38
+ * @event {Function} error 媒体加载出错时触发
39
+ */
40
+ // #ifndef APP-PLUS-NVUE
41
+ import node from './node/node'
42
+ // #endif
43
+ import Parser from './parser'
44
+ const plugins=[]
45
+ // #ifdef APP-PLUS-NVUE
46
+ const dom = weex.requireModule('dom')
47
+ // #endif
48
+ export default {
49
+ name: 'uv-parse',
50
+ data () {
51
+ return {
52
+ nodes: [],
53
+ // #ifdef APP-PLUS-NVUE
54
+ height: 3
55
+ // #endif
56
+ }
57
+ },
58
+ props: {
59
+ containerStyle: {
60
+ type: String,
61
+ default: ''
62
+ },
63
+ content: {
64
+ type: String,
65
+ default: ''
66
+ },
67
+ copyLink: {
68
+ type: [Boolean, String],
69
+ default: true
70
+ },
71
+ domain: String,
72
+ errorImg: {
73
+ type: String,
74
+ default: ''
75
+ },
76
+ lazyLoad: {
77
+ type: [Boolean, String],
78
+ default: false
79
+ },
80
+ loadingImg: {
81
+ type: String,
82
+ default: ''
83
+ },
84
+ pauseVideo: {
85
+ type: [Boolean, String],
86
+ default: true
87
+ },
88
+ previewImg: {
89
+ type: [Boolean, String],
90
+ default: true
91
+ },
92
+ scrollTable: [Boolean, String],
93
+ selectable: [Boolean, String],
94
+ setTitle: {
95
+ type: [Boolean, String],
96
+ default: true
97
+ },
98
+ showImgMenu: {
99
+ type: [Boolean, String],
100
+ default: true
101
+ },
102
+ tagStyle: Object,
103
+ useAnchor: [Boolean, Number]
104
+ },
105
+ // #ifdef VUE3
106
+ emits: ['load', 'ready', 'imgtap', 'linktap', 'play', 'error'],
107
+ // #endif
108
+ // #ifndef APP-PLUS-NVUE
109
+ components: {
110
+ node
111
+ },
112
+ // #endif
113
+ watch: {
114
+ content (content) {
115
+ this.setContent(content)
116
+ }
117
+ },
118
+ created () {
119
+ this.plugins = []
120
+ for (let i = plugins.length; i--;) {
121
+ this.plugins.push(new plugins[i](this))
122
+ }
123
+ },
124
+ mounted () {
125
+ if (this.content && !this.nodes.length) {
126
+ this.setContent(this.content)
127
+ }
128
+ },
129
+ beforeDestroy () {
130
+ this._hook('onDetached')
131
+ },
132
+ methods: {
133
+ /**
134
+ * @description 将锚点跳转的范围限定在一个 scroll-view 内
135
+ * @param {Object} page scroll-view 所在页面的示例
136
+ * @param {String} selector scroll-view 的选择器
137
+ * @param {String} scrollTop scroll-view scroll-top 属性绑定的变量名
138
+ */
139
+ in (page, selector, scrollTop) {
140
+ // #ifndef APP-PLUS-NVUE
141
+ if (page && selector && scrollTop) {
142
+ this._in = {
143
+ page,
144
+ selector,
145
+ scrollTop
146
+ }
147
+ }
148
+ // #endif
149
+ },
150
+
151
+ /**
152
+ * @description 锚点跳转
153
+ * @param {String} id 要跳转的锚点 id
154
+ * @param {Number} offset 跳转位置的偏移量
155
+ * @returns {Promise}
156
+ */
157
+ navigateTo (id, offset) {
158
+ return new Promise((resolve, reject) => {
159
+ if (!this.useAnchor) {
160
+ reject(Error('Anchor is disabled'))
161
+ return
162
+ }
163
+ offset = offset || parseInt(this.useAnchor) || 0
164
+ // #ifdef APP-PLUS-NVUE
165
+ if (!id) {
166
+ dom.scrollToElement(this.$refs.web, {
167
+ offset
168
+ })
169
+ resolve()
170
+ } else {
171
+ this._navigateTo = {
172
+ resolve,
173
+ reject,
174
+ offset
175
+ }
176
+ this.$refs.web.evalJs('uni.postMessage({data:{action:"getOffset",offset:(document.getElementById(' + id + ')||{}).offsetTop}})')
177
+ }
178
+ // #endif
179
+ // #ifndef APP-PLUS-NVUE
180
+ let deep = ' '
181
+ // #ifdef MP-WEIXIN || MP-QQ || MP-TOUTIAO
182
+ deep = '>>>'
183
+ // #endif
184
+ const selector = uni.createSelectorQuery()
185
+ // #ifndef MP-ALIPAY
186
+ .in(this._in ? this._in.page : this)
187
+ // #endif
188
+ .select((this._in ? this._in.selector : '._root') + (id ? `${deep}#${id}` : '')).boundingClientRect()
189
+ if (this._in) {
190
+ selector.select(this._in.selector).scrollOffset()
191
+ .select(this._in.selector).boundingClientRect()
192
+ } else {
193
+ // 获取 scroll-view 的位置和滚动距离
194
+ selector.selectViewport().scrollOffset() // 获取窗口的滚动距离
195
+ }
196
+ selector.exec(res => {
197
+ if (!res[0]) {
198
+ reject(Error('Label not found'))
199
+ return
200
+ }
201
+ const scrollTop = res[1].scrollTop + res[0].top - (res[2] ? res[2].top : 0) + offset
202
+ if (this._in) {
203
+ // scroll-view 跳转
204
+ this._in.page[this._in.scrollTop] = scrollTop
205
+ } else {
206
+ // 页面跳转
207
+ uni.pageScrollTo({
208
+ scrollTop,
209
+ duration: 300
210
+ })
211
+ }
212
+ resolve()
213
+ })
214
+ // #endif
215
+ })
216
+ },
217
+
218
+ /**
219
+ * @description 获取文本内容
220
+ * @return {String}
221
+ */
222
+ getText (nodes) {
223
+ let text = '';
224
+ (function traversal (nodes) {
225
+ for (let i = 0; i < nodes.length; i++) {
226
+ const node = nodes[i]
227
+ if (node.type === 'text') {
228
+ text += node.text.replace(/&amp;/g, '&')
229
+ } else if (node.name === 'br') {
230
+ text += '\n'
231
+ } else {
232
+ // 块级标签前后加换行
233
+ 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')
234
+ if (isBlock && text && text[text.length - 1] !== '\n') {
235
+ text += '\n'
236
+ }
237
+ // 递归获取子节点的文本
238
+ if (node.children) {
239
+ traversal(node.children)
240
+ }
241
+ if (isBlock && text[text.length - 1] !== '\n') {
242
+ text += '\n'
243
+ } else if (node.name === 'td' || node.name === 'th') {
244
+ text += '\t'
245
+ }
246
+ }
247
+ }
248
+ })(nodes || this.nodes)
249
+ return text
250
+ },
251
+
252
+ /**
253
+ * @description 获取内容大小和位置
254
+ * @return {Promise}
255
+ */
256
+ getRect () {
257
+ return new Promise((resolve, reject) => {
258
+ uni.createSelectorQuery()
259
+ // #ifndef MP-ALIPAY
260
+ .in(this)
261
+ // #endif
262
+ .select('#_root').boundingClientRect().exec(res => res[0] ? resolve(res[0]) : reject(Error('Root label not found')))
263
+ })
264
+ },
265
+
266
+ /**
267
+ * @description 暂停播放媒体
268
+ */
269
+ pauseMedia () {
270
+ for (let i = (this._videos || []).length; i--;) {
271
+ this._videos[i].pause()
272
+ }
273
+ // #ifdef APP-PLUS
274
+ const command = 'for(var e=document.getElementsByTagName("video"),i=e.length;i--;)e[i].pause()'
275
+ // #ifndef APP-PLUS-NVUE
276
+ let page = this.$parent
277
+ while (!page.$scope) page = page.$parent
278
+ page.$scope.$getAppWebview().evalJS(command)
279
+ // #endif
280
+ // #ifdef APP-PLUS-NVUE
281
+ this.$refs.web.evalJs(command)
282
+ // #endif
283
+ // #endif
284
+ },
285
+
286
+ /**
287
+ * @description 设置媒体播放速率
288
+ * @param {Number} rate 播放速率
289
+ */
290
+ setPlaybackRate (rate) {
291
+ this.playbackRate = rate
292
+ for (let i = (this._videos || []).length; i--;) {
293
+ this._videos[i].playbackRate(rate)
294
+ }
295
+ // #ifdef APP-PLUS
296
+ const command = 'for(var e=document.getElementsByTagName("video"),i=e.length;i--;)e[i].playbackRate=' + rate
297
+ // #ifndef APP-PLUS-NVUE
298
+ let page = this.$parent
299
+ while (!page.$scope) page = page.$parent
300
+ page.$scope.$getAppWebview().evalJS(command)
301
+ // #endif
302
+ // #ifdef APP-PLUS-NVUE
303
+ this.$refs.web.evalJs(command)
304
+ // #endif
305
+ // #endif
306
+ },
307
+
308
+ /**
309
+ * @description 设置内容
310
+ * @param {String} content html 内容
311
+ * @param {Boolean} append 是否在尾部追加
312
+ */
313
+ setContent (content, append) {
314
+ if (!append || !this.imgList) {
315
+ this.imgList = []
316
+ }
317
+ const nodes = new Parser(this).parse(content)
318
+ // #ifdef APP-PLUS-NVUE
319
+ if (this._ready) {
320
+ this._set(nodes, append)
321
+ }
322
+ // #endif
323
+ this.$set(this, 'nodes', append ? (this.nodes || []).concat(nodes) : nodes)
324
+
325
+ // #ifndef APP-PLUS-NVUE
326
+ this._videos = []
327
+ this.$nextTick(() => {
328
+ this._hook('onLoad')
329
+ this.$emit('load')
330
+ })
331
+
332
+ if (this.lazyLoad || this.imgList._unloadimgs < this.imgList.length / 2) {
333
+ // 设置懒加载,每 350ms 获取高度,不变则认为加载完毕
334
+ let height = 0
335
+ const callback = rect => {
336
+ if (!rect || !rect.height) rect = {}
337
+ // 350ms 总高度无变化就触发 ready 事件
338
+ if (rect.height === height) {
339
+ this.$emit('ready', rect)
340
+ } else {
341
+ height = rect.height
342
+ setTimeout(() => {
343
+ this.getRect().then(callback).catch(callback)
344
+ }, 350)
345
+ }
346
+ }
347
+ this.getRect().then(callback).catch(callback)
348
+ } else {
349
+ // 未设置懒加载,等待所有图片加载完毕
350
+ if (!this.imgList._unloadimgs) {
351
+ this.getRect().then(rect => {
352
+ this.$emit('ready', rect)
353
+ }).catch(() => {
354
+ this.$emit('ready', {})
355
+ })
356
+ }
357
+ }
358
+ // #endif
359
+ },
360
+
361
+ /**
362
+ * @description 调用插件钩子函数
363
+ */
364
+ _hook (name) {
365
+ for (let i = plugins.length; i--;) {
366
+ if (this.plugins[i][name]) {
367
+ this.plugins[i][name]()
368
+ }
369
+ }
370
+ },
371
+
372
+ // #ifdef APP-PLUS-NVUE
373
+ /**
374
+ * @description 设置内容
375
+ */
376
+ _set (nodes, append) {
377
+ this.$refs.web.evalJs('setContent(' + JSON.stringify(nodes).replace(/%22/g, '') + ',' + JSON.stringify([this.containerStyle.replace(/(?:margin|padding)[^;]+/g, ''), this.errorImg, this.loadingImg, this.pauseVideo, this.scrollTable, this.selectable]) + ',' + append + ')')
378
+ },
379
+
380
+ /**
381
+ * @description 接收到 web-view 消息
382
+ */
383
+ _onMessage (e) {
384
+ const message = e.detail.data[0]
385
+ switch (message.action) {
386
+ // web-view 初始化完毕
387
+ case 'onJSBridgeReady':
388
+ this._ready = true
389
+ if (this.nodes) {
390
+ this._set(this.nodes)
391
+ }
392
+ break
393
+ // 内容 dom 加载完毕
394
+ case 'onLoad':
395
+ this.height = message.height
396
+ this._hook('onLoad')
397
+ this.$emit('load')
398
+ break
399
+ // 所有图片加载完毕
400
+ case 'onReady':
401
+ this.getRect().then(res => {
402
+ this.$emit('ready', res)
403
+ }).catch(() => {
404
+ this.$emit('ready', {})
405
+ })
406
+ break
407
+ // 总高度发生变化
408
+ case 'onHeightChange':
409
+ this.height = message.height
410
+ break
411
+ // 图片点击
412
+ case 'onImgTap':
413
+ this.$emit('imgtap', message.attrs)
414
+ if (this.previewImg) {
415
+ uni.previewImage({
416
+ current: parseInt(message.attrs.i),
417
+ urls: this.imgList
418
+ })
419
+ }
420
+ break
421
+ // 链接点击
422
+ case 'onLinkTap': {
423
+ const href = message.attrs.href
424
+ this.$emit('linktap', message.attrs)
425
+ if (href) {
426
+ // 锚点跳转
427
+ if (href[0] === '#') {
428
+ if (this.useAnchor) {
429
+ dom.scrollToElement(this.$refs.web, {
430
+ offset: message.offset
431
+ })
432
+ }
433
+ } else if (href.includes('://')) {
434
+ // 打开外链
435
+ if (this.copyLink) {
436
+ plus.runtime.openWeb(href)
437
+ }
438
+ } else {
439
+ uni.navigateTo({
440
+ url: href,
441
+ fail () {
442
+ uni.switchTab({
443
+ url: href
444
+ })
445
+ }
446
+ })
447
+ }
448
+ }
449
+ break
450
+ }
451
+ case 'onPlay':
452
+ this.$emit('play')
453
+ break
454
+ // 获取到锚点的偏移量
455
+ case 'getOffset':
456
+ if (typeof message.offset === 'number') {
457
+ dom.scrollToElement(this.$refs.web, {
458
+ offset: message.offset + this._navigateTo.offset
459
+ })
460
+ this._navigateTo.resolve()
461
+ } else {
462
+ this._navigateTo.reject(Error('Label not found'))
463
+ }
464
+ break
465
+ // 点击
466
+ case 'onClick':
467
+ this.$emit('tap')
468
+ this.$emit('click')
469
+ break
470
+ // 出错
471
+ case 'onError':
472
+ this.$emit('error', {
473
+ source: message.source,
474
+ attrs: message.attrs
475
+ })
476
+ }
477
+ }
478
+ // #endif
479
+ }
480
+ }
481
+ </script>
482
+
483
+ <style>
484
+ /* #ifndef APP-PLUS-NVUE */
485
+ /* 根节点样式 */
486
+ ._root {
487
+ padding: 1px 0;
488
+ overflow-x: auto;
489
+ overflow-y: hidden;
490
+ -webkit-overflow-scrolling: touch;
491
+ }
492
+
493
+ /* 长按复制 */
494
+ ._select {
495
+ user-select: text;
496
+ }
497
+ /* #endif */
498
+ </style>
@@ -0,0 +1,217 @@
1
+ /**
2
+ * hsb 转 rgb
3
+ * @param {Object} hsb 颜色模式 H(hues)表示色相,S(saturation)表示饱和度,B(brightness)表示亮度
4
+ */
5
+ export function hsbToRgb(hsb) {
6
+ let rgb = {};
7
+ let h = hsb.h;
8
+ let s = hsb.s * 255 / 100;
9
+ let v = hsb.b * 255 / 100;
10
+ if (s == 0) {
11
+ rgb.r = rgb.g = rgb.b = v;
12
+ } else {
13
+ let t1 = v;
14
+ let t2 = ((255 - s) * v) / 255;
15
+ let t3 = ((t1 - t2) * (h % 60)) / 60;
16
+ if (h == 360) h = 0;
17
+ if (h < 60) {
18
+ rgb.r = t1;
19
+ rgb.b = t2;
20
+ rgb.g = t2 + t3;
21
+ } else if (h < 120) {
22
+ rgb.g = t1;
23
+ rgb.b = t2;
24
+ rgb.r = t1 - t3;
25
+ } else if (h < 180) {
26
+ rgb.g = t1;
27
+ rgb.r = t2;
28
+ rgb.b = t2 + t3;
29
+ } else if (h < 240) {
30
+ rgb.b = t1;
31
+ rgb.r = t2;
32
+ rgb.g = t1 - t3;
33
+ } else if (h < 300) {
34
+ rgb.b = t1;
35
+ rgb.g = t2;
36
+ rgb.r = t2 + t3;
37
+ } else if (h < 360) {
38
+ rgb.r = t1;
39
+ rgb.g = t2;
40
+ rgb.b = t1 - t3;
41
+ } else {
42
+ rgb.r = 0;
43
+ rgb.g = 0;
44
+ rgb.b = 0;
45
+ }
46
+ }
47
+ return {
48
+ r: Math.round(rgb.r),
49
+ g: Math.round(rgb.g),
50
+ b: Math.round(rgb.b)
51
+ };
52
+ }
53
+ /**
54
+ * rgb转hsb
55
+ * @param {Object} rgb 颜色rgb值
56
+ */
57
+ export function rgbToHsb(rgb) {
58
+ let hsb = {
59
+ h: 0,
60
+ s: 0,
61
+ b: 0
62
+ };
63
+ let h = 0,
64
+ s = 0,
65
+ v = 0;
66
+ let r = rgb.r,
67
+ g = rgb.g,
68
+ b = rgb.b;
69
+ let min = Math.min(rgb.r, rgb.g, rgb.b);
70
+ let max = Math.max(rgb.r, rgb.g, rgb.b);
71
+ v = max / 255;
72
+ if (max === 0) {
73
+ s = 0;
74
+ } else {
75
+ s = 1 - (min / max);
76
+ }
77
+ if (max === min) {
78
+ h = 0; //事实上,max===min的时候,h无论为多少都无所谓
79
+ } else if (max === r && g >= b) {
80
+ h = 60 * ((g - b) / (max - min)) + 0;
81
+ } else if (max === r && g < b) {
82
+ h = 60 * ((g - b) / (max - min)) + 360
83
+ } else if (max === g) {
84
+ h = 60 * ((b - r) / (max - min)) + 120
85
+ } else if (max === b) {
86
+ h = 60 * ((r - g) / (max - min)) + 240
87
+ }
88
+ hsb.h = parseInt(h);
89
+ hsb.s = parseInt(s * 100);
90
+ hsb.b = parseInt(v * 100);
91
+ return hsb;
92
+ }
93
+ /**
94
+ * rgb 转 二进制 hex
95
+ * @param {Object} rgb
96
+ */
97
+ export function rgbToHex(rgb) {
98
+ let hex = [rgb.r.toString(16), rgb.g.toString(16), rgb.b.toString(16)];
99
+ hex.map(function(str, i) {
100
+ if (str.length == 1) {
101
+ hex[i] = '0' + str;
102
+ }
103
+ });
104
+ return hex.join('');
105
+ }
106
+ //预制颜色
107
+ export const colorList = [{
108
+ r: 60,
109
+ g: 156,
110
+ b: 255,
111
+ a: 1
112
+ }, {
113
+ r: 245,
114
+ g: 108,
115
+ b: 108,
116
+ a: 1
117
+ }, {
118
+ r: 249,
119
+ g: 174,
120
+ b: 61,
121
+ a: 1
122
+ }, {
123
+ r: 90,
124
+ g: 199,
125
+ b: 37,
126
+ a: 1
127
+ }, {
128
+ r: 144,
129
+ g: 147,
130
+ b: 153,
131
+ a: 1
132
+ }, {
133
+ r: 48,
134
+ g: 49,
135
+ b: 51,
136
+ a: 1
137
+ }, {
138
+ r: 233,
139
+ g: 30,
140
+ b: 99,
141
+ a: 1
142
+ }, {
143
+ r: 156,
144
+ g: 39,
145
+ b: 176,
146
+ a: 1
147
+ }, {
148
+ r: 103,
149
+ g: 58,
150
+ b: 183,
151
+ a: 1
152
+ }, {
153
+ r: 63,
154
+ g: 81,
155
+ b: 181,
156
+ a: 1
157
+ }, {
158
+ r: 0,
159
+ g: 188,
160
+ b: 212,
161
+ a: 1
162
+ }, {
163
+ r: 0,
164
+ g: 150,
165
+ b: 136,
166
+ a: 1
167
+ }, {
168
+ r: 139,
169
+ g: 195,
170
+ b: 74,
171
+ a: 1
172
+ }, {
173
+ r: 205,
174
+ g: 220,
175
+ b: 57,
176
+ a: 1
177
+ }, {
178
+ r: 255,
179
+ g: 235,
180
+ b: 59,
181
+ a: 1
182
+ }, {
183
+ r: 255,
184
+ g: 193,
185
+ b: 7,
186
+ a: 1
187
+ }, {
188
+ r: 255,
189
+ g: 152,
190
+ b: 0,
191
+ a: 1
192
+ }, {
193
+ r: 255,
194
+ g: 87,
195
+ b: 34,
196
+ a: 1
197
+ }, {
198
+ r: 121,
199
+ g: 85,
200
+ b: 72,
201
+ a: 1
202
+ }, {
203
+ r: 158,
204
+ g: 158,
205
+ b: 158,
206
+ a: 1
207
+ }, {
208
+ r: 0,
209
+ g: 0,
210
+ b: 0,
211
+ a: 0.5
212
+ }, {
213
+ r: 0,
214
+ g: 0,
215
+ b: 0,
216
+ a: 0
217
+ }]