hy-app 0.3.0 → 0.3.2

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 (108) hide show
  1. package/README.md +6 -3
  2. package/common/shakeService.ts +31 -29
  3. package/components/avatar.zip +0 -0
  4. package/components/hy-action-sheet/hy-action-sheet.vue +71 -46
  5. package/components/hy-address-picker/hy-address-picker.vue +94 -83
  6. package/components/hy-avatar/hy-avatar.vue +84 -85
  7. package/components/hy-back-top/hy-back-top.vue +8 -6
  8. package/components/hy-badge/hy-badge.vue +47 -46
  9. package/components/hy-button/hy-button.vue +117 -93
  10. package/components/hy-calendar/hy-calendar.vue +168 -160
  11. package/components/hy-card/hy-card.vue +50 -43
  12. package/components/hy-card/typing.d.ts +33 -32
  13. package/components/hy-cell/hy-cell.vue +73 -51
  14. package/components/hy-check-button/hy-check-button.vue +54 -47
  15. package/components/hy-checkbox/hy-checkbox.vue +97 -105
  16. package/components/hy-code-input/hy-code-input.vue +80 -89
  17. package/components/hy-config-provider/hy-config-provider.vue +20 -21
  18. package/components/hy-count-down/hy-count-down.vue +66 -67
  19. package/components/hy-count-to/hy-count-to.vue +105 -99
  20. package/components/hy-count-to/typing.d.ts +13 -12
  21. package/components/hy-datetime-picker/hy-datetime-picker.vue +261 -253
  22. package/components/hy-datetime-picker/typing.d.ts +42 -40
  23. package/components/hy-divider/hy-divider.vue +68 -73
  24. package/components/hy-dropdown/hy-dropdown.vue +20 -19
  25. package/components/hy-dropdown-item/hy-dropdown-item.vue +66 -61
  26. package/components/hy-dropdown-item/typing.d.ts +9 -9
  27. package/components/hy-empty/hy-empty.vue +42 -42
  28. package/components/hy-flex/hy-flex.vue +99 -0
  29. package/components/hy-flex/index.scss +8 -0
  30. package/components/hy-flex/typing.d.ts +23 -0
  31. package/components/hy-float-button/hy-float-button.vue +218 -210
  32. package/components/hy-folding-panel/hy-folding-panel.vue +32 -33
  33. package/components/hy-form/hy-form.vue +264 -252
  34. package/components/hy-form/typing.d.ts +4 -0
  35. package/components/hy-form-group/hy-form-group.vue +114 -183
  36. package/components/hy-form-item/hy-form-item.vue +12 -10
  37. package/components/hy-form-item/index.scss +2 -2
  38. package/components/hy-form-item/typing.d.ts +3 -6
  39. package/components/hy-grid/hy-grid.vue +44 -43
  40. package/components/hy-icon/hy-icon.vue +61 -67
  41. package/components/hy-image/hy-image.vue +112 -88
  42. package/components/hy-image/typing.d.ts +27 -23
  43. package/components/hy-input/hy-input.vue +157 -127
  44. package/components/hy-input/typing.d.ts +53 -47
  45. package/components/hy-line/hy-line.vue +26 -26
  46. package/components/hy-line-progress/hy-line-progress.vue +42 -35
  47. package/components/hy-list/hy-list.vue +76 -85
  48. package/components/hy-loading/hy-loading.vue +26 -23
  49. package/components/hy-login/TheUserLogin.vue +1 -1
  50. package/components/hy-menu/hy-menu.vue +48 -43
  51. package/components/hy-menu/typing.d.ts +18 -17
  52. package/components/hy-modal/hy-modal.vue +39 -35
  53. package/components/hy-navbar/hy-navbar.vue +25 -25
  54. package/components/hy-navbar/typing.d.ts +24 -22
  55. package/components/hy-notice-bar/hy-notice-bar.vue +26 -27
  56. package/components/hy-notify/hy-notify.vue +53 -53
  57. package/components/hy-number-step/hy-number-step.vue +134 -146
  58. package/components/hy-number-step/typing.d.ts +35 -35
  59. package/components/hy-overlay/hy-overlay.vue +23 -21
  60. package/components/hy-pagination/hy-pagination.vue +41 -36
  61. package/components/hy-picker/hy-picker.vue +184 -154
  62. package/components/hy-picker/typing.d.ts +39 -39
  63. package/components/hy-popover/hy-popover.vue +97 -77
  64. package/components/hy-popup/hy-popup.vue +107 -98
  65. package/components/hy-price/hy-price.vue +38 -34
  66. package/components/hy-qrcode/hy-qrcode.vue +50 -51
  67. package/components/hy-radio/hy-radio.vue +101 -113
  68. package/components/hy-rate/hy-rate.vue +107 -88
  69. package/components/hy-read-more/hy-read-more.vue +64 -49
  70. package/components/hy-scroll-list/hy-scroll-list.vue +45 -48
  71. package/components/hy-search/hy-search.vue +73 -66
  72. package/components/hy-search/typing.d.ts +36 -35
  73. package/components/hy-signature/hy-signature.vue +282 -240
  74. package/components/hy-slider/hy-slider.vue +195 -153
  75. package/components/hy-slider/typing.d.ts +21 -21
  76. package/components/hy-steps/hy-steps.vue +118 -90
  77. package/components/hy-steps/index.scss +31 -21
  78. package/components/hy-submit-bar/hy-submit-bar.vue +61 -70
  79. package/components/hy-subsection/hy-subsection.vue +99 -102
  80. package/components/hy-subsection/typing.d.ts +19 -19
  81. package/components/hy-swipe-action/hy-swipe-action.vue +131 -118
  82. package/components/hy-swiper/hy-swiper.vue +85 -71
  83. package/components/hy-switch/hy-switch.vue +67 -72
  84. package/components/hy-switch/typing.d.ts +21 -19
  85. package/components/hy-tabs/hy-tabs.vue +168 -113
  86. package/components/hy-tag/hy-tag.vue +90 -86
  87. package/components/hy-tag/typing.d.ts +26 -21
  88. package/components/hy-text/hy-text.vue +119 -111
  89. package/components/hy-textarea/hy-textarea.vue +100 -93
  90. package/components/hy-textarea/typing.d.ts +36 -31
  91. package/components/hy-toast/hy-toast.vue +77 -67
  92. package/components/hy-tooltip/hy-tooltip.vue +109 -91
  93. package/components/hy-transition/hy-transition.vue +62 -66
  94. package/components/hy-upload/hy-upload.vue +294 -152
  95. package/components/hy-upload/typing.d.ts +41 -36
  96. package/components/hy-warn/hy-warn.vue +34 -27
  97. package/components/hy-waterfall/hy-waterfall.vue +83 -74
  98. package/components/hy-watermark/hy-watermark.vue +134 -115
  99. package/components/index.ts +1 -1
  100. package/composables/usePopover.ts +236 -221
  101. package/composables/useQueue.ts +53 -52
  102. package/global.d.ts +1 -0
  103. package/package.json +2 -2
  104. package/store/index.ts +9 -1
  105. package/theme.scss +5 -5
  106. package/typing/index.ts +0 -1
  107. package/typing/modules/common.d.ts +0 -2
  108. package/web-types.json +1 -1
