uview-plus 3.8.55 → 3.8.106

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 (229) hide show
  1. package/changelog.md +2147 -1828
  2. package/components/u-action-sheet/props.js +3 -1
  3. package/components/u-action-sheet/u-action-sheet.vue +22 -2
  4. package/components/u-album/props.js +3 -1
  5. package/components/u-alert/props.js +4 -2
  6. package/components/u-avatar/props.js +4 -1
  7. package/components/u-avatar-group/props.js +4 -1
  8. package/components/u-back-top/props.js +4 -1
  9. package/components/u-badge/props.js +4 -1
  10. package/components/u-barcode/u-barcode.vue +44 -15
  11. package/components/u-box/props.js +5 -2
  12. package/components/u-button/props.js +4 -1
  13. package/components/u-button/u-button.vue +2 -5
  14. package/components/u-button/vue.scss +3 -3
  15. package/components/u-calendar/calendar.js +8 -0
  16. package/components/u-calendar/props.js +43 -1
  17. package/components/u-calendar/u-calendar.vue +16 -0
  18. package/components/u-calendar-strip/props.js +3 -1
  19. package/components/u-canvas/u-canvas.vue +1028 -423
  20. package/components/u-car-keyboard/props.js +3 -1
  21. package/components/u-card/props.js +3 -1
  22. package/components/u-cell/props.js +4 -1
  23. package/components/u-cell/u-cell.vue +9 -1
  24. package/components/u-cell-group/props.js +4 -1
  25. package/components/u-checkbox/props.js +4 -1
  26. package/components/u-checkbox/u-checkbox.vue +7 -3
  27. package/components/u-checkbox-group/props.js +3 -1
  28. package/components/u-circle-progress/props.js +4 -1
  29. package/components/u-code/props.js +4 -1
  30. package/components/u-code-input/props.js +4 -1
  31. package/components/u-col/props.js +4 -1
  32. package/components/u-collapse/props.js +4 -1
  33. package/components/u-collapse-item/props.js +4 -1
  34. package/components/u-color-picker/u-color-picker.vue +1 -0
  35. package/components/u-column-notice/props.js +4 -1
  36. package/components/u-count-down/props.js +4 -1
  37. package/components/u-count-to/props.js +4 -1
  38. package/components/u-cropper/u-cropper.vue +95 -51
  39. package/components/u-datetime-picker/props.js +4 -1
  40. package/components/u-datetime-picker/u-datetime-picker.vue +53 -4
  41. package/components/u-divider/props.js +4 -1
  42. package/components/u-dragsort/u-dragsort.vue +57 -32
  43. package/components/u-dropdown/props.js +3 -1
  44. package/components/u-dropdown-item/props.js +3 -1
  45. package/components/u-empty/props.js +4 -1
  46. package/components/u-form/props.js +4 -1
  47. package/components/u-form-item/props.js +4 -1
  48. package/components/u-gap/props.js +4 -1
  49. package/components/u-grid/props.js +4 -1
  50. package/components/u-grid-item/props.js +4 -1
  51. package/components/u-guide/props.js +3 -1
  52. package/components/u-icon/props.js +4 -1
  53. package/components/u-icon/u-icon.vue +11 -2
  54. package/components/u-icon/upicon.ttf +0 -0
  55. package/components/u-icon/util.js +103 -10
  56. package/components/u-image/props.js +4 -1
  57. package/components/u-image/u-image.vue +280 -267
  58. package/components/u-index-anchor/props.js +4 -1
  59. package/components/u-index-item/props.js +2 -1
  60. package/components/u-index-item/u-index-item.vue +1 -1
  61. package/components/u-index-list/props.js +4 -1
  62. package/components/u-index-list/u-index-list.vue +1 -1
  63. package/components/u-input/props.js +3 -1
  64. package/components/u-keyboard/props.js +4 -1
  65. package/components/u-line/props.js +4 -1
  66. package/components/u-line-progress/props.js +6 -3
  67. package/components/u-link/props.js +4 -1
  68. package/components/u-list/props.js +4 -1
  69. package/components/u-list-item/props.js +4 -1
  70. package/components/u-loading-icon/props.js +4 -1
  71. package/components/u-loading-page/props.js +3 -1
  72. package/components/u-loadmore/props.js +4 -1
  73. package/components/u-markdown/u-markdown.vue +45 -3
  74. package/components/u-modal/props.js +4 -1
  75. package/components/u-navbar/props.js +4 -2
  76. package/components/u-navbar/u-navbar.vue +15 -9
  77. package/components/u-no-network/props.js +4 -1
  78. package/components/u-notice-bar/props.js +4 -1
  79. package/components/u-notify/props.js +4 -1
  80. package/components/u-novel-reader/content-normalizer.js +80 -0
  81. package/components/u-novel-reader/layout-engine.js +225 -0
  82. package/components/u-novel-reader/measure-adapter.js +69 -0
  83. package/components/u-novel-reader/novelReader.js +35 -0
  84. package/components/u-novel-reader/persistence.js +144 -0
  85. package/components/u-novel-reader/props.js +100 -0
  86. package/components/u-novel-reader/reader-catalog.vue +234 -0
  87. package/components/u-novel-reader/reader-content.vue +226 -0
  88. package/components/u-novel-reader/reader-core.js +151 -0
  89. package/components/u-novel-reader/reader-settings.vue +325 -0
  90. package/components/u-novel-reader/reader-toolbar.vue +313 -0
  91. package/components/u-novel-reader/theme-vars.scss +49 -0
  92. package/components/u-novel-reader/u-novel-reader.vue +836 -0
  93. package/components/u-number-box/props.js +4 -1
  94. package/components/u-number-box/u-number-box.vue +2 -2
  95. package/components/u-number-keyboard/props.js +4 -1
  96. package/components/u-overlay/props.js +4 -1
  97. package/components/u-pagination/u-pagination.vue +60 -39
  98. package/components/u-parse/props.js +4 -1
  99. package/components/u-picker/props.js +4 -1
  100. package/components/u-picker-column/props.js +3 -1
  101. package/components/u-popover/props.js +2 -1
  102. package/components/u-popup/props.js +4 -1
  103. package/components/u-poster/u-poster.vue +246 -214
  104. package/components/u-qrcode/qrcode.js +105 -97
  105. package/components/u-qrcode/u-qrcode.vue +242 -289
  106. package/components/u-radio/props.js +4 -1
  107. package/components/u-radio/u-radio.vue +7 -3
  108. package/components/u-radio-group/props.js +4 -1
  109. package/components/u-rate/props.js +4 -1
  110. package/components/u-read-more/props.js +4 -1
  111. package/components/u-row/props.js +4 -1
  112. package/components/u-row-notice/props.js +4 -1
  113. package/components/u-safe-bottom/props.js +2 -1
  114. package/components/u-scroll-list/props.js +4 -1
  115. package/components/u-scroll-list/scrollWxs.wxs +1 -1
  116. package/components/u-search/props.js +3 -1
  117. package/components/u-skeleton/props.js +4 -1
  118. package/components/u-slider/props.js +3 -1
  119. package/components/u-slider/u-slider.vue +71 -29
  120. package/components/u-status-bar/props.js +4 -1
  121. package/components/u-steps/props.js +4 -1
  122. package/components/u-steps-item/props.js +4 -1
  123. package/components/u-sticky/props.js +4 -1
  124. package/components/u-sticky/u-sticky.vue +11 -0
  125. package/components/u-subsection/props.js +3 -1
  126. package/components/u-swipe-action/props.js +4 -1
  127. package/components/u-swipe-action-item/index.wxs +43 -25
  128. package/components/u-swipe-action-item/nvue.js +9 -0
  129. package/components/u-swipe-action-item/other.js +32 -21
  130. package/components/u-swipe-action-item/props.js +9 -1
  131. package/components/u-swipe-action-item/swipeActionItem.js +1 -0
  132. package/components/u-swipe-action-item/u-swipe-action-item.vue +42 -4
  133. package/components/u-swiper/props.js +9 -1
  134. package/components/u-swiper/swiper.js +1 -0
  135. package/components/u-swiper/u-swiper.vue +2 -0
  136. package/components/u-swiper-indicator/props.js +4 -1
  137. package/components/u-switch/props.js +4 -1
  138. package/components/u-switch/u-switch.vue +1 -1
  139. package/components/u-tabbar/props.js +3 -1
  140. package/components/u-tabbar/u-tabbar.vue +2 -1
  141. package/components/u-tabbar-item/props.js +4 -1
  142. package/components/u-tabbar-item/u-tabbar-item.vue +64 -21
  143. package/components/u-table/props.js +3 -1
  144. package/components/u-table2/tableRow.vue +155 -69
  145. package/components/u-table2/u-table2.vue +327 -137
  146. package/components/u-tabs/props.js +4 -1
  147. package/components/u-tabs/u-tabs.vue +11 -8
  148. package/components/u-tabs-item/props.js +3 -1
  149. package/components/u-tabs-pro/u-tabs-pro.vue +212 -0
  150. package/components/u-tag/props.js +4 -1
  151. package/components/u-td/props.js +3 -1
  152. package/components/u-text/props.js +4 -1
  153. package/components/u-text/text.js +1 -1
  154. package/components/u-text/u-text.vue +18 -6
  155. package/components/u-textarea/props.js +3 -1
  156. package/components/u-textarea/u-textarea.vue +16 -5
  157. package/components/u-th/props.js +3 -1
  158. package/components/u-toolbar/props.js +4 -1
  159. package/components/u-tooltip/props.js +10 -2
  160. package/components/u-tooltip/tooltip.js +2 -1
  161. package/components/u-tooltip/u-tooltip.vue +31 -3
  162. package/components/u-tr/props.js +3 -1
  163. package/components/u-transition/nvue-ani-map.js +75 -68
  164. package/components/u-transition/props.js +4 -1
  165. package/components/u-transition/transitionMixin.js +164 -163
  166. package/components/u-upload/props.js +4 -1
  167. package/components/u-upload/u-upload.vue +48 -41
  168. package/components/u-waterfall/u-waterfall.vue +162 -110
  169. package/index.js +65 -8
  170. package/libs/config/config.js +1 -1
  171. package/libs/config/props.js +180 -204
  172. package/libs/css/components.scss +3 -0
  173. package/libs/function/index.js +66 -0
  174. package/libs/function/uni-api-shims.js +29 -0
  175. package/libs/i18n/index.js +71 -36
  176. package/libs/i18n/locale-packs.js +11 -0
  177. package/libs/i18n/locales/all.js +23 -0
  178. package/libs/i18n/locales/{de.json → de.js} +1 -1
  179. package/libs/i18n/locales/{en.json → en.js} +2 -2
  180. package/libs/i18n/locales/{es.json → es.js} +1 -1
  181. package/libs/i18n/locales/{fr.json → fr.js} +2 -2
  182. package/libs/i18n/locales/{ja.json → ja.js} +1 -1
  183. package/libs/i18n/locales/{ko.json → ko.js} +1 -1
  184. package/libs/i18n/locales/{ru.json → ru.js} +1 -1
  185. package/libs/i18n/locales/{th.json → th.js} +1 -1
  186. package/libs/i18n/locales/{zh-Hans.json → zh-Hans.js} +1 -1
  187. package/libs/i18n/locales/{zh-Hant.json → zh-Hant.js} +1 -1
  188. package/libs/mixin/mixin.js +18 -54
  189. package/libs/root/index.js +78 -5
  190. package/libs/root/page.js +7 -7
  191. package/libs/root/root.js +73 -3
  192. package/libs/util/app-nvue-webview-canvas.js +486 -0
  193. package/libs/util/gcanvas/bridge/bridge-weex.js +10 -7
  194. package/libs/util/gcanvas/context-2d/FillStyleLinearGradient.js +0 -0
  195. package/libs/util/gcanvas/context-2d/FillStylePattern.js +0 -0
  196. package/libs/util/gcanvas/context-2d/FillStyleRadialGradient.js +0 -0
  197. package/libs/util/gcanvas/context-2d/RenderingContext.js +0 -0
  198. package/libs/util/gcanvas/context-webgl/ActiveInfo.js +0 -0
  199. package/libs/util/gcanvas/context-webgl/Buffer.js +0 -0
  200. package/libs/util/gcanvas/context-webgl/Framebuffer.js +0 -0
  201. package/libs/util/gcanvas/context-webgl/GLenum.js +0 -0
  202. package/libs/util/gcanvas/context-webgl/GLmethod.js +0 -0
  203. package/libs/util/gcanvas/context-webgl/GLtype.js +0 -0
  204. package/libs/util/gcanvas/context-webgl/Program.js +0 -0
  205. package/libs/util/gcanvas/context-webgl/Renderbuffer.js +0 -0
  206. package/libs/util/gcanvas/context-webgl/RenderingContext.js +0 -0
  207. package/libs/util/gcanvas/context-webgl/Shader.js +0 -0
  208. package/libs/util/gcanvas/context-webgl/ShaderPrecisionFormat.js +0 -0
  209. package/libs/util/gcanvas/context-webgl/Texture.js +0 -0
  210. package/libs/util/gcanvas/context-webgl/UniformLocation.js +0 -0
  211. package/libs/util/gcanvas/context-webgl/classUtils.js +0 -0
  212. package/libs/util/gcanvas/env/canvas.js +0 -0
  213. package/libs/util/gcanvas/env/image.js +0 -0
  214. package/libs/util/gcanvas/env/tool.js +0 -0
  215. package/libs/util/gcanvas/index.js +3 -3
  216. package/package.json +4 -5
  217. package/tsconfig.json +18 -0
  218. package/types/comps/calendar.d.ts +38 -0
  219. package/types/comps/checkbox.d.ts +12 -0
  220. package/types/comps/lineProgress.d.ts +5 -0
  221. package/types/comps/navbar.d.ts +3 -3
  222. package/types/comps/swipeActionItem.d.ts +13 -0
  223. package/types/comps/swiper.d.ts +5 -0
  224. package/types/comps/tabs.d.ts +2 -1
  225. package/types/comps/text.d.ts +1 -1
  226. package/types/comps/tooltip.d.ts +36 -1
  227. package/types/func.d.ts +23 -0
  228. package/types/index.d.ts +1 -0
  229. /package/components/u-markdown/{marked.esm.js → marked.esm.mjs} +0 -0
