oxy-uni-ui 1.2.0 → 2.0.0

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 (306) hide show
  1. package/attributes.json +1 -1
  2. package/components/common/abstracts/variable.scss +396 -321
  3. package/components/common/path.ts +9 -0
  4. package/components/common/util.ts +200 -5
  5. package/components/composables/index.ts +1 -0
  6. package/components/composables/useGlobalLoading.ts +42 -0
  7. package/components/composables/useGlobalMessage.ts +48 -0
  8. package/components/composables/useGlobalToast.ts +84 -0
  9. package/components/composables/usePopover.ts +24 -20
  10. package/components/composables/useVirtualScroll.ts +13 -11
  11. package/components/composables/useWindowResize.ts +35 -0
  12. package/components/oxy-action-sheet/index.scss +24 -11
  13. package/components/oxy-action-sheet/oxy-action-sheet.vue +27 -19
  14. package/components/oxy-action-sheet/types.ts +7 -0
  15. package/components/oxy-backtop/index.scss +3 -3
  16. package/components/oxy-backtop/oxy-backtop.vue +9 -6
  17. package/components/oxy-backtop/types.ts +7 -7
  18. package/components/oxy-badge/index.scss +4 -4
  19. package/components/oxy-badge/oxy-badge.vue +3 -3
  20. package/components/oxy-badge/types.ts +2 -2
  21. package/components/oxy-button/index.scss +5 -5
  22. package/components/oxy-button/oxy-button.vue +5 -1
  23. package/components/oxy-calendar/index.scss +11 -11
  24. package/components/oxy-calendar/oxy-calendar.vue +1 -0
  25. package/components/oxy-calendar/types.ts +5 -0
  26. package/components/oxy-calendar-view/month/index.scss +4 -4
  27. package/components/oxy-calendar-view/month/types.ts +36 -0
  28. package/components/oxy-calendar-view/monthPanel/index.scss +7 -7
  29. package/components/oxy-calendar-view/monthPanel/month-panel.vue +14 -8
  30. package/components/oxy-calendar-view/year/index.scss +4 -4
  31. package/components/oxy-calendar-view/yearPanel/index.scss +4 -4
  32. package/components/oxy-calendar-view/yearPanel/year-panel.vue +21 -5
  33. package/components/oxy-card/index.scss +2 -2
  34. package/components/oxy-cell/index.scss +8 -8
  35. package/components/oxy-cell/oxy-cell.vue +15 -2
  36. package/components/oxy-cell/types.ts +4 -0
  37. package/components/oxy-checkbox/index.scss +8 -8
  38. package/components/oxy-checkbox/oxy-checkbox.vue +2 -2
  39. package/components/oxy-checkbox-group/index.scss +2 -2
  40. package/components/oxy-circle/oxy-circle.vue +10 -7
  41. package/components/oxy-circle/types.ts +5 -5
  42. package/components/oxy-col/oxy-col.vue +2 -2
  43. package/components/oxy-col-picker/index.scss +4 -4
  44. package/components/oxy-col-picker/oxy-col-picker.vue +9 -5
  45. package/components/oxy-col-picker/types.ts +12 -3
  46. package/components/oxy-collapse/index.scss +2 -2
  47. package/components/oxy-collapse-item/oxy-collapse-item.vue +3 -3
  48. package/components/oxy-corner/index.scss +32 -32
  49. package/components/oxy-corner/oxy-corner.vue +15 -3
  50. package/components/oxy-corner/types.ts +15 -1
  51. package/components/oxy-count-to/oxy-count-to.vue +3 -3
  52. package/components/oxy-curtain/index.scss +15 -15
  53. package/components/oxy-curtain/oxy-curtain.vue +4 -2
  54. package/components/oxy-curtain/types.ts +6 -1
  55. package/components/oxy-date-strip/index.scss +10 -0
  56. package/components/oxy-date-strip/oxy-date-strip.vue +198 -0
  57. package/components/oxy-date-strip/types.ts +98 -0
  58. package/components/oxy-date-strip/utils.ts +67 -0
  59. package/components/oxy-date-strip-item/index.scss +94 -0
  60. package/components/oxy-date-strip-item/oxy-date-strip-item.vue +102 -0
  61. package/components/oxy-date-strip-item/types.ts +53 -0
  62. package/components/oxy-datetime-picker/index.scss +11 -11
  63. package/components/oxy-datetime-picker/oxy-datetime-picker.vue +4 -1
  64. package/components/oxy-datetime-picker/types.ts +10 -1
  65. package/components/oxy-drop-menu/index.scss +3 -3
  66. package/components/oxy-drop-menu/oxy-drop-menu.vue +3 -3
  67. package/components/oxy-drop-menu-item/index.scss +1 -1
  68. package/components/oxy-drop-menu-item/oxy-drop-menu-item.vue +4 -3
  69. package/components/oxy-drop-menu-item/types.ts +5 -0
  70. package/components/oxy-echarts/index.scss +17 -0
  71. package/components/oxy-echarts/index.ts +1 -0
  72. package/components/oxy-echarts/oxy-echarts.vue +32 -0
  73. package/components/oxy-echarts/types.ts +18 -0
  74. package/components/oxy-fab/index.scss +8 -8
  75. package/components/oxy-fab/oxy-fab.vue +22 -3
  76. package/components/oxy-file-list/index.scss +42 -15
  77. package/components/oxy-file-list/oxy-file-list.vue +208 -34
  78. package/components/oxy-file-list/types.ts +58 -2
  79. package/components/oxy-floating-panel/oxy-floating-panel.vue +13 -9
  80. package/components/oxy-floating-panel/{type.ts → types.ts} +8 -8
  81. package/components/oxy-footer/index.scss +19 -0
  82. package/components/oxy-footer/oxy-footer.vue +78 -0
  83. package/components/oxy-footer/types.ts +17 -0
  84. package/components/oxy-form-item/types.ts +22 -1
  85. package/components/oxy-gap/oxy-gap.vue +2 -2
  86. package/components/oxy-gap/types.ts +2 -2
  87. package/components/oxy-global-loading/oxy-global-loading.vue +53 -0
  88. package/components/oxy-global-message/oxy-global-message.vue +64 -0
  89. package/components/oxy-global-toast/oxy-global-toast.vue +53 -0
  90. package/components/oxy-grid/oxy-grid.vue +1 -1
  91. package/components/oxy-grid/types.ts +1 -1
  92. package/components/oxy-grid-item/index.scss +1 -1
  93. package/components/oxy-grid-item/oxy-grid-item.vue +7 -5
  94. package/components/oxy-grid-item/types.ts +1 -1
  95. package/components/oxy-guidance/index.scss +75 -0
  96. package/components/oxy-guidance/oxy-guidance.vue +201 -0
  97. package/components/oxy-guidance/types.ts +33 -0
  98. package/components/oxy-icon/oxy-icon.vue +2 -2
  99. package/components/oxy-icon/types.ts +1 -1
  100. package/components/oxy-img/oxy-img.vue +4 -4
  101. package/components/oxy-img/types.ts +3 -3
  102. package/components/oxy-img-cropper/index.scss +12 -12
  103. package/components/oxy-img-cropper/oxy-img-cropper.vue +97 -52
  104. package/components/oxy-img-cropper/types.ts +2 -2
  105. package/components/oxy-img-lazy/index.scss +17 -0
  106. package/components/oxy-img-lazy/oxy-img-lazy.vue +332 -0
  107. package/components/oxy-img-lazy/types.ts +69 -0
  108. package/components/oxy-index-anchor/index.scss +2 -2
  109. package/components/oxy-index-anchor/oxy-index-anchor.vue +2 -2
  110. package/components/oxy-index-anchor/{type.ts → types.ts} +3 -0
  111. package/components/oxy-index-bar/index.scss +3 -3
  112. package/components/oxy-index-bar/oxy-index-bar.vue +3 -3
  113. package/components/oxy-index-bar/{type.ts → types.ts} +2 -2
  114. package/components/oxy-input/index.scss +1 -1
  115. package/components/oxy-input-number/index.scss +5 -5
  116. package/components/oxy-input-number/oxy-input-number.vue +2 -2
  117. package/components/oxy-input-number/types.ts +3 -2
  118. package/components/oxy-keyboard/index.scss +5 -5
  119. package/components/oxy-keyboard/key/index.scss +3 -3
  120. package/components/oxy-keyboard/key/index.vue +2 -2
  121. package/components/oxy-keyboard/key/types.ts +15 -0
  122. package/components/oxy-keyboard/oxy-keyboard.vue +1 -0
  123. package/components/oxy-keyboard/types.ts +5 -0
  124. package/components/oxy-link/index.scss +57 -0
  125. package/components/oxy-link/oxy-link.vue +130 -0
  126. package/components/oxy-link/types.ts +81 -0
  127. package/components/oxy-list/index.scss +7 -1
  128. package/components/oxy-list/oxy-list.vue +4 -3
  129. package/components/oxy-list/types.ts +1 -1
  130. package/components/oxy-loading/oxy-loading.vue +8 -4
  131. package/components/oxy-loading/types.ts +1 -1
  132. package/components/oxy-loadmore/index.scss +3 -3
  133. package/components/oxy-long-press-menu/index.scss +93 -0
  134. package/components/oxy-long-press-menu/oxy-long-press-menu.vue +338 -0
  135. package/components/oxy-long-press-menu/types.ts +34 -0
  136. package/components/oxy-message-box/index.scss +12 -11
  137. package/components/oxy-message-box/oxy-message-box.vue +11 -3
  138. package/components/oxy-message-box/types.ts +14 -0
  139. package/components/oxy-navbar/index.scss +2 -2
  140. package/components/oxy-navbar/oxy-navbar.vue +58 -13
  141. package/components/oxy-navbar/types.ts +8 -1
  142. package/components/oxy-navbar-capsule/types.ts +3 -0
  143. package/components/oxy-notice-bar/index.scss +3 -3
  144. package/components/oxy-notice-bar/oxy-notice-bar.vue +9 -5
  145. package/components/oxy-notice-bar/types.ts +3 -3
  146. package/components/oxy-notify/index.ts +1 -0
  147. package/components/oxy-notify/oxy-notify.vue +3 -2
  148. package/components/oxy-notify/types.ts +7 -0
  149. package/components/oxy-pagination/index.scss +1 -1
  150. package/components/oxy-password-input/oxy-password-input.vue +2 -2
  151. package/components/oxy-password-input/types.ts +1 -1
  152. package/components/oxy-picker/index.scss +45 -2
  153. package/components/oxy-picker/oxy-picker.vue +103 -14
  154. package/components/oxy-picker/types.ts +33 -1
  155. package/components/oxy-picker-view/index.scss +3 -3
  156. package/components/oxy-picker-view/oxy-picker-view.vue +4 -4
  157. package/components/oxy-popover/index.scss +9 -9
  158. package/components/oxy-popup/index.scss +2 -2
  159. package/components/oxy-popup/oxy-popup.vue +35 -2
  160. package/components/oxy-popup/types.ts +8 -1
  161. package/components/oxy-progress/index.scss +3 -3
  162. package/components/oxy-qrcode/draw.ts +398 -0
  163. package/components/oxy-qrcode/index.scss +2 -0
  164. package/components/oxy-qrcode/oxy-qrcode.vue +124 -0
  165. package/components/oxy-qrcode/qrcode.ts +936 -0
  166. package/components/oxy-qrcode/types.ts +42 -0
  167. package/components/oxy-radio/index.scss +13 -13
  168. package/components/oxy-radio/oxy-radio.vue +1 -1
  169. package/components/oxy-radio-group/index.scss +2 -2
  170. package/components/oxy-rate/types.ts +4 -4
  171. package/components/oxy-resize/index.scss +2 -2
  172. package/components/oxy-resize/oxy-resize.vue +4 -4
  173. package/components/oxy-resize/types.ts +3 -0
  174. package/components/oxy-rich-text/icon/emjio.svg +1 -0
  175. package/components/oxy-rich-text/icon/quote.svg +1 -0
  176. package/components/oxy-rich-text/icon/text.svg +1 -0
  177. package/components/oxy-rich-text/icon/title.svg +1 -0
  178. package/components/oxy-rich-text/index.scss +160 -0
  179. package/components/oxy-rich-text/mp-html/card/card.vue +122 -0
  180. package/components/oxy-rich-text/mp-html/card/index.js +7 -0
  181. package/components/oxy-rich-text/mp-html/editable/config.js +15 -0
  182. package/components/oxy-rich-text/mp-html/editable/index.js +553 -0
  183. package/components/oxy-rich-text/mp-html/emoji/index.js +203 -0
  184. package/components/oxy-rich-text/mp-html/highlight/config.js +5 -0
  185. package/components/oxy-rich-text/mp-html/highlight/index.js +96 -0
  186. package/components/oxy-rich-text/mp-html/highlight/prism.css +1 -0
  187. package/components/oxy-rich-text/mp-html/highlight/prism.min.js +7 -0
  188. package/components/oxy-rich-text/mp-html/img-cache/index.js +138 -0
  189. package/components/oxy-rich-text/mp-html/latex/index.js +80 -0
  190. package/components/oxy-rich-text/mp-html/latex/katex.css +1 -0
  191. package/components/oxy-rich-text/mp-html/latex/katex.min.js +1 -0
  192. package/components/oxy-rich-text/mp-html/markdown/index.js +50 -0
  193. package/components/oxy-rich-text/mp-html/markdown/marked.min.js +71 -0
  194. package/components/oxy-rich-text/mp-html/mp-html.d.ts +184 -0
  195. package/components/oxy-rich-text/mp-html/mp-html.vue +684 -0
  196. package/components/oxy-rich-text/mp-html/node/node.vue +1172 -0
  197. package/components/oxy-rich-text/mp-html/parser.js +1428 -0
  198. package/components/oxy-rich-text/mp-html/search/index.js +132 -0
  199. package/components/oxy-rich-text/mp-html/style/index.js +129 -0
  200. package/components/oxy-rich-text/mp-html/style/parser.js +175 -0
  201. package/components/oxy-rich-text/mp-html/template/index.js +67 -0
  202. package/components/oxy-rich-text/mp-html/txv-video/index.js +46 -0
  203. package/components/oxy-rich-text/oxy-rich-text.vue +642 -0
  204. package/components/oxy-rich-text/types.ts +76 -0
  205. package/components/oxy-row/oxy-row.vue +3 -3
  206. package/components/oxy-row/types.ts +1 -1
  207. package/components/oxy-search/index.scss +3 -3
  208. package/components/oxy-segmented/index.scss +16 -16
  209. package/components/oxy-segmented/oxy-segmented.vue +23 -3
  210. package/components/oxy-select/index.scss +331 -0
  211. package/components/oxy-select/oxy-select.vue +456 -0
  212. package/components/oxy-select/types.ts +83 -0
  213. package/components/oxy-select-picker/index.scss +7 -7
  214. package/components/oxy-select-picker/oxy-select-picker.vue +4 -0
  215. package/components/oxy-select-picker/types.ts +7 -1
  216. package/components/oxy-sidebar-item/index.scss +1 -1
  217. package/components/oxy-signature/oxy-signature.vue +18 -10
  218. package/components/oxy-signature/types.ts +106 -13
  219. package/components/oxy-skeleton/oxy-skeleton.vue +6 -6
  220. package/components/oxy-skeleton/types.ts +1 -1
  221. package/components/oxy-slider/index.scss +3 -3
  222. package/components/oxy-sort-button/index.scss +8 -8
  223. package/components/oxy-status-tip/index.scss +4 -4
  224. package/components/oxy-status-tip/oxy-status-tip.vue +5 -5
  225. package/components/oxy-status-tip/types.ts +3 -3
  226. package/components/oxy-step/index.scss +14 -14
  227. package/components/oxy-sticky/oxy-sticky.vue +6 -6
  228. package/components/oxy-stream-render/index.scss +6 -0
  229. package/components/oxy-stream-render/oxy-stream-render.vue +204 -0
  230. package/components/oxy-stream-render/types.ts +8 -0
  231. package/components/oxy-swipe-action/oxy-swipe-action.vue +27 -2
  232. package/components/oxy-swiper/oxy-swiper.vue +6 -6
  233. package/components/oxy-swiper/types.ts +5 -5
  234. package/components/oxy-switch/index.scss +8 -8
  235. package/components/oxy-switch/oxy-switch.vue +2 -2
  236. package/components/oxy-switch/types.ts +1 -1
  237. package/components/oxy-tab/index.scss +11 -1
  238. package/components/oxy-tabbar/index.scss +1 -1
  239. package/components/oxy-tabbar/oxy-tabbar.vue +39 -10
  240. package/components/oxy-table/index.scss +5 -5
  241. package/components/oxy-table/oxy-table.vue +8 -6
  242. package/components/oxy-table/types.ts +2 -2
  243. package/components/oxy-table-col/oxy-table-col.vue +3 -3
  244. package/components/oxy-table-col/types.ts +2 -2
  245. package/components/oxy-tabs/index.scss +43 -15
  246. package/components/oxy-tabs/oxy-tabs.vue +53 -19
  247. package/components/oxy-tabs/types.ts +15 -3
  248. package/components/oxy-tag/index.scss +15 -15
  249. package/components/oxy-text/index.scss +5 -1
  250. package/components/oxy-text/oxy-text.vue +76 -7
  251. package/components/oxy-text/types.ts +12 -0
  252. package/components/oxy-textarea/index.scss +6 -6
  253. package/components/oxy-toast/oxy-toast.vue +24 -8
  254. package/components/oxy-tooltip/index.scss +9 -9
  255. package/components/oxy-tree/index.scss +61 -9
  256. package/components/oxy-tree/oxy-tree.vue +102 -17
  257. package/components/oxy-tree/types.ts +23 -10
  258. package/components/oxy-upload/index.scss +21 -21
  259. package/components/oxy-upload/types.ts +2 -2
  260. package/components/oxy-verification-code/index.scss +6 -0
  261. package/components/oxy-verification-code/oxy-verification-code.vue +187 -0
  262. package/components/oxy-verification-code/types.ts +82 -0
  263. package/components/oxy-video-preview/index.scss +4 -4
  264. package/components/oxy-virtual-scroll/index.scss +4 -4
  265. package/components/oxy-virtual-scroll/oxy-virtual-scroll.vue +11 -7
  266. package/components/oxy-virtual-scroll/types.ts +14 -14
  267. package/components/oxy-voice-player/index.scss +908 -0
  268. package/components/oxy-voice-player/oxy-voice-player.vue +821 -0
  269. package/components/oxy-voice-player/types.ts +567 -0
  270. package/components/oxy-waterfall/index.scss +18 -0
  271. package/components/oxy-waterfall/oxy-waterfall.vue +218 -0
  272. package/components/oxy-waterfall/types.ts +90 -0
  273. package/components/oxy-waterfall-item/index.scss +8 -0
  274. package/components/oxy-waterfall-item/oxy-waterfall-item.vue +89 -0
  275. package/components/oxy-waterfall-item/types.ts +16 -0
  276. package/components/oxy-watermark/oxy-watermark.vue +35 -13
  277. package/components/oxy-watermark/types.ts +14 -14
  278. package/global.d.ts +9 -0
  279. package/index.ts +3 -0
  280. package/locale/lang/ar-SA.ts +3 -0
  281. package/locale/lang/en-US.ts +29 -0
  282. package/locale/lang/zh-CN.ts +29 -0
  283. package/package.json +97 -1
  284. package/tags.json +1 -1
  285. package/uni-echarts/changelog.md +2 -0
  286. package/uni-echarts/components/index.js +1 -0
  287. package/uni-echarts/components/uni-echarts/events.js +95 -0
  288. package/uni-echarts/components/uni-echarts/types.d.ts +183 -0
  289. package/uni-echarts/components/uni-echarts/types.js +1 -0
  290. package/uni-echarts/components/uni-echarts/uni-echarts.vue +530 -0
  291. package/uni-echarts/components/uni-echarts/uni-echarts.vue.d.ts +19 -0
  292. package/uni-echarts/global.d.ts +7 -0
  293. package/uni-echarts/index.d.ts +440 -0
  294. package/uni-echarts/index.js +2 -0
  295. package/uni-echarts/package.json +105 -0
  296. package/uni-echarts/shared-core.d.ts +269 -0
  297. package/uni-echarts/shared-core.js +900 -0
  298. package/web-types.json +1 -1
  299. package/components/oxy-number-keyboard/index.scss +0 -78
  300. package/components/oxy-number-keyboard/key/index.scss +0 -81
  301. package/components/oxy-number-keyboard/key/index.vue +0 -78
  302. package/components/oxy-number-keyboard/key/types.ts +0 -11
  303. package/components/oxy-number-keyboard/oxy-number-keyboard.vue +0 -151
  304. package/components/oxy-number-keyboard/types.ts +0 -83
  305. package/components/oxy-tree/components/tree-node-content.vue +0 -72
  306. package/components/oxy-tree/index.ts +0 -51
