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.
- package/README.md +6 -3
- package/common/shakeService.ts +31 -29
- package/components/avatar.zip +0 -0
- package/components/hy-action-sheet/hy-action-sheet.vue +71 -46
- package/components/hy-address-picker/hy-address-picker.vue +94 -83
- package/components/hy-avatar/hy-avatar.vue +84 -85
- package/components/hy-back-top/hy-back-top.vue +8 -6
- package/components/hy-badge/hy-badge.vue +47 -46
- package/components/hy-button/hy-button.vue +117 -93
- package/components/hy-calendar/hy-calendar.vue +168 -160
- package/components/hy-card/hy-card.vue +50 -43
- package/components/hy-card/typing.d.ts +33 -32
- package/components/hy-cell/hy-cell.vue +73 -51
- package/components/hy-check-button/hy-check-button.vue +54 -47
- package/components/hy-checkbox/hy-checkbox.vue +97 -105
- package/components/hy-code-input/hy-code-input.vue +80 -89
- package/components/hy-config-provider/hy-config-provider.vue +20 -21
- package/components/hy-count-down/hy-count-down.vue +66 -67
- package/components/hy-count-to/hy-count-to.vue +105 -99
- package/components/hy-count-to/typing.d.ts +13 -12
- package/components/hy-datetime-picker/hy-datetime-picker.vue +261 -253
- package/components/hy-datetime-picker/typing.d.ts +42 -40
- package/components/hy-divider/hy-divider.vue +68 -73
- package/components/hy-dropdown/hy-dropdown.vue +20 -19
- package/components/hy-dropdown-item/hy-dropdown-item.vue +66 -61
- package/components/hy-dropdown-item/typing.d.ts +9 -9
- package/components/hy-empty/hy-empty.vue +42 -42
- package/components/hy-flex/hy-flex.vue +99 -0
- package/components/hy-flex/index.scss +8 -0
- package/components/hy-flex/typing.d.ts +23 -0
- package/components/hy-float-button/hy-float-button.vue +218 -210
- package/components/hy-folding-panel/hy-folding-panel.vue +32 -33
- package/components/hy-form/hy-form.vue +264 -252
- package/components/hy-form/typing.d.ts +4 -0
- package/components/hy-form-group/hy-form-group.vue +114 -183
- package/components/hy-form-item/hy-form-item.vue +12 -10
- package/components/hy-form-item/index.scss +2 -2
- package/components/hy-form-item/typing.d.ts +3 -6
- package/components/hy-grid/hy-grid.vue +44 -43
- package/components/hy-icon/hy-icon.vue +61 -67
- package/components/hy-image/hy-image.vue +112 -88
- package/components/hy-image/typing.d.ts +27 -23
- package/components/hy-input/hy-input.vue +157 -127
- package/components/hy-input/typing.d.ts +53 -47
- package/components/hy-line/hy-line.vue +26 -26
- package/components/hy-line-progress/hy-line-progress.vue +42 -35
- package/components/hy-list/hy-list.vue +76 -85
- package/components/hy-loading/hy-loading.vue +26 -23
- package/components/hy-login/TheUserLogin.vue +1 -1
- package/components/hy-menu/hy-menu.vue +48 -43
- package/components/hy-menu/typing.d.ts +18 -17
- package/components/hy-modal/hy-modal.vue +39 -35
- package/components/hy-navbar/hy-navbar.vue +25 -25
- package/components/hy-navbar/typing.d.ts +24 -22
- package/components/hy-notice-bar/hy-notice-bar.vue +26 -27
- package/components/hy-notify/hy-notify.vue +53 -53
- package/components/hy-number-step/hy-number-step.vue +134 -146
- package/components/hy-number-step/typing.d.ts +35 -35
- package/components/hy-overlay/hy-overlay.vue +23 -21
- package/components/hy-pagination/hy-pagination.vue +41 -36
- package/components/hy-picker/hy-picker.vue +184 -154
- package/components/hy-picker/typing.d.ts +39 -39
- package/components/hy-popover/hy-popover.vue +97 -77
- package/components/hy-popup/hy-popup.vue +107 -98
- package/components/hy-price/hy-price.vue +38 -34
- package/components/hy-qrcode/hy-qrcode.vue +50 -51
- package/components/hy-radio/hy-radio.vue +101 -113
- package/components/hy-rate/hy-rate.vue +107 -88
- package/components/hy-read-more/hy-read-more.vue +64 -49
- package/components/hy-scroll-list/hy-scroll-list.vue +45 -48
- package/components/hy-search/hy-search.vue +73 -66
- package/components/hy-search/typing.d.ts +36 -35
- package/components/hy-signature/hy-signature.vue +282 -240
- package/components/hy-slider/hy-slider.vue +195 -153
- package/components/hy-slider/typing.d.ts +21 -21
- package/components/hy-steps/hy-steps.vue +118 -90
- package/components/hy-steps/index.scss +31 -21
- package/components/hy-submit-bar/hy-submit-bar.vue +61 -70
- package/components/hy-subsection/hy-subsection.vue +99 -102
- package/components/hy-subsection/typing.d.ts +19 -19
- package/components/hy-swipe-action/hy-swipe-action.vue +131 -118
- package/components/hy-swiper/hy-swiper.vue +85 -71
- package/components/hy-switch/hy-switch.vue +67 -72
- package/components/hy-switch/typing.d.ts +21 -19
- package/components/hy-tabs/hy-tabs.vue +168 -113
- package/components/hy-tag/hy-tag.vue +90 -86
- package/components/hy-tag/typing.d.ts +26 -21
- package/components/hy-text/hy-text.vue +119 -111
- package/components/hy-textarea/hy-textarea.vue +100 -93
- package/components/hy-textarea/typing.d.ts +36 -31
- package/components/hy-toast/hy-toast.vue +77 -67
- package/components/hy-tooltip/hy-tooltip.vue +109 -91
- package/components/hy-transition/hy-transition.vue +62 -66
- package/components/hy-upload/hy-upload.vue +294 -152
- package/components/hy-upload/typing.d.ts +41 -36
- package/components/hy-warn/hy-warn.vue +34 -27
- package/components/hy-waterfall/hy-waterfall.vue +83 -74
- package/components/hy-watermark/hy-watermark.vue +134 -115
- package/components/index.ts +1 -1
- package/composables/usePopover.ts +236 -221
- package/composables/useQueue.ts +53 -52
- package/global.d.ts +1 -0
- package/package.json +2 -2
- package/store/index.ts +9 -1
- package/theme.scss +5 -5
- package/typing/index.ts +0 -1
- package/typing/modules/common.d.ts +0 -2
- package/web-types.json +1 -1
|
@@ -1,147 +1,152 @@
|
|
|
1
|
-
import type { CSSProperties } from
|
|
1
|
+
import type { CSSProperties } from "vue";
|
|
2
2
|
|
|
3
3
|
export interface FileVo {
|
|
4
4
|
/**
|
|
5
5
|
* 上传文件本地地址链接
|
|
6
6
|
* */
|
|
7
|
-
url?: string
|
|
7
|
+
url?: string;
|
|
8
8
|
/**
|
|
9
9
|
* 上传文件类型
|
|
10
10
|
* */
|
|
11
|
-
type?:
|
|
11
|
+
type?: "image" | "video" | "file";
|
|
12
12
|
/**
|
|
13
13
|
* 上传文件本地地址链接
|
|
14
14
|
* */
|
|
15
|
-
thumb?: string
|
|
15
|
+
thumb?: string;
|
|
16
16
|
/**
|
|
17
17
|
* 文件大小
|
|
18
18
|
* */
|
|
19
|
-
size?: number
|
|
19
|
+
size?: number;
|
|
20
20
|
/**
|
|
21
21
|
* 是否视频
|
|
22
22
|
* */
|
|
23
|
-
isVideo?: boolean
|
|
23
|
+
isVideo?: boolean;
|
|
24
24
|
/**
|
|
25
25
|
* 是否图片
|
|
26
26
|
* */
|
|
27
|
-
isImage?: boolean
|
|
27
|
+
isImage?: boolean;
|
|
28
28
|
/**
|
|
29
29
|
* 是否显示删除按钮
|
|
30
30
|
* */
|
|
31
|
-
deletable?: boolean
|
|
31
|
+
deletable?: boolean;
|
|
32
32
|
/**
|
|
33
33
|
* 上传时候状态
|
|
34
34
|
* */
|
|
35
|
-
status?:
|
|
35
|
+
status?: "loading" | "failed" | "success";
|
|
36
36
|
/**
|
|
37
37
|
* 提示信息
|
|
38
38
|
* */
|
|
39
|
-
message?: string
|
|
39
|
+
message?: string;
|
|
40
40
|
/**
|
|
41
41
|
* 进度条
|
|
42
42
|
* */
|
|
43
|
-
schedule?: string | number
|
|
43
|
+
schedule?: string | number;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
export type ReadFunctionVo = (
|
|
47
|
+
file: FileVo,
|
|
48
|
+
detail: { name: string; index: number },
|
|
49
|
+
) => void;
|
|
50
|
+
|
|
46
51
|
export default interface HyUploadProps {
|
|
47
52
|
/**
|
|
48
53
|
* 接受的文件类型, 可选值为all media image file video (默认 'image' )
|
|
49
54
|
* */
|
|
50
|
-
accept?: HyApp.FileType
|
|
55
|
+
accept?: HyApp.FileType;
|
|
51
56
|
/**
|
|
52
57
|
* 根据文件拓展名过滤,每一项都不能是空字符串。默认不过滤。
|
|
53
58
|
* */
|
|
54
|
-
extension?: string[]
|
|
59
|
+
extension?: string[];
|
|
55
60
|
/**
|
|
56
61
|
* 图片或视频拾取模式,当accept为image类型时设置capture可选额外camera可以直接调起摄像头(默认 ['album', 'camera'] )
|
|
57
62
|
* */
|
|
58
|
-
capture?: (
|
|
63
|
+
capture?: ("album" | "camera")[];
|
|
59
64
|
/**
|
|
60
65
|
* 当accept为video时生效,是否压缩视频,默认为true(默认 true )
|
|
61
66
|
* */
|
|
62
|
-
compressed?: boolean
|
|
67
|
+
compressed?: boolean;
|
|
63
68
|
/**
|
|
64
69
|
* 当accept为video时生效,可选值为back或front(默认 'back' )
|
|
65
70
|
* */
|
|
66
|
-
camera?:
|
|
71
|
+
camera?: "back" | "front";
|
|
67
72
|
/**
|
|
68
73
|
* 当accept为video时生效,拍摄视频最长拍摄时间,单位秒(默认 60 )
|
|
69
74
|
* */
|
|
70
|
-
maxDuration?: number
|
|
75
|
+
maxDuration?: number;
|
|
71
76
|
/**
|
|
72
77
|
* 上传区域的图标,只能内置图标(默认 'camera-fill' )
|
|
73
78
|
* */
|
|
74
|
-
uploadIcon?: string
|
|
79
|
+
uploadIcon?: string;
|
|
75
80
|
/**
|
|
76
81
|
* 上传区域的图标的字体颜色,只能内置图标(默认 #D3D4D6 )
|
|
77
82
|
* */
|
|
78
|
-
uploadIconColor?: string
|
|
83
|
+
uploadIconColor?: string;
|
|
79
84
|
/**
|
|
80
85
|
* 是否开启文件读取前事件(默认 false )
|
|
81
86
|
* */
|
|
82
|
-
useBeforeRead?: boolean
|
|
87
|
+
useBeforeRead?: boolean;
|
|
83
88
|
/**
|
|
84
89
|
* 是否显示组件自带的图片预览功能(默认 true )
|
|
85
90
|
* */
|
|
86
|
-
previewFullImage?: boolean
|
|
91
|
+
previewFullImage?: boolean;
|
|
87
92
|
/**
|
|
88
93
|
* 最大上传数量(默认 52 )
|
|
89
94
|
* */
|
|
90
|
-
maxCount?: number
|
|
95
|
+
maxCount?: number;
|
|
91
96
|
/**
|
|
92
97
|
* 是否启用(默认 false )
|
|
93
98
|
* */
|
|
94
|
-
disabled?: boolean
|
|
99
|
+
disabled?: boolean;
|
|
95
100
|
/**
|
|
96
101
|
* 预览上传的图片时的裁剪模式,和image组件mode属性一致(默认 'aspectFill' )
|
|
97
102
|
* */
|
|
98
|
-
imageMode?:
|
|
103
|
+
imageMode?: "aspectFill" | "aspectFit" | "widthFix";
|
|
99
104
|
/**
|
|
100
105
|
* 标识符,可以在回调函数的第二项参数中获取
|
|
101
106
|
* */
|
|
102
|
-
name?: string
|
|
107
|
+
name?: string;
|
|
103
108
|
/**
|
|
104
109
|
* 所选的图片的尺寸, 可选值为original compressed(默认 ['original', 'compressed'] )
|
|
105
110
|
* */
|
|
106
|
-
sizeType?: (
|
|
111
|
+
sizeType?: ("original" | "compressed")[];
|
|
107
112
|
/**
|
|
108
113
|
* 是否开启图片多选,部分安卓机型不支持 (默认 false )
|
|
109
114
|
* */
|
|
110
|
-
multiple?: boolean
|
|
115
|
+
multiple?: boolean;
|
|
111
116
|
/**
|
|
112
117
|
* 是否展示删除按钮(默认 true )
|
|
113
118
|
* */
|
|
114
|
-
deletable?: boolean
|
|
119
|
+
deletable?: boolean;
|
|
115
120
|
/**
|
|
116
121
|
* 文件大小限制,单位为byte (默认 Number.MAX_VALUE )
|
|
117
122
|
* */
|
|
118
|
-
maxSize?: number
|
|
123
|
+
maxSize?: number;
|
|
119
124
|
/**
|
|
120
125
|
* 显示已上传的文件列表
|
|
121
126
|
* */
|
|
122
|
-
fileList?: FileVo[]
|
|
127
|
+
fileList?: FileVo[];
|
|
123
128
|
/**
|
|
124
129
|
* 上传区域的提示文字
|
|
125
130
|
* */
|
|
126
|
-
uploadText?: string
|
|
131
|
+
uploadText?: string;
|
|
127
132
|
/**
|
|
128
133
|
* 内部预览图片区域和选择图片按钮的区域宽度(默认 80 )
|
|
129
134
|
* */
|
|
130
|
-
width?: string | number
|
|
135
|
+
width?: string | number;
|
|
131
136
|
/**
|
|
132
137
|
* 内部预览图片区域和选择图片按钮的区域高度(默认 80 )
|
|
133
138
|
* */
|
|
134
|
-
height?: string | number
|
|
139
|
+
height?: string | number;
|
|
135
140
|
/**
|
|
136
141
|
* 读取前的处理函数
|
|
137
142
|
* */
|
|
138
|
-
beforeRead?: (file: FileVo, detail: { name: string; index: number }) => void
|
|
143
|
+
beforeRead?: (file: FileVo, detail: { name: string; index: number }) => void;
|
|
139
144
|
/**
|
|
140
145
|
* 读取后的处理函数
|
|
141
146
|
* */
|
|
142
|
-
afterRead?: (file: FileVo, detail: { name: string; index: number }) => void
|
|
147
|
+
afterRead?: (file: FileVo, detail: { name: string; index: number }) => void;
|
|
143
148
|
/**
|
|
144
149
|
* 定义需要用到的外部样式
|
|
145
150
|
* */
|
|
146
|
-
customStyle?: CSSProperties
|
|
151
|
+
customStyle?: CSSProperties;
|
|
147
152
|
}
|
|
@@ -25,7 +25,11 @@
|
|
|
25
25
|
textAlign: center ? 'center' : 'left',
|
|
26
26
|
},
|
|
27
27
|
]"
|
|
28
|
-
:class="[
|
|
28
|
+
:class="[
|
|
29
|
+
theme === 'dark'
|
|
30
|
+
? 'hy-warn__text--dark'
|
|
31
|
+
: `hy-warn__text--${type}--light`,
|
|
32
|
+
]"
|
|
29
33
|
>
|
|
30
34
|
{{ title }}
|
|
31
35
|
</text>
|
|
@@ -38,7 +42,11 @@
|
|
|
38
42
|
textAlign: center ? 'center' : 'left',
|
|
39
43
|
},
|
|
40
44
|
]"
|
|
41
|
-
:class="[
|
|
45
|
+
:class="[
|
|
46
|
+
theme === 'dark'
|
|
47
|
+
? 'hy-warn__text--dark'
|
|
48
|
+
: `hy-warn__text--${type}--light`,
|
|
49
|
+
]"
|
|
42
50
|
>
|
|
43
51
|
{{ description }}
|
|
44
52
|
</text>
|
|
@@ -52,30 +60,30 @@
|
|
|
52
60
|
|
|
53
61
|
<script lang="ts">
|
|
54
62
|
export default {
|
|
55
|
-
name:
|
|
63
|
+
name: "hy-warn",
|
|
56
64
|
options: {
|
|
57
65
|
addGlobalClass: true,
|
|
58
66
|
virtualHost: true,
|
|
59
|
-
styleIsolation:
|
|
67
|
+
styleIsolation: "shared",
|
|
60
68
|
},
|
|
61
|
-
}
|
|
69
|
+
};
|
|
62
70
|
</script>
|
|
63
71
|
|
|
64
72
|
<script setup lang="ts">
|
|
65
|
-
import { computed, ref
|
|
66
|
-
import type { CSSProperties, PropType } from
|
|
67
|
-
import type { IWarnEmits } from
|
|
68
|
-
import { addUnit } from
|
|
69
|
-
import { IconConfig, iconName } from
|
|
73
|
+
import { computed, ref } from "vue";
|
|
74
|
+
import type { CSSProperties, PropType } from "vue";
|
|
75
|
+
import type { IWarnEmits } from "./typing";
|
|
76
|
+
import { addUnit } from "../../utils";
|
|
77
|
+
import { IconConfig, iconName } from "../../config";
|
|
70
78
|
// 组件
|
|
71
|
-
import HyTransition from
|
|
72
|
-
import HyIcon from
|
|
79
|
+
import HyTransition from "../hy-transition/hy-transition.vue";
|
|
80
|
+
import HyIcon from "../hy-icon/hy-icon.vue";
|
|
73
81
|
|
|
74
82
|
/**
|
|
75
83
|
* 警告提示,展现需要关注的信息
|
|
76
84
|
* @displayName hy-warn
|
|
77
85
|
*/
|
|
78
|
-
defineOptions({})
|
|
86
|
+
defineOptions({});
|
|
79
87
|
|
|
80
88
|
// const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
81
89
|
const props = defineProps({
|
|
@@ -87,7 +95,7 @@ const props = defineProps({
|
|
|
87
95
|
* */
|
|
88
96
|
type: {
|
|
89
97
|
type: String,
|
|
90
|
-
default:
|
|
98
|
+
default: "warning",
|
|
91
99
|
},
|
|
92
100
|
/** 辅助性文字,颜色比title浅一点,字号也小一点 */
|
|
93
101
|
description: String,
|
|
@@ -104,7 +112,7 @@ const props = defineProps({
|
|
|
104
112
|
/** 显示的暗色或者亮色 */
|
|
105
113
|
theme: {
|
|
106
114
|
type: String,
|
|
107
|
-
default:
|
|
115
|
+
default: "light",
|
|
108
116
|
},
|
|
109
117
|
/** 文字是否居中 */
|
|
110
118
|
center: {
|
|
@@ -122,34 +130,33 @@ const props = defineProps({
|
|
|
122
130
|
},
|
|
123
131
|
/** 自定义外部类名 */
|
|
124
132
|
customClass: String,
|
|
125
|
-
})
|
|
126
|
-
const
|
|
127
|
-
const emit = defineEmits<IWarnEmits>()
|
|
133
|
+
});
|
|
134
|
+
const emit = defineEmits<IWarnEmits>();
|
|
128
135
|
|
|
129
|
-
const show = ref<boolean>(true)
|
|
136
|
+
const show = ref<boolean>(true);
|
|
130
137
|
|
|
131
138
|
/**
|
|
132
139
|
* @description icon颜色
|
|
133
140
|
* */
|
|
134
141
|
const iconColor = computed(() => {
|
|
135
|
-
return theme
|
|
136
|
-
})
|
|
142
|
+
return props.theme === "light" ? props.type : "#fff";
|
|
143
|
+
});
|
|
137
144
|
|
|
138
145
|
/**
|
|
139
146
|
* @description 点击内容
|
|
140
147
|
* */
|
|
141
148
|
const clickHandler = () => {
|
|
142
|
-
emit(
|
|
143
|
-
}
|
|
149
|
+
emit("click");
|
|
150
|
+
};
|
|
144
151
|
/**
|
|
145
152
|
* @description 点击关闭按钮
|
|
146
153
|
* */
|
|
147
154
|
const closeHandler = () => {
|
|
148
|
-
show.value = false
|
|
149
|
-
emit(
|
|
150
|
-
}
|
|
155
|
+
show.value = false;
|
|
156
|
+
emit("close");
|
|
157
|
+
};
|
|
151
158
|
</script>
|
|
152
159
|
|
|
153
160
|
<style lang="scss" scoped>
|
|
154
|
-
@import
|
|
161
|
+
@import "./index.scss";
|
|
155
162
|
</style>
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view class="hy-waterfall">
|
|
3
|
-
<view
|
|
3
|
+
<view
|
|
4
|
+
ref="hy-waterfall__left"
|
|
5
|
+
id="hy-waterfall__left--column"
|
|
6
|
+
class="hy-waterfall__column"
|
|
7
|
+
>
|
|
4
8
|
<slot name="left" :leftList="leftList"></slot>
|
|
5
9
|
</view>
|
|
6
|
-
<view
|
|
10
|
+
<view
|
|
11
|
+
ref="hy-waterfall__right"
|
|
12
|
+
id="hy-waterfall__right--column"
|
|
13
|
+
class="hy-waterfall__column"
|
|
14
|
+
>
|
|
7
15
|
<slot name="right" :rightList="rightList"></slot>
|
|
8
16
|
</view>
|
|
9
17
|
</view>
|
|
@@ -11,18 +19,19 @@
|
|
|
11
19
|
|
|
12
20
|
<script lang="ts">
|
|
13
21
|
export default {
|
|
14
|
-
name:
|
|
22
|
+
name: "hy-waterfall",
|
|
15
23
|
options: {
|
|
16
24
|
addGlobalClass: true,
|
|
17
25
|
virtualHost: true,
|
|
18
|
-
styleIsolation:
|
|
26
|
+
styleIsolation: "shared",
|
|
19
27
|
},
|
|
20
|
-
}
|
|
28
|
+
};
|
|
21
29
|
</script>
|
|
22
30
|
|
|
23
31
|
<script setup lang="ts">
|
|
24
|
-
import { computed, getCurrentInstance, ref,
|
|
25
|
-
import {
|
|
32
|
+
import { computed, getCurrentInstance, ref, watch } from "vue";
|
|
33
|
+
import type { PropType } from "vue";
|
|
34
|
+
import { getRect, isArray } from "../../utils";
|
|
26
35
|
|
|
27
36
|
/**
|
|
28
37
|
* 这是一个瀑布流形式的组件,内容分为左右两列,结合uview的懒加载组件效果更佳。
|
|
@@ -30,141 +39,141 @@ import { getRect, isArray } from '../../utils'
|
|
|
30
39
|
* uView的瀑布流实现了真正的 组件化,搭配LazyLoad 懒加载和loadMore 加载更多组件,让您开箱即用,眼前一亮。
|
|
31
40
|
* @displayName hy-waterfall
|
|
32
41
|
*/
|
|
33
|
-
defineOptions({})
|
|
42
|
+
defineOptions({});
|
|
34
43
|
|
|
35
44
|
// const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
36
45
|
const props = defineProps({
|
|
37
46
|
/** 数据列表 */
|
|
38
47
|
modelValue: {
|
|
39
|
-
type: Array
|
|
40
|
-
default()
|
|
41
|
-
return []
|
|
42
|
-
},
|
|
48
|
+
type: Array as PropType<AnyObject[]>,
|
|
49
|
+
default: () => [],
|
|
43
50
|
},
|
|
44
51
|
/** 每次向结构插入数据的时间间隔,间隔越长,越能保证两列高度相近,但是对用户体验越不好 */
|
|
45
52
|
addTime: {
|
|
46
|
-
type:
|
|
53
|
+
type: Number,
|
|
47
54
|
default: 200,
|
|
48
55
|
},
|
|
49
56
|
/** id值 */
|
|
50
57
|
idKey: {
|
|
51
58
|
type: String,
|
|
52
|
-
default:
|
|
59
|
+
default: "id",
|
|
53
60
|
},
|
|
54
|
-
})
|
|
55
|
-
const
|
|
56
|
-
const emit = defineEmits(['update:modelValue'])
|
|
61
|
+
});
|
|
62
|
+
const emit = defineEmits(["update:modelValue"]);
|
|
57
63
|
|
|
58
|
-
const instance = getCurrentInstance()
|
|
59
|
-
const leftList = ref<Record<string, any>[]>([])
|
|
60
|
-
const rightList = ref<Record<string, any>[]>([])
|
|
61
|
-
const tempList = ref([])
|
|
64
|
+
const instance = getCurrentInstance();
|
|
65
|
+
const leftList = ref<Record<string, any>[]>([]);
|
|
66
|
+
const rightList = ref<Record<string, any>[]>([]);
|
|
67
|
+
const tempList = ref([]);
|
|
62
68
|
|
|
63
69
|
/**
|
|
64
70
|
* @description 清空数据列表
|
|
65
71
|
*/
|
|
66
72
|
const clear = (bak = true) => {
|
|
67
|
-
leftList.value = []
|
|
68
|
-
rightList.value = []
|
|
73
|
+
leftList.value = [];
|
|
74
|
+
rightList.value = [];
|
|
69
75
|
// 同时清除父组件列表中的数据
|
|
70
76
|
if (bak) {
|
|
71
|
-
emit(
|
|
77
|
+
emit("update:modelValue", []);
|
|
72
78
|
}
|
|
73
|
-
tempList.value = []
|
|
74
|
-
}
|
|
79
|
+
tempList.value = [];
|
|
80
|
+
};
|
|
75
81
|
// 复制而不是引用对象和数组
|
|
76
|
-
const cloneData = (data:
|
|
77
|
-
return JSON.parse(JSON.stringify(data))
|
|
78
|
-
}
|
|
82
|
+
const cloneData = (data: AnyObject[]) => {
|
|
83
|
+
return JSON.parse(JSON.stringify(data));
|
|
84
|
+
};
|
|
79
85
|
const splitData = async () => {
|
|
80
|
-
if (!tempList.value.length) return
|
|
86
|
+
if (!tempList.value.length) return;
|
|
81
87
|
const leftRect = (await getRect(
|
|
82
|
-
|
|
88
|
+
"#hy-waterfall__left--column",
|
|
83
89
|
false,
|
|
84
90
|
instance,
|
|
85
|
-
)) as UniApp.NodeInfo
|
|
91
|
+
)) as UniApp.NodeInfo;
|
|
86
92
|
const rightRect = (await getRect(
|
|
87
|
-
|
|
93
|
+
"#hy-waterfall__right--column",
|
|
88
94
|
false,
|
|
89
95
|
instance,
|
|
90
|
-
)) as UniApp.NodeInfo
|
|
96
|
+
)) as UniApp.NodeInfo;
|
|
91
97
|
// 如果左边小于或等于右边,就添加到左边,否则添加到右边
|
|
92
|
-
let item = tempList.value[0]
|
|
98
|
+
let item = tempList.value[0];
|
|
93
99
|
// 解决多次快速上拉后,可能数据会乱的问题,因为经过上面的两个await节点查询阻塞一定时间,加上后面的定时器干扰
|
|
94
100
|
// 数组可能变成[],导致此item值可能为undefined
|
|
95
|
-
if (!item) return
|
|
101
|
+
if (!item) return;
|
|
96
102
|
if (leftRect.height !== undefined && rightRect.height !== undefined) {
|
|
97
103
|
if (leftRect.height < rightRect.height) {
|
|
98
|
-
leftList.value.push(item)
|
|
104
|
+
leftList.value.push(item);
|
|
99
105
|
} else if (leftRect.height > rightRect.height) {
|
|
100
|
-
rightList.value.push(item)
|
|
106
|
+
rightList.value.push(item);
|
|
101
107
|
} else {
|
|
102
108
|
// 这里是为了保证第一和第二张添加时,左右都能有内容
|
|
103
109
|
// 因为添加第一张,实际队列的高度可能还是0,这时需要根据队列元素长度判断下一个该放哪边
|
|
104
110
|
if (leftList.value.length <= rightList.value.length) {
|
|
105
|
-
leftList.value.push(item)
|
|
111
|
+
leftList.value.push(item);
|
|
106
112
|
} else {
|
|
107
|
-
rightList.value.push(item)
|
|
113
|
+
rightList.value.push(item);
|
|
108
114
|
}
|
|
109
115
|
}
|
|
110
116
|
}
|
|
111
117
|
// 移除临时列表的第一项
|
|
112
|
-
tempList.value.splice(0, 1)
|
|
118
|
+
tempList.value.splice(0, 1);
|
|
113
119
|
// 如果临时数组还有数据,继续循环
|
|
114
120
|
if (tempList.value.length) {
|
|
115
121
|
setTimeout(() => {
|
|
116
|
-
splitData()
|
|
117
|
-
}, addTime
|
|
122
|
+
splitData();
|
|
123
|
+
}, props.addTime);
|
|
118
124
|
}
|
|
119
|
-
}
|
|
125
|
+
};
|
|
120
126
|
|
|
121
127
|
/**
|
|
122
128
|
* @description 破坏flowList变量的引用,否则watch的结果新旧值是一样的
|
|
123
129
|
* */
|
|
124
130
|
const copyFlowList = computed(() => {
|
|
125
|
-
if (!modelValue
|
|
126
|
-
clear(false)
|
|
127
|
-
return []
|
|
131
|
+
if (!props.modelValue || props.modelValue.length == 0) {
|
|
132
|
+
clear(false);
|
|
133
|
+
return [];
|
|
128
134
|
} else {
|
|
129
|
-
return cloneData(modelValue
|
|
135
|
+
return cloneData(props.modelValue);
|
|
130
136
|
}
|
|
131
|
-
})
|
|
137
|
+
});
|
|
132
138
|
|
|
133
139
|
watch(
|
|
134
140
|
() => copyFlowList.value,
|
|
135
141
|
(newVal, oldValue) => {
|
|
136
142
|
if (!newVal || newVal.length == 0) {
|
|
137
|
-
clear(false)
|
|
143
|
+
clear(false);
|
|
138
144
|
} else {
|
|
139
145
|
// 取差值,即这一次数组变化新增的部分
|
|
140
|
-
let startIndex =
|
|
146
|
+
let startIndex =
|
|
147
|
+
isArray(oldValue) && oldValue.length > 0 ? oldValue.length : 0;
|
|
141
148
|
// 拼接上原有数据
|
|
142
|
-
tempList.value = tempList.value.concat(
|
|
143
|
-
|
|
149
|
+
tempList.value = tempList.value.concat(
|
|
150
|
+
cloneData(newVal.slice(startIndex)),
|
|
151
|
+
);
|
|
152
|
+
splitData();
|
|
144
153
|
}
|
|
145
154
|
},
|
|
146
155
|
{ immediate: true },
|
|
147
|
-
)
|
|
156
|
+
);
|
|
148
157
|
|
|
149
158
|
/**
|
|
150
159
|
* @description 清除某一条指定的数据,根据id实现
|
|
151
160
|
* */
|
|
152
161
|
const remove = (id: string) => {
|
|
153
162
|
// 如果findIndex找不到合适的条件,就会返回-1
|
|
154
|
-
let index
|
|
155
|
-
index = leftList.value.findIndex((val) => val[idKey
|
|
163
|
+
let index;
|
|
164
|
+
index = leftList.value.findIndex((val) => val[props.idKey] == id);
|
|
156
165
|
if (index != -1) {
|
|
157
166
|
// 如果index不等于-1,说明已经找到了要找的id,根据index索引删除这一条数据
|
|
158
|
-
leftList.value.splice(index, 1)
|
|
167
|
+
leftList.value.splice(index, 1);
|
|
159
168
|
} else {
|
|
160
169
|
// 同理于上方面的方法
|
|
161
|
-
index = rightList.value.findIndex((val) => val[idKey
|
|
162
|
-
if (index != -1) rightList.value.splice(index, 1)
|
|
170
|
+
index = rightList.value.findIndex((val) => val[props.idKey] == id);
|
|
171
|
+
if (index != -1) rightList.value.splice(index, 1);
|
|
163
172
|
}
|
|
164
173
|
// 同时清除父组件的数据中的对应id的条目
|
|
165
|
-
index = modelValue.
|
|
166
|
-
if (index != -1) emit(
|
|
167
|
-
}
|
|
174
|
+
index = props.modelValue.findIndex((val) => val[props.idKey] == id);
|
|
175
|
+
if (index != -1) emit("update:modelValue", props.modelValue.splice(index, 1));
|
|
176
|
+
};
|
|
168
177
|
/**
|
|
169
178
|
* @description 修改某条数据的某个属性
|
|
170
179
|
* @param id 唯一值
|
|
@@ -173,34 +182,34 @@ const remove = (id: string) => {
|
|
|
173
182
|
* */
|
|
174
183
|
const modify = (id: string, key: string, value: Record<string, any>[]) => {
|
|
175
184
|
// 如果findIndex找不到合适的条件,就会返回-1
|
|
176
|
-
let index
|
|
177
|
-
index = leftList.value.findIndex((val) => val[idKey
|
|
185
|
+
let index;
|
|
186
|
+
index = leftList.value.findIndex((val) => val[props.idKey] == id);
|
|
178
187
|
if (index != -1) {
|
|
179
188
|
// 如果index不等于-1,说明已经找到了要找的id,修改对应key的值
|
|
180
|
-
leftList.value[index][key] = value
|
|
189
|
+
leftList.value[index][key] = value;
|
|
181
190
|
} else {
|
|
182
191
|
// 同理于上方面的方法
|
|
183
|
-
index = rightList.value.findIndex((val) => val[idKey
|
|
184
|
-
if (index != -1) rightList.value[index][key] = value
|
|
192
|
+
index = rightList.value.findIndex((val) => val[props.idKey] == id);
|
|
193
|
+
if (index != -1) rightList.value[index][key] = value;
|
|
185
194
|
}
|
|
186
195
|
// 修改父组件的数据中的对应id的条目
|
|
187
|
-
index = modelValue.
|
|
196
|
+
index = props.modelValue.findIndex((val) => val[props.idKey] == id);
|
|
188
197
|
if (index != -1) {
|
|
189
198
|
// 首先复制一份value的数据
|
|
190
|
-
const data = cloneData(modelValue
|
|
199
|
+
const data = cloneData(props.modelValue);
|
|
191
200
|
// 修改对应索引的key属性的值为value
|
|
192
|
-
data[index][key] = value
|
|
201
|
+
data[index][key] = value;
|
|
193
202
|
// 修改父组件通过v-model绑定的变量的值
|
|
194
|
-
emit(
|
|
203
|
+
emit("update:modelValue", data);
|
|
195
204
|
}
|
|
196
|
-
}
|
|
205
|
+
};
|
|
197
206
|
|
|
198
207
|
defineExpose({
|
|
199
208
|
remove,
|
|
200
209
|
clear,
|
|
201
|
-
})
|
|
210
|
+
});
|
|
202
211
|
</script>
|
|
203
212
|
|
|
204
213
|
<style lang="scss" scoped>
|
|
205
|
-
@import
|
|
214
|
+
@import "./index.scss";
|
|
206
215
|
</style>
|