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
|
@@ -1,322 +1,192 @@
|
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
<hy-icon :name="errorIcon" size="30"></hy-icon>
|
|
53
|
-
</slot>
|
|
54
|
-
</view>
|
|
55
|
-
</view>
|
|
56
|
-
</hy-transition>
|
|
2
|
+
<hy-transition mode="fade" :show="show" :style="transStyle" :duration="fade ? 1000 : 0">
|
|
3
|
+
<view
|
|
4
|
+
:class="['hy-image', 'box-border', customClass]"
|
|
5
|
+
@tap="clickHandler"
|
|
6
|
+
:style="[wrapStyle, backgroundStyle]"
|
|
7
|
+
>
|
|
8
|
+
<image
|
|
9
|
+
v-if="!isError"
|
|
10
|
+
:src="src"
|
|
11
|
+
:mode="mode"
|
|
12
|
+
@error="onErrorHandler"
|
|
13
|
+
@load="onLoadHandler"
|
|
14
|
+
:show-menu-by-longpress="showMenuByLongPress"
|
|
15
|
+
:lazy-load="lazyLoad"
|
|
16
|
+
:class="['hy-image__url', indistinct && 'hy-image__indistinct']"
|
|
17
|
+
:style="{
|
|
18
|
+
width: addUnit(width),
|
|
19
|
+
height: addUnit(height),
|
|
20
|
+
borderRadius: shape == 'circle' ? '1000px' : addUnit(radius)
|
|
21
|
+
}"
|
|
22
|
+
referrerpolicy="no-referrer"
|
|
23
|
+
></image>
|
|
24
|
+
<view
|
|
25
|
+
v-if="showLoading && loading"
|
|
26
|
+
class="hy-image__loading"
|
|
27
|
+
:style="{
|
|
28
|
+
borderRadius: shape == 'circle' ? '50%' : addUnit(radius),
|
|
29
|
+
backgroundColor: bgColor,
|
|
30
|
+
width: addUnit(width),
|
|
31
|
+
height: addUnit(height)
|
|
32
|
+
}"
|
|
33
|
+
>
|
|
34
|
+
<slot v-if="$slots.loading" name="loading"></slot>
|
|
35
|
+
<template v-else>
|
|
36
|
+
<hy-loading :name="loadingIcon"></hy-loading>
|
|
37
|
+
</template>
|
|
38
|
+
</view>
|
|
39
|
+
<view
|
|
40
|
+
v-if="showError && isError && !loading"
|
|
41
|
+
class="hy-image__error"
|
|
42
|
+
:style="{
|
|
43
|
+
borderRadius: shape == 'circle' ? '50%' : addUnit(radius)
|
|
44
|
+
}"
|
|
45
|
+
>
|
|
46
|
+
<slot name="error">
|
|
47
|
+
<hy-icon :name="errorIcon" size="30"></hy-icon>
|
|
48
|
+
</slot>
|
|
49
|
+
</view>
|
|
50
|
+
</view>
|
|
51
|
+
</hy-transition>
|
|
57
52
|
</template>
|
|
58
53
|
|
|
59
54
|
<script lang="ts">
|
|
60
55
|
export default {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
56
|
+
name: 'hy-image',
|
|
57
|
+
options: {
|
|
58
|
+
addGlobalClass: true,
|
|
59
|
+
virtualHost: true,
|
|
60
|
+
styleIsolation: 'shared'
|
|
61
|
+
}
|
|
62
|
+
}
|
|
68
63
|
</script>
|
|
69
64
|
|
|
70
65
|
<script setup lang="ts">
|
|
71
|
-
import { computed, onMounted, ref, watch } from
|
|
72
|
-
import type {
|
|
73
|
-
import type { IImageEmits } from
|
|
74
|
-
import {
|
|
66
|
+
import { computed, onMounted, ref, watch } from 'vue'
|
|
67
|
+
import type { CSSProperties } from 'vue'
|
|
68
|
+
import type { IImageEmits } from './typing'
|
|
69
|
+
import { addUnit, getPx } from '../../libs'
|
|
70
|
+
import type { ImageOnErrorEvent, ImageOnLoadEvent } from '@uni-helper/uni-types'
|
|
71
|
+
import imageProps from './props'
|
|
75
72
|
// 组件
|
|
76
|
-
import HyIcon from
|
|
77
|
-
import HyTransition from
|
|
78
|
-
import HyLoading from
|
|
79
|
-
import type {
|
|
80
|
-
ImageOnErrorEvent,
|
|
81
|
-
ImageOnLoadEvent,
|
|
82
|
-
} from "@uni-helper/uni-types";
|
|
73
|
+
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
74
|
+
import HyTransition from '../hy-transition/hy-transition.vue'
|
|
75
|
+
import HyLoading from '../hy-loading/hy-loading.vue'
|
|
83
76
|
|
|
84
77
|
/**
|
|
85
78
|
* uni-app的image组件的加强版,在继承了原有功能外,还支持淡入动画、加载中、加载失败提示、圆角值和形状等。
|
|
86
79
|
* @displayName hy-image
|
|
87
80
|
*/
|
|
88
|
-
defineOptions({})
|
|
81
|
+
defineOptions({})
|
|
89
82
|
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
/** 图片地址 */
|
|
93
|
-
src: {
|
|
94
|
-
type: String,
|
|
95
|
-
default: "",
|
|
96
|
-
required: true,
|
|
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: "aspectFill",
|
|
105
|
-
},
|
|
106
|
-
/** 宽度,单位任意,如果为数值,则为px单位 */
|
|
107
|
-
width: {
|
|
108
|
-
type: [String, Number],
|
|
109
|
-
default: "",
|
|
110
|
-
},
|
|
111
|
-
/** 高度,单位任意,如果为数值,则为px单位 */
|
|
112
|
-
height: {
|
|
113
|
-
type: [String, Number],
|
|
114
|
-
default: "",
|
|
115
|
-
},
|
|
116
|
-
/**
|
|
117
|
-
* 图片形状
|
|
118
|
-
* @values circle,square
|
|
119
|
-
* */
|
|
120
|
-
shape: {
|
|
121
|
-
type: String,
|
|
122
|
-
default: "square",
|
|
123
|
-
},
|
|
124
|
-
/** 圆角值,单位任意,如果为数值,则为px单位 */
|
|
125
|
-
radius: {
|
|
126
|
-
type: [Number, String],
|
|
127
|
-
default: 0,
|
|
128
|
-
},
|
|
129
|
-
/** 是否懒加载,仅微信小程序、App、百度小程序、字节跳动小程序有效 */
|
|
130
|
-
lazyLoad: {
|
|
131
|
-
type: Boolean,
|
|
132
|
-
default: true,
|
|
133
|
-
},
|
|
134
|
-
/** 是否开启长按图片显示识别小程序码菜单,仅微信小程序有效 */
|
|
135
|
-
showMenuByLongPress: {
|
|
136
|
-
type: Boolean,
|
|
137
|
-
default: true,
|
|
138
|
-
},
|
|
139
|
-
/** 加载中的图标,或者小图片 */
|
|
140
|
-
loadingIcon: {
|
|
141
|
-
type: String,
|
|
142
|
-
default: IconConfig.LOADING,
|
|
143
|
-
},
|
|
144
|
-
/** 加载失败的图标,或者小图片 */
|
|
145
|
-
errorIcon: {
|
|
146
|
-
type: String,
|
|
147
|
-
default: IconConfig.NOTICE,
|
|
148
|
-
},
|
|
149
|
-
/** 是否显示加载中的图标或者自定义的slot */
|
|
150
|
-
showLoading: {
|
|
151
|
-
type: Boolean,
|
|
152
|
-
default: true,
|
|
153
|
-
},
|
|
154
|
-
/** 是否显示加载错误的图标或者自定义的slot */
|
|
155
|
-
showError: {
|
|
156
|
-
type: Boolean,
|
|
157
|
-
default: true,
|
|
158
|
-
},
|
|
159
|
-
/** 是否需要淡入效果 */
|
|
160
|
-
fade: {
|
|
161
|
-
type: Boolean,
|
|
162
|
-
default: true,
|
|
163
|
-
},
|
|
164
|
-
/** 只支持网络资源,只对微信小程序有效 */
|
|
165
|
-
webp: {
|
|
166
|
-
type: Boolean,
|
|
167
|
-
default: false,
|
|
168
|
-
},
|
|
169
|
-
/** 搭配fade参数的过渡时间,单位ms */
|
|
170
|
-
duration: {
|
|
171
|
-
type: Number,
|
|
172
|
-
default: 500,
|
|
173
|
-
},
|
|
174
|
-
/** 背景颜色,用于深色页面加载图片时,为了和背景色融合 */
|
|
175
|
-
bgColor: String,
|
|
176
|
-
/** 是否模糊图片 */
|
|
177
|
-
indistinct: {
|
|
178
|
-
type: Boolean,
|
|
179
|
-
default: false,
|
|
180
|
-
},
|
|
181
|
-
/** 是否预览图片 */
|
|
182
|
-
previewImage: {
|
|
183
|
-
type: Boolean,
|
|
184
|
-
default: false,
|
|
185
|
-
},
|
|
186
|
-
/** 定义需要用到的外部样式 */
|
|
187
|
-
customStyle: {
|
|
188
|
-
type: Object as PropType<CSSProperties>,
|
|
189
|
-
},
|
|
190
|
-
/** 自定义外部类名 */
|
|
191
|
-
customClass: String,
|
|
192
|
-
});
|
|
193
|
-
const emit = defineEmits<IImageEmits>();
|
|
83
|
+
const props = defineProps(imageProps)
|
|
84
|
+
const emit = defineEmits<IImageEmits>()
|
|
194
85
|
|
|
195
86
|
// 图片是否加载错误,如果是,则显示错误占位图
|
|
196
|
-
const isError = ref(false)
|
|
87
|
+
const isError = ref(false)
|
|
197
88
|
// 初始化组件时,默认为加载中状态
|
|
198
|
-
const loading = ref(true)
|
|
89
|
+
const loading = ref(true)
|
|
199
90
|
// 不透明度,为了实现淡入淡出的效果
|
|
200
|
-
const opacity = ref(1)
|
|
91
|
+
const opacity = ref(1)
|
|
201
92
|
// 过渡时间,因为props的值无法修改,故需要一个中间值
|
|
202
|
-
const durationTime = ref(props.duration)
|
|
93
|
+
const durationTime = ref(props.duration)
|
|
203
94
|
// 图片加载完成时,去掉背景颜色,因为如果是png图片,就会显示灰色的背景
|
|
204
|
-
const backgroundStyle = ref({})
|
|
95
|
+
const backgroundStyle = ref({})
|
|
205
96
|
// 用于fade模式的控制组件显示与否
|
|
206
|
-
const show = ref(false)
|
|
97
|
+
const show = ref(false)
|
|
207
98
|
|
|
208
99
|
watch(
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
)
|
|
100
|
+
() => props.src,
|
|
101
|
+
(newValue) => {
|
|
102
|
+
if (!newValue) {
|
|
103
|
+
// 如果传入null或者'',或者false,或者undefined,标记为错误状态
|
|
104
|
+
isError.value = true
|
|
105
|
+
loading.value = false
|
|
106
|
+
} else {
|
|
107
|
+
isError.value = false
|
|
108
|
+
loading.value = true
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
{ immediate: true }
|
|
112
|
+
)
|
|
222
113
|
|
|
223
114
|
const transStyle = computed<CSSProperties>(() => {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
isError.value ||
|
|
238
|
-
props.height == "100%" ||
|
|
239
|
-
props.mode != "widthFix"
|
|
240
|
-
) {
|
|
241
|
-
style.height = addUnit(props.height);
|
|
242
|
-
} else {
|
|
243
|
-
style.height = "fit-content";
|
|
244
|
-
}
|
|
245
|
-
return style;
|
|
246
|
-
});
|
|
115
|
+
const style: CSSProperties = {}
|
|
116
|
+
if (loading.value || isError.value || props.width == '100%' || props.mode != 'heightFix') {
|
|
117
|
+
style.width = addUnit(props.width)
|
|
118
|
+
} else {
|
|
119
|
+
style.width = 'fit-content'
|
|
120
|
+
}
|
|
121
|
+
if (loading.value || isError.value || props.height == '100%' || props.mode != 'widthFix') {
|
|
122
|
+
style.height = addUnit(props.height)
|
|
123
|
+
} else {
|
|
124
|
+
style.height = 'fit-content'
|
|
125
|
+
}
|
|
126
|
+
return style
|
|
127
|
+
})
|
|
247
128
|
|
|
248
129
|
const wrapStyle = computed(() => {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
props.
|
|
264
|
-
props.mode != "widthFix"
|
|
265
|
-
) {
|
|
266
|
-
style.height = addUnit(props.height);
|
|
267
|
-
} else {
|
|
268
|
-
style.height = "fit-content";
|
|
269
|
-
}
|
|
270
|
-
// 如果是显示圆形,设置一个很多的半径值即可
|
|
271
|
-
style.borderRadius =
|
|
272
|
-
props.shape == "circle" ? "10000px" : addUnit(props.radius);
|
|
273
|
-
// 如果设置圆角,必须要有hidden,否则可能圆角无效
|
|
274
|
-
style.overflow = getPx(props.radius) > 0 ? "hidden" : "visible";
|
|
130
|
+
const style: CSSProperties = {}
|
|
131
|
+
if (loading.value || isError.value || props.width == '100%' || props.mode != 'heightFix') {
|
|
132
|
+
style.width = addUnit(props.width)
|
|
133
|
+
} else {
|
|
134
|
+
style.width = 'fit-content'
|
|
135
|
+
}
|
|
136
|
+
if (loading.value || isError.value || props.height == '100%' || props.mode != 'widthFix') {
|
|
137
|
+
style.height = addUnit(props.height)
|
|
138
|
+
} else {
|
|
139
|
+
style.height = 'fit-content'
|
|
140
|
+
}
|
|
141
|
+
// 如果是显示圆形,设置一个很多的半径值即可
|
|
142
|
+
style.borderRadius = props.shape == 'circle' ? '10000px' : addUnit(props.radius)
|
|
143
|
+
// 如果设置圆角,必须要有hidden,否则可能圆角无效
|
|
144
|
+
style.overflow = getPx(props.radius) > 0 ? 'hidden' : 'visible'
|
|
275
145
|
|
|
276
|
-
|
|
277
|
-
})
|
|
146
|
+
return Object.assign(style, props.customStyle)
|
|
147
|
+
})
|
|
278
148
|
|
|
279
149
|
onMounted(() => {
|
|
280
|
-
|
|
281
|
-
})
|
|
150
|
+
show.value = true
|
|
151
|
+
})
|
|
282
152
|
|
|
283
153
|
const clickHandler = () => {
|
|
284
|
-
|
|
154
|
+
emit('click')
|
|
285
155
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}
|
|
156
|
+
if (props.previewImage) {
|
|
157
|
+
uni.previewImage({
|
|
158
|
+
urls: [props.src]
|
|
159
|
+
})
|
|
160
|
+
}
|
|
161
|
+
}
|
|
292
162
|
|
|
293
163
|
/**
|
|
294
164
|
* @description 图片加载失败
|
|
295
165
|
* */
|
|
296
166
|
const onErrorHandler = (err: ImageOnErrorEvent) => {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
167
|
+
loading.value = false
|
|
168
|
+
isError.value = true
|
|
169
|
+
emit('error', err)
|
|
170
|
+
}
|
|
301
171
|
|
|
302
172
|
/**
|
|
303
173
|
* @description 图片加载成功
|
|
304
174
|
* */
|
|
305
175
|
const onLoadHandler = (e: ImageOnLoadEvent) => {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
}
|
|
176
|
+
loading.value = false
|
|
177
|
+
isError.value = false
|
|
178
|
+
emit('load', e)
|
|
179
|
+
removeBgColor()
|
|
180
|
+
}
|
|
311
181
|
|
|
312
182
|
const removeBgColor = () => {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}
|
|
183
|
+
// 淡入动画过渡完成后,将背景设置为透明色,否则png图片会看到灰色的背景
|
|
184
|
+
backgroundStyle.value = {
|
|
185
|
+
backgroundColor: props.bgColor
|
|
186
|
+
}
|
|
187
|
+
}
|
|
318
188
|
</script>
|
|
319
189
|
|
|
320
190
|
<style scoped lang="scss">
|
|
321
|
-
@import
|
|
191
|
+
@import './index.scss';
|
|
322
192
|
</style>
|
|
@@ -1,25 +1,107 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { IconConfig } from '../../libs/config'
|
|
2
|
+
import type { CSSProperties, PropType } from 'vue'
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
4
|
+
const imageProps = {
|
|
5
|
+
/** 图片地址 */
|
|
6
|
+
src: {
|
|
7
|
+
type: String,
|
|
8
|
+
default: '',
|
|
9
|
+
required: true
|
|
10
|
+
},
|
|
11
|
+
/**
|
|
12
|
+
* 裁剪模式,见官网说明
|
|
13
|
+
* @values scaleToFill,aspectFit,aspectFill,widthFix,heightFix,top,bottom,center,left,right,top left,top right,bottom left,bottom right
|
|
14
|
+
* */
|
|
15
|
+
mode: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: 'aspectFill'
|
|
18
|
+
},
|
|
19
|
+
/** 宽度,单位任意,如果为数值,则为px单位 */
|
|
20
|
+
width: {
|
|
21
|
+
type: [String, Number],
|
|
22
|
+
default: ''
|
|
23
|
+
},
|
|
24
|
+
/** 高度,单位任意,如果为数值,则为px单位 */
|
|
25
|
+
height: {
|
|
26
|
+
type: [String, Number],
|
|
27
|
+
default: ''
|
|
28
|
+
},
|
|
29
|
+
/**
|
|
30
|
+
* 图片形状
|
|
31
|
+
* @values circle,square
|
|
32
|
+
* */
|
|
33
|
+
shape: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: 'square'
|
|
36
|
+
},
|
|
37
|
+
/** 圆角值,单位任意,如果为数值,则为px单位 */
|
|
38
|
+
radius: {
|
|
39
|
+
type: [Number, String],
|
|
40
|
+
default: 0
|
|
41
|
+
},
|
|
42
|
+
/** 是否懒加载,仅微信小程序、App、百度小程序、字节跳动小程序有效 */
|
|
43
|
+
lazyLoad: {
|
|
44
|
+
type: Boolean,
|
|
45
|
+
default: true
|
|
46
|
+
},
|
|
47
|
+
/** 是否开启长按图片显示识别小程序码菜单,仅微信小程序有效 */
|
|
48
|
+
showMenuByLongPress: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: true
|
|
51
|
+
},
|
|
52
|
+
/** 加载中的图标,或者小图片 */
|
|
53
|
+
loadingIcon: {
|
|
54
|
+
type: String,
|
|
55
|
+
default: IconConfig.LOADING
|
|
56
|
+
},
|
|
57
|
+
/** 加载失败的图标,或者小图片 */
|
|
58
|
+
errorIcon: {
|
|
59
|
+
type: String,
|
|
60
|
+
default: IconConfig.NOTICE
|
|
61
|
+
},
|
|
62
|
+
/** 是否显示加载中的图标或者自定义的slot */
|
|
63
|
+
showLoading: {
|
|
64
|
+
type: Boolean,
|
|
65
|
+
default: true
|
|
66
|
+
},
|
|
67
|
+
/** 是否显示加载错误的图标或者自定义的slot */
|
|
68
|
+
showError: {
|
|
69
|
+
type: Boolean,
|
|
70
|
+
default: true
|
|
71
|
+
},
|
|
72
|
+
/** 是否需要淡入效果 */
|
|
73
|
+
fade: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
default: true
|
|
76
|
+
},
|
|
77
|
+
/** 只支持网络资源,只对微信小程序有效 */
|
|
78
|
+
webp: {
|
|
79
|
+
type: Boolean,
|
|
80
|
+
default: false
|
|
81
|
+
},
|
|
82
|
+
/** 搭配fade参数的过渡时间,单位ms */
|
|
83
|
+
duration: {
|
|
84
|
+
type: Number,
|
|
85
|
+
default: 500
|
|
86
|
+
},
|
|
87
|
+
/** 背景颜色,用于深色页面加载图片时,为了和背景色融合 */
|
|
88
|
+
bgColor: String,
|
|
89
|
+
/** 是否模糊图片 */
|
|
90
|
+
indistinct: {
|
|
91
|
+
type: Boolean,
|
|
92
|
+
default: false
|
|
93
|
+
},
|
|
94
|
+
/** 是否预览图片 */
|
|
95
|
+
previewImage: {
|
|
96
|
+
type: Boolean,
|
|
97
|
+
default: false
|
|
98
|
+
},
|
|
99
|
+
/** 定义需要用到的外部样式 */
|
|
100
|
+
customStyle: {
|
|
101
|
+
type: Object as PropType<CSSProperties>
|
|
102
|
+
},
|
|
103
|
+
/** 自定义外部类名 */
|
|
104
|
+
customClass: String
|
|
105
|
+
}
|
|
24
106
|
|
|
25
|
-
export default
|
|
107
|
+
export default imageProps
|