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,170 +1,176 @@
|
|
|
1
|
-
import type { CSSProperties } from
|
|
2
|
-
import type HyIconProps from
|
|
1
|
+
import type { CSSProperties } from "vue";
|
|
2
|
+
import type HyIconProps from "../hy-icon/typing";
|
|
3
|
+
import type {
|
|
4
|
+
InputOnBlurEvent,
|
|
5
|
+
InputOnConfirmEvent,
|
|
6
|
+
InputOnFocusEvent,
|
|
7
|
+
InputOnKeyboardheightchange,
|
|
8
|
+
} from "@uni-helper/uni-types";
|
|
3
9
|
|
|
4
10
|
export default interface HyInputProps {
|
|
5
11
|
/**
|
|
6
12
|
* @description 输入的值
|
|
7
13
|
* */
|
|
8
|
-
modelValue: string | number
|
|
14
|
+
modelValue: string | number;
|
|
9
15
|
/**
|
|
10
16
|
* @description 输入框类型,见上方说明 ( 默认 'text' )
|
|
11
17
|
* */
|
|
12
|
-
type?: HyApp.InputType
|
|
18
|
+
type?: HyApp.InputType;
|
|
13
19
|
/**
|
|
14
20
|
* @description 如果 textarea 是在一个 position:fixed 的区域,需要显示指定属性 fixed 为 true,兼容性:微信小程序、百度小程序、字节跳动小程序、QQ小程序 ( 默认 false )
|
|
15
21
|
* */
|
|
16
|
-
fixed?: boolean
|
|
22
|
+
fixed?: boolean;
|
|
17
23
|
/**
|
|
18
24
|
* @description 是否禁用输入框 ( 默认 false )
|
|
19
25
|
* */
|
|
20
|
-
disabled?: boolean
|
|
26
|
+
disabled?: boolean;
|
|
21
27
|
/**
|
|
22
28
|
* @description 禁用状态时的背景色( 默认 '#f5f7fa' )
|
|
23
29
|
* */
|
|
24
|
-
disabledColor?: string
|
|
30
|
+
disabledColor?: string;
|
|
25
31
|
/**
|
|
26
32
|
* @description 是否显示清除控件 ( 默认 false )
|
|
27
33
|
* */
|
|
28
|
-
clearable?: boolean
|
|
34
|
+
clearable?: boolean;
|
|
29
35
|
/**
|
|
30
36
|
* @description 是否密码类型 ( 默认 false )
|
|
31
37
|
* */
|
|
32
|
-
password?: boolean
|
|
38
|
+
password?: boolean;
|
|
33
39
|
/**
|
|
34
40
|
* @description 最大输入长度,设置为 -1 的时候不限制最大长度 ( 默认 -1 )
|
|
35
41
|
* */
|
|
36
|
-
maxlength?: number
|
|
42
|
+
maxlength?: number;
|
|
37
43
|
/**
|
|
38
44
|
* @description 输入框为空时的占位符
|
|
39
45
|
* */
|
|
40
|
-
placeholder?: string | null
|
|
46
|
+
placeholder?: string | null;
|
|
41
47
|
/**
|
|
42
48
|
* @description 指定placeholder的样式类,注意页面或组件的style中写了scoped时,需要在类名前写/deep/ ( 默认 'input-placeholder' )
|
|
43
49
|
* */
|
|
44
|
-
placeholderClass?: string
|
|
50
|
+
placeholderClass?: string;
|
|
45
51
|
/**
|
|
46
52
|
* @description 指定placeholder的样式,字符串/对象形式,如"color: red;"
|
|
47
53
|
* */
|
|
48
|
-
placeholderStyle?: CSSProperties
|
|
54
|
+
placeholderStyle?: CSSProperties;
|
|
49
55
|
/**
|
|
50
56
|
* @description 是否显示输入字数统计,只在 type ="text"或type ="textarea"时有效 ( 默认 false )
|
|
51
57
|
* */
|
|
52
|
-
showWordLimit?: boolean
|
|
58
|
+
showWordLimit?: boolean;
|
|
53
59
|
/**
|
|
54
60
|
* @description 设置右下角按钮的文字,兼容性详见uni-app文档 ( 默认 'done' )
|
|
55
61
|
* */
|
|
56
|
-
confirmType?: string
|
|
62
|
+
confirmType?: string;
|
|
57
63
|
/**
|
|
58
64
|
* @description 点击键盘右下角按钮时是否保持键盘不收起,H5无效 ( 默认 false )
|
|
59
65
|
* */
|
|
60
|
-
confirmHold?: boolean
|
|
66
|
+
confirmHold?: boolean;
|
|
61
67
|
/**
|
|
62
68
|
* @description focus时,点击页面的时候不收起键盘,微信小程序有效 ( 默认 false )
|
|
63
69
|
* */
|
|
64
|
-
holdKeyboard?: boolean
|
|
70
|
+
holdKeyboard?: boolean;
|
|
65
71
|
/**
|
|
66
72
|
* @description 自动获取焦点,在 H5 平台能否聚焦以及软键盘是否跟随弹出,取决于当前浏览器本身的实现。nvue 页面不支持,需使用组件的 focus()、blur() 方法控制焦点 ( 默认 false )
|
|
67
73
|
* */
|
|
68
|
-
focus?: boolean
|
|
74
|
+
focus?: boolean;
|
|
69
75
|
/**
|
|
70
76
|
* @description 键盘收起时,是否自动失去焦点,目前仅App3.0.0+有效 ( 默认 false )
|
|
71
77
|
* */
|
|
72
|
-
autoBlur?: boolean
|
|
78
|
+
autoBlur?: boolean;
|
|
73
79
|
/**
|
|
74
80
|
* @description 是否去掉 iOS 下的默认内边距,仅微信小程序,且type=textarea时有效 ( 默认 false )
|
|
75
81
|
* */
|
|
76
|
-
disableDefaultPadding?: boolean
|
|
82
|
+
disableDefaultPadding?: boolean;
|
|
77
83
|
/**
|
|
78
84
|
* @description 指定focus时光标的位置( 默认 140 )
|
|
79
85
|
* */
|
|
80
|
-
cursor?: number
|
|
86
|
+
cursor?: number;
|
|
81
87
|
/**
|
|
82
88
|
* @description 输入框聚焦时底部与键盘的距离 ( 默认 30 )
|
|
83
89
|
* */
|
|
84
|
-
cursorSpacing?: number
|
|
90
|
+
cursorSpacing?: number;
|
|
85
91
|
/**
|
|
86
92
|
* @description 光标起始位置,自动聚集时有效,需与selection-end搭配使用 ( 默认 -1 )
|
|
87
93
|
* */
|
|
88
|
-
selectionStart?: number
|
|
94
|
+
selectionStart?: number;
|
|
89
95
|
/**
|
|
90
96
|
* @description 光标结束位置,自动聚集时有效,需与selection-start搭配使用 ( 默认 -1 )
|
|
91
97
|
* */
|
|
92
|
-
selectionEnd?: number
|
|
98
|
+
selectionEnd?: number;
|
|
93
99
|
/**
|
|
94
100
|
* @description 键盘弹起时,是否自动上推页面 ( 默认 true )
|
|
95
101
|
* */
|
|
96
|
-
adjustPosition?: boolean
|
|
102
|
+
adjustPosition?: boolean;
|
|
97
103
|
/**
|
|
98
104
|
* @description 输入框内容对齐方式( 默认 'left' )
|
|
99
105
|
* */
|
|
100
|
-
inputAlign?: HyApp.RowCenterType
|
|
106
|
+
inputAlign?: HyApp.RowCenterType;
|
|
101
107
|
/**
|
|
102
108
|
* @description 输入框字体的大小 ( 默认 '15px' )
|
|
103
109
|
* */
|
|
104
|
-
fontSize?: string | number
|
|
110
|
+
fontSize?: string | number;
|
|
105
111
|
/**
|
|
106
112
|
* @description 输入框字体颜色 ( 默认 '#303133' )
|
|
107
113
|
* */
|
|
108
|
-
color?: string
|
|
114
|
+
color?: string;
|
|
109
115
|
/**
|
|
110
116
|
* @description 输入框前置图标
|
|
111
117
|
* */
|
|
112
|
-
prefixIcon?: Partial<HyIconProps
|
|
118
|
+
prefixIcon?: Partial<HyIconProps>;
|
|
113
119
|
/**
|
|
114
120
|
* @description 输入框后置图标
|
|
115
121
|
* */
|
|
116
|
-
suffixIcon?: Partial<HyIconProps
|
|
122
|
+
suffixIcon?: Partial<HyIconProps>;
|
|
117
123
|
/**
|
|
118
124
|
* @description 边框类型,surround-四周边框,bottom-底部边框,none-无边框 ( 默认 'surround' )
|
|
119
125
|
* */
|
|
120
|
-
border?: HyApp.BorderType
|
|
126
|
+
border?: HyApp.BorderType;
|
|
121
127
|
/**
|
|
122
128
|
* @description 是否只读,与disabled不同之处在于disabled会置灰组件,而readonly则不会 ( 默认 false )
|
|
123
129
|
* */
|
|
124
|
-
readonly?: boolean
|
|
130
|
+
readonly?: boolean;
|
|
125
131
|
/**
|
|
126
132
|
* @description 输入框形状,circle-圆形,square-方形 ( 默认 'square' )
|
|
127
133
|
* */
|
|
128
|
-
shape?: HyApp.ShapeType
|
|
134
|
+
shape?: HyApp.ShapeType;
|
|
129
135
|
/**
|
|
130
136
|
* @description 内容式化函数
|
|
131
137
|
* */
|
|
132
|
-
formatter?: Function | null
|
|
138
|
+
formatter?: Function | null;
|
|
133
139
|
/**
|
|
134
140
|
* @description 定义需要用到的外部样式
|
|
135
141
|
* */
|
|
136
|
-
customStyle?: CSSProperties
|
|
142
|
+
customStyle?: CSSProperties;
|
|
137
143
|
/**
|
|
138
144
|
* @description 值变化事件
|
|
139
145
|
* */
|
|
140
|
-
onChange?: Function
|
|
146
|
+
onChange?: Function;
|
|
141
147
|
/**
|
|
142
148
|
* @description 失去焦点事件
|
|
143
149
|
* */
|
|
144
|
-
onBlur?: Function
|
|
150
|
+
onBlur?: Function;
|
|
145
151
|
/**
|
|
146
152
|
* @description 是否忽略组件内对文本合成系统事件的处理。
|
|
147
153
|
* */
|
|
148
|
-
ignoreCompositionEvent?: boolean
|
|
154
|
+
ignoreCompositionEvent?: boolean;
|
|
149
155
|
}
|
|
150
156
|
|
|
151
157
|
export interface IInputEmits {
|
|
152
158
|
/** 输入框失去焦点时触发 */
|
|
153
|
-
(e:
|
|
159
|
+
(e: "blur", event: InputOnBlurEvent, value: string | number): void;
|
|
154
160
|
/** 输入框聚焦时触发 */
|
|
155
|
-
(e:
|
|
161
|
+
(e: "focus", event: InputOnFocusEvent): void;
|
|
156
162
|
/** 点击完成按钮时触发 */
|
|
157
|
-
(e:
|
|
163
|
+
(e: "confirm", event: InputOnConfirmEvent, value: string | number): void;
|
|
158
164
|
/** 键盘高度发生变化的时候触发此事件 */
|
|
159
|
-
(e:
|
|
165
|
+
(e: "keyboardheightchange", event: InputOnKeyboardheightchange): void;
|
|
160
166
|
/** 内容发生变化触发此事件 */
|
|
161
|
-
(e:
|
|
167
|
+
(e: "change", value: string | number): void;
|
|
162
168
|
/** 内容发生变化触发此事件 */
|
|
163
|
-
(e:
|
|
169
|
+
(e: "update:modelValue", value: string | number): void;
|
|
164
170
|
/** 点击清空内容 */
|
|
165
|
-
(e:
|
|
171
|
+
(e: "clear"): void;
|
|
166
172
|
/** 点击前缀触发 */
|
|
167
|
-
(e:
|
|
173
|
+
(e: "onPrefix"): void;
|
|
168
174
|
/** 点击后缀触发 */
|
|
169
|
-
(e:
|
|
175
|
+
(e: "onSuffix"): void;
|
|
170
176
|
}
|
|
@@ -4,25 +4,25 @@
|
|
|
4
4
|
|
|
5
5
|
<script lang="ts">
|
|
6
6
|
export default {
|
|
7
|
-
name:
|
|
7
|
+
name: "hy-line",
|
|
8
8
|
options: {
|
|
9
9
|
addGlobalClass: true,
|
|
10
10
|
virtualHost: true,
|
|
11
|
-
styleIsolation:
|
|
11
|
+
styleIsolation: "shared",
|
|
12
12
|
},
|
|
13
|
-
}
|
|
13
|
+
};
|
|
14
14
|
</script>
|
|
15
15
|
|
|
16
16
|
<script setup lang="ts">
|
|
17
|
-
import { computed
|
|
18
|
-
import type { CSSProperties, PropType } from
|
|
19
|
-
import { addUnit } from
|
|
17
|
+
import { computed } from "vue";
|
|
18
|
+
import type { CSSProperties, PropType } from "vue";
|
|
19
|
+
import { addUnit } from "../../utils";
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* 一般用于显示一根线条,用于分隔内容块,有横向和竖向两种模式,且能设置0.5px线条,使用也很简单。
|
|
23
23
|
* @displayName hy-line
|
|
24
24
|
*/
|
|
25
|
-
defineOptions({})
|
|
25
|
+
defineOptions({});
|
|
26
26
|
|
|
27
27
|
// const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
28
28
|
const props = defineProps({
|
|
@@ -31,7 +31,7 @@ const props = defineProps({
|
|
|
31
31
|
/** 长度,竖向时表现为高度,横向时表现为长度,可以为百分比,带px单位的值等 */
|
|
32
32
|
length: {
|
|
33
33
|
type: String,
|
|
34
|
-
default:
|
|
34
|
+
default: "100%",
|
|
35
35
|
},
|
|
36
36
|
/**
|
|
37
37
|
* 线条的方向
|
|
@@ -39,7 +39,7 @@ const props = defineProps({
|
|
|
39
39
|
* */
|
|
40
40
|
direction: {
|
|
41
41
|
type: String,
|
|
42
|
-
default:
|
|
42
|
+
default: "row",
|
|
43
43
|
},
|
|
44
44
|
/** 是否显示细线条 */
|
|
45
45
|
hairline: {
|
|
@@ -59,35 +59,35 @@ const props = defineProps({
|
|
|
59
59
|
/** 定义需要用到的外部样式 */
|
|
60
60
|
customStyle: {
|
|
61
61
|
type: Object as PropType<CSSProperties>,
|
|
62
|
+
default: () => {},
|
|
62
63
|
},
|
|
63
64
|
/** 自定义外部类名 */
|
|
64
65
|
customClass: String,
|
|
65
|
-
})
|
|
66
|
-
const { margin, length, dashed, direction, hairline, color, customStyle } = toRefs(props)
|
|
66
|
+
});
|
|
67
67
|
|
|
68
68
|
const lineStyle = computed<CSSProperties>(() => {
|
|
69
|
-
const style: CSSProperties = {}
|
|
70
|
-
style.margin = margin
|
|
69
|
+
const style: CSSProperties = {};
|
|
70
|
+
style.margin = props.margin;
|
|
71
71
|
// 如果是水平线条,边框高度为1px,再通过transform缩小一半,就是0.5px了
|
|
72
|
-
if (direction
|
|
72
|
+
if (props.direction === "row") {
|
|
73
73
|
// 此处采用兼容分开写,兼容nvue的写法
|
|
74
|
-
style.borderBottomWidth =
|
|
75
|
-
style.borderBottomStyle = dashed
|
|
76
|
-
style.width = addUnit(length
|
|
77
|
-
if (!hairline
|
|
74
|
+
style.borderBottomWidth = "1px";
|
|
75
|
+
style.borderBottomStyle = props.dashed ? "dashed" : "solid";
|
|
76
|
+
style.width = addUnit(props.length);
|
|
77
|
+
if (!props.hairline) style.borderBottomWidth = "1.5px";
|
|
78
78
|
} else {
|
|
79
79
|
// 如果是竖向线条,边框宽度为1px,再通过transform缩小一半,就是0.5px了
|
|
80
|
-
style.borderLeftWidth =
|
|
81
|
-
style.borderLeftStyle = dashed
|
|
82
|
-
style.height = addUnit(length
|
|
83
|
-
if (hairline
|
|
80
|
+
style.borderLeftWidth = "1px";
|
|
81
|
+
style.borderLeftStyle = props.dashed ? "dashed" : "solid";
|
|
82
|
+
style.height = addUnit(props.length);
|
|
83
|
+
if (props.hairline) style.transform = "scaleX(0.5)";
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
style.borderColor = color
|
|
87
|
-
return Object.assign(style, customStyle
|
|
88
|
-
})
|
|
86
|
+
style.borderColor = props.color;
|
|
87
|
+
return Object.assign(style, props.customStyle);
|
|
88
|
+
});
|
|
89
89
|
</script>
|
|
90
90
|
|
|
91
91
|
<style lang="scss" scoped>
|
|
92
|
-
@import
|
|
92
|
+
@import "./index.scss";
|
|
93
93
|
</style>
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
fontSize: fontSize ? addUnit(fontSize) : addUnit(getPx(height)),
|
|
18
18
|
}"
|
|
19
19
|
>
|
|
20
|
-
{{ innserPercentage +
|
|
20
|
+
{{ innserPercentage + "%" }}
|
|
21
21
|
</text>
|
|
22
22
|
</slot>
|
|
23
23
|
</view>
|
|
@@ -26,25 +26,32 @@
|
|
|
26
26
|
|
|
27
27
|
<script lang="ts">
|
|
28
28
|
export default {
|
|
29
|
-
name:
|
|
29
|
+
name: "hy-line-progress",
|
|
30
30
|
options: {
|
|
31
31
|
addGlobalClass: true,
|
|
32
32
|
virtualHost: true,
|
|
33
|
-
styleIsolation:
|
|
33
|
+
styleIsolation: "shared",
|
|
34
34
|
},
|
|
35
|
-
}
|
|
35
|
+
};
|
|
36
36
|
</script>
|
|
37
37
|
|
|
38
38
|
<script setup lang="ts">
|
|
39
|
-
import { computed, getCurrentInstance, onMounted, ref,
|
|
40
|
-
import type { CSSProperties, PropType } from
|
|
41
|
-
import {
|
|
39
|
+
import { computed, getCurrentInstance, onMounted, ref, watch } from "vue";
|
|
40
|
+
import type { CSSProperties, PropType } from "vue";
|
|
41
|
+
import {
|
|
42
|
+
addUnit,
|
|
43
|
+
getPx,
|
|
44
|
+
getRect,
|
|
45
|
+
range,
|
|
46
|
+
type RectResultType,
|
|
47
|
+
sleep,
|
|
48
|
+
} from "../../utils";
|
|
42
49
|
|
|
43
50
|
/**
|
|
44
51
|
* 展示操作或任务的当前进度,比如上传文件,是一个线形的进度条。
|
|
45
52
|
* @displayName hy-line-progress
|
|
46
53
|
*/
|
|
47
|
-
defineOptions({})
|
|
54
|
+
defineOptions({});
|
|
48
55
|
|
|
49
56
|
// const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
50
57
|
const props = defineProps({
|
|
@@ -75,56 +82,56 @@ const props = defineProps({
|
|
|
75
82
|
},
|
|
76
83
|
/** 自定义外部类名 */
|
|
77
84
|
customClass: String,
|
|
78
|
-
})
|
|
79
|
-
const { percentage, activeColor, height } = toRefs(props)
|
|
85
|
+
});
|
|
80
86
|
|
|
81
|
-
const instance = getCurrentInstance()
|
|
82
|
-
const lineWidth = ref<string | number>(0)
|
|
87
|
+
const instance = getCurrentInstance();
|
|
88
|
+
const lineWidth = ref<string | number>(0);
|
|
83
89
|
|
|
84
90
|
watch(
|
|
85
|
-
() => percentage
|
|
91
|
+
() => props.percentage,
|
|
86
92
|
() => resizeProgressWidth(),
|
|
87
|
-
)
|
|
93
|
+
);
|
|
88
94
|
|
|
89
95
|
const progressStyle = computed<CSSProperties>(() => {
|
|
90
|
-
const style: CSSProperties = {}
|
|
91
|
-
style.width = lineWidth.value
|
|
92
|
-
style.backgroundColor = activeColor
|
|
93
|
-
style.height = addUnit(height
|
|
94
|
-
return style
|
|
95
|
-
})
|
|
96
|
+
const style: CSSProperties = {};
|
|
97
|
+
style.width = lineWidth.value;
|
|
98
|
+
style.backgroundColor = props.activeColor;
|
|
99
|
+
style.height = addUnit(props.height);
|
|
100
|
+
return style;
|
|
101
|
+
});
|
|
96
102
|
|
|
97
103
|
const innserPercentage = computed(() => {
|
|
98
104
|
// 控制范围在0-100之间
|
|
99
|
-
return range(0, 100, percentage
|
|
100
|
-
})
|
|
105
|
+
return range(0, 100, props.percentage);
|
|
106
|
+
});
|
|
101
107
|
|
|
102
108
|
onMounted(() => {
|
|
103
|
-
init()
|
|
104
|
-
})
|
|
109
|
+
init();
|
|
110
|
+
});
|
|
105
111
|
|
|
106
112
|
const init = async () => {
|
|
107
|
-
await sleep(20)
|
|
108
|
-
resizeProgressWidth()
|
|
109
|
-
}
|
|
110
|
-
const getProgressWidth = () => {
|
|
113
|
+
await sleep(20);
|
|
114
|
+
await resizeProgressWidth();
|
|
115
|
+
};
|
|
116
|
+
const getProgressWidth = (): Promise<RectResultType<false>> => {
|
|
111
117
|
return new Promise((resolve) => {
|
|
112
118
|
// #ifndef APP-NVUE
|
|
113
|
-
resolve(getRect(
|
|
119
|
+
resolve(getRect(".hy-line-progress__background", false, instance));
|
|
114
120
|
// #endif
|
|
115
|
-
})
|
|
116
|
-
}
|
|
121
|
+
});
|
|
122
|
+
};
|
|
117
123
|
|
|
118
124
|
/**
|
|
119
125
|
* @description 计算轨道长度
|
|
120
126
|
* */
|
|
121
127
|
const resizeProgressWidth = async () => {
|
|
122
|
-
const { width } = await getProgressWidth()
|
|
128
|
+
const { width } = await getProgressWidth();
|
|
123
129
|
// 通过设置的percentage值,计算其所占总长度的百分比
|
|
124
|
-
|
|
125
|
-
|
|
130
|
+
if (!width) return;
|
|
131
|
+
lineWidth.value = addUnit((width * innserPercentage.value) / 100);
|
|
132
|
+
};
|
|
126
133
|
</script>
|
|
127
134
|
|
|
128
135
|
<style lang="scss" scoped>
|
|
129
|
-
@import
|
|
136
|
+
@import "./index.scss";
|
|
130
137
|
</style>
|