hy-app 0.6.9 → 0.7.1
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.
- package/attributes.json +1 -1
- package/components/hy-avatar/hy-avatar.vue +12 -5
- package/components/hy-avatar/props.ts +4 -2
- package/components/hy-avatar/typing.d.ts +8 -1
- package/components/hy-calendar/hy-calendar.vue +3 -2
- package/components/hy-calendar/month.vue +25 -5
- package/components/hy-calendar/props.ts +1 -1
- package/components/hy-calendar/typing.d.ts +9 -0
- package/components/hy-cascader/hy-cascader.vue +503 -0
- package/components/hy-cascader/index.scss +84 -0
- package/components/hy-cascader/props.ts +88 -0
- package/components/hy-cascader/typing.d.ts +34 -0
- package/components/hy-check-button/typing.d.ts +12 -7
- package/components/hy-code-input/hy-code-input.vue +33 -11
- package/components/hy-code-input/typing.d.ts +4 -0
- package/components/hy-config-provider/hy-config-provider.vue +58 -53
- package/components/hy-count-down/hy-count-down.vue +8 -8
- package/components/hy-count-down/typing.d.ts +16 -0
- package/components/hy-count-to/hy-count-to.vue +7 -7
- package/components/hy-count-to/typing.d.ts +24 -0
- package/components/hy-datetime-picker/props.ts +1 -1
- package/components/hy-datetime-picker/typing.d.ts +1 -1
- package/components/hy-dropdown/typing.d.ts +5 -0
- package/components/hy-dropdown-item/hy-dropdown-item.vue +1 -1
- package/components/hy-folding-panel/hy-folding-panel.vue +3 -3
- package/components/hy-folding-panel/typing.d.ts +23 -0
- package/components/hy-folding-panel-item/hy-folding-panel-item.vue +2 -2
- package/components/hy-folding-panel-item/typing.d.ts +21 -0
- package/components/hy-form/hy-form.vue +2 -2
- package/components/hy-form/typing.d.ts +37 -0
- package/components/hy-form-item/typing.d.ts +1 -1
- package/components/hy-grid/hy-grid.vue +12 -12
- package/components/hy-grid/index.scss +1 -2
- package/components/hy-grid/props.ts +7 -2
- package/components/hy-grid/typing.d.ts +1 -1
- package/components/hy-icon/typing.d.ts +52 -9
- package/components/hy-keyboard/constants.ts +83 -0
- package/components/hy-keyboard/hy-keyboard.vue +375 -0
- package/components/hy-keyboard/index.scss +73 -0
- package/components/hy-keyboard/key/index.scss +79 -0
- package/components/hy-keyboard/key/index.vue +91 -0
- package/components/hy-keyboard/key/types.ts +1 -0
- package/components/hy-keyboard/props.ts +108 -0
- package/components/hy-keyboard/typing.d.ts +18 -0
- package/components/hy-list/hy-list.vue +15 -13
- package/components/hy-list/props.ts +1 -1
- package/components/hy-modal/typing.d.ts +2 -2
- package/components/hy-notice-bar/hy-column-notice.vue +54 -94
- package/components/hy-notice-bar/hy-notice-bar.vue +128 -96
- package/components/hy-notice-bar/hy-row-notice.vue +89 -121
- package/components/hy-notice-bar/props.ts +86 -85
- package/components/hy-notify/hy-notify.vue +10 -10
- package/components/hy-notify/typing.d.ts +35 -0
- package/components/hy-number-step/hy-number-step.vue +370 -367
- package/components/hy-number-step/index.scss +1 -0
- package/components/hy-number-step/props.ts +1 -1
- package/components/hy-picker/hy-picker.vue +126 -149
- package/components/hy-picker/props.ts +4 -1
- package/components/hy-picker/typing.d.ts +22 -0
- package/components/hy-popover/hy-popover.vue +2 -2
- package/components/hy-popover/typing.d.ts +1 -1
- package/components/hy-popup/hy-popup.vue +1 -1
- package/components/hy-popup/index.scss +1 -0
- package/components/hy-price/hy-price.vue +52 -23
- package/components/hy-price/props.ts +54 -54
- package/components/hy-radio/props.ts +1 -1
- package/components/hy-radio/typing.d.ts +5 -1
- package/components/hy-rolling-num/typing.d.ts +1 -0
- package/components/hy-signature/hy-signature.vue +17 -17
- package/components/hy-signature/typing.d.ts +1 -1
- package/components/hy-skeleton/index.scss +17 -0
- package/components/hy-steps/hy-steps.vue +1 -1
- package/components/hy-submit-bar/typing.d.ts +3 -3
- package/components/hy-swipe-action/hy-swipe-action.vue +34 -15
- package/components/hy-swipe-action/index.scss +0 -1
- package/components/hy-switch/typing.d.ts +4 -0
- package/components/hy-tabbar/props.ts +2 -1
- package/components/hy-tabbar/typing.d.ts +5 -4
- package/components/hy-tabs/hy-tabs.vue +338 -336
- package/components/hy-tabs/index.scss +6 -6
- package/components/hy-tabs/typing.d.ts +41 -33
- package/components/hy-textarea/hy-textarea.vue +2 -2
- package/components/hy-textarea/typing.d.ts +4 -0
- package/components/hy-toast/hy-toast.vue +17 -9
- package/components/hy-toast/index.scss +1 -1
- package/components/hy-toast/typing.d.ts +56 -37
- package/components/hy-tooltip/hy-tooltip.vue +1 -1
- package/components/hy-tooltip/index.scss +1 -0
- package/components/hy-tooltip/props.ts +1 -1
- package/components/hy-upload/hy-upload.vue +16 -1
- package/components/hy-upload/index.scss +149 -144
- package/components/index.ts +6 -0
- package/global.d.ts +2 -0
- package/libs/api/http.ts +122 -119
- package/libs/config/icon.ts +442 -430
- package/libs/css/_function.scss +7 -13
- package/libs/css/iconfont.css +445 -441
- package/libs/css/theme.scss +3 -1
- package/libs/locale/lang/en-US.ts +4 -0
- package/libs/locale/lang/zh-CN.ts +4 -0
- package/libs/typing/index.ts +80 -0
- package/package.json +5 -2
- package/tags.json +1 -1
- package/web-types.json +1 -1
- package/components/hy-folding-panel/hy-folding-panel-group.vue +0 -163
- package/components/hy-qrcode/qrcode.js.bak +0 -1434
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import type { CSSProperties, PropType } from 'vue'
|
|
2
|
-
|
|
3
|
-
const priceProps = {
|
|
4
|
-
/** 传入金额值 */
|
|
5
|
-
text: {
|
|
6
|
-
type: [String, Number],
|
|
7
|
-
default: 0,
|
|
8
|
-
required: true
|
|
9
|
-
},
|
|
10
|
-
/** 金额符号 */
|
|
11
|
-
symbol: {
|
|
12
|
-
type: String,
|
|
13
|
-
default: '¥'
|
|
14
|
-
},
|
|
15
|
-
/** 比例大小 */
|
|
16
|
-
ratio: {
|
|
17
|
-
type: Number,
|
|
18
|
-
default: 1.4
|
|
19
|
-
},
|
|
20
|
-
/** 保留小数点后几位数 */
|
|
21
|
-
num: {
|
|
22
|
-
type: Number,
|
|
23
|
-
default: 2
|
|
24
|
-
},
|
|
25
|
-
/** 字体颜色 */
|
|
26
|
-
color: {
|
|
27
|
-
type: String,
|
|
28
|
-
default: '#FE3232'
|
|
29
|
-
},
|
|
30
|
-
/** 字体大小 */
|
|
31
|
-
size: {
|
|
32
|
-
type: [Number, String],
|
|
33
|
-
default: 12
|
|
34
|
-
},
|
|
35
|
-
/** 字体粗细 */
|
|
36
|
-
weight: {
|
|
37
|
-
type: Number,
|
|
38
|
-
default: 500
|
|
39
|
-
},
|
|
40
|
-
/** 是否倾斜 */
|
|
41
|
-
slant: {
|
|
42
|
-
type: Boolean,
|
|
43
|
-
default: false
|
|
44
|
-
},
|
|
45
|
-
/** 定义需要用到的外部样式 */
|
|
46
|
-
customStyle: {
|
|
47
|
-
type: Object as PropType<CSSProperties>,
|
|
48
|
-
default: () => {}
|
|
49
|
-
},
|
|
50
|
-
/** 自定义外部类名 */
|
|
51
|
-
customClass: String
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export default priceProps
|
|
1
|
+
import type { CSSProperties, PropType } from 'vue'
|
|
2
|
+
|
|
3
|
+
const priceProps = {
|
|
4
|
+
/** 传入金额值 */
|
|
5
|
+
text: {
|
|
6
|
+
type: [String, Number],
|
|
7
|
+
default: 0,
|
|
8
|
+
required: true
|
|
9
|
+
},
|
|
10
|
+
/** 金额符号 */
|
|
11
|
+
symbol: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: '¥'
|
|
14
|
+
},
|
|
15
|
+
/** 比例大小 */
|
|
16
|
+
ratio: {
|
|
17
|
+
type: Number,
|
|
18
|
+
default: 1.4
|
|
19
|
+
},
|
|
20
|
+
/** 保留小数点后几位数 */
|
|
21
|
+
num: {
|
|
22
|
+
type: Number,
|
|
23
|
+
default: 2
|
|
24
|
+
},
|
|
25
|
+
/** 字体颜色 */
|
|
26
|
+
color: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: '#FE3232'
|
|
29
|
+
},
|
|
30
|
+
/** 字体大小 */
|
|
31
|
+
size: {
|
|
32
|
+
type: [Number, String],
|
|
33
|
+
default: 12
|
|
34
|
+
},
|
|
35
|
+
/** 字体粗细 */
|
|
36
|
+
weight: {
|
|
37
|
+
type: Number,
|
|
38
|
+
default: 500
|
|
39
|
+
},
|
|
40
|
+
/** 是否倾斜 */
|
|
41
|
+
slant: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: false
|
|
44
|
+
},
|
|
45
|
+
/** 定义需要用到的外部样式 */
|
|
46
|
+
customStyle: {
|
|
47
|
+
type: Object as PropType<CSSProperties>,
|
|
48
|
+
default: () => {}
|
|
49
|
+
},
|
|
50
|
+
/** 自定义外部类名 */
|
|
51
|
+
customClass: String
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default priceProps
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ExtractPropTypes } from 'vue'
|
|
2
|
+
import type radioProps from './props'
|
|
3
|
+
import type { CheckboxColumnsVo } from '../../index'
|
|
4
|
+
|
|
5
|
+
export interface HyRadioProps extends ExtractPropTypes<typeof radioProps> {}
|
|
2
6
|
|
|
3
7
|
export interface IRadioEmits {
|
|
4
8
|
/** 选择触发 */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export interface HyRollingNum {}
|
|
@@ -99,7 +99,7 @@ export default {
|
|
|
99
99
|
import { computed, getCurrentInstance, onBeforeMount, onMounted, reactive, ref, watch } from 'vue'
|
|
100
100
|
import type { CSSProperties } from 'vue'
|
|
101
101
|
import { addUnit, getRect, guid } from '../../libs'
|
|
102
|
-
import type {
|
|
102
|
+
import type { ISignatureExpose, SignatureResult, Point, Line, ISignatureEmits } from './typing'
|
|
103
103
|
// #ifdef MP-WEIXIN
|
|
104
104
|
import { canvas2dAdapter } from './canvasHelper'
|
|
105
105
|
// #endif
|
|
@@ -165,7 +165,7 @@ const currentLine = ref<Line>() // 当前正在绘制的线
|
|
|
165
165
|
const currentStep = ref(0) // 当前步骤
|
|
166
166
|
|
|
167
167
|
/**
|
|
168
|
-
*
|
|
168
|
+
* 添加计算笔画宽度的方法
|
|
169
169
|
* */
|
|
170
170
|
function calculateLineWidth(speed: number): number {
|
|
171
171
|
if (!props.pressure) return props.lineWidth
|
|
@@ -178,7 +178,7 @@ function calculateLineWidth(speed: number): number {
|
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
/**
|
|
181
|
-
*
|
|
181
|
+
* 获取默认笔画宽度
|
|
182
182
|
* */
|
|
183
183
|
const getDefaultLineWidth = () => {
|
|
184
184
|
if (props.pressure) {
|
|
@@ -189,7 +189,7 @@ const getDefaultLineWidth = () => {
|
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
/**
|
|
192
|
-
*
|
|
192
|
+
* 开始画线
|
|
193
193
|
* */
|
|
194
194
|
const startDrawing = (e: any) => {
|
|
195
195
|
e.preventDefault()
|
|
@@ -219,7 +219,7 @@ const startDrawing = (e: any) => {
|
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
/**
|
|
222
|
-
*
|
|
222
|
+
* 结束画线
|
|
223
223
|
* */
|
|
224
224
|
const stopDrawing = (e: TouchEvent) => {
|
|
225
225
|
e.preventDefault()
|
|
@@ -250,7 +250,7 @@ const stopDrawing = (e: TouchEvent) => {
|
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
/**
|
|
253
|
-
*
|
|
253
|
+
* 初始化 canvas
|
|
254
254
|
* @param forceUpdate 是否强制更新
|
|
255
255
|
*/
|
|
256
256
|
const initCanvas = (forceUpdate: boolean = false) => {
|
|
@@ -269,7 +269,7 @@ const initCanvas = (forceUpdate: boolean = false) => {
|
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
/**
|
|
272
|
-
*
|
|
272
|
+
* 清空 canvas
|
|
273
273
|
* */
|
|
274
274
|
const clear = () => {
|
|
275
275
|
lines.value = []
|
|
@@ -285,7 +285,7 @@ const confirmSignature = () => {
|
|
|
285
285
|
}
|
|
286
286
|
|
|
287
287
|
/**
|
|
288
|
-
*
|
|
288
|
+
* canvas划线
|
|
289
289
|
* */
|
|
290
290
|
const draw = (e: any) => {
|
|
291
291
|
e.preventDefault()
|
|
@@ -349,7 +349,7 @@ const draw = (e: any) => {
|
|
|
349
349
|
}
|
|
350
350
|
|
|
351
351
|
/**
|
|
352
|
-
*
|
|
352
|
+
* 重绘整个画布
|
|
353
353
|
* */
|
|
354
354
|
const redrawCanvas = () => {
|
|
355
355
|
const { ctx } = canvasState
|
|
@@ -422,7 +422,7 @@ const redrawCanvas = () => {
|
|
|
422
422
|
}
|
|
423
423
|
|
|
424
424
|
/**
|
|
425
|
-
*
|
|
425
|
+
* 修改撤销功能
|
|
426
426
|
* */
|
|
427
427
|
const revoke = () => {
|
|
428
428
|
if (!lines.value.length) return
|
|
@@ -434,7 +434,7 @@ const revoke = () => {
|
|
|
434
434
|
}
|
|
435
435
|
|
|
436
436
|
/**
|
|
437
|
-
*
|
|
437
|
+
* 修改恢复功能
|
|
438
438
|
* */
|
|
439
439
|
const restore = () => {
|
|
440
440
|
if (!redoLines.value.length) return
|
|
@@ -446,7 +446,7 @@ const restore = () => {
|
|
|
446
446
|
}
|
|
447
447
|
|
|
448
448
|
/**
|
|
449
|
-
*
|
|
449
|
+
* 添加平滑线条绘制方法
|
|
450
450
|
* */
|
|
451
451
|
function drawSmoothLine(prePoint: Point, point: Point) {
|
|
452
452
|
const { ctx } = canvasState
|
|
@@ -513,7 +513,7 @@ onBeforeMount(() => {
|
|
|
513
513
|
})
|
|
514
514
|
|
|
515
515
|
/**
|
|
516
|
-
*
|
|
516
|
+
* 获取canvas上下文
|
|
517
517
|
*/
|
|
518
518
|
function getContext() {
|
|
519
519
|
return new Promise<UniApp.CanvasContext>((resolve) => {
|
|
@@ -557,7 +557,7 @@ function getContext() {
|
|
|
557
557
|
}
|
|
558
558
|
|
|
559
559
|
/**
|
|
560
|
-
*
|
|
560
|
+
* 设置 canvasState
|
|
561
561
|
*/
|
|
562
562
|
function setCanvasState(width: number, height: number) {
|
|
563
563
|
canvasState.canvasHeight = height * pixelRatio.value
|
|
@@ -565,7 +565,7 @@ function setCanvasState(width: number, height: number) {
|
|
|
565
565
|
}
|
|
566
566
|
|
|
567
567
|
/**
|
|
568
|
-
*
|
|
568
|
+
* 设置线段
|
|
569
569
|
* */
|
|
570
570
|
function setLine() {
|
|
571
571
|
const { ctx } = canvasState
|
|
@@ -578,7 +578,7 @@ function setLine() {
|
|
|
578
578
|
}
|
|
579
579
|
|
|
580
580
|
/**
|
|
581
|
-
*
|
|
581
|
+
* canvas 绘制图片输出成文件类型
|
|
582
582
|
*/
|
|
583
583
|
function canvasToImage() {
|
|
584
584
|
const { fileType, quality, exportScale } = props
|
|
@@ -633,7 +633,7 @@ function clearCanvas() {
|
|
|
633
633
|
}
|
|
634
634
|
}
|
|
635
635
|
|
|
636
|
-
defineExpose<
|
|
636
|
+
defineExpose<ISignatureExpose>({
|
|
637
637
|
init: initCanvas,
|
|
638
638
|
clear,
|
|
639
639
|
confirm: confirmSignature,
|
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
@use "../../libs/css/theme" as *;
|
|
2
2
|
@use "../../libs/css/mixin" as *;
|
|
3
3
|
|
|
4
|
+
@include b(theme--dark) {
|
|
5
|
+
.hy-skeleton--animation-gradient {
|
|
6
|
+
&::after {
|
|
7
|
+
content: ' ';
|
|
8
|
+
position: absolute;
|
|
9
|
+
animation: wd-skeleton-gradient 1.5s linear 2s infinite;
|
|
10
|
+
background: linear-gradient(
|
|
11
|
+
90deg,
|
|
12
|
+
transparent,
|
|
13
|
+
rgba(255, 255, 255, 0.1),
|
|
14
|
+
transparent
|
|
15
|
+
);
|
|
16
|
+
inset: 0;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
4
21
|
|
|
5
22
|
@include b(skeleton) {
|
|
6
23
|
box-sizing: border-box;
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
:class="[`hy-steps-item__content--${direction}`]"
|
|
92
92
|
:style="[contentStyle]"
|
|
93
93
|
>
|
|
94
|
-
<slot v-if="$slots.content" name="content" :
|
|
94
|
+
<slot v-if="$slots.content" name="content" :item="item" :index="i"></slot>
|
|
95
95
|
<template v-else>
|
|
96
96
|
<slot
|
|
97
97
|
v-if="$slots.title"
|
|
@@ -2,15 +2,15 @@ import type BadgeProps from '../hy-badge/props'
|
|
|
2
2
|
|
|
3
3
|
export interface SubmitBarIconMenus {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* icon图标
|
|
6
6
|
* */
|
|
7
7
|
icon: string
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* 文本
|
|
10
10
|
* */
|
|
11
11
|
text: string
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* 徽标值
|
|
14
14
|
* */
|
|
15
15
|
badge?: BadgeProps['badge']
|
|
16
16
|
[key: string]: any
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
<!--注意阻止横向滑动的穿透:横向移动时阻止冒泡-->
|
|
3
3
|
<view
|
|
4
4
|
class="hy-swipe-action"
|
|
5
|
+
:style="touchActionStyle"
|
|
5
6
|
@click.stop="onClick"
|
|
6
7
|
@touchstart="startDrag"
|
|
7
8
|
@touchmove="onDrag"
|
|
@@ -17,7 +18,13 @@
|
|
|
17
18
|
<!--左侧操作-->
|
|
18
19
|
|
|
19
20
|
<!--内容-->
|
|
20
|
-
<view
|
|
21
|
+
<view
|
|
22
|
+
:class="[
|
|
23
|
+
'hy-swipe-action__center',
|
|
24
|
+
centerClass,
|
|
25
|
+
borderBottom && 'hy-border__bottom'
|
|
26
|
+
]"
|
|
27
|
+
>
|
|
21
28
|
<slot></slot>
|
|
22
29
|
</view>
|
|
23
30
|
<!--内容-->
|
|
@@ -29,6 +36,7 @@
|
|
|
29
36
|
<view
|
|
30
37
|
class="hy-swipe-action__right--action__btn"
|
|
31
38
|
v-for="(item, i) in options"
|
|
39
|
+
:key="i"
|
|
32
40
|
:style="item.style"
|
|
33
41
|
@tap.stop="onActiveClick(item, i)"
|
|
34
42
|
>
|
|
@@ -83,11 +91,13 @@ const props = defineProps(swipeActionProps)
|
|
|
83
91
|
const emit = defineEmits<ISwipeActionEmits>()
|
|
84
92
|
const leftClass = `hy-swipe-action__left--${guid()}`
|
|
85
93
|
const rightClass = `hy-swipe-action__right--${guid()}`
|
|
94
|
+
const centerClass = `hy-swipe-action__center--${guid()}`
|
|
86
95
|
|
|
87
96
|
const slots = useSlots()
|
|
88
97
|
const wrapperStyle = ref<string>('')
|
|
98
|
+
const touchActionStyle = ref<Record<string, string>>({ touchAction: 'pan-y' })
|
|
89
99
|
|
|
90
|
-
// 滑动开始时,wrapper的偏移量
|
|
100
|
+
// 滑动开始时,wrapper 的偏移量
|
|
91
101
|
const originOffset = ref<number>(0)
|
|
92
102
|
// wrapper现在的偏移量
|
|
93
103
|
const wrapperOffset = ref<number>(0)
|
|
@@ -150,7 +160,7 @@ function changeState(value?: SwipeActionStatus, old?: SwipeActionStatus) {
|
|
|
150
160
|
}
|
|
151
161
|
|
|
152
162
|
/**
|
|
153
|
-
*
|
|
163
|
+
* 获取左/右操作按钮的宽度
|
|
154
164
|
* @return {Promise<[Number, Number]>} 左宽度、右宽度
|
|
155
165
|
*/
|
|
156
166
|
const getWidths = (): Promise<number[]> => {
|
|
@@ -164,7 +174,7 @@ const getWidths = (): Promise<number[]> => {
|
|
|
164
174
|
])
|
|
165
175
|
}
|
|
166
176
|
/**
|
|
167
|
-
*
|
|
177
|
+
* wrapper滑动函数
|
|
168
178
|
* @param {Number} offset 滑动漂移量
|
|
169
179
|
*/
|
|
170
180
|
function swipeMove(offset = 0) {
|
|
@@ -182,7 +192,7 @@ function swipeMove(offset = 0) {
|
|
|
182
192
|
wrapperOffset.value = offset
|
|
183
193
|
}
|
|
184
194
|
/**
|
|
185
|
-
*
|
|
195
|
+
* click的handler
|
|
186
196
|
* @param position
|
|
187
197
|
*/
|
|
188
198
|
function onClick(position?: SwipeActionPosition) {
|
|
@@ -195,7 +205,7 @@ function onClick(position?: SwipeActionPosition) {
|
|
|
195
205
|
emit('click', position)
|
|
196
206
|
}
|
|
197
207
|
/**
|
|
198
|
-
*
|
|
208
|
+
* 开始滑动
|
|
199
209
|
*/
|
|
200
210
|
function startDrag(event: TouchEvent) {
|
|
201
211
|
if (props.disabled) return
|
|
@@ -203,9 +213,13 @@ function startDrag(event: TouchEvent) {
|
|
|
203
213
|
originOffset.value = wrapperOffset.value
|
|
204
214
|
touch.touchStart(event)
|
|
205
215
|
closeOther(proxy)
|
|
216
|
+
|
|
217
|
+
// 设置 touch-action 为 none,阻止默认的滚动行为
|
|
218
|
+
// 这样可以在 touchmove 中安全调用 preventDefault 而不产生警告
|
|
219
|
+
touchActionStyle.value = { touchAction: 'none' }
|
|
206
220
|
}
|
|
207
221
|
/**
|
|
208
|
-
*
|
|
222
|
+
* 滑动时,逐渐展示按钮
|
|
209
223
|
* @param event
|
|
210
224
|
*/
|
|
211
225
|
function onDrag(event: TouchEvent) {
|
|
@@ -214,22 +228,24 @@ function onDrag(event: TouchEvent) {
|
|
|
214
228
|
touch.touchMove(event)
|
|
215
229
|
if (touch.direction.value === 'vertical') {
|
|
216
230
|
return
|
|
217
|
-
} else {
|
|
218
|
-
event.preventDefault()
|
|
219
|
-
event.stopPropagation()
|
|
220
231
|
}
|
|
221
232
|
|
|
233
|
+
// 阻止默认行为和事件冒泡
|
|
234
|
+
// 由于在 touchstart 时设置了 touch-action: none,这里可以安全调用 preventDefault
|
|
235
|
+
event.preventDefault()
|
|
236
|
+
event.stopPropagation()
|
|
237
|
+
|
|
222
238
|
touching.value = true
|
|
223
239
|
|
|
224
|
-
// 本次滑动,wrapper应该设置的偏移量
|
|
240
|
+
// 本次滑动,wrapper 应该设置的偏移量
|
|
225
241
|
const offset = originOffset.value + touch.deltaX.value
|
|
226
242
|
getWidths().then(([leftWidth, rightWidth]) => {
|
|
227
|
-
// 如果需要想滑出来的按钮不存在,对应的按钮肯定滑不出来,容器处于初始状态。此时需要模拟一下位于此处的start事件。
|
|
243
|
+
// 如果需要想滑出来的按钮不存在,对应的按钮肯定滑不出来,容器处于初始状态。此时需要模拟一下位于此处的 start 事件。
|
|
228
244
|
if ((leftWidth === 0 && offset > 0) || (rightWidth === 0 && offset < 0)) {
|
|
229
245
|
swipeMove(0)
|
|
230
246
|
return startDrag(event)
|
|
231
247
|
}
|
|
232
|
-
// 按钮已经展示完了,再滑动没有任何意义,相当于滑动结束。此时需要模拟一下位于此处的start事件。
|
|
248
|
+
// 按钮已经展示完了,再滑动没有任何意义,相当于滑动结束。此时需要模拟一下位于此处的 start 事件。
|
|
233
249
|
if (leftWidth !== 0 && offset >= leftWidth) {
|
|
234
250
|
swipeMove(leftWidth)
|
|
235
251
|
return startDrag(event)
|
|
@@ -241,7 +257,7 @@ function onDrag(event: TouchEvent) {
|
|
|
241
257
|
})
|
|
242
258
|
}
|
|
243
259
|
/**
|
|
244
|
-
*
|
|
260
|
+
* 滑动结束,自动修正位置
|
|
245
261
|
*/
|
|
246
262
|
function endDrag() {
|
|
247
263
|
if (props.disabled) return
|
|
@@ -249,6 +265,9 @@ function endDrag() {
|
|
|
249
265
|
const THRESHOLD = 0.3
|
|
250
266
|
touching.value = false
|
|
251
267
|
|
|
268
|
+
// 恢复 touch-action,允许正常滚动
|
|
269
|
+
touchActionStyle.value = { touchAction: 'pan-y' }
|
|
270
|
+
|
|
252
271
|
getWidths().then(([leftWidth, rightWidth]) => {
|
|
253
272
|
if (
|
|
254
273
|
originOffset.value < 0 && // 之前展示的是右按钮
|
|
@@ -287,7 +306,7 @@ function endDrag() {
|
|
|
287
306
|
})
|
|
288
307
|
}
|
|
289
308
|
/**
|
|
290
|
-
*
|
|
309
|
+
* 关闭操过按钮,并在合适的时候调用 beforeClose
|
|
291
310
|
*/
|
|
292
311
|
function close(reason: SwipeActionReason, position?: SwipeActionPosition) {
|
|
293
312
|
if (reason === 'swipe' && originOffset.value === 0) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CSSProperties, PropType } from 'vue'
|
|
2
2
|
import type { HyBadgeProps } from '../hy-badge/typing'
|
|
3
|
+
import type { TabBarItem } from './typing'
|
|
3
4
|
|
|
4
5
|
const tabBarProps = {
|
|
5
6
|
/** 选中项的索引值 */
|
|
@@ -9,7 +10,7 @@ const tabBarProps = {
|
|
|
9
10
|
},
|
|
10
11
|
/** 导航栏数据集合 */
|
|
11
12
|
list: {
|
|
12
|
-
type: Array
|
|
13
|
+
type: Array as PropType<TabBarItem[]>,
|
|
13
14
|
default: () => []
|
|
14
15
|
},
|
|
15
16
|
/** 是否固定在底部 */
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
/** 导航栏列表项类型 */
|
|
2
|
+
export interface TabBarItem {
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* 标题
|
|
4
5
|
* */
|
|
5
6
|
name: string
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* icon 图标或者图片
|
|
8
9
|
* */
|
|
9
10
|
icon: string
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
+
* 徽标值
|
|
12
13
|
* */
|
|
13
14
|
badge?: number
|
|
14
15
|
}
|