oxy-uni-ui 1.2.3 → 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 (235) hide show
  1. package/attributes.json +1 -1
  2. package/components/common/abstracts/variable.scss +353 -328
  3. package/components/common/util.ts +185 -32
  4. package/components/composables/index.ts +1 -0
  5. package/components/composables/usePopover.ts +24 -20
  6. package/components/composables/useVirtualScroll.ts +10 -9
  7. package/components/composables/useWindowResize.ts +35 -0
  8. package/components/oxy-action-sheet/index.scss +24 -11
  9. package/components/oxy-action-sheet/oxy-action-sheet.vue +27 -19
  10. package/components/oxy-action-sheet/types.ts +7 -0
  11. package/components/oxy-backtop/index.scss +3 -3
  12. package/components/oxy-backtop/oxy-backtop.vue +9 -6
  13. package/components/oxy-backtop/types.ts +7 -7
  14. package/components/oxy-badge/index.scss +4 -4
  15. package/components/oxy-badge/oxy-badge.vue +3 -3
  16. package/components/oxy-badge/types.ts +2 -2
  17. package/components/oxy-button/index.scss +5 -5
  18. package/components/oxy-button/oxy-button.vue +5 -1
  19. package/components/oxy-calendar/index.scss +11 -11
  20. package/components/oxy-calendar/oxy-calendar.vue +1 -0
  21. package/components/oxy-calendar/types.ts +5 -0
  22. package/components/oxy-calendar-view/month/index.scss +4 -4
  23. package/components/oxy-calendar-view/month/types.ts +36 -0
  24. package/components/oxy-calendar-view/monthPanel/index.scss +7 -7
  25. package/components/oxy-calendar-view/monthPanel/month-panel.vue +14 -8
  26. package/components/oxy-calendar-view/year/index.scss +4 -4
  27. package/components/oxy-calendar-view/yearPanel/index.scss +4 -4
  28. package/components/oxy-calendar-view/yearPanel/year-panel.vue +21 -5
  29. package/components/oxy-card/index.scss +2 -2
  30. package/components/oxy-cell/index.scss +8 -8
  31. package/components/oxy-checkbox/index.scss +7 -7
  32. package/components/oxy-checkbox-group/index.scss +2 -2
  33. package/components/oxy-circle/oxy-circle.vue +10 -7
  34. package/components/oxy-circle/types.ts +5 -5
  35. package/components/oxy-col/oxy-col.vue +2 -2
  36. package/components/oxy-col-picker/index.scss +4 -4
  37. package/components/oxy-col-picker/oxy-col-picker.vue +6 -5
  38. package/components/oxy-col-picker/types.ts +7 -2
  39. package/components/oxy-collapse/index.scss +2 -2
  40. package/components/oxy-collapse-item/oxy-collapse-item.vue +3 -3
  41. package/components/oxy-corner/index.scss +32 -32
  42. package/components/oxy-count-to/oxy-count-to.vue +3 -3
  43. package/components/oxy-curtain/index.scss +15 -15
  44. package/components/oxy-curtain/oxy-curtain.vue +4 -2
  45. package/components/oxy-curtain/types.ts +6 -1
  46. package/components/oxy-date-strip/oxy-date-strip.vue +2 -2
  47. package/components/oxy-date-strip/types.ts +1 -1
  48. package/components/oxy-date-strip-item/index.scss +3 -3
  49. package/components/oxy-datetime-picker/index.scss +11 -11
  50. package/components/oxy-datetime-picker/oxy-datetime-picker.vue +1 -0
  51. package/components/oxy-datetime-picker/types.ts +5 -0
  52. package/components/oxy-drop-menu/index.scss +3 -3
  53. package/components/oxy-drop-menu/oxy-drop-menu.vue +3 -3
  54. package/components/oxy-drop-menu-item/index.scss +1 -1
  55. package/components/oxy-drop-menu-item/oxy-drop-menu-item.vue +4 -3
  56. package/components/oxy-drop-menu-item/types.ts +5 -0
  57. package/components/oxy-echarts/types.ts +6 -0
  58. package/components/oxy-fab/index.scss +8 -8
  59. package/components/oxy-fab/oxy-fab.vue +22 -3
  60. package/components/oxy-file-list/index.scss +24 -23
  61. package/components/oxy-file-list/oxy-file-list.vue +2 -2
  62. package/components/oxy-floating-panel/oxy-floating-panel.vue +13 -9
  63. package/components/oxy-floating-panel/{type.ts → types.ts} +8 -8
  64. package/components/oxy-footer/index.scss +19 -0
  65. package/components/oxy-footer/oxy-footer.vue +78 -0
  66. package/components/oxy-footer/types.ts +17 -0
  67. package/components/oxy-form-item/types.ts +22 -1
  68. package/components/oxy-gap/oxy-gap.vue +2 -2
  69. package/components/oxy-gap/types.ts +2 -2
  70. package/components/oxy-grid/oxy-grid.vue +1 -1
  71. package/components/oxy-grid/types.ts +1 -1
  72. package/components/oxy-grid-item/index.scss +1 -1
  73. package/components/oxy-grid-item/oxy-grid-item.vue +7 -5
  74. package/components/oxy-grid-item/types.ts +1 -1
  75. package/components/oxy-guidance/index.scss +75 -0
  76. package/components/oxy-guidance/oxy-guidance.vue +201 -0
  77. package/components/oxy-guidance/types.ts +33 -0
  78. package/components/oxy-icon/oxy-icon.vue +2 -2
  79. package/components/oxy-icon/types.ts +1 -1
  80. package/components/oxy-img/oxy-img.vue +4 -4
  81. package/components/oxy-img/types.ts +3 -3
  82. package/components/oxy-img-cropper/index.scss +12 -12
  83. package/components/oxy-img-cropper/oxy-img-cropper.vue +97 -52
  84. package/components/oxy-img-cropper/types.ts +2 -2
  85. package/components/oxy-img-lazy/oxy-img-lazy.vue +3 -3
  86. package/components/oxy-img-lazy/types.ts +3 -3
  87. package/components/oxy-index-anchor/index.scss +2 -2
  88. package/components/oxy-index-anchor/oxy-index-anchor.vue +2 -2
  89. package/components/oxy-index-anchor/{type.ts → types.ts} +3 -0
  90. package/components/oxy-index-bar/index.scss +3 -3
  91. package/components/oxy-index-bar/oxy-index-bar.vue +3 -3
  92. package/components/oxy-index-bar/{type.ts → types.ts} +2 -2
  93. package/components/oxy-input/index.scss +1 -1
  94. package/components/oxy-input-number/index.scss +5 -5
  95. package/components/oxy-input-number/oxy-input-number.vue +2 -2
  96. package/components/oxy-input-number/types.ts +3 -2
  97. package/components/oxy-keyboard/index.scss +5 -5
  98. package/components/oxy-keyboard/key/index.scss +3 -3
  99. package/components/oxy-keyboard/key/index.vue +2 -2
  100. package/components/oxy-keyboard/key/types.ts +15 -0
  101. package/components/oxy-keyboard/oxy-keyboard.vue +1 -0
  102. package/components/oxy-keyboard/types.ts +5 -0
  103. package/components/oxy-link/index.scss +2 -2
  104. package/components/oxy-list/oxy-list.vue +4 -3
  105. package/components/oxy-loading/oxy-loading.vue +8 -4
  106. package/components/oxy-loading/types.ts +1 -1
  107. package/components/oxy-loadmore/index.scss +3 -3
  108. package/components/oxy-long-press-menu/index.scss +93 -0
  109. package/components/oxy-long-press-menu/oxy-long-press-menu.vue +338 -0
  110. package/components/oxy-long-press-menu/types.ts +34 -0
  111. package/components/oxy-message-box/index.scss +12 -11
  112. package/components/oxy-message-box/oxy-message-box.vue +11 -3
  113. package/components/oxy-message-box/types.ts +14 -0
  114. package/components/oxy-navbar/index.scss +2 -2
  115. package/components/oxy-navbar/oxy-navbar.vue +58 -13
  116. package/components/oxy-navbar/types.ts +8 -1
  117. package/components/oxy-navbar-capsule/types.ts +3 -0
  118. package/components/oxy-notice-bar/index.scss +3 -3
  119. package/components/oxy-notice-bar/oxy-notice-bar.vue +9 -5
  120. package/components/oxy-notice-bar/types.ts +3 -3
  121. package/components/oxy-notify/index.ts +1 -0
  122. package/components/oxy-notify/oxy-notify.vue +3 -2
  123. package/components/oxy-notify/types.ts +7 -0
  124. package/components/oxy-pagination/index.scss +1 -1
  125. package/components/oxy-password-input/oxy-password-input.vue +2 -2
  126. package/components/oxy-password-input/types.ts +1 -1
  127. package/components/oxy-picker/index.scss +45 -2
  128. package/components/oxy-picker/oxy-picker.vue +100 -14
  129. package/components/oxy-picker/types.ts +29 -1
  130. package/components/oxy-picker-view/index.scss +3 -3
  131. package/components/oxy-picker-view/oxy-picker-view.vue +4 -4
  132. package/components/oxy-popover/index.scss +9 -9
  133. package/components/oxy-popup/index.scss +2 -2
  134. package/components/oxy-popup/oxy-popup.vue +35 -2
  135. package/components/oxy-popup/types.ts +8 -1
  136. package/components/oxy-progress/index.scss +3 -3
  137. package/components/oxy-qrcode/draw.ts +398 -0
  138. package/components/oxy-qrcode/index.scss +2 -0
  139. package/components/oxy-qrcode/oxy-qrcode.vue +124 -0
  140. package/components/oxy-qrcode/qrcode.ts +936 -0
  141. package/components/oxy-qrcode/types.ts +42 -0
  142. package/components/oxy-radio/index.scss +10 -10
  143. package/components/oxy-radio-group/index.scss +2 -2
  144. package/components/oxy-rate/types.ts +4 -4
  145. package/components/oxy-resize/index.scss +2 -2
  146. package/components/oxy-resize/oxy-resize.vue +4 -4
  147. package/components/oxy-resize/types.ts +3 -0
  148. package/components/oxy-rich-text/index.scss +30 -29
  149. package/components/oxy-rich-text/mp-html/mp-html.vue +33 -24
  150. package/components/oxy-rich-text/mp-html/node/node.vue +30 -19
  151. package/components/oxy-rich-text/oxy-rich-text.vue +31 -31
  152. package/components/oxy-rich-text/types.ts +6 -1
  153. package/components/oxy-row/oxy-row.vue +3 -3
  154. package/components/oxy-row/types.ts +1 -1
  155. package/components/oxy-search/index.scss +3 -3
  156. package/components/oxy-segmented/index.scss +16 -16
  157. package/components/oxy-segmented/oxy-segmented.vue +23 -3
  158. package/components/oxy-select/index.scss +144 -68
  159. package/components/oxy-select/oxy-select.vue +85 -50
  160. package/components/oxy-select/types.ts +13 -1
  161. package/components/oxy-select-picker/index.scss +7 -7
  162. package/components/oxy-select-picker/oxy-select-picker.vue +1 -0
  163. package/components/oxy-select-picker/types.ts +2 -0
  164. package/components/oxy-sidebar-item/index.scss +1 -1
  165. package/components/oxy-signature/oxy-signature.vue +18 -10
  166. package/components/oxy-signature/types.ts +106 -13
  167. package/components/oxy-skeleton/oxy-skeleton.vue +6 -6
  168. package/components/oxy-skeleton/types.ts +1 -1
  169. package/components/oxy-slider/index.scss +3 -3
  170. package/components/oxy-sort-button/index.scss +8 -8
  171. package/components/oxy-status-tip/index.scss +4 -4
  172. package/components/oxy-status-tip/oxy-status-tip.vue +5 -5
  173. package/components/oxy-status-tip/types.ts +3 -3
  174. package/components/oxy-step/index.scss +14 -14
  175. package/components/oxy-sticky/oxy-sticky.vue +6 -6
  176. package/components/oxy-stream-render/types.ts +4 -1
  177. package/components/oxy-swipe-action/oxy-swipe-action.vue +27 -2
  178. package/components/oxy-swiper/oxy-swiper.vue +6 -6
  179. package/components/oxy-swiper/types.ts +5 -5
  180. package/components/oxy-switch/index.scss +8 -8
  181. package/components/oxy-switch/oxy-switch.vue +2 -2
  182. package/components/oxy-switch/types.ts +1 -1
  183. package/components/oxy-tab/index.scss +11 -1
  184. package/components/oxy-tabbar/index.scss +1 -1
  185. package/components/oxy-tabbar/oxy-tabbar.vue +39 -10
  186. package/components/oxy-table/index.scss +5 -5
  187. package/components/oxy-table/oxy-table.vue +8 -6
  188. package/components/oxy-table/types.ts +2 -2
  189. package/components/oxy-table-col/oxy-table-col.vue +3 -3
  190. package/components/oxy-table-col/types.ts +2 -2
  191. package/components/oxy-tabs/index.scss +43 -15
  192. package/components/oxy-tabs/oxy-tabs.vue +53 -19
  193. package/components/oxy-tabs/types.ts +15 -3
  194. package/components/oxy-tag/index.scss +15 -15
  195. package/components/oxy-text/index.scss +5 -1
  196. package/components/oxy-text/oxy-text.vue +76 -7
  197. package/components/oxy-text/types.ts +12 -0
  198. package/components/oxy-textarea/index.scss +6 -6
  199. package/components/oxy-toast/oxy-toast.vue +24 -8
  200. package/components/oxy-tooltip/index.scss +9 -9
  201. package/components/oxy-tree/index.scss +51 -15
  202. package/components/oxy-tree/oxy-tree.vue +13 -9
  203. package/components/oxy-tree/types.ts +12 -9
  204. package/components/oxy-upload/index.scss +21 -21
  205. package/components/oxy-upload/types.ts +2 -2
  206. package/components/oxy-verification-code/index.scss +6 -0
  207. package/components/oxy-verification-code/oxy-verification-code.vue +187 -0
  208. package/components/oxy-verification-code/types.ts +82 -0
  209. package/components/oxy-video-preview/index.scss +4 -4
  210. package/components/oxy-virtual-scroll/index.scss +4 -4
  211. package/components/oxy-virtual-scroll/oxy-virtual-scroll.vue +11 -7
  212. package/components/oxy-virtual-scroll/types.ts +14 -14
  213. package/components/oxy-voice-player/index.scss +908 -0
  214. package/components/oxy-voice-player/oxy-voice-player.vue +821 -0
  215. package/components/oxy-voice-player/types.ts +567 -0
  216. package/components/oxy-waterfall/oxy-waterfall.vue +6 -6
  217. package/components/oxy-waterfall/types.ts +6 -6
  218. package/components/oxy-watermark/oxy-watermark.vue +35 -13
  219. package/components/oxy-watermark/types.ts +14 -14
  220. package/global.d.ts +2 -0
  221. package/locale/lang/ar-SA.ts +3 -0
  222. package/locale/lang/en-US.ts +3 -0
  223. package/locale/lang/zh-CN.ts +3 -0
  224. package/package.json +97 -1
  225. package/tags.json +1 -1
  226. package/web-types.json +1 -1
  227. package/components/oxy-number-keyboard/index.scss +0 -78
  228. package/components/oxy-number-keyboard/key/index.scss +0 -81
  229. package/components/oxy-number-keyboard/key/index.vue +0 -78
  230. package/components/oxy-number-keyboard/key/types.ts +0 -11
  231. package/components/oxy-number-keyboard/oxy-number-keyboard.vue +0 -151
  232. package/components/oxy-number-keyboard/types.ts +0 -83
  233. package/components/oxy-tree/components/tree-node-content.vue +0 -72
  234. package/components/oxy-tree/index.ts +0 -51
  235. package/oxy-uni-ui.zip +0 -0