@@ -0,0 +1,201 @@
1
+ <template>
2
+ <view :class="['oxy-guide', customClass]" v-if="showGuide" :style="customStyle" @touchmove.stop.prevent>
3
+ <view class="oxy-guide__box" :style="guideStyle">
4
+ <view ref="tips" class="oxy-guide__box__tips" :style="tipPosition">
5
+ <view class="text">{{ guideInfo.tips }}</view>
6
+ <view class="oxy-guide__box__tips__tool-btn">
7
+ <text class="oxy-guide__box__tips__tool-btn-skip" @click="skip">跳过</text>
8
+ <view class="oxy-guide__box__tips__tool-btn__next" @click="next">{{ guideInfo.next }}</view>
9
+ </view>
10
+ </view>
11
+ <view class="oxy-guide__box__arrow" :style="arrowTop"></view>
12
+ </view>
13
+ <!-- 遮罩层,防止点击 -->
14
+ <view class="oxy-guide__model"></view>
15
+ </view>
16
+ </template>
17
+
18
+ <script lang="ts">
19
+ export default {
20
+ name: 'oxy-guidance',
21
+ options: {
22
+ virtualHost: true,
23
+ addGlobalClass: true,
24
+ styleIsolation: 'shared'
25
+ }
26
+ }
27
+ </script>
28
+
29
+ <script lang="ts" setup>
30
+ import { computed, getCurrentInstance, nextTick, onMounted, ref, watch } from 'vue'
31
+ import { unitConvert } from '../common/util'
32
+ import { guidanceProps, type guideListType } from './types'
33
+ import NodeInfo = UniNamespace.NodeInfo
34
+
35
+ const props = defineProps(guidanceProps)
36
+
37
+ const stepName = ref('step') //该提示步骤的名称,用于不在重复展示
38
+
39
+ const guideList = ref([] as guideListType[])
40
+
41
+ const index = ref(0) // 当前展示的索引
42
+ const showGuide = ref(true) // 是否显示引导
43
+
44
+ const arrowTop = ref('') //步骤提示三角形的定位
45
+ const tipPosition = ref('') //步骤提示的定位
46
+ const systemInfo = ref({} as UniNamespace.GetSystemInfoResult) //屏幕宽度高度等信息
47
+ const tipWidth = ref(0) //步骤提示默认的宽度
48
+ const guideStyle = ref<Record<string, string | number>>({}) //默认样式
49
+ const toPx = (value: number | string | null | undefined) => unitConvert(value, 0, { output: 'px' })
50
+
51
+ const { proxy } = getCurrentInstance()!
52
+
53
+ const guideInfo = computed(() => {
54
+ return guideList.value.length ? guideList.value[index.value] : ({} as guideListType)
55
+ })
56
+
57
+ onMounted(() => {
58
+ guideList.value = props.step.guideList
59
+ stepName.value = props.step.name
60
+ systemInfo.value = uni.getSystemInfoSync()
61
+ const guide = uni.getStorageSync(stepName.value)
62
+ if (!guide) {
63
+ getDomInfo()
64
+ } else {
65
+ showGuide.value = false
66
+ }
67
+ })
68
+
69
+ // 获取dom信息
70
+ function getDomInfo() {
71
+ const { el } = guideInfo.value
72
+ nextTick(() => {
73
+ const query = uni.createSelectorQuery()
74
+ query.select(el).boundingClientRect()
75
+ // 回调结果exec一起处理,解决报错增加空回调
76
+ query.selectViewport().scrollOffset(() => {})
77
+ query.exec((res) => {
78
+ if (res[0]) {
79
+ let data = res[0]
80
+ let scrollTop = res[1].scrollTop
81
+ viewTips(data, scrollTop)
82
+ }
83
+ })
84
+ })
85
+ }
86
+ // 重置
87
+ function openGuid() {
88
+ uni.setStorageSync(stepName.value, '')
89
+ index.value = 0
90
+ showGuide.value = true
91
+ getDomInfo()
92
+ }
93
+ // 跳过新手提示
94
+ function skip() {
95
+ showGuide.value = false
96
+ uni.setStorageSync(stepName.value, 'true')
97
+ uni.pageScrollTo({
98
+ scrollTop: 0,
99
+ duration: 100
100
+ })
101
+ }
102
+ // 下一步
103
+ function next() {
104
+ if (index.value === guideList.value.length - 1) {
105
+ showGuide.value = false
106
+ uni.setStorageSync(stepName.value, 'true')
107
+ uni.pageScrollTo({
108
+ scrollTop: 0,
109
+ duration: 100
110
+ })
111
+ } else {
112
+ index.value += 1
113
+ getDomInfo()
114
+ }
115
+ }
116
+
117
+ const tips = ref()
118
+
119
+ // 展示新手提示
120
+ function viewTips(data: any, scrollTop: number) {
121
+ if (data) {
122
+ // 如果dom宽度大于或者等于窗口宽度,需要重新调整dom展示宽度
123
+ let newWidth = systemInfo.value.windowWidth - 20
124
+ if (data.width >= newWidth) {
125
+ data.width = newWidth
126
+ }
127
+ // 如果距离左边为0,自动增加一点左边距
128
+ if (data.left == 0) {
129
+ data.left = 10
130
+ }
131
+ let domRW = systemInfo.value.windowWidth - data.left
132
+ let left = 0
133
+ tipWidth.value = tips.value.$el.clientWidth
134
+ // 如果dom距离右边没有tips的宽度大的话,就要让tips向左偏移
135
+ if (domRW < tipWidth.value) {
136
+ left = domRW - tipWidth.value
137
+ }
138
+ // 步骤条展示的高度需要加上屏幕滚动的高度
139
+ data.top += scrollTop
140
+ // 根据实际情况需要滚动到展示区域
141
+ uni.pageScrollTo({
142
+ scrollTop: data.top > 44 ? data.top - 44 : 0,
143
+ duration: 100
144
+ })
145
+ let obj = Object.assign(guideList.value[index.value], data)
146
+ // 设置三角形高度
147
+ let arrowTopHeight = data.height + 9
148
+ //如果dom在屏幕底部的话,重新调整提示框和三角形的定位
149
+ let newHeight = systemInfo.value.windowHeight - data.bottom
150
+ uni
151
+ .createSelectorQuery()
152
+ .in(proxy)
153
+ .select('.oxy-guide__box__tips')
154
+ .boundingClientRect((res) => {
155
+ if (newHeight > ((res as NodeInfo).height ?? 0) + 5) {
156
+ // 设置提示框定位
157
+ arrowTop.value = `top: ${toPx(arrowTopHeight)};`
158
+ tipPosition.value = `top: ${toPx(arrowTopHeight + 5)};${
159
+ left < 0 ? 'right: 0;' : 'left: ' + toPx(left) + ';'
160
+ }background: linear-gradient(180deg, #1cbbb4, #0081ff);`
161
+ } else {
162
+ // 设置提示框定位
163
+ arrowTop.value = `top: ${toPx(-19)};`
164
+ tipPosition.value = `top: ${toPx(-14)};${
165
+ left < 0 ? 'right: 0;' : 'left: ' + toPx(left) + ';'
166
+ }transform: translateY(-100%);background: linear-gradient(0deg, #1cbbb4, #0081ff);`
167
+ }
168
+ })
169
+ .exec()
170
+ // 重新设置guideList的值
171
+ guideList.value.splice(index.value, 1, obj)
172
+ guideStyle.value = getStyle()
173
+ } else {
174
+ index.value += 1
175
+ getDomInfo()
176
+ }
177
+ }
178
+ // 获取步骤提示的主要样式
179
+ function getStyle() {
180
+ const { width, height, left, top, style = {} } = guideInfo.value
181
+ const newstyle: Record<string, string | number> = {
182
+ width: toPx(width),
183
+ height: toPx(height),
184
+ left: toPx(left),
185
+ top: toPx(top),
186
+ boxShadow: `rgb(33 33 33 / 80%) ${toPx(0)} ${toPx(0)} ${toPx(0)} ${toPx(0)}, rgb(33 33 33 / 50%) ${toPx(0)} ${toPx(0)} ${toPx(0)} ${toPx(5000)}`,
187
+ borderRadius: '8rpx',
188
+ margin: '0'
189
+ }
190
+ Object.assign(newstyle, style)
191
+ return newstyle
192
+ }
193
+
194
+ defineExpose({
195
+ openGuid
196
+ })
197
+ </script>
198
+
199
+ <style lang="scss" scoped>
200
+ @import './index.scss';
201
+ </style>
@@ -0,0 +1,33 @@
1
+ import type { PropType } from 'vue'
2
+ import { baseProps } from '../common/props'
3
+
4
+ export type guideListType = {
5
+ el: string
6
+ tips: string
7
+ next: string
8
+ width?: number
9
+ height?: number
10
+ left?: number
11
+ top?: number
12
+ style?: Record<string, string | number>
13
+ }
14
+
15
+ export type stepType = {
16
+ name: string
17
+ guideList: Array<guideListType>
18
+ }
19
+
20
+ export const guidanceProps = {
21
+ ...baseProps,
22
+
23
+ /**
24
+ * 步骤集合
25
+ * 类型: Object
26
+ * 默认值: null
27
+ */
28
+ step: {
29
+ required: true as const,
30
+ type: Object as PropType<stepType>,
31
+ default: null
32
+ }
33
+ }
@@ -17,7 +17,7 @@ export default {
17
17
 
18
18
  <script lang="ts" setup>
19
19
  import { computed, type CSSProperties } from 'vue'
20
- import { addUnit, isDef, objToStyle } from '../common/util'
20
+ import { withDefaultUnit, isDef, objToStyle } from '../common/util'
21
21
  import { iconProps } from './types'
22
22
 
23
23
  const props = defineProps(iconProps)
@@ -38,7 +38,7 @@ const rootStyle = computed(() => {
38
38
  style['color'] = props.color
39
39
  }
40
40
  if (props.size) {
41
- style['font-size'] = addUnit(props.size)
41
+ style['font-size'] = withDefaultUnit(props.size)
42
42
  }
43
43
  return `${objToStyle(style)} ${props.customStyle}`
44
44
  })