@@ -26,7 +26,9 @@
26
26
  :color="iconColor"
27
27
  :size="iconSize ? iconSize : addUnit(getPx(getFloatBtnSize) * 0.7)"
28
28
  />
29
- <text v-if="text" :style="{ color: textColor, fontSize: fontSize }">{{ text }}</text>
29
+ <text v-if="text" :style="{ color: textColor, fontSize: fontSize }">{{
30
+ text
31
+ }}</text>
30
32
  </slot>
31
33
  </view>
32
34
 
@@ -45,7 +47,7 @@
45
47
  }"
46
48
  @click="handleMenuItemClick(item, i)"
47
49
  >
48
- {{ typeof item === 'string' ? item : item.label }}
50
+ {{ typeof item === "string" ? item : item.label }}
49
51
  </view>
50
52
  <HyLine
51
53
  v-if="i !== menus.length - 1"
@@ -62,32 +64,38 @@
62
64
 
63
65
  <script lang="ts">
64
66
  export default {
65
- name: 'hy-float-button',
67
+ name: "hy-float-button",
66
68
  options: {
67
69
  addGlobalClass: true,
68
70
  virtualHost: true,
69
- styleIsolation: 'shared',
71
+ styleIsolation: "shared",
70
72
  },
71
- }
73
+ };
72
74
  </script>