@@ -0,0 +1,78 @@
1
+ <template>
2
+ <view class="oxy-footer-placeholder" :style="{ height: placeholderHeight }"></view>
3
+ <view class="oxy-footer-wrapper">
4
+ <view :class="`oxy-footer ${customClass}`" :style="`background-color: ${backgroundColor};${customStyle}`">
5
+ <view class="oxy-footer__content" :style="contentStyle">
6
+ <slot></slot>
7
+ </view>
8
+ </view>
9
+ </view>
10
+ </template>
11
+ <script lang="ts">
12
+ export default {
13
+ name: 'oxy-footer',
14
+ options: {
15
+ addGlobalClass: true,
16
+ virtualHost: true,
17
+ styleIsolation: 'shared'
18
+ }
19
+ }
20
+ </script>
21
+ <script setup lang="ts">
22
+ import { getCurrentInstance, nextTick, onMounted, ref, computed, watch } from 'vue'
23
+ import { footerProps } from './types'
24
+ import { withDefaultUnit } from '../common/util'
25
+ import NodeInfo = UniNamespace.NodeInfo
26
+
27
+ const props = defineProps(footerProps)
28
+
29
+ // 占位高度
30
+ const placeholderHeight = ref('')
31
+
32
+ // 内容样式
33
+ const contentStyle = computed(() => {
34
+ const style: { height?: string } = {}
35
+
36
+ if (props.height && props.height != 0) {
37
+ style['height'] = withDefaultUnit(props.height)
38
+ }
39
+ return style
40
+ })
41
+
42
+ // 设置内容高度(rpx 语义)
43
+ function setHeight(val: number) {
44
+ const pxPer100Rpx = uni.upx2px(100)
45
+ const heightInRpx = pxPer100Rpx ? (val / pxPer100Rpx) * 100 : val * 2
46
+ placeholderHeight.value = `${heightInRpx}rpx`
47
+ }
48
+
49
+ const { proxy } = getCurrentInstance()!
50
+
51
+ // 获取内容高度
52
+ function getHeight() {
53
+ nextTick(() => {
54
+ setTimeout(() => {
55
+ uni
56
+ .createSelectorQuery()
57
+ .in(proxy)
58
+ .select('.oxy-footer')
59
+ .boundingClientRect((res) => {
60
+ setHeight(Number((res as NodeInfo).height ?? 0))
61
+ })
62
+ .exec()
63
+ }, 0)
64
+ })
65
+ }
66
+
67
+ onMounted(() => {
68
+ getHeight()
69
+ })
70
+
71
+ watch([() => props.height, () => props.customStyle, () => props.customClass, () => props.backgroundColor], () => {
72
+ getHeight()
73
+ })
74
+ </script>
75
+
76
+ <style lang="scss" scoped>
77
+ @import './index.scss';
78
+ </style>
@@ -0,0 +1,17 @@
1
+ import { baseProps, makeStringProp, makeNumberProp } from '../common/props'
2
+
3
+ export const footerProps = {
4
+ ...baseProps,
5
+ /**
6
+ * 固定的内容高度
7
+ * 类型:number
8
+ * 默认值:'id'
9
+ */
10
+ height: makeNumberProp(0),
11
+ /**
12
+ * 背景色
13
+ * 类型:string
14
+ * 默认值:''
15
+ */
16
+ backgroundColor: makeStringProp('')
17
+ }
@@ -4,12 +4,33 @@ import type { FormItemRule } from '../oxy-form/types'
4
4
 