@@ -4,36 +4,36 @@
4
4
  :style="{
5
5
  width: useRootHeightAndWidth ? '100%' : 'auto',
6
6
  height: useRootHeightAndWidth ? '100%' : 'auto',
7
- }"
8
- @longpress="longpress">
9
- <view class="u-qrcode__content" @click="preview">
10
- <!-- #ifdef MP || H5 -->
11
- <canvas
12
- class="u-qrcode__canvas"
13
- :id="cid"
14
- :canvas-id="cid"
15
- type="2d"
16
- :style="{ width: sizeLocal + unit, height: sizeLocal + unit }" />
17
- <!-- #endif -->
18
-
19
- <!-- #ifdef APP-PLUS -->
20
- <canvas
21
- class="u-qrcode__canvas"
22
- :id="cid"
23
- :canvas-id="cid"
24
- :style="{ width: sizeLocal + unit, height: sizeLocal + unit }" />
25
- <!-- #endif -->
26
-
27
- <!-- #ifdef APP-NVUE -->
28
- <web-view v-if="icon != ''" ref="web" src="/static/app-plus/up-canvas/local.html"
29
- :style="'width:' + sizeLocal + 'px;height:' + sizeLocal + 'px'"
30
- @onPostMessage="_onMessage" />
31
- <gcanvas v-else class="u-qrcode__canvas" ref="gcanvess"
32
- :style="{ width: sizeLocal + unit, height: sizeLocal + unit }">
33
- </gcanvas>
34
- <!-- #endif -->
35
- <view v-if="showLoading && loading" class="u-qrcode__loading"
36
- :style="{ width: sizeLocal + unit, height: sizeLocal + unit }">
7
+ }"
8
+ @longpress="longpress">
9
+ <view
10
+ class="u-qrcode__content"
11
+ :style="{ width: sizeLocal + unit, height: sizeLocal + unit }"
12
+ @click="preview">
13
+ <!-- #ifdef APP-NVUE -->
14
+ <up-canvas
15
+ ref="qrcodeCanvas"
16
+ class="u-qrcode__canvas"
17
+ :canvas-id="cid"
18
+ :width="sizeLocal"
19
+ :height="sizeLocal"
20
+ :unit="unit"
21
+ bg-color="transparent"
22
+ :style="{ width: sizeLocal + unit, height: sizeLocal + unit }" />
23
+ <!-- #endif -->
24
+ <!-- #ifndef APP-NVUE -->
25
+ <up-canvas
26
+ ref="qrcodeCanvas"
27
+ class="u-qrcode__canvas"
28
+ :canvas-id="cid"
29
+ :width="sizeLocal"
30
+ :height="sizeLocal"
31
+ :unit="unit"
32
+ bg-color="transparent"
33
+ :style="{ width: sizeLocal + unit, height: sizeLocal + unit }" />
34
+ <!-- #endif -->
35
+ <view v-if="showLoading && loading" class="u-qrcode__loading"
36
+ :style="{ width: sizeLocal + unit, height: sizeLocal + unit }">
37
37
  <up-loading-icon vertical :text="loadingText" textSize="14px"></up-loading-icon>