73
75
 
74
76
  <script lang="ts" setup>
75
- import { computed, getCurrentInstance, onMounted, ref, toRefs } from 'vue'
76
- import type { CSSProperties, PropType } from 'vue'
77
- import type { IFloatButtonEmits, IGap } from './typing'
78
- import type { MenusType } from './typing'
79
- import { addUnit, getPx, getRect, guid, isH5 } from '../../utils'
80
- import { HyApp } from '../../typing/modules/common'
81
- import { IconConfig } from '../../config'
77
+ import {
78
+ computed,
79
+ getCurrentInstance,
80
+ onMounted,
81
+ ref,
82
+ reactive,
83
+ watch,
84
+ } from "vue";
85
+ import type { CSSProperties, PropType } from "vue";
86
+ import type { IFloatButtonEmits, IGap } from "./typing";
87
+ import type { MenusType } from "./typing";
88
+ import { addUnit, getPx, getRect, guid, isH5 } from "../../utils";
89
+ import { IconConfig } from "../../config";
82
90
  // 组件
83
- import HyIcon from '../hy-icon/hy-icon.vue'
84
- import HyLine from '../hy-line/hy-line.vue'
91
+ import HyIcon from "../hy-icon/hy-icon.vue";
92
+ import HyLine from "../hy-line/hy-line.vue";
85
93
 
86
94
  /**
87
95
  * 悬浮动作按钮组件,按下可显示一组动作按钮。
88
96
  * @displayName hy-float-button
89
97
  */
90
- defineOptions({})
98
+ defineOptions({});
91
99
 
92
100
  // const props = withDefaults(defineProps<IProps>(), defaultProps)
93
101
  const props = defineProps({
@@ -102,7 +110,7 @@ const props = defineProps({
102
110
  * */
103
111
  direction: {
104
112
  type: String,
105
- default: 'column',
113
+ default: "column",
106
114
  },
107
115
  /** 按钮显示的图标 */
108
116
  icon: {
@@ -139,8 +147,8 @@ const props = defineProps({
139
147
  * @values small,medium,large
140
148
  * */
141
149
  size: {
142
- type: String,
143
- default: 'medium',
150
+ type: [String, Number] as PropType<string | number>,
151
+ default: "medium",
144
152
  },
145
153
  /**
146
154
  * 按钮的形状
@@ -148,7 +156,7 @@ const props = defineProps({
148
156
  * */
149
157
  shape: {
150
158
  type: String,
151
- default: 'circle',
159
+ default: "circle",
152
160
  },
153
161
  /** 按钮的透明度 */
154
162
  opacity: {
@@ -181,7 +189,7 @@ const props = defineProps({
181
189
  * */
182
190
  position: {
183
191
  type: String,
184
- default: 'right-bottom',
192
+ default: "right-bottom",
185
193
  },
186
194
  /** 禁用点击打开菜单栏 */
187
195
  expandable: {
@@ -194,289 +202,289 @@ const props = defineProps({
194
202
  },
195
203
  /** 自定义外部类名 */
196
204
  customClass: String,
197
- })
198
- const {
199
- menus,
200
- customStyle,
201
- gap,
202
- zIndex,
203
- bgColor,
204
- text,
205
- textColor,
206
- size,
207
- fixed,
208
- direction,
209
- draggable,
210
- position,
211
- expandable,
212
- } = toRefs(props)
213
- const emit = defineEmits<IFloatButtonEmits>()
205
+ });
206
+ const emit = defineEmits<IFloatButtonEmits>();
214
207
 
215
- const instance = getCurrentInstance()
208
+ const instance = getCurrentInstance();
216
209
  const btnSize: AnyObject = {
217
- small: '50px',
218
- medium: '60px',
219
- large: '70px',
220
- }
221
- const open = ref(false)
222
- const rotate = computed(() => (open.value && !text.value ? '45deg' : '0deg'))
223
- const soleId = `hy-float-button__${guid()}`
224
- const fabSize = reactive({ width: 0, height: 0 }) // 悬浮按钮大小
225
- const screen = reactive({ width: 0, height: 0 })
210
+ small: "50px",
211
+ medium: "60px",
212
+ large: "70px",
213
+ };
214
+ const open = ref(false);
215
+ const rotate = computed(() => (open.value && !props.text ? "45deg" : "0deg"));
216
+ const soleId = `hy-float-button__${guid()}`;
217
+ const fabSize = reactive({ width: 0, height: 0 }); // 悬浮按钮大小
218
+ const screen = reactive({ width: 0, height: 0 });
226
219
  const currentCoordinate = reactive({
227
220
  top: 0,
228
221
  left: 0,
229
- })
222
+ });
230
223
  // 按下时坐标相对于元素的偏移量
231
- const touchOffset = reactive({ x: 0, y: 0 })
232
- const attractTransition = ref<boolean>(false)
233
- const fabDirection = ref<HyApp.LeftRightType>('left')
234
- const fabDirection2 = ref<HyApp.TopBottomType>('top')
224
+ const touchOffset = reactive({ x: 0, y: 0 });
225
+ const attractTransition = ref<boolean>(false);
226
+ const fabDirection = ref<HyApp.LeftRightType>("left");
227
+ const fabDirection2 = ref<HyApp.TopBottomType>("top");
235
228
  const bounding = reactive({
236
229
  minLeft: 10,
237
230
  minTop: 10,
238
231
  maxLeft: 380,
239
232
  maxTop: 680,
240
- })
233
+ });
241
234
 
242
235
  onMounted(async () => {
243
- await getFatRect()
244
- await getBounding()
245
- initPosition()
246
- })
236
+ await getFatRect();
237
+ await getBounding();
238
+ initPosition();
239
+ });
247
240
 
248
241
  watch(
249
- () => position.value,
242
+ () => props.position,
250
243
  () => initPosition(),
251
- )
244
+ );
252
245
 