5
5
  export const formItemProps = {
6
6
  ...baseProps,
7
+ /**
8
+ * 表单字段标识
9
+ */
7
10
  prop: makeRequiredProp(String),
11
+ /**
12
+ * 当前表单项校验规则
13
+ */
8
14
  rules: makeArrayProp<FormItemRule>(),
15
+ /**
16
+ * 是否必填
17
+ */
9
18
  required: Boolean,
19
+ /**
20
+ * 是否垂直居中
21
+ */
10
22
  center: makeBooleanProp(false),
23
+ /**
24
+ * 标签文案
25
+ */
11
26
  label: String,
12
- labelWidth: makeStringProp('100px'),
27
+ /**
28
+ * 标签宽度
29
+ */
30
+ labelWidth: makeStringProp('200rpx'),
31
+ /**
32
+ * 是否显示右箭头
33
+ */
13
34
  isLink: Boolean
14
35
  }
15
36
 
@@ -15,7 +15,7 @@ export default {
15
15
 
16
16
  <script setup lang="ts">
17
17
  import { type CSSProperties, computed } from 'vue'
18
- import { addUnit, isDef, objToStyle } from '../common/util'
18
+ import { withDefaultUnit, isDef, objToStyle } from '../common/util'
19
19
  import { gapProps } from './types'
20
20
 
21
21
  const props = defineProps(gapProps)
@@ -26,7 +26,7 @@ const rootStyle = computed(() => {
26
26
  rootStyle['background'] = props.bgColor
27
27
  }
28
28
  if (isDef(props.height)) {
29
- rootStyle['height'] = addUnit(props.height)
29
+ rootStyle['height'] = withDefaultUnit(props.height)
30
30
  }
31
31
  return `${objToStyle(rootStyle)}${props.customStyle}`
32
32
  })
