hy-app 0.1.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/README.md +42 -0
- package/api/http.ts +138 -0
- package/api/index.ts +1 -0
- package/common/index.ts +1 -0
- package/common/versionControl.ts +102 -0
- package/components/dialog/TheDialog.vue +128 -0
- package/components/dialog/index.ts +38 -0
- package/components/hy-address-picker/hy-address-picker.vue +262 -0
- package/components/hy-address-picker/props.ts +27 -0
- package/components/hy-address-picker/typing.d.ts +98 -0
- package/components/hy-avatar/hy-avatar.vue +217 -0
- package/components/hy-avatar/props.ts +20 -0
- package/components/hy-avatar/typing.d.ts +64 -0
- package/components/hy-back-top/hy-back-top.vue +71 -0
- package/components/hy-back-top/props.ts +23 -0
- package/components/hy-back-top/typing.d.ts +49 -0
- package/components/hy-badge/hy-badge.vue +155 -0
- package/components/hy-badge/props.ts +19 -0
- package/components/hy-badge/typing.d.ts +60 -0
- package/components/hy-button/hy-button.vue +394 -0
- package/components/hy-button/props.ts +36 -0
- package/components/hy-button/typing.d.ts +125 -0
- package/components/hy-card/hy-card.vue +198 -0
- package/components/hy-card/props.ts +29 -0
- package/components/hy-card/typing.d.ts +112 -0
- package/components/hy-cell/hy-cell.vue +268 -0
- package/components/hy-cell/props.ts +20 -0
- package/components/hy-cell/typing.d.ts +98 -0
- package/components/hy-check-button/hy-check-button.vue +71 -0
- package/components/hy-check-button/props.ts +20 -0
- package/components/hy-check-button/typing.d.ts +79 -0
- package/components/hy-checkbox/hy-checkbox.vue +299 -0
- package/components/hy-checkbox/props.ts +28 -0
- package/components/hy-checkbox/typing.d.ts +77 -0
- package/components/hy-datetime-picker/hy-datetime-picker.vue +584 -0
- package/components/hy-datetime-picker/props.ts +36 -0
- package/components/hy-datetime-picker/typing.d.ts +135 -0
- package/components/hy-divider/hy-divider.vue +164 -0
- package/components/hy-divider/props.ts +21 -0
- package/components/hy-divider/typing.d.ts +64 -0
- package/components/hy-empty/hy-empty.vue +122 -0
- package/components/hy-empty/props.ts +21 -0
- package/components/hy-empty/typing.d.ts +68 -0
- package/components/hy-folding-panel/hy-folding-panel.vue +94 -0
- package/components/hy-folding-panel/props.ts +17 -0
- package/components/hy-folding-panel/typing.d.ts +59 -0
- package/components/hy-form/hy-form.vue +372 -0
- package/components/hy-form/props.ts +15 -0
- package/components/hy-form/typing.d.ts +51 -0
- package/components/hy-grid/hy-grid.vue +126 -0
- package/components/hy-grid/props.ts +16 -0
- package/components/hy-grid/typing.d.ts +62 -0
- package/components/hy-icon/hy-icon.vue +207 -0
- package/components/hy-icon/props.ts +24 -0
- package/components/hy-icon/typing.d.ts +80 -0
- package/components/hy-input/hy-input.vue +402 -0
- package/components/hy-input/props.ts +41 -0
- package/components/hy-input/typing.d.ts +148 -0
- package/components/hy-line/hy-line.vue +44 -0
- package/components/hy-line/props.ts +12 -0
- package/components/hy-line/typing.d.ts +32 -0
- package/components/hy-line-progress/hy-line-progress.vue +118 -0
- package/components/hy-line-progress/props.ts +12 -0
- package/components/hy-line-progress/typing.d.ts +28 -0
- package/components/hy-list/hy-list.vue +250 -0
- package/components/hy-list/props.ts +18 -0
- package/components/hy-list/typing.d.ts +50 -0
- package/components/hy-login/ThePhoneLogin.vue +106 -0
- package/components/hy-login/TheUserLogin.vue +391 -0
- package/components/hy-login/hy-login.vue +283 -0
- package/components/hy-login/props.ts +32 -0
- package/components/hy-login/typing.d.ts +60 -0
- package/components/hy-modal/hy-modal.vue +240 -0
- package/components/hy-modal/props.ts +24 -0
- package/components/hy-modal/typing.d.ts +70 -0
- package/components/hy-navbar/hy-navbar.vue +194 -0
- package/components/hy-navbar/props.ts +24 -0
- package/components/hy-navbar/typing.d.ts +81 -0
- package/components/hy-notice-bar/hy-column-notice.vue +130 -0
- package/components/hy-notice-bar/hy-notice-bar.vue +82 -0
- package/components/hy-notice-bar/hy-row-notice.vue +182 -0
- package/components/hy-notice-bar/props.ts +19 -0
- package/components/hy-notice-bar/typing.d.ts +56 -0
- package/components/hy-number-step/hy-number-step.vue +428 -0
- package/components/hy-number-step/props.ts +29 -0
- package/components/hy-number-step/typing.d.ts +104 -0
- package/components/hy-overlay/hy-overlay.vue +54 -0
- package/components/hy-overlay/props.ts +10 -0
- package/components/hy-overlay/typing.d.ts +24 -0
- package/components/hy-picker/hy-picker.vue +499 -0
- package/components/hy-picker/props.ts +30 -0
- package/components/hy-picker/typing.d.ts +115 -0
- package/components/hy-popup/hy-popup.vue +269 -0
- package/components/hy-popup/props.ts +21 -0
- package/components/hy-popup/typing.d.ts +68 -0
- package/components/hy-price/hy-price.vue +86 -0
- package/components/hy-price/props.ts +13 -0
- package/components/hy-price/typing.d.ts +36 -0
- package/components/hy-qrcode/hy-qrcode.vue +153 -0
- package/components/hy-qrcode/props.ts +20 -0
- package/components/hy-qrcode/qrcode.js +1364 -0
- package/components/hy-qrcode/typing.d.ts +64 -0
- package/components/hy-radio/hy-radio.vue +319 -0
- package/components/hy-radio/props.ts +28 -0
- package/components/hy-radio/typing.d.ts +85 -0
- package/components/hy-rate/hy-rate.vue +261 -0
- package/components/hy-rate/props.ts +18 -0
- package/components/hy-rate/typing.d.ts +60 -0
- package/components/hy-read-more/hy-read-more.vue +134 -0
- package/components/hy-read-more/props.ts +20 -0
- package/components/hy-read-more/typing.d.ts +44 -0
- package/components/hy-safe-bottom/hy-safe-bottom.vue +64 -0
- package/components/hy-scroll-list/hy-scroll-list.vue +146 -0
- package/components/hy-scroll-list/props.ts +12 -0
- package/components/hy-scroll-list/typing.d.ts +28 -0
- package/components/hy-search/hy-search.vue +294 -0
- package/components/hy-search/props.ts +29 -0
- package/components/hy-search/typing.d.ts +109 -0
- package/components/hy-slider/hy-slider.vue +511 -0
- package/components/hy-slider/props.ts +21 -0
- package/components/hy-slider/typing.d.ts +68 -0
- package/components/hy-steps/hy-steps.vue +352 -0
- package/components/hy-steps/props.ts +15 -0
- package/components/hy-steps/typing.d.ts +58 -0
- package/components/hy-subsection/hy-subsection.vue +272 -0
- package/components/hy-subsection/props.ts +16 -0
- package/components/hy-subsection/typing.d.ts +44 -0
- package/components/hy-swiper/hy-swiper-indicator.vue +105 -0
- package/components/hy-swiper/hy-swiper.vue +242 -0
- package/components/hy-swiper/props.ts +30 -0
- package/components/hy-swiper/typing.d.ts +107 -0
- package/components/hy-switch/hy-switch.vue +168 -0
- package/components/hy-switch/props.ts +16 -0
- package/components/hy-switch/typing.d.ts +48 -0
- package/components/hy-tabs/hy-tabs.vue +416 -0
- package/components/hy-tabs/props.ts +26 -0
- package/components/hy-tabs/typing.d.ts +86 -0
- package/components/hy-tag/hy-tag.vue +374 -0
- package/components/hy-tag/props.ts +22 -0
- package/components/hy-tag/typing.d.ts +76 -0
- package/components/hy-textarea/hy-textarea.vue +229 -0
- package/components/hy-textarea/props.ts +26 -0
- package/components/hy-textarea/typing.d.ts +27 -0
- package/components/hy-tooltip/hy-tooltip.vue +332 -0
- package/components/hy-tooltip/props.ts +17 -0
- package/components/hy-tooltip/typing.d.ts +52 -0
- package/components/hy-transition/hy-transition.vue +150 -0
- package/components/hy-transition/index.scss +113 -0
- package/components/hy-transition/props.ts +10 -0
- package/components/hy-transition/typing.d.ts +36 -0
- package/components/hy-upload/hy-upload.vue +557 -0
- package/components/hy-upload/props.ts +29 -0
- package/components/hy-upload/typing.d.ts +147 -0
- package/components/hy-warn/hy-warn.vue +228 -0
- package/components/hy-warn/props.ts +14 -0
- package/components/hy-warn/typing.d.ts +40 -0
- package/components/hy-waterfall/hy-waterfall.vue +51 -0
- package/components/hy-waterfall/props.ts +10 -0
- package/components/hy-waterfall/typing.d.ts +20 -0
- package/components/index.ts +162 -0
- package/components/message/TheMessage.vue +169 -0
- package/components/message/index.ts +54 -0
- package/components/u-form/form.js +22 -0
- package/components/u-form/hy-form.vue +324 -0
- package/components/u-form/props.js +49 -0
- package/components/u-form/schema.js +1451 -0
- package/components/u-form/u-form.vue +267 -0
- package/components/u-form/utils.js +65 -0
- package/components/u-form-item/formItem.js +24 -0
- package/components/u-form-item/hy-form-item.vue +360 -0
- package/components/u-form-item/props.js +57 -0
- package/components/u-form-item/u-form-item.vue +294 -0
- package/components/yk-dialog/yk-dialog.vue +129 -0
- package/components/yk-tabbar/props.ts +49 -0
- package/components/yk-tabbar/yk-tabbar.vue +224 -0
- package/config/color.ts +6 -0
- package/config/icon.ts +366 -0
- package/config/index.ts +2 -0
- package/global/index.ts +6 -0
- package/global/register-properties.ts +37 -0
- package/index.ts +8 -0
- package/libs/css/common.scss +0 -0
- package/libs/css/iconfont.css +379 -0
- package/libs/css/iconfont.ttf +0 -0
- package/libs/css/mixin.scss +15 -0
- package/package.json +42 -0
- package/public/icons/error.png +0 -0
- package/public/icons/success.png +0 -0
- package/public/icons/warning.png +0 -0
- package/store/index.ts +1 -0
- package/store/userInfo.ts +25 -0
- package/theme.scss +94 -0
- package/typing/index.ts +7 -0
- package/typing/modules/common.d.ts +50 -0
- package/typing/modules/dialog.ts +17 -0
- package/typing/modules/enum.ts +67 -0
- package/typing/modules/form.ts +161 -0
- package/typing/modules/http.ts +68 -0
- package/typing/modules/icon.d.ts +366 -0
- package/typing/modules/img.ts +15 -0
- package/typing/modules/rect.ts +10 -0
- package/utils/address.json +5890 -0
- package/utils/base64.ts +119 -0
- package/utils/index.ts +3 -0
- package/utils/inside.ts +310 -0
- package/utils/utils.ts +446 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import IProps from "./typing";
|
|
2
|
+
|
|
3
|
+
const defaultProps: IProps = {
|
|
4
|
+
modelValue: "",
|
|
5
|
+
type: "text",
|
|
6
|
+
fixed: false,
|
|
7
|
+
disabled: false,
|
|
8
|
+
disabledColor: "#F5F5F5",
|
|
9
|
+
clearable: false,
|
|
10
|
+
password: false,
|
|
11
|
+
maxlength: 140,
|
|
12
|
+
placeholder: null,
|
|
13
|
+
placeholderClass: "input-placeholder",
|
|
14
|
+
placeholderStyle: {},
|
|
15
|
+
showWordLimit: false,
|
|
16
|
+
confirmType: "done",
|
|
17
|
+
confirmHold: false,
|
|
18
|
+
holdKeyboard: false,
|
|
19
|
+
focus: false,
|
|
20
|
+
autoBlur: false,
|
|
21
|
+
disableDefaultPadding: false,
|
|
22
|
+
cursor: -1,
|
|
23
|
+
cursorSpacing: 30,
|
|
24
|
+
selectionStart: -1,
|
|
25
|
+
selectionEnd: -1,
|
|
26
|
+
adjustPosition: true,
|
|
27
|
+
inputAlign: "left",
|
|
28
|
+
fontSize: "15px",
|
|
29
|
+
color: "#303133",
|
|
30
|
+
prefixIcon: "",
|
|
31
|
+
prefixIconStyle: {},
|
|
32
|
+
suffixIcon: "",
|
|
33
|
+
suffixIconStyle: {},
|
|
34
|
+
border: "surround",
|
|
35
|
+
readonly: false,
|
|
36
|
+
shape: "square",
|
|
37
|
+
formatter: null,
|
|
38
|
+
customStyle: {}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default defaultProps;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { CSSProperties } from "vue";
|
|
2
|
+
|
|
3
|
+
export default interface IProps {
|
|
4
|
+
/**
|
|
5
|
+
* @description 输入的值
|
|
6
|
+
* */
|
|
7
|
+
modelValue: string | number;
|
|
8
|
+
/**
|
|
9
|
+
* @description 输入框类型,见上方说明 ( 默认 'text' )
|
|
10
|
+
* */
|
|
11
|
+
type?: "text" | "idcard" | "number" | "digit" | "password";
|
|
12
|
+
/**
|
|
13
|
+
* @description 如果 textarea 是在一个 position:fixed 的区域,需要显示指定属性 fixed 为 true,兼容性:微信小程序、百度小程序、字节跳动小程序、QQ小程序 ( 默认 false )
|
|
14
|
+
* */
|
|
15
|
+
fixed?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* @description 是否禁用输入框 ( 默认 false )
|
|
18
|
+
* */
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* @description 禁用状态时的背景色( 默认 '#f5f7fa' )
|
|
22
|
+
* */
|
|
23
|
+
disabledColor?: string;
|
|
24
|
+
/**
|
|
25
|
+
* @description 是否显示清除控件 ( 默认 false )
|
|
26
|
+
* */
|
|
27
|
+
clearable?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* @description 是否密码类型 ( 默认 false )
|
|
30
|
+
* */
|
|
31
|
+
password?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* @description 最大输入长度,设置为 -1 的时候不限制最大长度 ( 默认 -1 )
|
|
34
|
+
* */
|
|
35
|
+
maxlength?: number;
|
|
36
|
+
/**
|
|
37
|
+
* @description 输入框为空时的占位符
|
|
38
|
+
* */
|
|
39
|
+
placeholder?: string | null;
|
|
40
|
+
/**
|
|
41
|
+
* @description 指定placeholder的样式类,注意页面或组件的style中写了scoped时,需要在类名前写/deep/ ( 默认 'input-placeholder' )
|
|
42
|
+
* */
|
|
43
|
+
placeholderClass?: string;
|
|
44
|
+
/**
|
|
45
|
+
* @description 指定placeholder的样式,字符串/对象形式,如"color: red;"
|
|
46
|
+
* */
|
|
47
|
+
placeholderStyle?: CSSProperties;
|
|
48
|
+
/**
|
|
49
|
+
* @description 是否显示输入字数统计,只在 type ="text"或type ="textarea"时有效 ( 默认 false )
|
|
50
|
+
* */
|
|
51
|
+
showWordLimit?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* @description 设置右下角按钮的文字,兼容性详见uni-app文档 ( 默认 'done' )
|
|
54
|
+
* */
|
|
55
|
+
confirmType?: string;
|
|
56
|
+
/**
|
|
57
|
+
* @description 点击键盘右下角按钮时是否保持键盘不收起,H5无效 ( 默认 false )
|
|
58
|
+
* */
|
|
59
|
+
confirmHold?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* @description focus时,点击页面的时候不收起键盘,微信小程序有效 ( 默认 false )
|
|
62
|
+
* */
|
|
63
|
+
holdKeyboard?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* @description 自动获取焦点,在 H5 平台能否聚焦以及软键盘是否跟随弹出,取决于当前浏览器本身的实现。nvue 页面不支持,需使用组件的 focus()、blur() 方法控制焦点 ( 默认 false )
|
|
66
|
+
* */
|
|
67
|
+
focus?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* @description 键盘收起时,是否自动失去焦点,目前仅App3.0.0+有效 ( 默认 false )
|
|
70
|
+
* */
|
|
71
|
+
autoBlur?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* @description 是否去掉 iOS 下的默认内边距,仅微信小程序,且type=textarea时有效 ( 默认 false )
|
|
74
|
+
* */
|
|
75
|
+
disableDefaultPadding?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* @description 指定focus时光标的位置( 默认 140 )
|
|
78
|
+
* */
|
|
79
|
+
cursor?: number;
|
|
80
|
+
/**
|
|
81
|
+
* @description 输入框聚焦时底部与键盘的距离 ( 默认 30 )
|
|
82
|
+
* */
|
|
83
|
+
cursorSpacing?: number;
|
|
84
|
+
/**
|
|
85
|
+
* @description 光标起始位置,自动聚集时有效,需与selection-end搭配使用 ( 默认 -1 )
|
|
86
|
+
* */
|
|
87
|
+
selectionStart?: number;
|
|
88
|
+
/**
|
|
89
|
+
* @description 光标结束位置,自动聚集时有效,需与selection-start搭配使用 ( 默认 -1 )
|
|
90
|
+
* */
|
|
91
|
+
selectionEnd?: number;
|
|
92
|
+
/**
|
|
93
|
+
* @description 键盘弹起时,是否自动上推页面 ( 默认 true )
|
|
94
|
+
* */
|
|
95
|
+
adjustPosition?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* @description 输入框内容对齐方式( 默认 'left' )
|
|
98
|
+
* */
|
|
99
|
+
inputAlign?: "center" | HyApp.LeftRightType;
|
|
100
|
+
/**
|
|
101
|
+
* @description 输入框字体的大小 ( 默认 '15px' )
|
|
102
|
+
* */
|
|
103
|
+
fontSize?: string | number;
|
|
104
|
+
/**
|
|
105
|
+
* @description 输入框字体颜色 ( 默认 '#303133' )
|
|
106
|
+
* */
|
|
107
|
+
color?: string;
|
|
108
|
+
/**
|
|
109
|
+
* @description 输入框前置图标
|
|
110
|
+
* */
|
|
111
|
+
prefixIcon?: string;
|
|
112
|
+
/**
|
|
113
|
+
* @description 前置图标样式,对象或字符串
|
|
114
|
+
* */
|
|
115
|
+
prefixIconStyle?: CSSProperties;
|
|
116
|
+
/**
|
|
117
|
+
* @description 输入框后置图标
|
|
118
|
+
* */
|
|
119
|
+
suffixIcon?: string;
|
|
120
|
+
/**
|
|
121
|
+
* @description 后置图标样式,对象或字符串
|
|
122
|
+
* */
|
|
123
|
+
suffixIconStyle?: CSSProperties;
|
|
124
|
+
/**
|
|
125
|
+
* @description 边框类型,surround-四周边框,bottom-底部边框,none-无边框 ( 默认 'surround' )
|
|
126
|
+
* */
|
|
127
|
+
border?: HyApp.BorderType;
|
|
128
|
+
/**
|
|
129
|
+
* @description 是否只读,与disabled不同之处在于disabled会置灰组件,而readonly则不会 ( 默认 false )
|
|
130
|
+
* */
|
|
131
|
+
readonly?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* @description 输入框形状,circle-圆形,square-方形 ( 默认 'square' )
|
|
134
|
+
* */
|
|
135
|
+
shape?: HyApp.ShapeType;
|
|
136
|
+
/**
|
|
137
|
+
* @description 内容式化函数
|
|
138
|
+
* */
|
|
139
|
+
formatter?: Function | null;
|
|
140
|
+
/**
|
|
141
|
+
* @description 定义需要用到的外部样式
|
|
142
|
+
* */
|
|
143
|
+
customStyle?: CSSProperties;
|
|
144
|
+
/**
|
|
145
|
+
* @description 是否忽略组件内对文本合成系统事件的处理。
|
|
146
|
+
* */
|
|
147
|
+
ignoreCompositionEvent?: boolean;
|
|
148
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="hy-line" :style="lineStyle"> </view>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { computed, CSSProperties, toRefs } from "vue";
|
|
7
|
+
import defaultProps from "./props";
|
|
8
|
+
import IProps from "./typing";
|
|
9
|
+
import { addUnit } from "../../utils";
|
|
10
|
+
|
|
11
|
+
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
12
|
+
const { margin, length, dashed, direction, hairline, color, customStyle } =
|
|
13
|
+
toRefs(props);
|
|
14
|
+
|
|
15
|
+
const lineStyle = computed<CSSProperties>(() => {
|
|
16
|
+
const style: CSSProperties = {};
|
|
17
|
+
style.margin = margin.value;
|
|
18
|
+
// 如果是水平线条,边框高度为1px,再通过transform缩小一半,就是0.5px了
|
|
19
|
+
if (direction.value === "row") {
|
|
20
|
+
// 此处采用兼容分开写,兼容nvue的写法
|
|
21
|
+
style.borderBottomWidth = "1px";
|
|
22
|
+
style.borderBottomStyle = dashed.value ? "dashed" : "solid";
|
|
23
|
+
style.width = addUnit(length.value);
|
|
24
|
+
if (hairline.value) style.transform = "scaleY(0.5)";
|
|
25
|
+
} else {
|
|
26
|
+
// 如果是竖向线条,边框宽度为1px,再通过transform缩小一半,就是0.5px了
|
|
27
|
+
style.borderLeftWidth = "1px";
|
|
28
|
+
style.borderLeftStyle = dashed.value ? "dashed" : "solid";
|
|
29
|
+
style.height = addUnit(length.value);
|
|
30
|
+
if (hairline.value) style.transform = "scaleX(0.5)";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
style.borderColor = color.value;
|
|
34
|
+
return Object.assign(style, customStyle.value);
|
|
35
|
+
});
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<style lang="scss" scoped>
|
|
39
|
+
.hy-line {
|
|
40
|
+
/* #ifndef APP-NVUE */
|
|
41
|
+
vertical-align: middle;
|
|
42
|
+
/* #endif */
|
|
43
|
+
}
|
|
44
|
+
</style>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CSSProperties } from "vue";
|
|
2
|
+
|
|
3
|
+
export default interface IProps {
|
|
4
|
+
/**
|
|
5
|
+
* @description 线条的颜色 ( 默认 '#d6d7d9' )
|
|
6
|
+
* */
|
|
7
|
+
color?: string;
|
|
8
|
+
/**
|
|
9
|
+
* @description 长度,竖向时表现为高度,横向时表现为长度,可以为百分比,带px单位的值等 ( 默认 '100%' )
|
|
10
|
+
* */
|
|
11
|
+
length?: string | number;
|
|
12
|
+
/**
|
|
13
|
+
* @description 线条的方向,row-横向,column-竖向 (默认 'row' )
|
|
14
|
+
* */
|
|
15
|
+
direction?: HyApp.PermutationType;
|
|
16
|
+
/**
|
|
17
|
+
* @description 是否显示细线条 (默认 true )
|
|
18
|
+
* */
|
|
19
|
+
hairline?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* @description 线条与上下左右 元素的间距,字符串形式,如"30px" (默认 0 )
|
|
22
|
+
* */
|
|
23
|
+
margin?: string;
|
|
24
|
+
/**
|
|
25
|
+
* @description 是否虚线,true-虚线,false-实线 (默认 false )
|
|
26
|
+
* */
|
|
27
|
+
dashed?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* @description 定义需要用到的外部样式
|
|
30
|
+
* */
|
|
31
|
+
customStyle?: CSSProperties;
|
|
32
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="hy-line-progress" :style="customStyle">
|
|
3
|
+
<view
|
|
4
|
+
class="hy-line-progress__background"
|
|
5
|
+
ref="hy-line-progress__background"
|
|
6
|
+
:style="{
|
|
7
|
+
backgroundColor: inactiveColor,
|
|
8
|
+
height: addUnit(height)
|
|
9
|
+
}"
|
|
10
|
+
>
|
|
11
|
+
</view>
|
|
12
|
+
<view class="hy-line-progress__line" :style="[progressStyle]">
|
|
13
|
+
<slot>
|
|
14
|
+
<text
|
|
15
|
+
v-if="showText && percentage >= 10"
|
|
16
|
+
class="hy-line-progress__text"
|
|
17
|
+
>{{ innserPercentage + "%" }}</text
|
|
18
|
+
>
|
|
19
|
+
</slot>
|
|
20
|
+
</view>
|
|
21
|
+
</view>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script setup lang="ts">
|
|
25
|
+
import { computed, CSSProperties, onMounted, ref, toRefs, watch } from "vue";
|
|
26
|
+
import defaultProps from "./props";
|
|
27
|
+
import IProps from "./typing";
|
|
28
|
+
import { addUnit, getRect, range, sleep } from "../../utils";
|
|
29
|
+
|
|
30
|
+
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
31
|
+
const { percentage, activeColor, height } = toRefs(props);
|
|
32
|
+
|
|
33
|
+
const lineWidth = ref<string | number>(0);
|
|
34
|
+
|
|
35
|
+
watch(
|
|
36
|
+
() => percentage.value,
|
|
37
|
+
() => resizeProgressWidth()
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const progressStyle = computed<CSSProperties>(() => {
|
|
41
|
+
const style: CSSProperties = {};
|
|
42
|
+
style.width = lineWidth.value;
|
|
43
|
+
style.backgroundColor = activeColor.value;
|
|
44
|
+
style.height = addUnit(height.value);
|
|
45
|
+
return style;
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const innserPercentage = computed(() => {
|
|
49
|
+
// 控制范围在0-100之间
|
|
50
|
+
return range(0, 100, percentage.value);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
onMounted(() => {
|
|
54
|
+
init();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const init = async () => {
|
|
58
|
+
await sleep(20);
|
|
59
|
+
resizeProgressWidth();
|
|
60
|
+
};
|
|
61
|
+
const getProgressWidth = () => {
|
|
62
|
+
return new Promise((resolve) => {
|
|
63
|
+
// #ifndef APP-NVUE
|
|
64
|
+
resolve(getRect(".u-line-progress__background"));
|
|
65
|
+
// #endif
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @description 计算轨道长度
|
|
71
|
+
* */
|
|
72
|
+
const resizeProgressWidth = async () => {
|
|
73
|
+
const { width } = await getProgressWidth();
|
|
74
|
+
// 通过设置的percentage值,计算其所占总长度的百分比
|
|
75
|
+
lineWidth.value = (width * innserPercentage.value) / 100 + "px";
|
|
76
|
+
};
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<style lang="scss" scoped>
|
|
80
|
+
@import "../../libs/css/mixin.scss";
|
|
81
|
+
|
|
82
|
+
.hy-line-progress {
|
|
83
|
+
align-items: stretch;
|
|
84
|
+
position: relative;
|
|
85
|
+
@include flex(row);
|
|
86
|
+
flex: 1;
|
|
87
|
+
overflow: hidden;
|
|
88
|
+
border-radius: 100px;
|
|
89
|
+
|
|
90
|
+
&__background {
|
|
91
|
+
background-color: #ececec;
|
|
92
|
+
border-radius: 100px;
|
|
93
|
+
flex: 1;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&__line {
|
|
97
|
+
position: absolute;
|
|
98
|
+
top: 0;
|
|
99
|
+
left: 0;
|
|
100
|
+
bottom: 0;
|
|
101
|
+
align-items: center;
|
|
102
|
+
@include flex(row);
|
|
103
|
+
color: #ffffff;
|
|
104
|
+
border-radius: 100px;
|
|
105
|
+
transition: width 0.5s ease;
|
|
106
|
+
justify-content: flex-end;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
&__text {
|
|
110
|
+
font-size: 10px;
|
|
111
|
+
align-items: center;
|
|
112
|
+
text-align: right;
|
|
113
|
+
color: #ffffff;
|
|
114
|
+
margin-right: 5px;
|
|
115
|
+
transform: scale(0.9);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import IProps from "./typing";
|
|
2
|
+
import { ColorConfig } from "../../config";
|
|
3
|
+
|
|
4
|
+
const defaultProps: IProps = {
|
|
5
|
+
activeColor: ColorConfig.primary,
|
|
6
|
+
inactiveColor: "#ececec",
|
|
7
|
+
percentage: 0,
|
|
8
|
+
showText: true,
|
|
9
|
+
height: 12
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default defaultProps;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CSSProperties } from "vue";
|
|
2
|
+
|
|
3
|
+
export default interface IProps {
|
|
4
|
+
/**
|
|
5
|
+
* @description 激活部分的颜色 ( 默认 '#19be6b' )
|
|
6
|
+
* */
|
|
7
|
+
activeColor?: string;
|
|
8
|
+
/**
|
|
9
|
+
* @description 背景色 ( 默认 '#ececec' )
|
|
10
|
+
* */
|
|
11
|
+
inactiveColor?: string;
|
|
12
|
+
/**
|
|
13
|
+
* @description 进度百分比,数值 ( 默认 0 )
|
|
14
|
+
* */
|
|
15
|
+
percentage: number;
|
|
16
|
+
/**
|
|
17
|
+
* @description 是否在进度条内部显示百分比的值 ( 默认 true )
|
|
18
|
+
* */
|
|
19
|
+
showText?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* @description 进度条的高度,单位px ( 默认 12 )
|
|
22
|
+
* */
|
|
23
|
+
height?: string | number;
|
|
24
|
+
/**
|
|
25
|
+
* @description 自定义样式
|
|
26
|
+
* */
|
|
27
|
+
customStyle?: CSSProperties;
|
|
28
|
+
}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<scroll-view
|
|
3
|
+
ref="hyVirtualContainer"
|
|
4
|
+
@scroll="onScroll"
|
|
5
|
+
@scrolltolower="scrollToLower"
|
|
6
|
+
:lower-threshold="showDivider ? 40 : 10"
|
|
7
|
+
:scroll-y="true"
|
|
8
|
+
scroll-with-animation
|
|
9
|
+
class="hy-virtual-container"
|
|
10
|
+
>
|
|
11
|
+
<view class="hy-virtual-container__list">
|
|
12
|
+
<slot
|
|
13
|
+
v-if="slotDefault"
|
|
14
|
+
:record="line === 1 ? virtualData : waterfall"
|
|
15
|
+
></slot>
|
|
16
|
+
<template v-else>
|
|
17
|
+
<view
|
|
18
|
+
v-if="line === 1"
|
|
19
|
+
class="hy-virtual-container__list--item"
|
|
20
|
+
v-for="(item, i) in virtualData"
|
|
21
|
+
:key="typeof item === 'string' ? i : item[keyField]"
|
|
22
|
+
:style="itemStyle"
|
|
23
|
+
@click="handleClick(item)"
|
|
24
|
+
>
|
|
25
|
+
<slot style="height: 100%" name="content" :record="item"></slot>
|
|
26
|
+
</view>
|
|
27
|
+
|
|
28
|
+
<view
|
|
29
|
+
v-if="line === 2"
|
|
30
|
+
class="hy-virtual-container__list--left hy-virtual-container__list--box"
|
|
31
|
+
>
|
|
32
|
+
<view
|
|
33
|
+
v-if="slots.left"
|
|
34
|
+
class="hy-virtual-container__list--box-item"
|
|
35
|
+
v-for="item in waterfall.left"
|
|
36
|
+
:key="item[keyField]"
|
|
37
|
+
:style="itemStyle"
|
|
38
|
+
@click="handleClick(item)"
|
|
39
|
+
>
|
|
40
|
+
<slot name="left" :record="item"></slot>
|
|
41
|
+
</view>
|
|
42
|
+
<slot v-else name="left-list" :record="waterfall.left"> </slot>
|
|
43
|
+
</view>
|
|
44
|
+
<view
|
|
45
|
+
v-if="line === 2"
|
|
46
|
+
class="hy-virtual-container__list--right hy-virtual-container__list--box"
|
|
47
|
+
>
|
|
48
|
+
<view
|
|
49
|
+
v-if="slots.right"
|
|
50
|
+
class="hy-virtual-container__list--box-item"
|
|
51
|
+
v-for="item in waterfall.right"
|
|
52
|
+
:key="item[keyField]"
|
|
53
|
+
:style="itemStyle"
|
|
54
|
+
@click="handleClick(item)"
|
|
55
|
+
>
|
|
56
|
+
<slot name="right" :record="item"></slot>
|
|
57
|
+
</view>
|
|
58
|
+
<slot v-else name="right-list" :record="waterfall.right"> </slot>
|
|
59
|
+
</view>
|
|
60
|
+
</template>
|
|
61
|
+
<!--加载更多样式-->
|
|
62
|
+
</view>
|
|
63
|
+
<!-- <HyDivider :text="load" v-if="showDivider"></HyDivider>-->
|
|
64
|
+
</scroll-view>
|
|
65
|
+
</template>
|
|
66
|
+
|
|
67
|
+
<script lang="ts">
|
|
68
|
+
export default {
|
|
69
|
+
options: {
|
|
70
|
+
virtualHost: true
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
</script>
|
|
74
|
+
|
|
75
|
+
<script lang="ts" setup>
|
|
76
|
+
import {
|
|
77
|
+
computed,
|
|
78
|
+
CSSProperties,
|
|
79
|
+
nextTick,
|
|
80
|
+
onMounted,
|
|
81
|
+
reactive,
|
|
82
|
+
ref,
|
|
83
|
+
toRefs,
|
|
84
|
+
useSlots,
|
|
85
|
+
watch
|
|
86
|
+
} from "vue";
|
|
87
|
+
import { addUnit, debounce, getPx, getRect } from "../../utils";
|
|
88
|
+
import HyDivider from "../hy-divider/hy-divider.vue";
|
|
89
|
+
import IProps from "./typing";
|
|
90
|
+
import defaultProps from "./props";
|
|
91
|
+
|
|
92
|
+
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
93
|
+
const {
|
|
94
|
+
list,
|
|
95
|
+
line,
|
|
96
|
+
keyField,
|
|
97
|
+
itemHeight,
|
|
98
|
+
containerHeight,
|
|
99
|
+
marginBottom,
|
|
100
|
+
padding,
|
|
101
|
+
borderRadius,
|
|
102
|
+
background,
|
|
103
|
+
border
|
|
104
|
+
} = toRefs(props);
|
|
105
|
+
const emit = defineEmits(["scrollButton", "click"]);
|
|
106
|
+
|
|
107
|
+
const slots = useSlots();
|
|
108
|
+
// 滚动条距离顶部距离
|
|
109
|
+
const scrollTop = ref(0);
|
|
110
|
+
// 可视区域的高度
|
|
111
|
+
const viewHeight = ref(0);
|
|
112
|
+
const waterfall: { left: AnyObject[]; right: AnyObject[] } = reactive({
|
|
113
|
+
left: [],
|
|
114
|
+
right: []
|
|
115
|
+
});
|
|
116
|
+
// 排列方式
|
|
117
|
+
const arrange = computed(() => (line.value === 1 ? "column" : "row"));
|
|
118
|
+
const boxHeight = getPx(itemHeight.value) + getPx(marginBottom.value);
|
|
119
|
+
const listHeight = addUnit(containerHeight.value);
|
|
120
|
+
|
|
121
|
+
onMounted(() => {
|
|
122
|
+
nextTick(async () => {
|
|
123
|
+
const res = await getRect(".hy-virtual-container");
|
|
124
|
+
viewHeight.value = (res as UniApp.NodeInfo).height ?? 0;
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const itemStyle = computed((): CSSProperties => {
|
|
129
|
+
return {
|
|
130
|
+
height: addUnit(itemHeight.value),
|
|
131
|
+
padding: addUnit(padding.value),
|
|
132
|
+
marginBottom: addUnit(marginBottom.value),
|
|
133
|
+
borderRadius: addUnit(borderRadius.value),
|
|
134
|
+
background: background.value,
|
|
135
|
+
border: border.value ? "1px solid #dadbde" : ""
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* @description 虚拟列表真实展示数据:起始下标
|
|
141
|
+
*/
|
|
142
|
+
const start = computed(() => {
|
|
143
|
+
const s = Math.floor(scrollTop.value / boxHeight);
|
|
144
|
+
return Math.max(0, s * line.value);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @description 虚拟列表真实展示数据:结束下标
|
|
149
|
+
*/
|
|
150
|
+
const over = computed(() => {
|
|
151
|
+
const o = Math.floor(
|
|
152
|
+
(scrollTop.value + viewHeight.value + 1) / boxHeight + 5
|
|
153
|
+
);
|
|
154
|
+
return Math.min(list.value.length, o * line.value);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @description 计算虚拟列表的padding(保持列表高度完整且滚动条能正常滚动)
|
|
159
|
+
*/
|
|
160
|
+
const paddingAttr = computed(() => {
|
|
161
|
+
const paddingTop = start.value * boxHeight;
|
|
162
|
+
const paddingBottom = (list.value.length - over.value) * boxHeight;
|
|
163
|
+
return `${paddingTop / line.value}px 0 ${paddingBottom / line.value}px`;
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* @description 虚拟列表真实展示数据
|
|
168
|
+
*/
|
|
169
|
+
const virtualData = computed(() => {
|
|
170
|
+
return list.value.slice(start.value, over.value);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
watch(
|
|
174
|
+
() => virtualData.value,
|
|
175
|
+
(newVal, oldValue) => {
|
|
176
|
+
waterfall.left.length = 0;
|
|
177
|
+
waterfall.right.length = 0;
|
|
178
|
+
if (line.value === 2 && newVal.every((item) => typeof item !== "string")) {
|
|
179
|
+
newVal.forEach((item, i) => {
|
|
180
|
+
if (i % 2 === 0) {
|
|
181
|
+
waterfall.left.push(item);
|
|
182
|
+
} else {
|
|
183
|
+
waterfall.right.push(item);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
{ immediate: true, deep: true }
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* @description 监听滚动条距离顶部距离,实时更新
|
|
193
|
+
*/
|
|
194
|
+
const onScroll = async (e: any) => {
|
|
195
|
+
scrollTop.value = e.detail.scrollTop ?? 0;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* @description 滚动底部函数
|
|
200
|
+
* */
|
|
201
|
+
const scrollToLower = () => {
|
|
202
|
+
emit("scrollButton");
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* @description 点击行触发函数
|
|
207
|
+
* */
|
|
208
|
+
const handleClick = (temp: string | AnyObject) => {
|
|
209
|
+
emit("click", temp);
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* @description 获取默认插槽
|
|
214
|
+
*/
|
|
215
|
+
const slotDefault = useSlots().default;
|
|
216
|
+
</script>
|
|
217
|
+
|
|
218
|
+
<style lang="scss" scoped>
|
|
219
|
+
@import "../../theme.scss";
|
|
220
|
+
@import "../../libs/css/mixin.scss";
|
|
221
|
+
.hy-virtual-container {
|
|
222
|
+
height: v-bind(listHeight);
|
|
223
|
+
padding: 0 $hy-border-margin-padding-base;
|
|
224
|
+
box-sizing: border-box;
|
|
225
|
+
|
|
226
|
+
&__list {
|
|
227
|
+
padding: v-bind(paddingAttr);
|
|
228
|
+
@include flex(v-bind(arrange));
|
|
229
|
+
overflow-anchor: none;
|
|
230
|
+
&--item {
|
|
231
|
+
box-sizing: border-box;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
&--left {
|
|
235
|
+
margin-right: $hy-border-margin-padding-base;
|
|
236
|
+
}
|
|
237
|
+
&--box {
|
|
238
|
+
box-sizing: border-box;
|
|
239
|
+
width: 50%;
|
|
240
|
+
display: flex;
|
|
241
|
+
flex-direction: column;
|
|
242
|
+
&-item {
|
|
243
|
+
box-sizing: border-box;
|
|
244
|
+
position: relative;
|
|
245
|
+
overflow: hidden;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
</style>
|