hy-app 0.4.13 → 0.5.0
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/components/hy-action-sheet/hy-action-sheet.vue +155 -238
- package/components/hy-action-sheet/props.ts +68 -15
- package/components/hy-action-sheet/typing.d.ts +115 -115
- package/components/hy-address-picker/hy-address-picker.vue +185 -289
- package/components/hy-address-picker/props.ts +97 -21
- package/components/hy-address-picker/typing.d.ts +90 -89
- package/components/hy-avatar/hy-avatar.vue +121 -204
- package/components/hy-avatar/props.ts +76 -18
- package/components/hy-avatar/typing.d.ts +63 -62
- package/components/hy-back-top/hy-back-top.vue +65 -120
- package/components/hy-back-top/props.ts +57 -16
- package/components/hy-back-top/typing.d.ts +43 -42
- package/components/hy-badge/hy-badge.vue +66 -138
- package/components/hy-badge/props.ts +73 -17
- package/components/hy-badge/typing.d.ts +59 -58
- package/components/hy-button/hy-button.vue +226 -375
- package/components/hy-button/props.ts +129 -158
- package/components/hy-calendar/header.vue +48 -64
- package/components/hy-calendar/hy-calendar.vue +274 -438
- package/components/hy-calendar/month.vue +508 -516
- package/components/hy-calendar/props.ts +157 -35
- package/components/hy-calendar/typing.d.ts +129 -128
- package/components/hy-card/hy-card.vue +118 -240
- package/components/hy-card/index.scss +1 -2
- package/components/hy-card/props.ts +122 -27
- package/components/hy-card/typing.d.ts +119 -118
- package/components/hy-cell/hy-cell.vue +176 -258
- package/components/hy-cell/props.ts +71 -17
- package/components/hy-cell/typing.d.ts +87 -86
- package/components/hy-check-button/hy-check-button.vue +69 -139
- package/components/hy-check-button/props.ts +72 -18
- package/components/hy-check-button/typing.d.ts +74 -73
- package/components/hy-checkbox/hy-checkbox.vue +170 -263
- package/components/hy-checkbox/props.ts +94 -24
- package/components/hy-checkbox/typing.d.ts +72 -72
- package/components/hy-checkbox-group/hy-checkbox-group.vue +25 -100
- package/components/hy-checkbox-group/props.ts +80 -0
- package/components/hy-checkbox-group/typing.d.ts +65 -65
- package/components/hy-checkbox-item/hy-checkbox-item.vue +140 -177
- package/components/hy-checkbox-item/props.ts +24 -0
- package/components/hy-checkbox-item/typing.d.ts +4 -3
- package/components/hy-code-input/hy-code-input.vue +179 -262
- package/components/hy-code-input/props.ts +84 -18
- package/components/hy-code-input/typing.d.ts +71 -71
- package/components/hy-config-provider/hy-config-provider.vue +28 -50
- package/components/hy-config-provider/props.ts +26 -11
- package/components/hy-config-provider/typing.d.ts +20 -20
- package/components/hy-count-down/hy-count-down.vue +103 -131
- package/components/hy-count-down/props.ts +30 -8
- package/components/hy-count-down/typing.d.ts +25 -25
- package/components/hy-count-to/hy-count-to.vue +148 -213
- package/components/hy-count-to/props.ts +60 -15
- package/components/hy-count-to/typing.d.ts +46 -46
- package/components/hy-coupon/README.md +133 -0
- package/components/hy-coupon/hy-coupon.vue +180 -0
- package/components/hy-coupon/index.scss +553 -0
- package/components/hy-coupon/props.ts +129 -0
- package/components/hy-coupon/typing.d.ts +146 -0
- package/components/hy-datetime-picker/hy-datetime-picker.vue +415 -580
- package/components/hy-datetime-picker/props.ts +142 -32
- package/components/hy-datetime-picker/typing.d.ts +132 -132
- package/components/hy-divider/hy-divider.vue +90 -169
- package/components/hy-divider/props.ts +78 -19
- package/components/hy-divider/typing.d.ts +60 -60
- package/components/hy-dropdown/hy-dropdown.vue +37 -71
- package/components/hy-dropdown/props.ts +38 -15
- package/components/hy-dropdown/typing.d.ts +44 -44
- package/components/hy-dropdown-item/hy-dropdown-item.vue +141 -173
- package/components/hy-dropdown-item/props.ts +19 -8
- package/components/hy-empty/hy-empty.vue +75 -129
- package/components/hy-empty/props.ts +57 -15
- package/components/hy-empty/typing.d.ts +84 -84
- package/components/hy-flex/hy-flex.vue +33 -88
- package/components/hy-flex/props.ts +58 -0
- package/components/hy-flex/typing.d.ts +14 -16
- package/components/hy-float-button/hy-float-button.vue +289 -406
- package/components/hy-float-button/props.ts +109 -25
- package/components/hy-folding-panel/hy-folding-panel.vue +86 -374
- package/components/hy-folding-panel/props.ts +40 -15
- package/components/hy-folding-panel/typing.d.ts +52 -63
- package/components/hy-folding-panel-item/hy-folding-panel-item.vue +186 -228
- package/components/hy-folding-panel-item/index.scss +87 -0
- package/components/hy-folding-panel-item/props.ts +81 -0
- package/components/hy-folding-panel-item/typing.d.ts +23 -0
- package/components/hy-form/hy-form.vue +172 -212
- package/components/hy-form/props.ts +37 -0
- package/components/hy-form/typing.d.ts +68 -61
- package/components/hy-form-group/typing.d.ts +74 -74
- package/components/hy-form-item/hy-form-item.vue +100 -129
- package/components/hy-form-item/props.ts +25 -0
- package/components/hy-form-item/typing.d.ts +40 -37
- package/components/hy-grid/hy-grid.vue +76 -132
- package/components/hy-grid/props.ts +58 -16
- package/components/hy-grid/typing.d.ts +66 -66
- package/components/hy-icon/hy-icon.vue +84 -161
- package/components/hy-icon/props.ts +76 -22
- package/components/hy-icon/typing.d.ts +83 -82
- package/components/hy-image/hy-image.vue +142 -272
- package/components/hy-image/props.ts +105 -23
- package/components/hy-image/typing.d.ts +84 -87
- package/components/hy-input/hy-input.vue +230 -421
- package/components/hy-input/props.ts +183 -35
- package/components/hy-input/typing.d.ts +169 -169
- package/components/hy-line/hy-line.vue +34 -72
- package/components/hy-line/props.ts +41 -10
- package/components/hy-line/typing.d.ts +29 -29
- package/components/hy-line-progress/hy-line-progress.vue +66 -101
- package/components/hy-line-progress/props.ts +31 -10
- package/components/hy-line-progress/typing.d.ts +29 -29
- package/components/hy-list/hy-list.vue +151 -220
- package/components/hy-list/props.ts +67 -16
- package/components/hy-list/typing.d.ts +52 -52
- package/components/hy-loading/hy-loading.vue +63 -119
- package/components/hy-loading/props.ts +63 -15
- package/components/hy-loading/typing.d.ts +49 -49
- package/components/hy-menu/hy-menu.vue +124 -166
- package/components/hy-menu/props.ts +42 -10
- package/components/hy-menu/typing.d.ts +60 -60
- package/components/hy-modal/hy-modal.vue +127 -218
- package/components/hy-modal/props.ts +89 -24
- package/components/hy-navbar/hy-navbar.vue +104 -177
- package/components/hy-navbar/props.ts +76 -22
- package/components/hy-navbar/typing.d.ts +81 -81
- package/components/hy-notice-bar/hy-notice-bar.vue +67 -144
- package/components/hy-notice-bar/props.ts +80 -19
- package/components/hy-notice-bar/typing.d.ts +62 -62
- package/components/hy-notify/hy-notify.vue +128 -177
- package/components/hy-notify/props.ts +49 -12
- package/components/hy-notify/typing.d.ts +45 -41
- package/components/hy-number-step/hy-number-step.vue +281 -394
- package/components/hy-number-step/props.ts +110 -27
- package/components/hy-number-step/typing.d.ts +120 -120
- package/components/hy-overlay/hy-overlay.vue +39 -66
- package/components/hy-overlay/props.ts +31 -8
- package/components/hy-pagination/hy-pagination.vue +100 -155
- package/components/hy-pagination/props.ts +53 -13
- package/components/hy-picker/hy-picker.vue +309 -430
- package/components/hy-picker/index.scss +8 -12
- package/components/hy-picker/props.ts +110 -26
- package/components/hy-popover/hy-popover.vue +190 -252
- package/components/hy-popover/props.ts +48 -10
- package/components/hy-popup/hy-popup.vue +162 -248
- package/components/hy-popup/props.ts +82 -18
- package/components/hy-price/hy-price.vue +45 -104
- package/components/hy-price/props.ts +52 -12
- package/components/hy-price/typing.d.ts +41 -36
- package/components/hy-qrcode/hy-qrcode.vue +115 -185
- package/components/hy-qrcode/props.ts +68 -18
- package/components/hy-qrcode/typing.d.ts +67 -66
- package/components/hy-radio/hy-radio.vue +161 -259
- package/components/hy-radio/props.ts +95 -25
- package/components/hy-radio/typing.d.ts +85 -84
- package/components/hy-rate/hy-rate.vue +185 -270
- package/components/hy-rate/props.ts +76 -18
- package/components/hy-rate/typing.d.ts +61 -60
- package/components/hy-read-more/hy-read-more.vue +93 -136
- package/components/hy-read-more/props.ts +43 -13
- package/components/hy-scroll-list/hy-scroll-list.vue +81 -102
- package/components/hy-scroll-list/props.ts +22 -11
- package/components/hy-search/hy-search.vue +155 -284
- package/components/hy-search/props.ts +130 -25
- package/components/hy-signature/hy-signature.vue +491 -635
- package/components/hy-signature/props.ts +115 -26
- package/components/hy-signature/typing.d.ts +138 -138
- package/components/hy-slider/hy-slider.vue +388 -477
- package/components/hy-slider/props.ts +75 -19
- package/components/hy-steps/hy-steps.vue +212 -279
- package/components/hy-steps/props.ts +47 -13
- package/components/hy-submit-bar/hy-submit-bar.vue +137 -222
- package/components/hy-submit-bar/props.ts +89 -20
- package/components/hy-submit-bar/typing.d.ts +86 -85
- package/components/hy-subsection/hy-subsection.vue +132 -185
- package/components/hy-subsection/props.ts +50 -17
- package/components/hy-subsection/typing.d.ts +52 -52
- package/components/hy-swipe-action/hy-swipe-action.vue +228 -283
- package/components/hy-swipe-action/props.ts +43 -18
- package/components/hy-swipe-action/typing.d.ts +46 -46
- package/components/hy-swiper/hy-swiper.vue +159 -286
- package/components/hy-swiper/props.ts +126 -28
- package/components/hy-swiper/typing.d.ts +115 -115
- package/components/hy-switch/hy-switch.vue +112 -176
- package/components/hy-switch/props.ts +60 -15
- package/components/hy-switch/typing.d.ts +63 -63
- package/components/hy-tabBar/hy-tabBar.vue +64 -60
- package/components/hy-tabs/hy-tabs.vue +277 -380
- package/components/hy-tabs/props.ts +75 -18
- package/components/hy-tag/hy-tag.vue +111 -204
- package/components/hy-tag/props.ts +81 -19
- package/components/hy-text/hy-text.vue +200 -322
- package/components/hy-text/props.ts +107 -28
- package/components/hy-textarea/hy-textarea.vue +147 -256
- package/components/hy-textarea/props.ts +112 -25
- package/components/hy-textarea/typing.d.ts +42 -42
- package/components/hy-toast/hy-toast.vue +135 -143
- package/components/hy-tooltip/hy-tooltip.vue +220 -306
- package/components/hy-tooltip/props.ts +79 -15
- package/components/hy-transition/hy-transition.vue +111 -138
- package/components/hy-transition/props.ts +30 -8
- package/components/hy-upload/hy-upload.vue +320 -469
- package/components/hy-upload/props.ts +130 -27
- package/components/hy-warn/hy-warn.vue +80 -129
- package/components/hy-warn/props.ts +47 -12
- package/components/hy-waterfall/hy-waterfall.vue +139 -163
- package/components/hy-waterfall/props.ts +19 -7
- package/components/hy-watermark/hy-watermark.vue +762 -870
- package/components/hy-watermark/props.ts +103 -22
- package/global.d.ts +2 -0
- package/libs/css/theme.scss +3 -3
- package/package.json +2 -2
- package/web-types.json +1 -1
- package/components/hy-folding-panel/index.scss +0 -9
|
@@ -2,98 +2,99 @@ import type { CSSProperties } from 'vue'
|
|
|
2
2
|
import type HyInputProps from '../hy-input/typing'
|
|
3
3
|
|
|
4
4
|
export default interface HyAddressPickerProps {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @description 用于控制选择器的弹出和收起 ( 默认 false )
|
|
7
|
+
* */
|
|
8
|
+
show?: boolean
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @description 弹出层弹出方向
|
|
12
|
+
* */
|
|
13
|
+
popupMode?: HyApp.LayoutType
|
|
14
|
+
/**
|
|
15
|
+
* @description 是否显示顶部的操作栏 ( 默认 true )
|
|
16
|
+
* */
|
|
17
|
+
showToolbar?: boolean
|
|
18
|
+
/**
|
|
19
|
+
* @description 绑定值
|
|
20
|
+
* */
|
|
21
|
+
modelValue: string
|
|
22
|
+
/**
|
|
23
|
+
* @description 顶部标题
|
|
24
|
+
* */
|
|
25
|
+
title?: string
|
|
26
|
+
/**
|
|
27
|
+
* @description 字符串截取数组条件
|
|
28
|
+
* */
|
|
29
|
+
separator?: string
|
|
30
|
+
/**
|
|
31
|
+
* @description 是否显示加载中状态 ( 默认 false )
|
|
32
|
+
* */
|
|
33
|
+
loading?: boolean
|
|
34
|
+
/**
|
|
35
|
+
* @description 各列中,单个选项的高度 ( 默认 44 )
|
|
36
|
+
* */
|
|
37
|
+
itemHeight?: number
|
|
38
|
+
/**
|
|
39
|
+
* @description 取消按钮的文字 ( 默认 '取消' )
|
|
40
|
+
* */
|
|
41
|
+
cancelText?: string
|
|
42
|
+
/**
|
|
43
|
+
* @description 确认按钮的文字 ( 默认 '确认' )
|
|
44
|
+
* */
|
|
45
|
+
confirmText?: string
|
|
46
|
+
/**
|
|
47
|
+
* @description 取消按钮的颜色 ( 默认 '#909193' )
|
|
48
|
+
* */
|
|
49
|
+
cancelColor?: string
|
|
50
|
+
/**
|
|
51
|
+
* @description 确认按钮的颜色 ( 默认 '#3c9cff' )
|
|
52
|
+
* */
|
|
53
|
+
confirmColor?: string
|
|
54
|
+
/**
|
|
55
|
+
* @description 每列中可见选项的数量 ( 默认 5 )
|
|
56
|
+
* */
|
|
57
|
+
visibleItemCount?: number
|
|
58
|
+
/**
|
|
59
|
+
* @description 是否允许点击遮罩关闭选择器 ( 默认 false )
|
|
60
|
+
* */
|
|
61
|
+
closeOnClickOverlay?: boolean
|
|
62
|
+
/**
|
|
63
|
+
* @description 各列的默认索引
|
|
64
|
+
* @note 类型有问题,需要调整
|
|
65
|
+
* */
|
|
66
|
+
defaultIndex?: Array<any>
|
|
67
|
+
/**
|
|
68
|
+
* @description 是否显示输入框 ( 默认 false )
|
|
69
|
+
* */
|
|
70
|
+
hasInput?: boolean
|
|
71
|
+
/**
|
|
72
|
+
* @description 输入框集合属性
|
|
73
|
+
* */
|
|
74
|
+
input?: Partial<HyInputProps>
|
|
75
|
+
/**
|
|
76
|
+
* @description 右边插槽
|
|
77
|
+
* */
|
|
78
|
+
toolbarRightSlot?: boolean
|
|
79
|
+
/**
|
|
80
|
+
* @description 自定义输入框外部样式
|
|
81
|
+
* */
|
|
82
|
+
customStyle?: CSSProperties
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
export type ConfirmParams = {
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
/** 选中值 */
|
|
87
|
+
value: string
|
|
87
88
|
}
|
|
88
89
|
export interface IAddressPickerEmits {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
90
|
+
/** 关闭选择器时触发 */
|
|
91
|
+
(e: 'close'): void
|
|
92
|
+
/** 点击取消按钮触发 */
|
|
93
|
+
(e: 'cancel'): void
|
|
94
|
+
/** 点击确认按钮触发 */
|
|
95
|
+
(e: 'confirm', params: ConfirmParams): void
|
|
96
|
+
/** 当选择值变化时触发 */
|
|
97
|
+
(e: 'change', args: any): void
|
|
98
|
+
/** 当选择值变化时触发 */
|
|
99
|
+
(e: 'update:modelValue', value: ConfirmParams['value']): void
|
|
99
100
|
}
|
|
@@ -1,245 +1,162 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
<image
|
|
42
|
-
class="hy-avatar__image"
|
|
43
|
-
v-else
|
|
44
|
-
:class="[`hy-avatar__image--${shape}`]"
|
|
45
|
-
:src="avatarUrl || defaultUrl"
|
|
46
|
-
:mode="mode"
|
|
47
|
-
@error="errorHandler"
|
|
48
|
-
></image>
|
|
49
|
-
</slot>
|
|
50
|
-
</view>
|
|
2
|
+
<view class="hy-avatar" :class="avatarClass" :style="avatarStyle" @tap="clickHandler">
|
|
3
|
+
<slot>
|
|
4
|
+
<!-- #ifdef MP-WEIXIN || MP-QQ || MP-BAIDU -->
|
|
5
|
+
<open-data
|
|
6
|
+
v-if="mpAvatar && allowMp"
|
|
7
|
+
type="userAvatarUrl"
|
|
8
|
+
:style="[
|
|
9
|
+
{
|
|
10
|
+
width: addUnit(size),
|
|
11
|
+
height: addUnit(size)
|
|
12
|
+
}
|
|
13
|
+
]"
|
|
14
|
+
/>
|
|
15
|
+
<!-- #endif -->
|
|
16
|
+
<!-- #ifndef MP-WEIXIN && MP-QQ && MP-BAIDU -->
|
|
17
|
+
<template v-if="mpAvatar && allowMp"></template>
|
|
18
|
+
<!-- #endif -->
|
|
19
|
+
<HyIcon v-else-if="icon" :name="icon" :size="fontSize" :color="color"></HyIcon>
|
|
20
|
+
<text
|
|
21
|
+
v-else-if="text"
|
|
22
|
+
:style="{
|
|
23
|
+
justifyContent: 'center',
|
|
24
|
+
textAlign: 'center',
|
|
25
|
+
color: color,
|
|
26
|
+
fontSize: fontSize
|
|
27
|
+
}"
|
|
28
|
+
>
|
|
29
|
+
{{ text }}
|
|
30
|
+
</text>
|
|
31
|
+
<image
|
|
32
|
+
class="hy-avatar__image"
|
|
33
|
+
v-else
|
|
34
|
+
:class="[`hy-avatar__image--${shape}`]"
|
|
35
|
+
:src="avatarUrl || defaultUrl"
|
|
36
|
+
:mode="mode"
|
|
37
|
+
@error="errorHandler"
|
|
38
|
+
></image>
|
|
39
|
+
</slot>
|
|
40
|
+
</view>
|
|
51
41
|
</template>
|
|
52
42
|
|
|
53
43
|
<script lang="ts">
|
|
54
44
|
export default {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
45
|
+
name: 'hy-avatar',
|
|
46
|
+
options: {
|
|
47
|
+
addGlobalClass: true,
|
|
48
|
+
virtualHost: true,
|
|
49
|
+
styleIsolation: 'shared'
|
|
50
|
+
}
|
|
51
|
+
}
|
|
62
52
|
</script>
|
|
63
53
|
|
|
64
54
|
<script setup lang="ts">
|
|
65
|
-
import { computed, ref, watch } from
|
|
66
|
-
import type { CSSProperties
|
|
67
|
-
import type { IAvatarEmit } from
|
|
68
|
-
import { addUnit, isNumber, random } from
|
|
55
|
+
import { computed, ref, watch } from 'vue'
|
|
56
|
+
import type { CSSProperties } from 'vue'
|
|
57
|
+
import type { IAvatarEmit } from './typing'
|
|
58
|
+
import { addUnit, isNumber, random } from '../../libs'
|
|
59
|
+
import avatarProps from './props'
|
|
69
60
|
// 组件
|
|
70
|
-
import HyIcon from
|
|
61
|
+
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
71
62
|
|
|
72
63
|
/**
|
|
73
64
|
* 本组件一般用于展示头像的地方,如个人中心,或者评论列表页的用户头像展示等场所
|
|
74
65
|
* @displayName hy-avatar
|
|
75
66
|
*/
|
|
76
|
-
defineOptions({})
|
|
67
|
+
defineOptions({})
|
|
77
68
|
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
/** 头像路径 */
|
|
81
|
-
src: String,
|
|
82
|
-
/**
|
|
83
|
-
* 头像形状
|
|
84
|
-
* @values circle,square
|
|
85
|
-
* */
|
|
86
|
-
shape: {
|
|
87
|
-
type: String,
|
|
88
|
-
default: "circle",
|
|
89
|
-
},
|
|
90
|
-
/**
|
|
91
|
-
* 头像尺寸
|
|
92
|
-
* @values large, medium, small
|
|
93
|
-
* */
|
|
94
|
-
size: {
|
|
95
|
-
type: [String, Number] as PropType<string | number>,
|
|
96
|
-
default: "medium",
|
|
97
|
-
},
|
|
98
|
-
/**
|
|
99
|
-
* 头像图片的裁剪类型
|
|
100
|
-
* @values scaleToFill,aspectFit,aspectFill,widthFix,heightFix,top,bottom,center,left,right,top left,top right,bottom left,bottom right
|
|
101
|
-
* */
|
|
102
|
-
mode: {
|
|
103
|
-
type: String,
|
|
104
|
-
default: "scaleToFill",
|
|
105
|
-
},
|
|
106
|
-
/** 用文字替代图片,级别优先于src */
|
|
107
|
-
text: String,
|
|
108
|
-
/** 头像背景颜色 */
|
|
109
|
-
bgColor: {
|
|
110
|
-
type: String,
|
|
111
|
-
default: "#c0c4cc",
|
|
112
|
-
},
|
|
113
|
-
/** 文字颜色 */
|
|
114
|
-
color: {
|
|
115
|
-
type: String,
|
|
116
|
-
default: "#ffffff",
|
|
117
|
-
},
|
|
118
|
-
/** 文字大小 */
|
|
119
|
-
fontSize: {
|
|
120
|
-
type: Number,
|
|
121
|
-
default: 18,
|
|
122
|
-
},
|
|
123
|
-
/** 显示的图标 */
|
|
124
|
-
icon: String,
|
|
125
|
-
/** 显示小程序头像,只对百度,微信,QQ小程序有效 */
|
|
126
|
-
mpAvatar: {
|
|
127
|
-
type: Boolean,
|
|
128
|
-
default: false,
|
|
129
|
-
},
|
|
130
|
-
/** 是否使用随机背景色 */
|
|
131
|
-
randomBgColor: {
|
|
132
|
-
type: Boolean,
|
|
133
|
-
default: false,
|
|
134
|
-
},
|
|
135
|
-
/** 加载失败的默认头像(组件有内置默认图片) */
|
|
136
|
-
defaultUrl: String,
|
|
137
|
-
/** 如果配置了randomBgColor为true,且配置了此值,则从默认的背景色数组中取出对应索引的颜色值,取值0-19之间 */
|
|
138
|
-
colorIndex: {
|
|
139
|
-
type: Number,
|
|
140
|
-
default: 0,
|
|
141
|
-
},
|
|
142
|
-
/** 组件标识符 */
|
|
143
|
-
name: {
|
|
144
|
-
type: String,
|
|
145
|
-
default: "",
|
|
146
|
-
},
|
|
147
|
-
/** 自定义输入框外部样式 */
|
|
148
|
-
customStyle: {
|
|
149
|
-
type: Object as PropType<CSSProperties>,
|
|
150
|
-
default: () => {},
|
|
151
|
-
},
|
|
152
|
-
});
|
|
153
|
-
const emit = defineEmits<IAvatarEmit>();
|
|
69
|
+
const props = defineProps(avatarProps)
|
|
70
|
+
const emit = defineEmits<IAvatarEmit>()
|
|
154
71
|
|
|
155
72
|
const base64Avatar =
|
|
156
|
-
|
|
73
|
+
'data:image/jpg;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAAA8AAD/4QMraHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA1LjMtYzAxMSA2Ni4xNDU2NjEsIDIwMTIvMDIvMDYtMTQ6NTY6MjcgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAv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LmJtePYpKS+5c+p8F2IDYAANJqj1T4oCfk7Nj3G5Wn9qXJax7gJ93Z82D8sVNc4v30A6Xg5i42Z+iLfqARwcyT0sz9MWvWBps7LlTf5Grce9/oBTxdtxseklHxT+uWr9AGoAB138ezfj4bsFJdD6V2MCPm7RdtJzs1uW1xXzL3gTgAAAAAAAAADRhYc8q74I6RWs5ckB6GxYtWLat21SK731sDsAAAAAAAAAAAAAAAASt021NO/YjrxuQXT1oCOAAAAAAABzGLlJRSq26JAelwsWONYjbXxcZvmwO8AAAAAAAAAAAAAAAAAAef3TEWPkVivx3NY9T6UBiAAAAAABo2+VmGXblddIJ8eivRUD0oAAAAAAAAAAAAAAAAAAAYt4tKeFKVNYNSXfRgefAAAAAAAAr7VuSSWPedKaW5v1MCsAAAAAAAAAAAAAAAAAAIe6bj96Ts2n+JPzSXzP3ATgAAAAAAAAFbbt1UUrOQ9FpC4/UwK6aaqtU+DAAAAAAAAAAAAAAA4lKMIuUmoxWrb4ARNx3R3q2rLpa4Sl0y/YCcAAAAAAAAAAANmFud7G8r89r6X0dgFvGzLGRGtuWvTF6NAdwAAAAAAAAAAAy5W442PVN+K59EePp5ARMvOv5MvO6QXCC4AZwAAAAAAAAAAAAAcxlKLUotprg1owN+PvORborq+7Hnwl3gUbO74VzRydt8pKn68ANcJwmqwkpLmnUDkAAAAfNy9atqtyagut0AxXt5xIV8Fbj6lRd7Am5G65V6qUvtwfyx94GMAAAAAAAAAAAAAAAAAAAOU2nVOj5gdsc3LiqRvTpyqwOxbnnrhdfpSfrQB7pnv/AGvuS9gHXPMy5/Fem1yq0v0A6W29XqwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf//Z'
|
|
157
74
|
// 如果配置randomBgColor参数为true,在图标或者文字的模式下,会随机从中取出一个颜色值当做背景色
|
|
158
75
|
const colors = ref<string[]>([
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
])
|
|
180
|
-
const avatarUrl = ref(props.src)
|
|
181
|
-
const allowMp = ref<boolean>(false)
|
|
76
|
+
'#ffb34b',
|
|
77
|
+
'#f2bba9',
|
|
78
|
+
'#f7a196',
|
|
79
|
+
'#f18080',
|
|
80
|
+
'#88a867',
|
|
81
|
+
'#bfbf39',
|
|
82
|
+
'#89c152',
|
|
83
|
+
'#94d554',
|
|
84
|
+
'#f19ec2',
|
|
85
|
+
'#afaae4',
|
|
86
|
+
'#e1b0df',
|
|
87
|
+
'#c38cc1',
|
|
88
|
+
'#72dcdc',
|
|
89
|
+
'#9acdcb',
|
|
90
|
+
'#77b1cc',
|
|
91
|
+
'#448aca',
|
|
92
|
+
'#86cefa',
|
|
93
|
+
'#98d1ee',
|
|
94
|
+
'#73d1f1',
|
|
95
|
+
'#80a7dc'
|
|
96
|
+
])
|
|
97
|
+
const avatarUrl = ref(props.src)
|
|
98
|
+
const allowMp = ref<boolean>(false)
|
|
182
99
|
|
|
183
100
|
watch(
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
)
|
|
101
|
+
() => props.src,
|
|
102
|
+
(newVal) => {
|
|
103
|
+
avatarUrl.value = newVal
|
|
104
|
+
// 如果没有传src,则主动触发error事件,用于显示默认的头像,否则src为''空字符等的时候,会无内容展示
|
|
105
|
+
if (!newVal) {
|
|
106
|
+
errorHandler()
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
{ immediate: true }
|
|
110
|
+
)
|
|
194
111
|
|
|
195
112
|
const avatarStyle = computed<CSSProperties>(() => {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
113
|
+
const style: CSSProperties = {
|
|
114
|
+
backgroundColor:
|
|
115
|
+
props.text || props.icon
|
|
116
|
+
? props.randomBgColor
|
|
117
|
+
? colors.value[props.colorIndex ? props.colorIndex : random(0, 19)]
|
|
118
|
+
: props.bgColor
|
|
119
|
+
: 'transparent'
|
|
120
|
+
}
|
|
121
|
+
if (isNumber(props.size)) {
|
|
122
|
+
style.width = addUnit(props.size)
|
|
123
|
+
style.height = addUnit(props.size)
|
|
124
|
+
}
|
|
208
125
|
|
|
209
|
-
|
|
210
|
-
})
|
|
126
|
+
return Object.assign(style, props.customStyle)
|
|
127
|
+
})
|
|
211
128
|
const avatarClass = computed<string[]>(() => {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
129
|
+
const classes: string[] = [`hy-avatar--${props.shape}`]
|
|
130
|
+
if (typeof props.size === 'string') {
|
|
131
|
+
classes.push(`hy-avatar--${props.size}`)
|
|
132
|
+
}
|
|
216
133
|
|
|
217
|
-
|
|
218
|
-
})
|
|
134
|
+
return classes
|
|
135
|
+
})
|
|
219
136
|
|
|
220
137
|
const init = () => {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
init()
|
|
138
|
+
// 目前只有这几个小程序平台具有open-data标签
|
|
139
|
+
// 其他平台可以通过uni.getUserInfo类似接口获取信息,但是需要弹窗授权(首次),不合符组件逻辑
|
|
140
|
+
// 故目前自动获取小程序头像只支持这几个平台
|
|
141
|
+
// #ifdef MP-WEIXIN || MP-QQ || MP-BAIDU
|
|
142
|
+
allowMp.value = true
|
|
143
|
+
// #endif
|
|
144
|
+
}
|
|
145
|
+
init()
|
|
229
146
|
|
|
230
147
|
// 图片加载时失败时触发
|
|
231
148
|
function errorHandler() {
|
|
232
|
-
|
|
149
|
+
avatarUrl.value = props.defaultUrl || base64Avatar
|
|
233
150
|
}
|
|
234
151
|
|
|
235
152
|
/**
|
|
236
153
|
* @description 点击头像
|
|
237
154
|
* */
|
|
238
155
|
const clickHandler = (e: Event) => {
|
|
239
|
-
|
|
240
|
-
}
|
|
156
|
+
emit('click', props.name, e)
|
|
157
|
+
}
|
|
241
158
|
</script>
|
|
242
159
|
|
|
243
160
|
<style lang="scss" scoped>
|
|
244
|
-
@import
|
|
161
|
+
@import './index.scss';
|
|
245
162
|
</style>
|
|
@@ -1,20 +1,78 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { CSSProperties, PropType } from 'vue'
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
3
|
+
const avatarProps = {
|
|
4
|
+
/** 头像路径 */
|
|
5
|
+
src: String,
|
|
6
|
+
/**
|
|
7
|
+
* 头像形状
|
|
8
|
+
* @values circle,square
|
|
9
|
+
* */
|
|
10
|
+
shape: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: 'circle'
|
|
13
|
+
},
|
|
14
|
+
/**
|
|
15
|
+
* 头像尺寸
|
|
16
|
+
* @values large, medium, small
|
|
17
|
+
* */
|
|
18
|
+
size: {
|
|
19
|
+
type: [String, Number] as PropType<string | number>,
|
|
20
|
+
default: 'medium'
|
|
21
|
+
},
|
|
22
|
+
/**
|
|
23
|
+
* 头像图片的裁剪类型
|
|
24
|
+
* @values scaleToFill,aspectFit,aspectFill,widthFix,heightFix,top,bottom,center,left,right,top left,top right,bottom left,bottom right
|
|
25
|
+
* */
|
|
26
|
+
mode: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: 'scaleToFill'
|
|
29
|
+
},
|
|
30
|
+
/** 用文字替代图片,级别优先于src */
|
|
31
|
+
text: String,
|
|
32
|
+
/** 头像背景颜色 */
|
|
33
|
+
bgColor: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: '#c0c4cc'
|
|
36
|
+
},
|
|
37
|
+
/** 文字颜色 */
|
|
38
|
+
color: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: '#ffffff'
|
|
41
|
+
},
|
|
42
|
+
/** 文字大小 */
|
|
43
|
+
fontSize: {
|
|
44
|
+
type: Number,
|
|
45
|
+
default: 18
|
|
46
|
+
},
|
|
47
|
+
/** 显示的图标 */
|
|
48
|
+
icon: String,
|
|
49
|
+
/** 显示小程序头像,只对百度,微信,QQ小程序有效 */
|
|
50
|
+
mpAvatar: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: false
|
|
53
|
+
},
|
|
54
|
+
/** 是否使用随机背景色 */
|
|
55
|
+
randomBgColor: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
default: false
|
|
58
|
+
},
|
|
59
|
+
/** 加载失败的默认头像(组件有内置默认图片) */
|
|
60
|
+
defaultUrl: String,
|
|
61
|
+
/** 如果配置了randomBgColor为true,且配置了此值,则从默认的背景色数组中取出对应索引的颜色值,取值0-19之间 */
|
|
62
|
+
colorIndex: {
|
|
63
|
+
type: Number,
|
|
64
|
+
default: 0
|
|
65
|
+
},
|
|
66
|
+
/** 组件标识符 */
|
|
67
|
+
name: {
|
|
68
|
+
type: String,
|
|
69
|
+
default: ''
|
|
70
|
+
},
|
|
71
|
+
/** 自定义输入框外部样式 */
|
|
72
|
+
customStyle: {
|
|
73
|
+
type: Object as PropType<CSSProperties>,
|
|
74
|
+
default: () => {}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
19
77
|
|
|
20
|
-
export default
|
|
78
|
+
export default avatarProps
|