@@ -11,7 +11,7 @@ export const iconProps = {
11
11
  */
12
12
  color: String,
13
13
  /**
14
- * 图标的字体大小
14
+ * 图标的字体大小,number 类型按 `rpx` 语义处理
15
15
  */
16
16
  size: numericProp,
17
17
  /**
@@ -27,7 +27,7 @@ export default {
27
27
 
28
28
  <script lang="ts" setup>
29
29
  import { computed, ref } from 'vue'
30
- import { addUnit, isDef, objToStyle } from '../common/util'
30
+ import { withDefaultUnit, isDef, objToStyle } from '../common/util'
31
31
  import { imgProps } from './types'
32
32
 
33
33
  const props = defineProps(imgProps)
@@ -40,13 +40,13 @@ const emit = defineEmits<{
40
40
  const rootStyle = computed(() => {
41
41
  const style: Record<string, string | number> = {}
42
42
  if (isDef(props.height)) {
43
- style['height'] = addUnit(props.height)
43
+ style['height'] = withDefaultUnit(props.height)
44
44
  }
45
45
  if (isDef(props.width)) {
46
- style['width'] = addUnit(props.width)
46
+ style['width'] = withDefaultUnit(props.width)
47
47
  }
48
48
  if (isDef(props.radius)) {
49
- style['border-radius'] = addUnit(props.radius)
49
+ style['border-radius'] = withDefaultUnit(props.radius)
50
50
  style['overflow'] = 'hidden'
51
51
  }
52
52
  return `${objToStyle(style)}${props.customStyle}`
@@ -39,15 +39,15 @@ export const imgProps = {
39
39
  */
40
40
  lazyLoad: makeBooleanProp(false),
41
41
  /**
42
- * 宽度,默认单位为px
42
+ * 宽度,number 类型按 `rpx` 语义处理,也支持 `px/rpx`
43
43
  */
44
44
  width: numericProp,
45
45
  /**
46
- * 高度,默认单位为px
46
+ * 高度,number 类型按 `rpx` 语义处理,也支持 `px/rpx`
47
47
  */
48
48
  height: numericProp,
49
49
  /**
50
- * 圆角大小,默认单位为px
50
+ * 圆角大小,number 类型按 `rpx` 语义处理,也支持 `px/rpx`
51
51
  */
52
52
  radius: numericProp,
53
53
  /**
@@ -65,7 +65,7 @@
65
65
  }
66
66
 
67
67
  // 结算框对角尺寸
68
- $border-size: 2px;
68
+ $border-size: 4rpx;
69
69
 
70
70
  // 节选框的四个角
71
71
  .is-left-top,
@@ -76,14 +76,14 @@
76
76
  content: "";
77
77
  position: absolute;
78
78
  width: $border-size;
79
- height: 20px;
79
+ height: 40rpx;
80
80
  background-color: #fff;
81
81
  }
82
82
 
83
83
  &::after {
84
84
  content: "";
85
85
  position: absolute;
86
- width: 20px;
86
+ width: 40rpx;
87
87
  height: $border-size;
88
88
  background-color: #fff;
89
89
  }
@@ -184,8 +184,8 @@
184
184
  @include e(canvas) {
185
185
  position: fixed;
186
186
  background: white;
187
- width: 150px;
188
- height: 150px;
187
+ width: 300rpx;
188
+ height: 300rpx;
189
189
  z-index: 10;
190
190
  top: -200%;
191
191
  pointer-events: none;
@@ -194,7 +194,7 @@
194
194
  @include e(footer) {
195
195
  position: fixed;
196
196
  z-index: 10;
197
- bottom: 10px;
197
+ bottom: 20rpx;
198
198
  width: 100%;
199
199
  height: 15vh;
200
200
  text-align: center;
@@ -202,7 +202,7 @@
202
202
  @include m(button) {
203
203
  position: relative;
204
204
  text-align: left;
205
- margin: 0 20px;
205
+ margin: 0 40rpx;
206
206
  padding-top: 4vh;
207
207
  // line-height: 32px;
208
208
  box-sizing: border-box;
@@ -210,16 +210,16 @@
210
210
  .is-cancel {
211
211
  display: inline-block;
212
212
  color: #fff;
213
- font-size: 16px;
213
+ font-size: 32rpx;
214
214
  }
215
215
 
216
216
  .is-confirm {
217
217
  position: absolute;
218
218
  right: 0;
219
219
  // height: 32px;
220
- width: 56px;
221
- border-radius: 16px;
222
- font-size: 16px;
220
+ width: 112rpx;
221
+ border-radius: 32rpx;
222
+ font-size: 32rpx;
223
223
  }
224
224
  }
225
225
  }
@@ -228,4 +228,4 @@
228
228
  font-size: $-img-cropper-icon-size;
229
229
  color: $-img-cropper-icon-color;
230
230
  }
231
- }
231
+ }
@@ -6,15 +6,15 @@
6
6
  <!-- 画出裁剪框 -->
7
7
  <view class="oxy-img-cropper__cut">
8
8
  <!-- 上方阴影块 -->
9
- <view :class="`oxy-img-cropper__cut--top ${IS_TOUCH_END ? '' : 'is-hightlight'}`" :style="`height: ${cutTop}px;`"></view>
10
- <view class="oxy-img-cropper__cut--middle" :style="`height: ${cutHeight}px;`">
9
+ <view :class="`oxy-img-cropper__cut--top ${IS_TOUCH_END ? '' : 'is-hightlight'}`" :style="`height: ${toPx(cutTop)};`"></view>
10
+ <view class="oxy-img-cropper__cut--middle" :style="`height: ${toPx(cutHeight)};`">
11
11
  <!-- 左侧阴影块 -->
12
12
  <view
13
13
  :class="`oxy-img-cropper__cut--left ${IS_TOUCH_END ? '' : 'is-hightlight'}`"
14
- :style="`width: ${cutLeft}px; height: ${cutHeight}px;`"
14
+ :style="`width: ${toPx(cutLeft)}; height: ${toPx(cutHeight)};`"
15
15
  ></view>
16
16
  <!-- 裁剪框 -->
17
- <view class="oxy-img-cropper__cut--body" :style="`width: ${cutWidth}px; height: ${cutHeight}px;`">
17
+ <view class="oxy-img-cropper__cut--body" :style="`width: ${toPx(cutWidth)}; height: ${toPx(cutHeight)};`">
18
18
  <!-- 内部网格线 -->
19
19
  <view class="is-gridlines-x"></view>
20
20
  <view class="is-gridlines-y"></view>
@@ -52,7 +52,7 @@
52
52
  :id="canvasId"
53
53
  class="oxy-img-cropper__canvas"
54
54
  :disable-scroll="true"
55
- :style="`width: ${Number(canvasWidth) * canvasScale}px; height: ${Number(canvasHeight) * canvasScale}px;`"
55
+ :style="`width: ${toPx(Number(canvasWidth) * canvasScale)}; height: ${toPx(Number(canvasHeight) * canvasScale)};`"
56
56
  />
57
57
  <!-- 下方按钮 -->
58
58
  <view class="oxy-img-cropper__footer">
@@ -80,7 +80,8 @@ export default {
80
80
  import OxyIcon from '../oxy-icon/oxy-icon.vue'
81
81
  import OxyButton from '../oxy-button/oxy-button.vue'
82
82
  import { computed, getCurrentInstance, ref, watch } from 'vue'
83
- import { addUnit, objToStyle, uuid } from '../common/util'
83
+ import { objToStyle, unitConvert, unitConvertWithDefault, uuid } from '../common/util'
84
+ import { useWindowResize, type WindowResizeResult } from '../composables/useWindowResize'
84
85
  import { useTranslate } from '../composables/useTranslate'
85
86
  import { imgCropperProps, type ImgCropperExpose } from './types'
86
87
 
@@ -132,11 +133,12 @@ const imgScale = ref<number>(1)
132
133
  // imgWidth: null,
133
134
  // imgHeight: null,
134
135
  // 图片中心轴点距左的距离
135
- const imgLeft = ref<number>(uni.getSystemInfoSync().windowWidth / 2)
136
- const imgTop = ref<number>((uni.getSystemInfoSync().windowHeight / 2) * TOP_PERCENT)
136
+ const initialInfo = uni.getSystemInfoSync()
137
+ const imgLeft = ref<number>(initialInfo.windowWidth / 2)
138
+ const imgTop = ref<number>((initialInfo.windowHeight / 2) * TOP_PERCENT)
137
139
 
138
140
  const imgInfo = ref<UniApp.GetImageInfoSuccessData | null>(null)
139
- const info = ref<UniApp.GetSystemInfoResult>(uni.getSystemInfoSync())
141
+ const info = ref<UniApp.GetSystemInfoResult>(initialInfo)
140
142
 
141
143
  // 是否移动中设置 同时控制背景颜色是否高亮
142
144
  const IS_TOUCH_END = ref<boolean>(true)
@@ -157,31 +159,58 @@ const fingerDistance = ref<string | number>('')
157
159
  const ctx = ref<UniApp.CanvasContext | null>(null)
158
160
 
159
161
  const { proxy } = getCurrentInstance() as any
162
+ const updateSystemInfo = (res?: WindowResizeResult) => {
163
+ const systemInfo = uni.getSystemInfoSync()
164
+ const resizeWidth = Number(res?.size?.windowWidth ?? res?.windowWidth)
165
+ const resizeHeight = Number(res?.size?.windowHeight ?? res?.windowHeight)
166
+ info.value = {
167
+ ...systemInfo,
168
+ windowWidth: Number.isFinite(resizeWidth) && resizeWidth > 0 ? resizeWidth : systemInfo.windowWidth,
169
+ windowHeight: Number.isFinite(resizeHeight) && resizeHeight > 0 ? resizeHeight : systemInfo.windowHeight
170
+ }
171
+ }
172
+
173
+ function updateCropLayout() {
174
+ INIT_IMGWIDTH = props.imgWidth
175
+ INIT_IMGHEIGHT = props.imgHeight
176
+
177
+ // 根据aspectRatio计算裁剪框尺寸
178
+ const [widthRatio, heightRatio] = props.aspectRatio.split(':').map(Number)
179
+ const tempCutWidth = info.value.windowWidth - offset.value * 2
180
+ const tempCutHeight = (tempCutWidth * heightRatio) / widthRatio
181
+
182
+ cutWidth.value = tempCutWidth
183
+ cutHeight.value = tempCutHeight
184
+ cutTop.value = (info.value.windowHeight * TOP_PERCENT - tempCutHeight) / 2
185
+ cutLeft.value = offset.value
186
+
187
+ canvasScale.value = props.exportScale
188
+ canvasHeight.value = tempCutHeight
189
+ canvasWidth.value = tempCutWidth
190
+
191
+ // 根据开发者设置的图片目标尺寸计算实际尺寸
192
+ initImageSize()
193
+ }
194
+
195
+ const handleWindowResize = (res?: WindowResizeResult) => {
196
+ updateSystemInfo(res)
197
+ if (!props.modelValue) return
198
+
199
+ updateCropLayout()
200
+ if (imgInfo.value) {
201
+ computeImgSize()
202
+ resetImg()
203
+ }
204
+ }
205
+
206
+ useWindowResize(handleWindowResize)
160
207
 
161
208
  watch(
162
209
  () => props.modelValue,
163
210
  (newValue) => {
164
211
  if (newValue) {
165
- INIT_IMGWIDTH = props.imgWidth
166
- INIT_IMGHEIGHT = props.imgHeight
167
- info.value = uni.getSystemInfoSync()
168
-
169
- // 根据aspectRatio计算裁剪框尺寸
170
- const [widthRatio, heightRatio] = props.aspectRatio.split(':').map(Number)
171
- const tempCutWidth = info.value.windowWidth - offset.value * 2
172
- const tempCutHeight = (tempCutWidth * heightRatio) / widthRatio
173
-
174
- cutWidth.value = tempCutWidth
175
- cutHeight.value = tempCutHeight
176
- cutTop.value = (info.value.windowHeight * TOP_PERCENT - tempCutHeight) / 2
177
- cutLeft.value = offset.value
178
-
179
- canvasScale.value = props.exportScale
180
- canvasHeight.value = tempCutHeight
181
- canvasWidth.value = tempCutWidth
182
-
183
- // 根据开发者设置的图片目标尺寸计算实际尺寸
184
- initImageSize()
212
+ updateSystemInfo()
213
+ updateCropLayout()
185
214
  // 初始化canvas
186
215
  initCanvas()
187
216
  // 加载图片
@@ -242,21 +271,25 @@ const buttonStyle = computed(() => {
242
271
  position: 'absolute',
243
272
  right: 0,
244
273
  // height: 32px;
245
- width: '56px',
246
- 'border-radius': '16px',
247
- 'font-size': '16px'
274
+ width: '112rpx',
275
+ 'border-radius': '32rpx',
276
+ 'font-size': '32rpx'
248
277
  }
249
278
 
250
279
  return objToStyle(style)
251
280
  })
252
281
 
282
+ const toPx = (value: string | number | null | undefined) => unitConvert(value, 0, { output: 'px' })
283
+
253
284
  const imageStyle = computed(() => {
254
285
  const style: Record<string, string | number> = {
255
- width: picWidth.value ? addUnit(picWidth.value) : 'auto',
256
- height: picHeight.value ? addUnit(picHeight.value) : 'auto',
257
- transform: `translate(${addUnit(imgLeft.value - picWidth.value / 2)}, ${addUnit(imgTop.value - picHeight.value / 2)}) scale(${
258
- imgScale.value
259
- }) rotate(${imgAngle.value}deg)`,
286
+ width: picWidth.value ? unitConvert(picWidth.value, 0, { output: 'px' }) : 'auto',
287
+ height: picHeight.value ? unitConvert(picHeight.value, 0, { output: 'px' }) : 'auto',
288
+ transform: `translate(${unitConvert(imgLeft.value - picWidth.value / 2, 0, { output: 'px' })}, ${unitConvert(
289
+ imgTop.value - picHeight.value / 2,
290
+ 0,
291
+ { output: 'px' }
292
+ )}) scale(${imgScale.value}) rotate(${imgAngle.value}deg)`,
260
293
  'transition-duration': (isAnimation.value ? 0.4 : 0) + 's'
261
294
  }
262
295
  return objToStyle(style)
@@ -305,7 +338,7 @@ function setRoate(angle: number) {
305
338
  * 初始化图片的大小和角度以及距离
306
339
  */
307
340
  function resetImg() {
308
- const { windowHeight, windowWidth } = uni.getSystemInfoSync()
341
+ const { windowHeight, windowWidth } = info.value
309
342
  imgScale.value = 1
310
343
  imgAngle.value = 0
311
344
  imgLeft.value = windowWidth / 2
@@ -387,21 +420,33 @@ function initCanvas() {
387
420
  * 图片初始化,处理宽高特殊单位
388
421
  */
389
422
  function initImageSize() {
390
- // 处理宽高特殊单位 %>px
391
- if (INIT_IMGWIDTH && typeof INIT_IMGWIDTH === 'string' && INIT_IMGWIDTH.indexOf('%') !== -1) {
392
- const width: string = INIT_IMGWIDTH.replace('%', '')
393
- INIT_IMGWIDTH = (info.value.windowWidth / 100) * Number(width)
394
- picWidth.value = INIT_IMGWIDTH
395
- } else if (INIT_IMGWIDTH && typeof INIT_IMGWIDTH === 'number') {
396
- picWidth.value = INIT_IMGWIDTH
423
+ const resolveImageLength = (value: number | string | null, base: number): number | null => {
424
+ if (value === null || value === undefined || value === '') return null
425
+
426
+ if (typeof value === 'string') {
427
+ const trimmed = value.trim()
428
+ if (!trimmed) return null
429
+ if (trimmed.endsWith('%')) {
430
+ const percentValue = Number(trimmed.slice(0, -1))
431
+ if (!Number.isFinite(percentValue)) return null
432
+ return (base * percentValue) / 100
433
+ }
434
+ }
435
+
436
+ const converted = unitConvertWithDefault(value, { defaultUnit: 'rpx' })
437
+ return Number.isFinite(converted) && converted > 0 ? converted : null
397
438
  }
398
- if (INIT_IMGHEIGHT && typeof INIT_IMGHEIGHT === 'string' && INIT_IMGHEIGHT.indexOf('%') !== -1) {
399
- const height = (props.imgHeight as string).replace('%', '')
400
- // INIT_IMGHEIGHT = this.data.imgHeight = (info.value.windowHeight / 100) * Number(height)
401
- INIT_IMGHEIGHT = (info.value.windowHeight / 100) * Number(height)
402
- picWidth.value = INIT_IMGHEIGHT
403
- } else if (INIT_IMGHEIGHT && typeof INIT_IMGHEIGHT === 'number') {
404
- picWidth.value = Number(INIT_IMGWIDTH)
439
+
440
+ const resolvedWidth = resolveImageLength(INIT_IMGWIDTH, info.value.windowWidth)
441
+ if (resolvedWidth !== null) {
442
+ INIT_IMGWIDTH = resolvedWidth
443
+ picWidth.value = resolvedWidth
444
+ }
445
+
446
+ const resolvedHeight = resolveImageLength(INIT_IMGHEIGHT, info.value.windowHeight)
447
+ if (resolvedHeight !== null) {
448
+ INIT_IMGHEIGHT = resolvedHeight
449
+ picHeight.value = resolvedHeight
405
450
  }
406
451
  }
407
452
 
@@ -38,11 +38,11 @@ export const imgCropperProps = {
38
38
  */
39
39
  imgSrc: makeStringProp(''),
40
40
  /**
41
- * 图片宽
41
+ * 图片宽,支持 `px/rpx/%`,number 与纯数字字符串按 rpx 处理
42
42
  */
43
43
  imgWidth: makeNumericProp(''),
44
44
  /**
45
- * 图片高
45
+ * 图片高,支持 `px/rpx/%`,number 与纯数字字符串按 rpx 处理
46
46
  */
47
47
  imgHeight: makeNumericProp(''),
48
48
  /**
@@ -0,0 +1,17 @@
1
+ @import "./../common/abstracts/_mixin.scss";
2
+ @import "./../common/abstracts/variable.scss";
3
+
4
+ @include b(img-lazy) {
5
+ // overflow: hidden;
6
+ position: relative;
7
+ @include e(image) {
8
+ display: block;
9
+ will-change: transform;
10
+ }
11
+
12
+ @include e(load) {
13
+ position: absolute;
14
+ left: 0;
15
+ top: 0;
16
+ }
17
+ }