hy-app 0.6.4 → 0.6.6
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-address-picker/hy-address-picker.vue +249 -249
- package/components/hy-address-picker/props.ts +103 -103
- package/components/hy-button/hy-button.vue +320 -289
- package/components/hy-button/props.ts +143 -143
- package/components/hy-button/typing.d.ts +43 -35
- package/components/hy-calendar/header.vue +58 -58
- package/components/hy-calendar/hy-calendar.vue +8 -6
- package/components/hy-calendar/month.vue +402 -402
- package/components/hy-calendar/props.ts +169 -169
- package/components/hy-calendar/typing.d.ts +47 -45
- package/components/hy-cell-item/hy-cell-item.vue +161 -161
- package/components/hy-cell-item/props.ts +59 -59
- package/components/hy-check-button/hy-check-button.vue +135 -135
- package/components/hy-code-input/hy-code-input.vue +231 -231
- package/components/hy-code-input/props.ts +90 -90
- package/components/hy-config-provider/hy-config-provider.vue +53 -53
- package/components/hy-config-provider/props.ts +30 -30
- package/components/hy-coupon/hy-coupon.vue +183 -183
- package/components/hy-coupon/props.ts +108 -108
- package/components/hy-datetime-picker/hy-datetime-picker.vue +41 -55
- package/components/hy-datetime-picker/props.ts +144 -144
- package/components/hy-datetime-picker/typing.d.ts +2 -0
- package/components/hy-divider/props.ts +83 -83
- package/components/hy-empty/icon.ts +72 -72
- package/components/hy-folding-panel/hy-folding-panel-group.vue +162 -162
- package/components/hy-form/hy-form.vue +220 -220
- package/components/hy-icon/hy-icon.vue +112 -112
- package/components/hy-index-bar/hy-index-bar.vue +185 -185
- package/components/hy-index-bar/index.scss +64 -64
- package/components/hy-index-bar/props.ts +94 -94
- package/components/hy-index-bar/typing.d.ts +36 -36
- package/components/hy-input/hy-input.vue +333 -333
- package/components/hy-input/props.ts +186 -186
- package/components/hy-modal/hy-modal.vue +211 -211
- package/components/hy-modal/props.ts +94 -94
- package/components/hy-modal/typing.d.ts +16 -16
- package/components/hy-notice-bar/hy-row-notice.vue +121 -121
- package/components/hy-notify/hy-notify.vue +174 -174
- package/components/hy-number-step/hy-number-step.vue +367 -367
- package/components/hy-overlay/hy-overlay.vue +61 -61
- package/components/hy-overlay/props.ts +38 -38
- package/components/hy-pagination/hy-pagination.vue +136 -136
- package/components/hy-pagination/props.ts +58 -58
- package/components/hy-parse/hy-parse.vue +550 -550
- package/components/hy-parse/node/node.vue +781 -781
- package/components/hy-parse/parser.js +1455 -1455
- package/components/hy-parse/props.ts +19 -19
- package/components/hy-parse/typing.d.ts +68 -68
- package/components/hy-picker/hy-picker.vue +435 -435
- package/components/hy-picker/props.ts +122 -122
- package/components/hy-picker/typing.d.ts +38 -38
- package/components/hy-qrcode/props.ts +72 -72
- package/components/hy-qrcode/qrcode.js.bak +1433 -1433
- package/components/hy-radio/props.ts +97 -97
- package/components/hy-read-more/props.ts +48 -48
- package/components/hy-search/props.ts +133 -133
- package/components/hy-signature/canvasHelper.ts +51 -51
- package/components/hy-signature/props.ts +121 -121
- package/components/hy-skeleton/hy-skeleton.vue +142 -142
- package/components/hy-skeleton/props.ts +46 -46
- package/components/hy-skeleton/typing.d.ts +31 -31
- package/components/hy-steps/hy-steps.vue +275 -275
- package/components/hy-steps/typing.d.ts +25 -25
- package/components/hy-swiper/hy-swiper.vue +3 -3
- package/components/hy-swiper/index.scss +5 -5
- package/components/hy-swiper/props.ts +0 -1
- package/components/hy-table/hy-table.vue +630 -630
- package/components/hy-table/props.ts +62 -62
- package/components/hy-table/typing.d.ts +29 -29
- package/components/hy-tabs/hy-tabs.vue +336 -335
- package/components/hy-tabs/props.ts +84 -77
- package/components/hy-tag/hy-tag.vue +173 -173
- package/components/hy-tag/props.ts +89 -89
- package/components/hy-text/hy-text.vue +237 -237
- package/components/hy-text/props.ts +115 -115
- package/components/hy-textarea/hy-textarea.vue +198 -198
- package/components/hy-toast/hy-toast.vue +200 -200
- package/components/hy-toast/props.ts +3 -3
- package/components/hy-transition/hy-transition.vue +157 -157
- package/components/hy-transition/props.ts +32 -32
- package/components/hy-upload/hy-upload.vue +384 -384
- package/components/hy-watermark/hy-watermark.vue +1058 -1058
- package/components/hy-watermark/props.ts +109 -109
- package/global.d.ts +94 -94
- package/libs/api/http.ts +119 -119
- package/libs/composables/index.ts +8 -8
- package/libs/composables/useMessage.ts +149 -149
- package/libs/composables/useToast.ts +45 -45
- package/libs/composables/useTranslate.ts +10 -10
- package/libs/css/_config.scss +5 -5
- package/libs/index.ts +8 -8
- package/libs/locale/index.ts +32 -32
- package/libs/locale/lang/en-US.ts +84 -84
- package/libs/locale/lang/zh-CN.ts +87 -87
- package/libs/typing/index.ts +2 -2
- package/libs/typing/modules/common.d.ts +139 -139
- package/libs/typing/modules/form.ts +176 -176
- package/libs/typing/modules/http.d.ts +19 -19
- package/libs/typing/modules/index.d.ts +12 -12
- package/libs/utils/inside.ts +340 -340
- package/libs/utils/inspect.ts +140 -140
- package/libs/utils/utils.ts +525 -525
- package/package.json +81 -81
- package/tags.json +1 -1
- package/web-types.json +1 -1
|
@@ -1,121 +1,121 @@
|
|
|
1
|
-
import type { CSSProperties, PropType } from 'vue'
|
|
2
|
-
import { useTranslate } from '../../libs'
|
|
3
|
-
|
|
4
|
-
const { t } = useTranslate('signature')
|
|
5
|
-
|
|
6
|
-
const signatureProps = {
|
|
7
|
-
/** 签名笔颜色 */
|
|
8
|
-
penColor: {
|
|
9
|
-
type: String,
|
|
10
|
-
default: '#000'
|
|
11
|
-
},
|
|
12
|
-
/** 签名笔宽度 */
|
|
13
|
-
lineWidth: {
|
|
14
|
-
type: Number,
|
|
15
|
-
default: 3
|
|
16
|
-
},
|
|
17
|
-
/** 清空按钮的文本 */
|
|
18
|
-
clearText: {
|
|
19
|
-
type: String,
|
|
20
|
-
default: () => t('clear')
|
|
21
|
-
},
|
|
22
|
-
/** 撤回按钮的文本 */
|
|
23
|
-
revokeText: {
|
|
24
|
-
type: String,
|
|
25
|
-
default: () => t('revoke')
|
|
26
|
-
},
|
|
27
|
-
/** 恢复按钮的文本 */
|
|
28
|
-
restoreText: {
|
|
29
|
-
type: String,
|
|
30
|
-
default: () => t('restore')
|
|
31
|
-
},
|
|
32
|
-
/** 确认按钮的文本 */
|
|
33
|
-
confirmText: {
|
|
34
|
-
type: String,
|
|
35
|
-
default: () => t('confirm')
|
|
36
|
-
},
|
|
37
|
-
/** 目标文件的类型 */
|
|
38
|
-
fileType: {
|
|
39
|
-
type: String,
|
|
40
|
-
default: 'png'
|
|
41
|
-
},
|
|
42
|
-
/** 签名笔颜色 */
|
|
43
|
-
quality: {
|
|
44
|
-
type: Number,
|
|
45
|
-
default: 1
|
|
46
|
-
},
|
|
47
|
-
/** 目标文件的质量 */
|
|
48
|
-
exportScale: {
|
|
49
|
-
type: Number,
|
|
50
|
-
default: 1
|
|
51
|
-
},
|
|
52
|
-
/** 是否禁用签名板 */
|
|
53
|
-
disabled: {
|
|
54
|
-
type: Boolean,
|
|
55
|
-
default: false
|
|
56
|
-
},
|
|
57
|
-
/** 画布的高度 */
|
|
58
|
-
height: {
|
|
59
|
-
type: Number,
|
|
60
|
-
default: 1
|
|
61
|
-
},
|
|
62
|
-
/** 画布的宽度 */
|
|
63
|
-
width: {
|
|
64
|
-
type: Number,
|
|
65
|
-
default: 1
|
|
66
|
-
},
|
|
67
|
-
/** 边框圆角 */
|
|
68
|
-
round: {
|
|
69
|
-
type: String,
|
|
70
|
-
default: '10rpx'
|
|
71
|
-
},
|
|
72
|
-
/** 画板的背景色 */
|
|
73
|
-
backgroundColor: String,
|
|
74
|
-
/** 是否禁用画布滚动 */
|
|
75
|
-
disableScroll: {
|
|
76
|
-
type: Boolean,
|
|
77
|
-
default: true
|
|
78
|
-
},
|
|
79
|
-
/** 是否开启历史记录 */
|
|
80
|
-
enableHistory: {
|
|
81
|
-
type: Boolean,
|
|
82
|
-
default: false
|
|
83
|
-
},
|
|
84
|
-
/** 撤回和恢复的步长 */
|
|
85
|
-
step: {
|
|
86
|
-
type: Number,
|
|
87
|
-
default: 1
|
|
88
|
-
},
|
|
89
|
-
/** 撤回按钮的文本 */
|
|
90
|
-
undoText: String,
|
|
91
|
-
/** 恢复按钮的文本 */
|
|
92
|
-
redoText: String,
|
|
93
|
-
/** 是否启用压感模式 */
|
|
94
|
-
pressure: {
|
|
95
|
-
type: Boolean,
|
|
96
|
-
default: false
|
|
97
|
-
},
|
|
98
|
-
/** 压感模式下笔画最小宽度 */
|
|
99
|
-
minWidth: {
|
|
100
|
-
type: Number,
|
|
101
|
-
default: 2
|
|
102
|
-
},
|
|
103
|
-
/** 压感模式下笔画最大宽度 */
|
|
104
|
-
maxWidth: {
|
|
105
|
-
type: Number,
|
|
106
|
-
default: 6
|
|
107
|
-
},
|
|
108
|
-
/** 最小速度阈值,影响压感模式下的笔画宽度变化 */
|
|
109
|
-
minSpeed: {
|
|
110
|
-
type: Number,
|
|
111
|
-
default: 1.5
|
|
112
|
-
},
|
|
113
|
-
/** 定义需要用到的外部样式 */
|
|
114
|
-
customStyle: {
|
|
115
|
-
type: Object as PropType<CSSProperties>
|
|
116
|
-
},
|
|
117
|
-
/** 自定义外部类名 */
|
|
118
|
-
customClass: String
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export default signatureProps
|
|
1
|
+
import type { CSSProperties, PropType } from 'vue'
|
|
2
|
+
import { useTranslate } from '../../libs'
|
|
3
|
+
|
|
4
|
+
const { t } = useTranslate('signature')
|
|
5
|
+
|
|
6
|
+
const signatureProps = {
|
|
7
|
+
/** 签名笔颜色 */
|
|
8
|
+
penColor: {
|
|
9
|
+
type: String,
|
|
10
|
+
default: '#000'
|
|
11
|
+
},
|
|
12
|
+
/** 签名笔宽度 */
|
|
13
|
+
lineWidth: {
|
|
14
|
+
type: Number,
|
|
15
|
+
default: 3
|
|
16
|
+
},
|
|
17
|
+
/** 清空按钮的文本 */
|
|
18
|
+
clearText: {
|
|
19
|
+
type: String,
|
|
20
|
+
default: () => t('clear')
|
|
21
|
+
},
|
|
22
|
+
/** 撤回按钮的文本 */
|
|
23
|
+
revokeText: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: () => t('revoke')
|
|
26
|
+
},
|
|
27
|
+
/** 恢复按钮的文本 */
|
|
28
|
+
restoreText: {
|
|
29
|
+
type: String,
|
|
30
|
+
default: () => t('restore')
|
|
31
|
+
},
|
|
32
|
+
/** 确认按钮的文本 */
|
|
33
|
+
confirmText: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: () => t('confirm')
|
|
36
|
+
},
|
|
37
|
+
/** 目标文件的类型 */
|
|
38
|
+
fileType: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: 'png'
|
|
41
|
+
},
|
|
42
|
+
/** 签名笔颜色 */
|
|
43
|
+
quality: {
|
|
44
|
+
type: Number,
|
|
45
|
+
default: 1
|
|
46
|
+
},
|
|
47
|
+
/** 目标文件的质量 */
|
|
48
|
+
exportScale: {
|
|
49
|
+
type: Number,
|
|
50
|
+
default: 1
|
|
51
|
+
},
|
|
52
|
+
/** 是否禁用签名板 */
|
|
53
|
+
disabled: {
|
|
54
|
+
type: Boolean,
|
|
55
|
+
default: false
|
|
56
|
+
},
|
|
57
|
+
/** 画布的高度 */
|
|
58
|
+
height: {
|
|
59
|
+
type: Number,
|
|
60
|
+
default: 1
|
|
61
|
+
},
|
|
62
|
+
/** 画布的宽度 */
|
|
63
|
+
width: {
|
|
64
|
+
type: Number,
|
|
65
|
+
default: 1
|
|
66
|
+
},
|
|
67
|
+
/** 边框圆角 */
|
|
68
|
+
round: {
|
|
69
|
+
type: String,
|
|
70
|
+
default: '10rpx'
|
|
71
|
+
},
|
|
72
|
+
/** 画板的背景色 */
|
|
73
|
+
backgroundColor: String,
|
|
74
|
+
/** 是否禁用画布滚动 */
|
|
75
|
+
disableScroll: {
|
|
76
|
+
type: Boolean,
|
|
77
|
+
default: true
|
|
78
|
+
},
|
|
79
|
+
/** 是否开启历史记录 */
|
|
80
|
+
enableHistory: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: false
|
|
83
|
+
},
|
|
84
|
+
/** 撤回和恢复的步长 */
|
|
85
|
+
step: {
|
|
86
|
+
type: Number,
|
|
87
|
+
default: 1
|
|
88
|
+
},
|
|
89
|
+
/** 撤回按钮的文本 */
|
|
90
|
+
undoText: String,
|
|
91
|
+
/** 恢复按钮的文本 */
|
|
92
|
+
redoText: String,
|
|
93
|
+
/** 是否启用压感模式 */
|
|
94
|
+
pressure: {
|
|
95
|
+
type: Boolean,
|
|
96
|
+
default: false
|
|
97
|
+
},
|
|
98
|
+
/** 压感模式下笔画最小宽度 */
|
|
99
|
+
minWidth: {
|
|
100
|
+
type: Number,
|
|
101
|
+
default: 2
|
|
102
|
+
},
|
|
103
|
+
/** 压感模式下笔画最大宽度 */
|
|
104
|
+
maxWidth: {
|
|
105
|
+
type: Number,
|
|
106
|
+
default: 6
|
|
107
|
+
},
|
|
108
|
+
/** 最小速度阈值,影响压感模式下的笔画宽度变化 */
|
|
109
|
+
minSpeed: {
|
|
110
|
+
type: Number,
|
|
111
|
+
default: 1.5
|
|
112
|
+
},
|
|
113
|
+
/** 定义需要用到的外部样式 */
|
|
114
|
+
customStyle: {
|
|
115
|
+
type: Object as PropType<CSSProperties>
|
|
116
|
+
},
|
|
117
|
+
/** 自定义外部类名 */
|
|
118
|
+
customClass: String
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export default signatureProps
|
|
@@ -1,142 +1,142 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view :class="`hy-skeleton ${customClass}`" :style="customStyle">
|
|
3
|
-
<view class="hy-skeleton__content" v-if="show">
|
|
4
|
-
<view
|
|
5
|
-
class="hy-skeleton__row"
|
|
6
|
-
v-for="(row, index) of parsedRowCols"
|
|
7
|
-
:key="`row-${index}`"
|
|
8
|
-
>
|
|
9
|
-
<view
|
|
10
|
-
v-for="(col, idx) of row"
|
|
11
|
-
:key="`col-${idx}`"
|
|
12
|
-
:class="col.class"
|
|
13
|
-
:style="col.style"
|
|
14
|
-
/>
|
|
15
|
-
</view>
|
|
16
|
-
</view>
|
|
17
|
-
<view v-else>
|
|
18
|
-
<slot />
|
|
19
|
-
</view>
|
|
20
|
-
</view>
|
|
21
|
-
</template>
|
|
22
|
-
|
|
23
|
-
<script lang="ts">
|
|
24
|
-
export default {
|
|
25
|
-
// #ifdef H5
|
|
26
|
-
name: 'hy-skeleton',
|
|
27
|
-
// #endif
|
|
28
|
-
options: { virtualHost: true, addGlobalClass: true, styleIsolation: 'shared' }
|
|
29
|
-
}
|
|
30
|
-
</script>
|
|
31
|
-
|
|
32
|
-
<script lang="ts" setup>
|
|
33
|
-
import type { CSSProperties } from 'vue'
|
|
34
|
-
import { ref, computed, watch } from 'vue'
|
|
35
|
-
import type { SkeletonRowCol, SkeletonRowColObj } from './typing'
|
|
36
|
-
import skeletonProps from './props'
|
|
37
|
-
import { isNumber, addUnit, isArray } from '../../libs'
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* 用于等待加载内容所展示的占位图形组合,有动态效果加载效果,减少用户等待焦虑。
|
|
41
|
-
* @displayName hy-skeleton
|
|
42
|
-
*/
|
|
43
|
-
defineOptions({})
|
|
44
|
-
|
|
45
|
-
const themeMap = {
|
|
46
|
-
avatar: [{ type: 'circle', height: '64px', width: '64px' }],
|
|
47
|
-
image: [{ type: 'rect', height: '64px', width: '64px' }],
|
|
48
|
-
text: [
|
|
49
|
-
1,
|
|
50
|
-
[
|
|
51
|
-
{ width: '24%', height: '16px', marginRight: '16px' },
|
|
52
|
-
{ width: '76%', height: '16px' }
|
|
53
|
-
]
|
|
54
|
-
],
|
|
55
|
-
paragraph: [1, 1, 1, { width: '55%' }]
|
|
56
|
-
}
|
|
57
|
-
const props = defineProps(skeletonProps)
|
|
58
|
-
const rowCols = ref<SkeletonRowCol[]>([])
|
|
59
|
-
|
|
60
|
-
const parsedRowCols = computed(() => {
|
|
61
|
-
return rowCols.value.map((item) => {
|
|
62
|
-
if (isNumber(item)) {
|
|
63
|
-
return [
|
|
64
|
-
{
|
|
65
|
-
class: getColItemClass({ type: 'text' }),
|
|
66
|
-
style: {}
|
|
67
|
-
}
|
|
68
|
-
]
|
|
69
|
-
}
|
|
70
|
-
if (Array.isArray(item)) {
|
|
71
|
-
return item.map((col) => {
|
|
72
|
-
return {
|
|
73
|
-
...col,
|
|
74
|
-
class: getColItemClass(col),
|
|
75
|
-
style: getColItemStyle(col)
|
|
76
|
-
}
|
|
77
|
-
})
|
|
78
|
-
}
|
|
79
|
-
const nItem = item as SkeletonRowColObj
|
|
80
|
-
|
|
81
|
-
return [
|
|
82
|
-
{
|
|
83
|
-
...nItem,
|
|
84
|
-
class: getColItemClass(nItem),
|
|
85
|
-
style: getColItemStyle(nItem)
|
|
86
|
-
}
|
|
87
|
-
]
|
|
88
|
-
})
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
function getColItemClass(rowCol: SkeletonRowColObj) {
|
|
92
|
-
return [
|
|
93
|
-
'hy-skeleton__col',
|
|
94
|
-
`hy-skeleton--type-${rowCol.type || 'text'}`,
|
|
95
|
-
{ [`hy-skeleton--animation-${props.animation}`]: props.animation }
|
|
96
|
-
]
|
|
97
|
-
}
|
|
98
|
-
function getColItemStyle(rowCol: SkeletonRowColObj) {
|
|
99
|
-
const style: CSSProperties = {}
|
|
100
|
-
const styleName = [
|
|
101
|
-
'size',
|
|
102
|
-
'width',
|
|
103
|
-
'height',
|
|
104
|
-
'margin',
|
|
105
|
-
'background',
|
|
106
|
-
'marginLeft',
|
|
107
|
-
'marginRight',
|
|
108
|
-
'borderRadius',
|
|
109
|
-
'backgroundColor'
|
|
110
|
-
]
|
|
111
|
-
|
|
112
|
-
for (const name of styleName) {
|
|
113
|
-
if (Object.prototype.hasOwnProperty.call(rowCol, name)) {
|
|
114
|
-
const px = addUnit(rowCol[name])
|
|
115
|
-
|
|
116
|
-
if (name === 'size') {
|
|
117
|
-
style.width = px
|
|
118
|
-
style.height = px
|
|
119
|
-
} else {
|
|
120
|
-
;(style as any)[name] = px
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return style
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
watch(
|
|
128
|
-
() => props.rowCol,
|
|
129
|
-
(rowCol) => {
|
|
130
|
-
rowCols.value = [
|
|
131
|
-
...(isArray(rowCol) && rowCol.length ? props.rowCol : themeMap[props.theme])
|
|
132
|
-
]
|
|
133
|
-
},
|
|
134
|
-
{ immediate: true }
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
const show = computed(() => props.loading == undefined || props.loading === true)
|
|
138
|
-
</script>
|
|
139
|
-
|
|
140
|
-
<style lang="scss" scoped>
|
|
141
|
-
@import './index.scss';
|
|
142
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="`hy-skeleton ${customClass}`" :style="customStyle">
|
|
3
|
+
<view class="hy-skeleton__content" v-if="show">
|
|
4
|
+
<view
|
|
5
|
+
class="hy-skeleton__row"
|
|
6
|
+
v-for="(row, index) of parsedRowCols"
|
|
7
|
+
:key="`row-${index}`"
|
|
8
|
+
>
|
|
9
|
+
<view
|
|
10
|
+
v-for="(col, idx) of row"
|
|
11
|
+
:key="`col-${idx}`"
|
|
12
|
+
:class="col.class"
|
|
13
|
+
:style="col.style"
|
|
14
|
+
/>
|
|
15
|
+
</view>
|
|
16
|
+
</view>
|
|
17
|
+
<view v-else>
|
|
18
|
+
<slot />
|
|
19
|
+
</view>
|
|
20
|
+
</view>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script lang="ts">
|
|
24
|
+
export default {
|
|
25
|
+
// #ifdef H5
|
|
26
|
+
name: 'hy-skeleton',
|
|
27
|
+
// #endif
|
|
28
|
+
options: { virtualHost: true, addGlobalClass: true, styleIsolation: 'shared' }
|
|
29
|
+
}
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<script lang="ts" setup>
|
|
33
|
+
import type { CSSProperties } from 'vue'
|
|
34
|
+
import { ref, computed, watch } from 'vue'
|
|
35
|
+
import type { SkeletonRowCol, SkeletonRowColObj } from './typing'
|
|
36
|
+
import skeletonProps from './props'
|
|
37
|
+
import { isNumber, addUnit, isArray } from '../../libs'
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 用于等待加载内容所展示的占位图形组合,有动态效果加载效果,减少用户等待焦虑。
|
|
41
|
+
* @displayName hy-skeleton
|
|
42
|
+
*/
|
|
43
|
+
defineOptions({})
|
|
44
|
+
|
|
45
|
+
const themeMap = {
|
|
46
|
+
avatar: [{ type: 'circle', height: '64px', width: '64px' }],
|
|
47
|
+
image: [{ type: 'rect', height: '64px', width: '64px' }],
|
|
48
|
+
text: [
|
|
49
|
+
1,
|
|
50
|
+
[
|
|
51
|
+
{ width: '24%', height: '16px', marginRight: '16px' },
|
|
52
|
+
{ width: '76%', height: '16px' }
|
|
53
|
+
]
|
|
54
|
+
],
|
|
55
|
+
paragraph: [1, 1, 1, { width: '55%' }]
|
|
56
|
+
}
|
|
57
|
+
const props = defineProps(skeletonProps)
|
|
58
|
+
const rowCols = ref<SkeletonRowCol[]>([])
|
|
59
|
+
|
|
60
|
+
const parsedRowCols = computed(() => {
|
|
61
|
+
return rowCols.value.map((item) => {
|
|
62
|
+
if (isNumber(item)) {
|
|
63
|
+
return [
|
|
64
|
+
{
|
|
65
|
+
class: getColItemClass({ type: 'text' }),
|
|
66
|
+
style: {}
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
if (Array.isArray(item)) {
|
|
71
|
+
return item.map((col) => {
|
|
72
|
+
return {
|
|
73
|
+
...col,
|
|
74
|
+
class: getColItemClass(col),
|
|
75
|
+
style: getColItemStyle(col)
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
const nItem = item as SkeletonRowColObj
|
|
80
|
+
|
|
81
|
+
return [
|
|
82
|
+
{
|
|
83
|
+
...nItem,
|
|
84
|
+
class: getColItemClass(nItem),
|
|
85
|
+
style: getColItemStyle(nItem)
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
function getColItemClass(rowCol: SkeletonRowColObj) {
|
|
92
|
+
return [
|
|
93
|
+
'hy-skeleton__col',
|
|
94
|
+
`hy-skeleton--type-${rowCol.type || 'text'}`,
|
|
95
|
+
{ [`hy-skeleton--animation-${props.animation}`]: props.animation }
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
function getColItemStyle(rowCol: SkeletonRowColObj) {
|
|
99
|
+
const style: CSSProperties = {}
|
|
100
|
+
const styleName = [
|
|
101
|
+
'size',
|
|
102
|
+
'width',
|
|
103
|
+
'height',
|
|
104
|
+
'margin',
|
|
105
|
+
'background',
|
|
106
|
+
'marginLeft',
|
|
107
|
+
'marginRight',
|
|
108
|
+
'borderRadius',
|
|
109
|
+
'backgroundColor'
|
|
110
|
+
]
|
|
111
|
+
|
|
112
|
+
for (const name of styleName) {
|
|
113
|
+
if (Object.prototype.hasOwnProperty.call(rowCol, name)) {
|
|
114
|
+
const px = addUnit(rowCol[name])
|
|
115
|
+
|
|
116
|
+
if (name === 'size') {
|
|
117
|
+
style.width = px
|
|
118
|
+
style.height = px
|
|
119
|
+
} else {
|
|
120
|
+
;(style as any)[name] = px
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return style
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
watch(
|
|
128
|
+
() => props.rowCol,
|
|
129
|
+
(rowCol) => {
|
|
130
|
+
rowCols.value = [
|
|
131
|
+
...(isArray(rowCol) && rowCol.length ? props.rowCol : themeMap[props.theme])
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
{ immediate: true }
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
const show = computed(() => props.loading == undefined || props.loading === true)
|
|
138
|
+
</script>
|
|
139
|
+
|
|
140
|
+
<style lang="scss" scoped>
|
|
141
|
+
@import './index.scss';
|
|
142
|
+
</style>
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import type { CSSProperties, PropType } from 'vue'
|
|
2
|
-
import type { SkeletonAnimation, SkeletonRowCol, SkeletonTheme } from './typing'
|
|
3
|
-
|
|
4
|
-
const skeletonProps = {
|
|
5
|
-
/**
|
|
6
|
-
* 骨架图风格,有基础、头像组合等两大类
|
|
7
|
-
* @values text,avatar,paragraph,image
|
|
8
|
-
*/
|
|
9
|
-
theme: {
|
|
10
|
-
type: String as PropType<SkeletonTheme>,
|
|
11
|
-
default: 'text'
|
|
12
|
-
},
|
|
13
|
-
/**
|
|
14
|
-
* 用于设置行列数量、宽度高度、间距等。
|
|
15
|
-
* @example
|
|
16
|
-
* 【示例一】,`[1, 1, 2]` 表示输出三行骨架图,第一行一列,第二行一列,第三行两列。
|
|
17
|
-
* 【示例二】,`[1, 1, { width: '100px' }]` 表示自定义第三行的宽度为 `100px`。
|
|
18
|
-
* 【示例三】,`[1, 2, [{ width, height }, { width, height, marginLeft }]]` 表示第三行有两列,且自定义宽度、高度和间距
|
|
19
|
-
*/
|
|
20
|
-
rowCol: {
|
|
21
|
-
type: Array as PropType<SkeletonRowCol>
|
|
22
|
-
},
|
|
23
|
-
/**
|
|
24
|
-
* 是否为加载状态,如果是则显示骨架图,如果不是则显示加载完成的内容
|
|
25
|
-
* @default true
|
|
26
|
-
*/
|
|
27
|
-
loading: {
|
|
28
|
-
type: Boolean,
|
|
29
|
-
default: true
|
|
30
|
-
},
|
|
31
|
-
/**
|
|
32
|
-
* 动画效果,有「渐变加载动画」和「闪烁加载动画」两种。值为空则表示没有动画
|
|
33
|
-
*/
|
|
34
|
-
animation: {
|
|
35
|
-
type: String as PropType<SkeletonAnimation>,
|
|
36
|
-
default: ''
|
|
37
|
-
},
|
|
38
|
-
/** 定义需要用到的外部样式 */
|
|
39
|
-
customStyle: {
|
|
40
|
-
type: Object as PropType<CSSProperties>
|
|
41
|
-
},
|
|
42
|
-
/** 自定义外部类名 */
|
|
43
|
-
customClass: String
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export default skeletonProps
|
|
1
|
+
import type { CSSProperties, PropType } from 'vue'
|
|
2
|
+
import type { SkeletonAnimation, SkeletonRowCol, SkeletonTheme } from './typing'
|
|
3
|
+
|
|
4
|
+
const skeletonProps = {
|
|
5
|
+
/**
|
|
6
|
+
* 骨架图风格,有基础、头像组合等两大类
|
|
7
|
+
* @values text,avatar,paragraph,image
|
|
8
|
+
*/
|
|
9
|
+
theme: {
|
|
10
|
+
type: String as PropType<SkeletonTheme>,
|
|
11
|
+
default: 'text'
|
|
12
|
+
},
|
|
13
|
+
/**
|
|
14
|
+
* 用于设置行列数量、宽度高度、间距等。
|
|
15
|
+
* @example
|
|
16
|
+
* 【示例一】,`[1, 1, 2]` 表示输出三行骨架图,第一行一列,第二行一列,第三行两列。
|
|
17
|
+
* 【示例二】,`[1, 1, { width: '100px' }]` 表示自定义第三行的宽度为 `100px`。
|
|
18
|
+
* 【示例三】,`[1, 2, [{ width, height }, { width, height, marginLeft }]]` 表示第三行有两列,且自定义宽度、高度和间距
|
|
19
|
+
*/
|
|
20
|
+
rowCol: {
|
|
21
|
+
type: Array as PropType<SkeletonRowCol>
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* 是否为加载状态,如果是则显示骨架图,如果不是则显示加载完成的内容
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
loading: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: true
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* 动画效果,有「渐变加载动画」和「闪烁加载动画」两种。值为空则表示没有动画
|
|
33
|
+
*/
|
|
34
|
+
animation: {
|
|
35
|
+
type: String as PropType<SkeletonAnimation>,
|
|
36
|
+
default: ''
|
|
37
|
+
},
|
|
38
|
+
/** 定义需要用到的外部样式 */
|
|
39
|
+
customStyle: {
|
|
40
|
+
type: Object as PropType<CSSProperties>
|
|
41
|
+
},
|
|
42
|
+
/** 自定义外部类名 */
|
|
43
|
+
customClass: String
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default skeletonProps
|