253
246
  /**
254
247
  * @description 初始化距离
255
248
  * */
256
249
  const initPosition = () => {
257
- const { minLeft, minTop, maxLeft, maxTop } = bounding
258
- const centerY = (maxTop + minTop) / 2
259
- const centerX = (maxLeft + minLeft) / 2
250
+ const { minLeft, minTop, maxLeft, maxTop } = bounding;
251
+ const centerY = (maxTop + minTop) / 2;
252
+ const centerX = (maxLeft + minLeft) / 2;
260
253
 
261
- switch (position.value) {
262
- case 'left-top':
263
- currentCoordinate.top = minTop
264
- currentCoordinate.left = minLeft
265
- fabDirection.value = 'left'
266
- fabDirection2.value = 'top'
267
- break
268
- case 'right-top':
269
- currentCoordinate.top = minTop
270
- currentCoordinate.left = maxLeft
271
- fabDirection.value = 'right'
272
- fabDirection2.value = 'top'
273
- break
274
- case 'left-bottom':
275
- currentCoordinate.top = maxTop
276
- currentCoordinate.left = minLeft
277
- fabDirection.value = 'left'
278
- fabDirection2.value = 'bottom'
279
- break
280
- case 'right-bottom':
281
- currentCoordinate.top = maxTop
282
- currentCoordinate.left = maxLeft
283
- fabDirection.value = 'right'
284
- fabDirection2.value = 'bottom'
285
- break
286
- case 'left-center':
287
- currentCoordinate.top = centerY
288
- currentCoordinate.left = minLeft
289
- fabDirection.value = 'left'
290
- fabDirection2.value = 'bottom'
291
- break
292
- case 'right-center':
293
- currentCoordinate.top = centerY
294
- currentCoordinate.left = maxLeft
295
- fabDirection.value = 'right'
296
- fabDirection2.value = 'bottom'
297
- break
298
- case 'top-center':
299
- currentCoordinate.top = minTop
300
- currentCoordinate.left = centerX
301
- fabDirection.value = 'left'
302
- fabDirection2.value = 'top'
303
- break
304
- case 'bottom-center':
305
- currentCoordinate.top = maxTop
306
- currentCoordinate.left = centerX
307
- fabDirection.value = 'left'
308
- fabDirection2.value = 'bottom'
309
- break
254
+ switch (props.position) {
255
+ case "left-top":
256
+ currentCoordinate.top = minTop;
257
+ currentCoordinate.left = minLeft;
258
+ fabDirection.value = "left";
259
+ fabDirection2.value = "top";
260
+ break;
261
+ case "right-top":
262
+ currentCoordinate.top = minTop;
263
+ currentCoordinate.left = maxLeft;
264
+ fabDirection.value = "right";
265
+ fabDirection2.value = "top";
266
+ break;
267
+ case "left-bottom":
268
+ currentCoordinate.top = maxTop;
269
+ currentCoordinate.left = minLeft;
270
+ fabDirection.value = "left";
271
+ fabDirection2.value = "bottom";
272
+ break;
273
+ case "right-bottom":
274
+ currentCoordinate.top = maxTop;
275
+ currentCoordinate.left = maxLeft;
276
+ fabDirection.value = "right";
277
+ fabDirection2.value = "bottom";
278
+ break;
279
+ case "left-center":
280
+ currentCoordinate.top = centerY;
281
+ currentCoordinate.left = minLeft;
282
+ fabDirection.value = "left";
283
+ fabDirection2.value = "bottom";
284
+ break;
285
+ case "right-center":
286
+ currentCoordinate.top = centerY;
287
+ currentCoordinate.left = maxLeft;
288
+ fabDirection.value = "right";
289
+ fabDirection2.value = "bottom";
290
+ break;
291
+ case "top-center":
292
+ currentCoordinate.top = minTop;
293
+ currentCoordinate.left = centerX;
294
+ fabDirection.value = "left";
295
+ fabDirection2.value = "top";
296
+ break;
297
+ case "bottom-center":
298
+ currentCoordinate.top = maxTop;
299
+ currentCoordinate.left = centerX;
300
+ fabDirection.value = "left";
301
+ fabDirection2.value = "bottom";
302
+ break;
310
303
  }
311
- }
304
+ };
312
305
 