38
38
  </view>
39
39
  </view>
@@ -41,22 +41,9 @@
41
41
  </view>
42
42
  </template>
43
43
 
44
- <script>
45
- import QRCode from "./qrcode.js"
46
- import { sleep } from '../../libs/function/index';
47
- // #ifdef APP-NVUE
48
- // https://github.com/dcloudio/NvueCanvasDemo/blob/master/README.md
49
- import {
50
- enable,
51
- WeexBridge,
52
- Image as GImage
53
- } from '../../libs/util/gcanvas/index.js';
54
- import { nextTick } from "vue";
55
- // #endif
56
- let qrcode
57
- // 20260201不能在data中存储canvas,否则会导致在微信小程序getContext获取不到canvas对象报错Cannot read property 'type'
58
- let canvas = null
59
- export default {
44
+ <script>
45
+ import QRCode from "./qrcode.js"
46
+ export default {
60
47
  name: "u-qrcode",
61
48
  props: {
62
49
  cid: {
@@ -149,103 +136,98 @@ export default {
149
136
  {
150
137
  name: '保存二维码',
151
138
  }
152
- ],
153
- rootId: `rootId${Number(Math.random() * 100).toFixed(0)}`,
154
- ganvas: null,
155
- canvasObj: {},
156
- sizeLocal: this.size,
157
- ctx: null,
158
- _ready: false
159
- }
160
- },
161
- async mounted(){
162
- // 如果使用根节点的宽高 则 重新设置 size
163
- if(this.useRootHeightAndWidth){
164
- await this.setNewSize()
165
- }
166
- canvas = await this.getCanvasNode(this.cid)
167
-
168
- if (!canvas) return
169
- // #ifdef MP
170
- // 不清楚是小程序的bug还是什么原因,canvas的node节点宽高和设置的宽高不一致 重新设置下
171
- canvas.width = this.sizeLocal
172
- canvas.height = this.sizeLocal
173
- // #endif
174
- // #ifdef APP-PLUS-NVUE
175
- this.isNvue = true
176
- // #endif
177
- this.ctx = this.getUPCanvasContext('2d')
178
-
179
- if (this.loadMake) {
139
+ ],
140
+ rootId: `rootId${Number(Math.random() * 100).toFixed(0)}`,
141
+ canvasObj: {},
142
+ sizeLocal: this.size,
143
+ ctx: null,
144
+ isNvue: false,
145
+ canvasHost: null
146
+ }
147
+ },
148
+ created() {
149
+ this._qrcode = null
150
+ },
151
+ async mounted(){
152
+ // 如果使用根节点的宽高 则 重新设置 size
153
+ if(this.useRootHeightAndWidth){
154
+ await this.setNewSize()
155
+ }
156
+ // #ifdef APP-NVUE
157
+ this.isNvue = true
158
+ // #endif
159
+ await this.initCanvas()
160
+
161
+ if (this.loadMake) {
180
162
  if (!this._empty(this.val)) {
181
163
  setTimeout(() => {
182
164
  setTimeout(()=>{
183
- this._makeCode()
165
+ this._makeCode().catch(error => {
166
+ console.error('二维码生成失败', error)
167
+ })
184
168
  })
185
169
  }, 0);
186
170
  }
187
171
  }
188
- },
189
- methods: {
190
- _onMessage(e) {
191
- // console.log('post message', e)
192
- const message = e.detail.data[0]
193
- switch (message.action) {
194
- // web-view 初始化完毕
195
- case 'onJSBridgeReady':
196
- this._ready = true
197
- this.$refs.web.evalJs('setContent('+JSON.stringify(this.$props) +')')
198
- break
199
- // qrcodeOk
200
- case 'qrcodeOk':
201
- this._result(message.imageData)
202
- // this.$emit('load')
203
- break
204
- }
205
- },
206
- _makeCode() {
207
- let that = this
208
- if (!canvas) return
209
- if (!this._empty(this.val)) {
210
- // #ifndef APP-NVUE
211
- this.loading = true
212
- // #endif
213
- // nvue下时因为gcanvas的GImage不生效,因此icon模式会采用webview
214
- if ((this.icon == '' && that.isNvue) || !that.isNvue) {
215
- qrcode = new QRCode({
216
- vuectx: that, // 上下文环境
217
- canvasId: that.cid, // canvas-id
218
- ctx: that.ctx,
219
- isNvue: that.isNvue,
220
- usingComponents: that.usingComponents, // 是否是自定义组件
221
- showLoading: false, // 是否显示loading
222
- loadingText: that.loadingText, // loading文字
223
- text: that.val, // 生成内容
224
- size: that.sizeLocal, // 二维码大小
225
- background: that.background, // 背景色
226
- foreground: that.foreground, // 前景色
227
- pdground: that.pdground, // 定位角点颜色
228
- quietZone: that.quietZone, // 静区宽度
229
- correctLevel: that.lv, // 容错级别
230
- image: that.icon, // 二维码图标
231
- imageSize: that.iconSize,// 二维码图标大小
232
- cbResult: function (res) { // 生成二维码的回调
233
- that._result(res)
234
- },
235
- });
236
- }
237
- } else {
238
- uni.showToast({
239
- title: '二维码内容不能为空',
240
- icon: 'none',
241
- duration: 2000
242
- });
243
- }
244
- },
245
- _clearCode() {
246
- this._result('')
247
- qrcode.clear()
172
+ },
173
+ methods: {
174
+ async _makeCode() {
175
+ let that = this
176
+ if (this._empty(this.val)) {
177
+ uni.showToast({
178
+ title: '二维码内容不能为空',
179
+ icon: 'none',
180
+ duration: 2000
181
+ });
182
+ return ''
183
+ }
184
+ if (!this.ctx) {
185
+ await this.initCanvas(true)
186
+ }
187
+ if (!this.ctx) throw new Error('无法获取二维码画布实例')
188
+ return new Promise((resolve, reject) => {
189
+ this.loading = true
190
+ try {
191
+ this._qrcode = new QRCode({
192
+ vuectx: that, // 上下文环境
193
+ canvasId: that.cid, // canvas-id
194
+ ctx: that.ctx,
195
+ canvasHost: that.canvasHost,
196
+ isNvue: that.isNvue,
197
+ usingComponents: that.usingComponents, // 是否是自定义组件
198
+ showLoading: false, // 是否显示loading
199
+ loadingText: that.loadingText, // loading文字
200
+ text: that.val, // 生成内容
201
+ size: that.sizeLocal, // 二维码大小
202
+ width: that.sizeLocal,
203
+ height: that.sizeLocal,
204
+ background: that.background, // 背景色
205
+ foreground: that.foreground, // 前景色
206
+ pdground: that.pdground, // 定位角点颜色
207
+ quietZone: that.quietZone, // 静区宽度
208
+ correctLevel: that.lv, // 容错级别
209
+ image: that.icon, // 二维码图标
210
+ imageSize: that.iconSize,// 二维码图标大小
211
+ cbResult: function (res) { // 生成二维码的回调
212
+ if (typeof res === 'string') {
213
+ that._result(res)
214
+ resolve(res)
215
+ } else {
216
+ that.loading = false
217
+ reject(res instanceof Error ? res : new Error(`二维码生成失败: ${JSON.stringify(res)}`))
218
+ }
219
+ },
220
+ });
221
+ } catch (error) {
222
+ that.loading = false
223
+ reject(error)
224
+ }
225
+ })
248
226
  },
227
+ _clearCode() {
228
+ this._result('')
229
+ if (this._qrcode) this._qrcode.clear()
230
+ },
249
231
  _saveCode() {
250
232
  let that = this;
251
233
  if (this.result != "") {
@@ -305,42 +287,28 @@ export default {
305
287
  url: this.result
306
288
  }, e)
307
289
  },
308
- async toTempFilePath({success, fail}) {
309
- if (this.ct) {
310
- this.ctx.toTempFilePath(
311
- 0,
312
- 0,
313
- this.sizeLocal,
314
- this.sizeLocal,
315
- this.sizeLocal,
316
- this.sizeLocal,
317
- "",
318
- 1,
319
- res => {
320
- success(res)
321
- }
322
- );
323
- }
324
- else {
325
- // #ifdef H5
326
- success({
327
- tempFilePath: this.ctx.canvas.toDataURL("image/png", 1)
328
- })
329
- // #endif
330
-
331
- // #ifndef H5
332
- uni.canvasToTempFilePath(
333
- {
334
- canvasId: this.cid,
335
- success :res => {
336
- success(res)
337
- },
338
- fail: fail
339
- },
340
- this)
341
- // #endif
342
- }
343
- },
290
+ async toTempFilePath({success, fail} = {}) {
291
+ try {
292
+ if (!this.canvasHost) {
293
+ await this.initCanvas(true)
294
+ }
295
+ if (!this.canvasHost) {
296
+ throw new Error('无法获取二维码画布实例')
297
+ }
298
+ const res = await this.canvasHost.toTempFilePath({
299
+ width: this.sizeLocal,
300
+ height: this.sizeLocal
301
+ })
302
+ if (success) success(res)
303
+ return res
304
+ } catch (error) {
305
+ if (fail) {
306
+ fail(error)
307
+ return false
308
+ }
309
+ throw error
310
+ }
311
+ },
344
312
  async longpress() {
345
313
  this.toTempFilePath({
346
314
  success: res => {
@@ -355,9 +323,10 @@ export default {
355
323
  * 使用根节点宽高 设置新的size
356
324
  * @return {Promise<void>}
357
325
  */
358
- async setNewSize(){
359
- const rootNode = await this.getCanvasNode(this.rootId, false);
360
- const { width , height } = rootNode;
326
+ async setNewSize(){
327
+ const rootNode = await this.getRootNode();
328
+ if (!rootNode) return
329
+ const { width , height } = rootNode;
361
330
  // 将最短的设置为二维码 的size
362
331
  if(width > height){
363
332
  this.sizeLocal = height
@@ -367,99 +336,68 @@ export default {
367
336
  }
368
337
  },
369
338
 
370
- /**
371
- * 获取节点
372
- * @param id 节点id
373
- * @param isCanvas 是否为Canvas节点
374
- * @return {Promise<unknown>}
375
- */
376
- async getCanvasNode(id, isCanvas = true) {
377
- let that = this
378
- return new Promise((resolve, reject) => {
379
- try {
380
- // #ifdef APP-NVUE
381
- setTimeout(() => {
382
- /*获取元素引用*/
383
- this.ganvas = this.$refs["gcanvess"]
384
- /*通过元素引用获取canvas对象*/
385
- let canvasNode = enable(this.ganvas, {
386
- bridge: WeexBridge
387
- })
388
- resolve(canvasNode)
389
- }, 200)
390
- // #endif
391
- // #ifndef APP-PLUS-NVUE
392
- const query = uni.createSelectorQuery().in(that).select(`#${id}`);
393
- query.fields({
394
- node: true,
395
- size: true
396
- })
397
- .exec((res) => {
398
- if (isCanvas) {
399
- if (res[0]?.node) {
400
- resolve(res[0].node)
401
- } else {
402
- resolve(false)
403
- console.error("获取节点出错", res)
404
- }
405
- } else {
406
- resolve(res[0])
407
- }
408
- })
409
- // #endif
410
- } catch (e) {
411
- console.error("获取节点失败", e)
412
- }
413
- })
414
- },
415
- getUPCanvasContext() {
416
- // #ifdef APP-PLUS
417
- return uni.createCanvasContext(this.cid, this);
418
- // #endif
419
- // #ifdef APP-PLUS-NVUE || MP || H5
420
- return canvas.getContext('2d');
421
- // #endif
422
- },
423
- drawImage(url, x, y, w, h) {
424
- try {
425
- let img = {}
426
- // #ifdef APP-NVUE
427
- img = new GImage();
428
- // #endif
429
-
430
- // #ifdef H5
431
- // APP下不支持会一直卡住
432
- img = new Image();
433
- // #endif
434
-
435
- // #ifdef MP
436
- // 小程序2d
437
- // https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Canvas.createImage.html
438
- img = canvas.createImage();
439
- // #endif
440
- // #ifdef APP-NVUE
441
- let that = this
442
- // console.log(img)
443
- img.onload = function(){
444
- if (process.env.NODE_ENV === 'development') {
445
- console.log('drawImage绘制2...')
446
- }
447
- that.cxt.drawImage(img, x, y, w, h);
448
- }
449
- // #endif
450
- // #ifdef H5 || MP
451
- img.onload = () => {
452
- this.ctx.drawImage(img, x, y, w, h);
453
- };
454
- // #endif
455
- img.src = url;
456
- // #ifdef APP-VUE
457
- this.ctx.drawImage(url, x, y, w, h);
458
- // #endif
459
- } catch (error) {
460
- console.log('drawImage绘制出错', error)
461
- }
462
- },
339
+ async getRootNode() {
340
+ return new Promise((resolve, reject) => {
341
+ try {
342
+ const query = uni.createSelectorQuery().in(this).select(`#${this.rootId}`);
343
+ query.fields({
344
+ size: true
345
+ })
346
+ .exec((res) => {
347
+ resolve(res[0] || false)
348
+ })
349
+ } catch (e) {
350
+ console.error("获取二维码根节点失败", e)
351
+ resolve(false)
352
+ }
353
+ })
354
+ },
355
+ async initCanvas(force = false) {
356
+ await this.$nextTick()
357
+ const canvasRef = this.$refs.qrcodeCanvas
358
+ if (!canvasRef) return false
359
+ const initialized = await canvasRef.initCanvas(force)
360
+ if (!initialized) {
361
+ this.canvasHost = null
362
+ this.ctx = null
363
+ return false
364
+ }
365
+ this.canvasHost = canvasRef
366
+ this.ctx = canvasRef.getRawContext()
367
+ return !!this.ctx
368
+ },
369
+ async refreshCanvas(force = false) {
370
+ await this.$nextTick()
371
+ return this.initCanvas(force)
372
+ },
373
+ getUPCanvasContext() {
374
+ return this.canvasHost ? this.canvasHost.getRawContext() : null
375
+ },
376
+ async drawImage(url, x, y, w, h) {
377
+ try {
378
+ if (!this.canvasHost) {
379
+ const initialized = await this.initCanvas(true)
380
+ if (!initialized) {
381
+ throw new Error('无法初始化二维码画布')
382
+ }
383
+ }
384
+ if (!this.canvasHost || !this.ctx) {
385
+ throw new Error('无法获取二维码画布实例')
386
+ }
387
+ await this.canvasHost.drawImage(url, x, y, w, h)
388
+ } catch (error) {
389
+ console.error('drawImage绘制出错', error)
390
+ throw error
391
+ }
392
+ },
393
+ _queueMakeCode(delay = 0) {
394
+ if (this._empty(this.val)) return
395
+ setTimeout(() => {
396
+ this._makeCode().catch(error => {
397
+ console.error('二维码生成失败', error)
398
+ })
399
+ }, delay)
400
+ },
463
401
 
464
402
  selectClick(index) {
465
403
  switch (index) {
@@ -492,33 +430,48 @@ export default {
492
430
  },
493
431
  },
494
432
  watch: {
495
- size: function (n, o) {
496
- if (n != o && !this._empty(n)) {
497
- this.cSize = n
498
- if (!this._empty(this.val)) {
499
- setTimeout(() => {
500
- this._makeCode()
501
- }, 100);
502
- }
503
- }
504
- },
505
- val: function (n, o) {
506
- if (this.onval) {
507
- if (n != o && !this._empty(n)) {
508
- setTimeout(() => {
509
- this._makeCode()
510
- }, 0);
511
- }
512
- }
513
- }
433
+ size: function (n, o) {
434
+ if (n != o && !this._empty(n)) {
435
+ this.sizeLocal = n
436
+ if (this.onval) {
437
+ this._queueMakeCode(100)
438
+ }
439
+ }
440
+ },
441
+ val: function (n, o) {
442
+ if (this.onval) {
443
+ if (n != o && !this._empty(n)) {
444
+ this._queueMakeCode()
445
+ }
446
+ }
447
+ },
448
+ icon: function (n, o) {
449
+ if (n === o) return
450
+ this._queueMakeCode(100)
451
+ },
452
+ background: function () {
453
+ this._queueMakeCode()
454
+ },
455
+ foreground: function () {
456
+ this._queueMakeCode()
457
+ },
458
+ iconSize: function () {
459
+ this._queueMakeCode()
460
+ },
461
+ quietZone: function () {
462
+ this._queueMakeCode()
463
+ },
464
+ lv: function () {
465
+ this._queueMakeCode()
466
+ }
514
467
  },
515
468
  computed: {
516
469
  }
517
470
  }
518
471
  </script>
519
- <style lang="scss" scoped>
520
- .u-qrcode {
521
- &__loading {
472
+ <style lang="scss" scoped>
473
+ .u-qrcode {
474
+ &__loading {
522
475
  display: flex;
523
476
  justify-content: center;
524
477
  align-items: center;
@@ -1,5 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import RadioDefaultProps from './radio'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(RadioDefaultProps)
3
6
  export const props = defineMixin({
4
7
  props: {
5
8
  // radio的名称
@@ -11,7 +11,7 @@
11
11
  :class="iconClasses"
12
12
  :style="[iconWrapStyle]"
13
13
  >
14
- <slot name="icon" :elIconSize="elIconSize" :elIconColor="elIconColor">
14
+ <slot name="icon" :elIconSize="elIconSize" :elIconColor="elIconColor" :checked="checked" :elDisabled="elDisabled">
15
15
  <up-icon
16
16
  class="u-radio__icon-wrap__icon"
17
17
  name="checkbox-mark"
@@ -145,8 +145,12 @@
145
145
  if (this.elDisabled) {
146
146
  classes.push('u-radio__icon-wrap--disabled')
147
147
  }
148
- if (this.checked && this.elDisabled) {
149
- classes.push('u-radio__icon-wrap--disabled--checked')
148
+ if (this.checked) {
149
+ if (this.elDisabled) {
150
+ classes.push('u-radio__icon-wrap--disabled--checked')
151
+ } else {
152
+ classes.push('u-radio__icon-wrap--checked')
153
+ }
150
154
  }
151
155
  // 支付宝,头条小程序无法动态绑定一个数组类名,否则解析出来的结果会带有",",而导致失效
152
156
  // #ifdef MP-ALIPAY || MP-TOUTIAO
@@ -1,5 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import RadioGroupDefaultProps from './radioGroup'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(RadioGroupDefaultProps)
3
6
  export const props = defineMixin({
4
7
  props: {
5
8
  // #ifdef VUE3
@@ -1,5 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import RateDefaultProps from './rate'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(RateDefaultProps)
3
6
  export const props = defineMixin({
4
7
  props: {
5
8
  // #ifdef VUE3