@@ -11,7 +11,7 @@ export const gapProps = {
11
11
  */
12
12
  safeAreaBottom: makeBooleanProp(false),
13
13
  /**
14
- * 高度
14
+ * 高度,number 类型按 `rpx` 语义处理
15
15
  */
16
- height: makeNumericProp(15)
16
+ height: makeNumericProp(30)
17
17
  }
@@ -73,7 +73,7 @@ watch(
73
73
  )
74
74
 
75
75
  const rootStyle = computed(() => {
76
- return `${props.gutter ? 'padding-left:' + props.gutter + 'px;' + 'padding-bottom:' + props.gutter + 'px;' : ''}${props.customStyle}`
76
+ return `${props.gutter ? 'padding-left:' + props.gutter * 2 + 'rpx;' + 'padding-bottom:' + props.gutter * 2 + 'rpx;' : ''}${props.customStyle}`
77
77
  })
78
78
 
79
79
  const handleChildrenChange = debounce(() => {
@@ -38,7 +38,7 @@ export const gridProps = {
38
38
  */
39
39
  bgColor: makeStringProp(''),
40
40
  /**
41
- * 格子之间的间距,默认单位为px
41
+ * 格子之间的间距,number 类型按 `rpx` 语义处理
42
42
  */
43
43
  gutter: Number,
44
44
  /**
@@ -140,7 +140,7 @@
140
140
  }
141
141
 
142
142
  @include e(text) {
143
- margin-top: 8px;
143
+ margin-top: 16rpx;
144
144
  font-size: $-grid-item-fs;
145
145
  line-height: $-grid-item-fs;
146
146
  @include lineEllipsis;
@@ -37,7 +37,7 @@ import OxyBadge from '../oxy-badge/oxy-badge.vue'
37
37
  import { onMounted, ref, watch, computed } from 'vue'
38
38
  import { useParent } from '../composables/useParent'
39
39
  import { GRID_KEY } from '../oxy-grid/types'
40
- import { deepAssign, isDef, isUndefined, omitBy } from '../common/util'
40
+ import { withDefaultUnit, deepAssign, isDef, isUndefined, omitBy } from '../common/util'
41
41
  import { gridItemProps } from './types'
42
42
  import type { BadgeProps } from '../oxy-badge/types'
43
43
 
@@ -81,8 +81,9 @@ watch(
81
81
  () => {
82
82
  if (!grid) return
83
83
  const width = grid.props.column ? 100 / grid.props.column + '%' : 100 / (childCount.value || 1) + '%'
84
+ const gutterSize = grid.props.gutter ? withDefaultUnit(grid.props.gutter) : ''
84
85
  // 单独定义间隔
85
- const gutterStyle = grid.props.gutter ? `padding:${grid.props.gutter}px ${grid.props.gutter}px 0 0; background-color: transparent;` : ''
86
+ const gutterStyle = gutterSize ? `padding:${gutterSize} ${gutterSize} 0 0; background-color: transparent;` : ''
86
87
  // 单独定义正方形
87
88
  const squareStyle = grid.props.square ? `background-color:transparent; padding-bottom: 0; padding-top:${width}` : ''
88
89
  style.value = `width: ${width}; ${squareStyle || gutterStyle}`
@@ -101,14 +102,15 @@ function init() {
101
102
  if (!grid) return
102
103
  const children = grid.children
103
104
  const width = grid.props.column ? 100 / grid.props.column + '%' : 100 / children.length + '%'
105
+ const gutterSize = grid.props.gutter ? withDefaultUnit(grid.props.gutter) : ''
104
106
  // 单独定义间隔
105
- const gutterStyle = grid.props.gutter ? `padding:${grid.props.gutter}px ${grid.props.gutter}px 0 0; background-color: transparent;` : ''
107
+ const gutterStyle = gutterSize ? `padding:${gutterSize} ${gutterSize} 0 0; background-color: transparent;` : ''
106
108
  // 单独定义正方形
107
109
  const squareStyle = grid.props.square ? `background-color:transparent; padding-bottom: 0; padding-top:${width}` : ''
108
110
  // 间隔+正方形
109
111
  gutterContentStyle.value =
110
- grid.props.gutter && grid.props.square
111
- ? `right: ${grid.props.gutter}px; bottom:${grid.props.gutter}px;height: auto; background-color: ${grid.props.bgColor}`
112
+ gutterSize && grid.props.square
113
+ ? `right: ${gutterSize}; bottom:${gutterSize};height: auto; background-color: ${grid.props.bgColor}`
112
114
  : `background-color: ${grid.props.bgColor}`
113
115
 
114
116
  border.value = Boolean(grid.props.border)
@@ -21,7 +21,7 @@ export const gridItemProps = {
21
21
  /**
22
22
  * 图标大小
23
23
  */
24
- iconSize: makeStringProp('26px'),
24
+ iconSize: makeStringProp('52rpx'),
25
25
  /**
26
26
  * 文字
27
27
  */
@@ -0,0 +1,75 @@
1
+ @import '../common/abstracts/variable';
2
+ @import '../common/abstracts/mixin';
3
+
4
+ @include b(guide){
5
+ z-index: 1001;
6
+ @include e(box) {
7
+ position: absolute;
8
+ z-index: 10001;
9
+ transition: all 0.2s;
10
+
11
+ &::before {
12
+ content: '';
13
+ box-sizing: content-box;
14
+ height: 100%;
15
+ width: 100%;
16
+ border: 1px dashed #fff;
17
+ border-radius: 8rpx;
18
+ position: absolute;
19
+ top: -8rpx;
20
+ left: -8rpx;
21
+ padding: 6rpx;
22
+ }
23
+
24
+ @include e(arrow) {
25
+ height: 20rpx;
26
+ width: 20rpx;
27
+ background: #1cbbb4;
28
+ position: absolute;
29
+ top: 144rpx;
30
+ left: 45%;
31
+ z-index: 10000;
32
+ transform: rotate(45deg);
33
+ }
34
+
35
+ @include e(tips) {
36
+ width: 400rpx;
37
+ box-shadow: 0 4rpx 18rpx 0 rgba(0, 0, 0, 0.1);
38
+ color: #fff;
39
+ position: absolute;
40
+ top: 152rpx;
41
+ z-index: 10001;
42
+ padding: 15rpx 20rpx;
43
+ font-size: 28rpx;
44
+ border-radius: 12rpx;
45
+ text-align: justify;
46
+
47
+ @include e(tool-btn) {
48
+ display: flex;
49
+ justify-content: space-between;
50
+ align-items: center;
51
+ padding-right: 0;
52
+ margin-top: 20rpx;
53
+
54
+ @include e(next) {
55
+ background: #fff;
56
+ height: 48rpx;
57
+ width: 100rpx;
58
+ text-align: center;
59
+ border-radius: 8rpx;
60
+ color: #666;
61
+ line-height: 48rpx;
62
+ font-size: 24rpx
63
+ }
64
+ }
65
+ }
66
+ }
67
+ @include e(model) {
68
+ position: fixed;
69
+ left: 0;
70
+ top: 0;
71
+ width: 100%;
72
+ height: 100%;
73
+ z-index: 1000;
74
+ }
75
+ }
@@ -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
  /**