313
306
  /**
314
307
  * @description 获取组件大小
315
308
  * */
316
309
  const getFloatBtnSize = computed(() => {
317
- if (typeof size.value === 'string' && Object.keys(btnSize).includes(size.value)) {
318
- return btnSize[size.value]
310
+ if (
311
+ typeof props.size === "string" &&
312
+ Object.keys(btnSize).includes(props.size)
313
+ ) {
314
+ return btnSize[props.size];
319
315
  } else {
320
- return addUnit(size.value)
316
+ return addUnit(props.size);
321
317
  }
322
- })
318
+ });
323
319
 
324
320
  /**
325
321
  * @description 悬浮按钮样式
326
322
  * */
327
323
  const FloatButtonStyle = computed(() => {
328
324
  const style: CSSProperties = {
329
- top: currentCoordinate.top + 'px',
330
- left: currentCoordinate.left + 'px',
331
- backgroundColor: bgColor.value,
332
- zIndex: zIndex.value,
333
- color: textColor.value,
334
- transition: 'all ease 0.3s',
335
- }
336
- if (fixed.value) style.position = 'fixed'
325
+ top: currentCoordinate.top + "px",
326
+ left: currentCoordinate.left + "px",
327
+ backgroundColor: props.bgColor,
328
+ zIndex: props.zIndex,
329
+ color: props.textColor,
330
+ transition: "all ease 0.3s",
331
+ };
332
+ if (props.fixed) style.position = "fixed";
337
333
 
338
- style.height = getFloatBtnSize.value
339
- style.width = getFloatBtnSize.value
340
- return Object.assign(style, customStyle.value)
341
- })
334
+ style.height = getFloatBtnSize.value;
335
+ style.width = getFloatBtnSize.value;
336
+ return Object.assign(style, props.customStyle);
337
+ });
342
338
  const menusStyle = computed(() => {
343
339
  const style: CSSProperties = {
344
- backgroundColor: bgColor.value,
345
- }
340
+ backgroundColor: props.bgColor,
341
+ };
346
342
 
347
343
  // 判断横向展示还是纵向展示
348
- if (direction.value === 'row') {
349
- if (fabDirection.value === 'right') {
350
- style.transform = 'translateX(-100%)'
351
- style.left = '100%'
352
- style.paddingRight = getFloatBtnSize.value
353
- style.flexDirection = 'row-reverse'
344
+ if (props.direction === "row") {
345
+ if (fabDirection.value === "right") {
346
+ style.transform = "translateX(-100%)";
347
+ style.left = "100%";
348
+ style.paddingRight = getFloatBtnSize.value;
349
+ style.flexDirection = "row-reverse";
354
350
  } else {
355
- style.paddingLeft = getFloatBtnSize.value
351
+ style.paddingLeft = getFloatBtnSize.value;
356
352
  }
357
- style.bottom = 0
358
- style.transition = 'width 0.5s ease'
359
- style.height = getFloatBtnSize.value
353
+ style.bottom = 0;
354
+ style.transition = "width 0.5s ease";
355
+ style.height = getFloatBtnSize.value;
360
356
  style.width = open.value
361
- ? addUnit(getPx(getFloatBtnSize.value) * menus.value.length + getPx(getFloatBtnSize.value))
362
- : 0
357
+ ? addUnit(
358
+ getPx(getFloatBtnSize.value) * props.menus.length +
359
+ getPx(getFloatBtnSize.value),
360
+ )
361
+ : 0;
363
362
  } else {
364
- if (fabDirection2.value === 'top') {
365
- style.transform = 'translateX(-100%)'
366
- style.height = '100%'
367
- style.left = getFloatBtnSize.value
368
- style.top = '0px'
369
- style.paddingTop = getFloatBtnSize.value
363
+ if (fabDirection2.value === "top") {
364
+ style.transform = "translateX(-100%)";
365
+ style.height = "100%";
366
+ style.left = getFloatBtnSize.value;
367
+ style.top = "0px";
368
+ style.paddingTop = getFloatBtnSize.value;
370
369
  } else {
371
- style.paddingBottom = getFloatBtnSize.value
372
- style.bottom = 0
370
+ style.paddingBottom = getFloatBtnSize.value;
371
+ style.bottom = 0;
373
372
  }
374
- style.transition = 'height 0.5s ease'
375
- style.width = getFloatBtnSize.value
373
+ style.transition = "height 0.5s ease";
374
+ style.width = getFloatBtnSize.value;
376
375
  style.height = open.value
377
- ? addUnit(getPx(getFloatBtnSize.value) * menus.value.length + getPx(getFloatBtnSize.value))
378
- : 0
376
+ ? addUnit(
377
+ getPx(getFloatBtnSize.value) * props.menus.length +
378
+ getPx(getFloatBtnSize.value),
379
+ )
380
+ : 0;
379
381
  }
380
- return style
381
- })
382
+ return style;
383
+ });
382
384
 
383
385
  /**
384
386
  * @description 获取悬浮按钮大小
385
387
  * */
386
388
  const getFatRect = () => {
387
389
  return new Promise((resolve, reject) => {
388
- getRect(`#${soleId}`, false, instance).then((rect) => {
389
- const { width, height } = rect as UniApp.NodeInfo
390
- fabSize.width = width
391
- fabSize.height = height
392
- resolve(rect)
393
- })
394
- })
395
- }
390
+ getRect(`#${soleId}`, false, instance)
391
+ .then((rect) => {
392
+ const { width, height } = rect as UniApp.NodeInfo;
393
+ fabSize.width = width as number;
394
+ fabSize.height = height as number;
395
+ resolve(rect);
396
+ })
397
+ .catch((err) => {
398
+ reject(err);
399
+ });
400
+ });
401
+ };
396
402
 
397
403
  /**
398
404
  * @description 点击悬浮按钮
399
405
  * */
400
406
  const handleClick = () => {
401
- emit('click')
402
- if (expandable.value) {
403
- open.value = !open.value
407
+ emit("click");
408
+ if (props.expandable) {
409
+ open.value = !open.value;
404
410
  }
405
- }
411
+ };
406
412
 
407
413
  /**
408
414
  * @description 点击单条菜单栏
409
415
  * */
410
416
  const handleMenuItemClick = (temp: MenusType, index: number) => {
411
- emit('clickItem', temp, index)
412
- open.value = false
413
- if (typeof temp !== 'string' && temp?.url) {
417
+ emit("clickItem", temp, index);
418
+ open.value = false;
419
+ if (typeof temp !== "string" && temp?.url) {
414
420
  uni.navigateTo({
415
421
  url: temp.url,
416
- })
422
+ });
417
423
  }
418
- }
424
+ };
419
425
 
420
426
  const getBounding = () => {
421
427
  return new Promise((resolve) => {
422
- const sysInfo = uni.getSystemInfoSync()
428
+ const sysInfo = uni.getSystemInfoSync();
423
429
 
424
- const { top = 16, left = 16, right = 16, bottom = 16 } = gap.value
425
- screen.width = sysInfo.windowWidth
426
- screen.height = isH5 ? sysInfo.windowTop + sysInfo.windowHeight : sysInfo.windowHeight
427
- bounding.minTop = isH5 ? sysInfo.windowTop + top : top
428
- bounding.minLeft = left
429
- bounding.maxLeft = screen.width - fabSize.width - right
430
- bounding.maxTop = screen.height - fabSize.height - bottom
431
- resolve(bounding)
432
- })
433
- }
430
+ const { top = 16, left = 16, right = 16, bottom = 16 } = props.gap;
431
+ screen.width = sysInfo.windowWidth;
432
+ screen.height = isH5
433
+ ? sysInfo.windowTop + sysInfo.windowHeight
434
+ : sysInfo.windowHeight;
435
+ bounding.minTop = isH5 ? sysInfo.windowTop + top : top;
436
+ bounding.minLeft = left;
437
+ bounding.maxLeft = screen.width - fabSize.width - right;
438
+ bounding.maxTop = screen.height - fabSize.height - bottom;
439
+ resolve(bounding);
440
+ });
441
+ };
434
442
 
435
443
  const handleTouchStart = (e: TouchEvent) => {
436
- if (!draggable.value) return
444
+ if (!props.draggable) return;
437
445
 
438
- const touch = e.touches[0]
439
- touchOffset.x = touch.clientX - getPx(currentCoordinate.left)
440
- touchOffset.y = touch.clientY - getPx(currentCoordinate.top)
441
- attractTransition.value = false
442
- }
446
+ const touch = e.touches[0];
447
+ touchOffset.x = touch.clientX - getPx(currentCoordinate.left);
448
+ touchOffset.y = touch.clientY - getPx(currentCoordinate.top);
449
+ attractTransition.value = false;
450
+ };
443
451
 
444
452
  function handleTouchMove(e: TouchEvent) {
445
- if (!draggable.value) return
453
+ if (!props.draggable) return;
446
454
 
447
- const touch = e.touches[0]
448
- const { minLeft, minTop, maxLeft, maxTop } = bounding
449
- let x = touch.clientX - touchOffset.x
450
- let y = touch.clientY - touchOffset.y
455
+ const touch = e.touches[0];
456
+ const { minLeft, minTop, maxLeft, maxTop } = bounding;
457
+ let x = touch.clientX - touchOffset.x;
458
+ let y = touch.clientY - touchOffset.y;
451
459
 
452
- if (x < minLeft) x = minLeft
453
- else if (x > maxLeft) x = maxLeft
460
+ if (x < minLeft) x = minLeft;
461
+ else if (x > maxLeft) x = maxLeft;
454
462
 
455
- if (y < minTop) y = minTop
456
- else if (y > maxTop) y = maxTop
463
+ if (y < minTop) y = minTop;
464
+ else if (y > maxTop) y = maxTop;
457
465
 
458
- currentCoordinate.top = y
459
- currentCoordinate.left = x
466
+ currentCoordinate.top = y;
467
+ currentCoordinate.left = x;
460
468
  }
461
469
 
462
470
  function handleTouchEnd() {
463
- if (props.draggable === false) return
471
+ if (!props.draggable) return;
464
472
 
465
- const screenCenterX = screen.width / 2
466
- const fabCenterX = currentCoordinate.left + fabSize.width / 2
467
- attractTransition.value = true
473
+ const screenCenterX = screen.width / 2;
474
+ const fabCenterX = currentCoordinate.left + fabSize.width / 2;
475
+ attractTransition.value = true;
468
476
  if (fabCenterX < screenCenterX) {
469
- currentCoordinate.left = bounding.minLeft
470
- fabDirection.value = 'left'
477
+ currentCoordinate.left = bounding.minLeft;
478
+ fabDirection.value = "left";
471
479
  } else {
472
- currentCoordinate.left = bounding.maxLeft
473
- fabDirection.value = 'right'
480
+ currentCoordinate.left = bounding.maxLeft;
481
+ fabDirection.value = "right";
474
482
  }
475
483
  }
476
484
  </script>
477
485
 
478
486
  <style scoped lang="scss">
479
- @import './index.scss';
487
+ @import "./index.scss";
480
488
  .hy-float-button {
481
489
  &__container {
482
490
  rotate: v-bind(rotate);