hy-app 0.2.13 → 0.2.15
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 +81 -13
- package/components/hy-action-sheet/typing.d.ts +1 -3
- package/components/hy-address-picker/hy-address-picker.vue +109 -8
- package/components/hy-address-picker/index.scss +2 -2
- package/components/hy-address-picker/typing.d.ts +39 -30
- package/components/hy-avatar/hy-avatar.vue +78 -4
- package/components/hy-avatar/typing.d.ts +21 -16
- package/components/hy-back-top/hy-back-top.vue +86 -28
- package/components/hy-back-top/typing.d.ts +17 -12
- package/components/hy-badge/hy-badge.vue +114 -43
- package/components/hy-badge/typing.d.ts +20 -15
- package/components/hy-button/HyButton.docgen.js +6 -0
- package/components/hy-button/hy-button.vue +70 -77
- package/components/hy-button/props.ts +40 -41
- package/components/hy-calendar/hy-calendar.vue +290 -143
- package/components/hy-calendar/typing.d.ts +38 -31
- package/components/hy-card/hy-card.vue +139 -36
- package/components/hy-card/typing.d.ts +39 -28
- package/components/hy-cell/hy-cell.vue +131 -67
- package/components/hy-cell/typing.d.ts +6 -1
- package/components/hy-check-button/hy-check-button.vue +101 -32
- package/components/hy-check-button/typing.d.ts +26 -19
- package/components/hy-checkbox/hy-checkbox.vue +167 -78
- package/components/hy-checkbox/typing.d.ts +26 -19
- package/components/hy-code-input/hy-code-input.vue +101 -5
- package/components/hy-code-input/typing.d.ts +9 -0
- package/components/hy-config-provider/hy-config-provider.vue +44 -24
- package/components/hy-config-provider/typing.d.ts +0 -4
- package/components/hy-count-down/hy-count-down.vue +99 -62
- package/components/hy-count-down/typing.d.ts +18 -5
- package/components/hy-count-to/hy-count-to.vue +165 -113
- package/components/hy-count-to/typing.d.ts +15 -11
- package/components/hy-datetime-picker/hy-datetime-picker.vue +338 -232
- package/components/hy-datetime-picker/typing.d.ts +49 -39
- package/components/hy-divider/hy-divider.vue +128 -64
- package/components/hy-divider/typing.d.ts +16 -16
- package/components/hy-dropdown/hy-dropdown.vue +57 -19
- package/components/hy-dropdown/typing.d.ts +14 -14
- package/components/hy-dropdown-item/hy-dropdown-item.vue +34 -5
- package/components/hy-dropdown-item/typing.d.ts +13 -6
- package/components/hy-empty/hy-empty.vue +64 -6
- package/components/hy-empty/typing.d.ts +5 -0
- package/components/hy-float-button/hy-float-button.vue +117 -5
- package/components/hy-float-button/typing.d.ts +7 -0
- package/components/hy-folding-panel/hy-folding-panel.vue +87 -25
- package/components/hy-folding-panel/typing.d.ts +24 -15
- package/components/hy-grid/hy-grid.vue +95 -35
- package/components/hy-grid/typing.d.ts +24 -19
- package/components/hy-icon/hy-icon.vue +84 -6
- package/components/hy-icon/typing.d.ts +5 -0
- package/components/hy-image/hy-image.vue +105 -6
- package/components/hy-image/typing.d.ts +9 -0
- package/components/hy-input/hy-input.vue +277 -130
- package/components/hy-input/props.ts +13 -14
- package/components/hy-input/typing.d.ts +59 -38
- package/components/hy-line/hy-line.vue +65 -25
- package/components/hy-line-progress/hy-line-progress.vue +68 -35
- package/components/hy-list/hy-list.vue +127 -61
- package/components/hy-list/typing.d.ts +19 -12
- package/components/hy-loading/hy-loading.vue +79 -25
- package/components/hy-menu/hy-menu.vue +69 -45
- package/components/hy-menu/typing.d.ts +22 -15
- package/components/hy-modal/hy-modal.vue +91 -4
- package/components/hy-modal/typing.d.ts +11 -0
- package/components/hy-navbar/hy-navbar.vue +105 -25
- package/components/hy-navbar/typing.d.ts +25 -20
- package/components/hy-notice-bar/hy-notice-bar.vue +97 -19
- package/components/hy-notice-bar/typing.d.ts +22 -17
- package/components/hy-notify/hy-notify.vue +106 -54
- package/components/hy-number-step/hy-number-step.vue +211 -120
- package/components/hy-number-step/typing.d.ts +45 -28
- package/components/hy-overlay/hy-overlay.vue +60 -16
- package/components/hy-overlay/typing.d.ts +11 -6
- package/components/hy-pagination/hy-pagination.vue +94 -37
- package/components/hy-pagination/typing.d.ts +20 -11
- package/components/hy-picker/hy-picker.vue +225 -160
- package/components/hy-picker/typing.d.ts +51 -28
- package/components/hy-popover/hy-popover.vue +55 -7
- package/components/hy-popover/typing.d.ts +21 -1
- package/components/hy-popup/hy-popup.vue +164 -99
- package/components/hy-popup/typing.d.ts +11 -0
- package/components/hy-price/hy-price.vue +77 -30
- package/components/hy-price/typing.d.ts +10 -10
- package/components/hy-qrcode/hy-qrcode.vue +75 -5
- package/components/hy-qrcode/typing.d.ts +25 -16
- package/components/hy-radio/hy-radio.vue +169 -88
- package/components/hy-radio/typing.d.ts +29 -22
- package/components/hy-rate/hy-rate.vue +155 -104
- package/components/hy-rate/typing.d.ts +23 -16
- package/components/hy-read-more/hy-read-more.vue +83 -56
- package/components/hy-read-more/typing.d.ts +18 -11
- package/components/hy-scroll-list/hy-scroll-list.vue +69 -58
- package/components/hy-scroll-list/typing.d.ts +14 -7
- package/components/hy-search/hy-search.vue +168 -62
- package/components/hy-search/typing.d.ts +47 -26
- package/components/hy-signature/hy-signature.vue +354 -272
- package/components/hy-signature/typing.d.ts +65 -52
- package/components/hy-slider/hy-slider.vue +208 -160
- package/components/hy-slider/typing.d.ts +28 -17
- package/components/hy-steps/hy-steps.vue +125 -99
- package/components/hy-steps/typing.d.ts +21 -14
- package/components/hy-submit-bar/hy-submit-bar.vue +129 -48
- package/components/hy-submit-bar/typing.d.ts +30 -23
- package/components/hy-subsection/hy-subsection.vue +139 -96
- package/components/hy-subsection/typing.d.ts +23 -16
- package/components/hy-swipe-action/hy-swipe-action.vue +161 -135
- package/components/hy-swipe-action/typing.d.ts +26 -17
- package/components/hy-swiper/hy-swiper.vue +178 -73
- package/components/hy-swiper/typing.d.ts +37 -28
- package/components/hy-switch/hy-switch.vue +107 -60
- package/components/hy-switch/typing.d.ts +25 -18
- package/components/hy-tabs/hy-tabs.vue +170 -160
- package/components/hy-tabs/typing.d.ts +36 -22
- package/components/hy-tag/hy-tag.vue +133 -58
- package/components/hy-tag/typing.d.ts +26 -18
- package/components/hy-text/hy-text.vue +106 -6
- package/components/hy-text/typing.d.ts +31 -26
- package/components/hy-textarea/hy-textarea.vue +183 -89
- package/components/hy-textarea/typing.d.ts +41 -24
- package/components/hy-tooltip/hy-tooltip.vue +145 -101
- package/components/hy-tooltip/typing.d.ts +18 -13
- package/components/hy-transition/hy-transition.vue +48 -13
- package/components/hy-transition/typing.d.ts +17 -0
- package/components/hy-upload/hy-upload.vue +113 -148
- package/components/hy-upload/typing.d.ts +71 -71
- package/components/hy-warn/hy-warn.vue +79 -36
- package/components/hy-warn/typing.d.ts +18 -11
- package/components/hy-waterfall/hy-waterfall.vue +90 -77
- package/components/hy-watermark/hy-watermark.vue +82 -5
- package/components/hy-watermark/typing.d.ts +20 -20
- package/global.d.ts +39 -59
- package/package.json +5 -13
- package/utils/inspect.ts +3 -1
- package/web-types.json +1 -1
- package/component-helper.ts +0 -177
- package/components.json +0 -3287
- package/dist/attributes.json +0 -1
- package/dist/docs/components/hy-action-sheet/hy-action-sheet.md +0 -41
- package/dist/docs/components/hy-address-picker/hy-address-picker.md +0 -25
- package/dist/docs/components/hy-avatar/hy-avatar.md +0 -19
- package/dist/docs/components/hy-back-top/hy-back-top.md +0 -19
- package/dist/docs/components/hy-badge/hy-badge.md +0 -13
- package/dist/docs/components/hy-button/hy-button.md +0 -61
- package/dist/docs/components/hy-calendar/header.md +0 -17
- package/dist/docs/components/hy-calendar/hy-calendar.md +0 -27
- package/dist/docs/components/hy-calendar/month.md +0 -38
- package/dist/docs/components/hy-card/hy-card.md +0 -24
- package/dist/docs/components/hy-cell/hy-cell.md +0 -26
- package/dist/docs/components/hy-check-button/hy-check-button.md +0 -14
- package/dist/docs/components/hy-checkbox/hy-checkbox.md +0 -21
- package/dist/docs/components/hy-code-input/hy-code-input.md +0 -15
- package/dist/docs/components/hy-config-provider/hy-config-provider.md +0 -13
- package/dist/docs/components/hy-count-down/hy-count-down.md +0 -34
- package/dist/docs/components/hy-count-to/hy-count-to.md +0 -31
- package/dist/docs/components/hy-datetime-picker/hy-datetime-picker.md +0 -25
- package/dist/docs/components/hy-divider/hy-divider.md +0 -13
- package/dist/docs/components/hy-dropdown/hy-dropdown.md +0 -13
- package/dist/docs/components/hy-dropdown-item/hy-dropdown-item.md +0 -20
- package/dist/docs/components/hy-empty/hy-empty.md +0 -20
- package/dist/docs/components/hy-float-button/hy-float-button.md +0 -20
- package/dist/docs/components/hy-folding-panel/hy-folding-panel.md +0 -24
- package/dist/docs/components/hy-form/hy-form.md +0 -29
- package/dist/docs/components/hy-grid/hy-grid.md +0 -19
- package/dist/docs/components/hy-icon/hy-icon.md +0 -13
- package/dist/docs/components/hy-image/hy-image.md +0 -22
- package/dist/docs/components/hy-input/hy-input.md +0 -29
- package/dist/docs/components/hy-line/hy-line.md +0 -7
- package/dist/docs/components/hy-line-progress/hy-line-progress.md +0 -13
- package/dist/docs/components/hy-list/hy-list.md +0 -25
- package/dist/docs/components/hy-loading/hy-loading.md +0 -14
- package/dist/docs/components/hy-login/ThePhoneLogin.md +0 -20
- package/dist/docs/components/hy-login/TheUserLogin.md +0 -44
- package/dist/docs/components/hy-login/hy-login.md +0 -14
- package/dist/docs/components/hy-menu/hy-menu.md +0 -21
- package/dist/docs/components/hy-modal/hy-modal.md +0 -23
- package/dist/docs/components/hy-navbar/hy-navbar.md +0 -22
- package/dist/docs/components/hy-notice-bar/hy-column-notice.md +0 -20
- package/dist/docs/components/hy-notice-bar/hy-notice-bar.md +0 -14
- package/dist/docs/components/hy-notice-bar/hy-row-notice.md +0 -20
- package/dist/docs/components/hy-notify/hy-notify.md +0 -23
- package/dist/docs/components/hy-number-step/hy-number-step.md +0 -27
- package/dist/docs/components/hy-overlay/hy-overlay.md +0 -19
- package/dist/docs/components/hy-pagination/hy-pagination.md +0 -14
- package/dist/docs/components/hy-parse/hy-parse.md +0 -46
- package/dist/docs/components/hy-parse/node/node.md +0 -7
- package/dist/docs/components/hy-picker/hy-picker.md +0 -32
- package/dist/docs/components/hy-popover/hy-popover.md +0 -34
- package/dist/docs/components/hy-popup/hy-popup.md +0 -22
- package/dist/docs/components/hy-price/hy-price.md +0 -13
- package/dist/docs/components/hy-qrcode/hy-qrcode.md +0 -15
- package/dist/docs/components/hy-radio/hy-radio.md +0 -21
- package/dist/docs/components/hy-rate/hy-rate.md +0 -14
- package/dist/docs/components/hy-read-more/hy-read-more.md +0 -21
- package/dist/docs/components/hy-scroll-list/hy-scroll-list.md +0 -21
- package/dist/docs/components/hy-search/hy-search.md +0 -27
- package/dist/docs/components/hy-signature/hy-signature.md +0 -45
- package/dist/docs/components/hy-slider/hy-slider.md +0 -24
- package/dist/docs/components/hy-status-bar/hy-status-bar.md +0 -13
- package/dist/docs/components/hy-steps/hy-steps.md +0 -23
- package/dist/docs/components/hy-submit-bar/hy-submit-bar.md +0 -21
- package/dist/docs/components/hy-subsection/hy-subsection.md +0 -14
- package/dist/docs/components/hy-swipe-action/hy-swipe-action.md +0 -29
- package/dist/docs/components/hy-swiper/hy-swiper-indicator.md +0 -23
- package/dist/docs/components/hy-swiper/hy-swiper.md +0 -22
- package/dist/docs/components/hy-switch/hy-switch.md +0 -20
- package/dist/docs/components/hy-tabBar/hy-tabBar.md +0 -13
- package/dist/docs/components/hy-tabs/hy-tabs.md +0 -27
- package/dist/docs/components/hy-tag/hy-tag.md +0 -21
- package/dist/docs/components/hy-text/hy-text.md +0 -13
- package/dist/docs/components/hy-textarea/hy-textarea.md +0 -19
- package/dist/docs/components/hy-toast/hy-toast.md +0 -17
- package/dist/docs/components/hy-tooltip/hy-tooltip.md +0 -13
- package/dist/docs/components/hy-transition/hy-transition.md +0 -25
- package/dist/docs/components/hy-upload/hy-upload.md +0 -25
- package/dist/docs/components/hy-warn/hy-warn.md +0 -14
- package/dist/docs/components/hy-waterfall/hy-waterfall.md +0 -30
- package/dist/docs/components/hy-watermark/hy-watermark.md +0 -7
- package/dist/docs/components/message/TheMessage.md +0 -17
- package/dist/docs/components/yk-dialog/yk-dialog.md +0 -7
- package/dist/tags.json +0 -1
- package/dist/web-types.json +0 -1
- package/docgen.config.js +0 -14
- package/web-types.config.js +0 -7
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
<view class="hy-upload" :style="[customStyle]">
|
|
3
3
|
<view class="hy-upload__wrap">
|
|
4
4
|
<template v-if="previewImage">
|
|
5
|
-
<view
|
|
6
|
-
class="hy-upload__wrap__preview"
|
|
7
|
-
v-for="(item, index) in lists"
|
|
8
|
-
:key="index"
|
|
9
|
-
>
|
|
5
|
+
<view class="hy-upload__wrap__preview" v-for="(item, index) in lists" :key="index">
|
|
10
6
|
<image
|
|
11
7
|
v-if="item.isImage || (item.type && item.type === 'image')"
|
|
12
8
|
:src="item.thumb || item.url"
|
|
@@ -20,26 +16,14 @@
|
|
|
20
16
|
},
|
|
21
17
|
]"
|
|
22
18
|
/>
|
|
23
|
-
<view
|
|
24
|
-
v-else
|
|
25
|
-
class="hy-upload__wrap__preview__other"
|
|
26
|
-
@tap="onClickPreview(item, index)"
|
|
27
|
-
>
|
|
19
|
+
<view v-else class="hy-upload__wrap__preview__other" @tap="onClickPreview(item, index)">
|
|
28
20
|
<u-icon
|
|
29
21
|
color="#80CBF9"
|
|
30
22
|
size="26"
|
|
31
|
-
:name="
|
|
32
|
-
item.isVideo || (item.type && item.type === 'video')
|
|
33
|
-
? 'movie'
|
|
34
|
-
: 'folder'
|
|
35
|
-
"
|
|
23
|
+
:name="item.isVideo || (item.type && item.type === 'video') ? 'movie' : 'folder'"
|
|
36
24
|
></u-icon>
|
|
37
25
|
<text class="hy-upload__wrap__preview__other__text">
|
|
38
|
-
{{
|
|
39
|
-
item.isVideo || (item.type && item.type === "video")
|
|
40
|
-
? "视频"
|
|
41
|
-
: "文件"
|
|
42
|
-
}}
|
|
26
|
+
{{ item.isVideo || (item.type && item.type === 'video') ? '视频' : '文件' }}
|
|
43
27
|
</text>
|
|
44
28
|
</view>
|
|
45
29
|
|
|
@@ -51,7 +35,7 @@
|
|
|
51
35
|
stroke-width="4"
|
|
52
36
|
activeColor="#B99C65"
|
|
53
37
|
/>
|
|
54
|
-
<view class="tips-text"
|
|
38
|
+
<view class="tips-text">上传进度{{ item.schedule }}%</view>
|
|
55
39
|
</view>
|
|
56
40
|
<!-- 上传进度条 -->
|
|
57
41
|
|
|
@@ -62,11 +46,7 @@
|
|
|
62
46
|
@tap.stop="deleteItem(index)"
|
|
63
47
|
>
|
|
64
48
|
<view class="hy-upload__deletable__icon">
|
|
65
|
-
<HyIcon
|
|
66
|
-
:name="IconConfig.CLOSE"
|
|
67
|
-
color="#ffffff"
|
|
68
|
-
size="14"
|
|
69
|
-
></HyIcon>
|
|
49
|
+
<HyIcon :name="IconConfig.CLOSE" color="#ffffff" size="14"></HyIcon>
|
|
70
50
|
</view>
|
|
71
51
|
</view>
|
|
72
52
|
<!-- 删除图片图标 -->
|
|
@@ -75,11 +55,7 @@
|
|
|
75
55
|
<view class="hy-upload__success" v-if="item.status === 'success'">
|
|
76
56
|
<!-- #ifndef APP-NVUE -->
|
|
77
57
|
<view class="hy-upload__success__icon">
|
|
78
|
-
<HyIcon
|
|
79
|
-
:name="IconConfig.CHECK_MASK"
|
|
80
|
-
color="#ffffff"
|
|
81
|
-
size="12"
|
|
82
|
-
></HyIcon>
|
|
58
|
+
<HyIcon :name="IconConfig.CHECK_MASK" color="#ffffff" size="12"></HyIcon>
|
|
83
59
|
</view>
|
|
84
60
|
<!-- #endif -->
|
|
85
61
|
</view>
|
|
@@ -111,14 +87,8 @@
|
|
|
111
87
|
},
|
|
112
88
|
]"
|
|
113
89
|
>
|
|
114
|
-
<HyIcon
|
|
115
|
-
|
|
116
|
-
size="26"
|
|
117
|
-
:color="uploadIconColor"
|
|
118
|
-
></HyIcon>
|
|
119
|
-
<text v-if="uploadText" class="hy-upload__button__text">{{
|
|
120
|
-
uploadText
|
|
121
|
-
}}</text>
|
|
90
|
+
<HyIcon :name="uploadIcon" size="26" :color="uploadIconColor"></HyIcon>
|
|
91
|
+
<text v-if="uploadText" class="hy-upload__button__text">{{ uploadText }}</text>
|
|
122
92
|
</view>
|
|
123
93
|
</template>
|
|
124
94
|
</view>
|
|
@@ -126,27 +96,32 @@
|
|
|
126
96
|
</template>
|
|
127
97
|
|
|
128
98
|
<script lang="ts">
|
|
99
|
+
/**
|
|
100
|
+
* 该组件用于上传图片或者视频等场景
|
|
101
|
+
* @displayName hy-upload
|
|
102
|
+
*/
|
|
103
|
+
defineOptions({})
|
|
129
104
|
export default {
|
|
130
105
|
name: 'hy-upload',
|
|
131
106
|
options: {
|
|
132
107
|
addGlobalClass: true,
|
|
133
108
|
virtualHost: true,
|
|
134
|
-
styleIsolation: 'shared'
|
|
135
|
-
}
|
|
109
|
+
styleIsolation: 'shared',
|
|
110
|
+
},
|
|
136
111
|
}
|
|
137
112
|
</script>
|
|
138
113
|
|
|
139
114
|
<script setup lang="ts">
|
|
140
|
-
import { ref, toRefs, watch } from
|
|
141
|
-
import defaultProps from
|
|
142
|
-
import type IProps from
|
|
143
|
-
import type { FileVo } from
|
|
144
|
-
import { addUnit, chooseFile } from
|
|
145
|
-
import { IconConfig } from
|
|
115
|
+
import { ref, toRefs, watch } from 'vue'
|
|
116
|
+
import defaultProps from './props'
|
|
117
|
+
import type IProps from './typing'
|
|
118
|
+
import type { FileVo } from './typing'
|
|
119
|
+
import { addUnit, chooseFile } from '../../utils'
|
|
120
|
+
import { IconConfig } from '../../config'
|
|
146
121
|
// 组件
|
|
147
|
-
import HyIcon from
|
|
122
|
+
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
148
123
|
|
|
149
|
-
const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
124
|
+
const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
150
125
|
const {
|
|
151
126
|
accept,
|
|
152
127
|
fileList,
|
|
@@ -163,69 +138,62 @@ const {
|
|
|
163
138
|
previewFullImage,
|
|
164
139
|
deletable,
|
|
165
140
|
useBeforeRead,
|
|
166
|
-
} = toRefs(props)
|
|
167
|
-
const emit = defineEmits([
|
|
168
|
-
"clickPreview",
|
|
169
|
-
"beforeRead",
|
|
170
|
-
"error",
|
|
171
|
-
"delete",
|
|
172
|
-
"afterRead",
|
|
173
|
-
"oversize",
|
|
174
|
-
]);
|
|
141
|
+
} = toRefs(props)
|
|
142
|
+
const emit = defineEmits(['clickPreview', 'beforeRead', 'error', 'delete', 'afterRead', 'oversize'])
|
|
175
143
|
|
|
176
|
-
const lists = ref<FileVo[]>([])
|
|
177
|
-
const isInCount = ref<boolean>(true)
|
|
178
|
-
const previewImage = ref<boolean>(true)
|
|
144
|
+
const lists = ref<FileVo[]>([])
|
|
145
|
+
const isInCount = ref<boolean>(true)
|
|
146
|
+
const previewImage = ref<boolean>(true)
|
|
179
147
|
|
|
180
148
|
const formatFileList = () => {
|
|
181
149
|
lists.value = fileList.value.map((item: FileVo) =>
|
|
182
150
|
Object.assign(Object.assign({}, item), {
|
|
183
151
|
// 如果item.url为本地选择的blob文件的话,无法判断其为video还是image,此处优先通过accept做判断处理
|
|
184
|
-
isImage: accept.value ===
|
|
185
|
-
isVideo: accept.value ===
|
|
152
|
+
isImage: accept.value === 'image',
|
|
153
|
+
isVideo: accept.value === 'video',
|
|
186
154
|
deletable: item.deletable || deletable.value,
|
|
187
155
|
}),
|
|
188
|
-
)
|
|
189
|
-
isInCount.value = lists.value.length < maxCount.value
|
|
190
|
-
}
|
|
156
|
+
)
|
|
157
|
+
isInCount.value = lists.value.length < maxCount.value
|
|
158
|
+
}
|
|
191
159
|
|
|
192
160
|
watch(
|
|
193
161
|
() => fileList.value,
|
|
194
162
|
() => {
|
|
195
|
-
formatFileList()
|
|
163
|
+
formatFileList()
|
|
196
164
|
},
|
|
197
165
|
{ immediate: true, deep: true },
|
|
198
|
-
)
|
|
166
|
+
)
|
|
199
167
|
|
|
200
168
|
watch(
|
|
201
169
|
() => deletable.value,
|
|
202
170
|
() => {
|
|
203
|
-
formatFileList()
|
|
171
|
+
formatFileList()
|
|
204
172
|
},
|
|
205
|
-
)
|
|
173
|
+
)
|
|
206
174
|
|
|
207
175
|
watch(
|
|
208
176
|
() => maxCount.value,
|
|
209
177
|
() => {
|
|
210
|
-
formatFileList()
|
|
178
|
+
formatFileList()
|
|
211
179
|
},
|
|
212
|
-
)
|
|
180
|
+
)
|
|
213
181
|
|
|
214
182
|
watch(
|
|
215
183
|
() => accept.value,
|
|
216
184
|
() => {
|
|
217
|
-
formatFileList()
|
|
185
|
+
formatFileList()
|
|
218
186
|
},
|
|
219
|
-
)
|
|
187
|
+
)
|
|
220
188
|
|
|
221
189
|
const chooseFileFn = () => {
|
|
222
|
-
if (disabled.value) return
|
|
190
|
+
if (disabled.value) return
|
|
223
191
|
// 如果用户传入的是字符串,需要格式化成数组
|
|
224
|
-
let capture
|
|
192
|
+
let capture
|
|
225
193
|
try {
|
|
226
|
-
capture = Array.isArray(capture) ? capture : capture!.split(
|
|
194
|
+
capture = Array.isArray(capture) ? capture : capture!.split(',')
|
|
227
195
|
} catch (e) {
|
|
228
|
-
capture = []
|
|
196
|
+
capture = []
|
|
229
197
|
}
|
|
230
198
|
chooseFile(
|
|
231
199
|
Object.assign(
|
|
@@ -245,24 +213,24 @@ const chooseFileFn = () => {
|
|
|
245
213
|
),
|
|
246
214
|
)
|
|
247
215
|
.then((res: any) => {
|
|
248
|
-
onBeforeRead(multiple.value ? res : res[0])
|
|
216
|
+
onBeforeRead(multiple.value ? res : res[0])
|
|
249
217
|
})
|
|
250
218
|
.catch((error) => {
|
|
251
|
-
emit(
|
|
252
|
-
})
|
|
253
|
-
}
|
|
219
|
+
emit('error', error)
|
|
220
|
+
})
|
|
221
|
+
}
|
|
254
222
|
// 文件读取之前
|
|
255
223
|
const onBeforeRead = (file: FileVo) => {
|
|
256
|
-
let res: any = true
|
|
224
|
+
let res: any = true
|
|
257
225
|
// beforeRead是否为一个方法
|
|
258
|
-
if (typeof props.beforeRead ===
|
|
226
|
+
if (typeof props.beforeRead === 'function') {
|
|
259
227
|
// 如果用户定义了此方法,则去执行此方法,并传入读取的文件回调
|
|
260
|
-
res = props.beforeRead(file, getDetail())
|
|
228
|
+
res = props.beforeRead(file, getDetail())
|
|
261
229
|
}
|
|
262
230
|
if (useBeforeRead.value) {
|
|
263
231
|
res = new Promise((resolve, reject) => {
|
|
264
232
|
emit(
|
|
265
|
-
|
|
233
|
+
'beforeRead',
|
|
266
234
|
Object.assign(
|
|
267
235
|
Object.assign(
|
|
268
236
|
{
|
|
@@ -272,152 +240,149 @@ const onBeforeRead = (file: FileVo) => {
|
|
|
272
240
|
),
|
|
273
241
|
{
|
|
274
242
|
callback: (ok: any) => {
|
|
275
|
-
ok ? resolve(ok) : reject()
|
|
243
|
+
ok ? resolve(ok) : reject()
|
|
276
244
|
},
|
|
277
245
|
},
|
|
278
246
|
),
|
|
279
|
-
)
|
|
280
|
-
})
|
|
247
|
+
)
|
|
248
|
+
})
|
|
281
249
|
}
|
|
282
|
-
if (!res) return
|
|
283
|
-
if (typeof res ===
|
|
284
|
-
res.then((data: any) => onAfterRead(data || file))
|
|
250
|
+
if (!res) return
|
|
251
|
+
if (typeof res === 'function') {
|
|
252
|
+
res.then((data: any) => onAfterRead(data || file))
|
|
285
253
|
} else {
|
|
286
|
-
onAfterRead(file)
|
|
254
|
+
onAfterRead(file)
|
|
287
255
|
}
|
|
288
|
-
}
|
|
256
|
+
}
|
|
289
257
|
const getDetail = (index?: number) => {
|
|
290
258
|
return {
|
|
291
259
|
name: name.value,
|
|
292
260
|
index: index == null ? fileList.value.length : index,
|
|
293
|
-
}
|
|
294
|
-
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
295
263
|
const onAfterRead = (file: FileVo) => {
|
|
296
264
|
const oversize = Array.isArray(file)
|
|
297
265
|
? file.some((item) => item.size > maxSize.value)
|
|
298
|
-
: file.size > maxSize.value
|
|
266
|
+
: file.size > maxSize.value
|
|
299
267
|
if (oversize) {
|
|
300
268
|
emit(
|
|
301
|
-
|
|
269
|
+
'oversize',
|
|
302
270
|
Object.assign(
|
|
303
271
|
{
|
|
304
272
|
file,
|
|
305
273
|
},
|
|
306
274
|
getDetail(),
|
|
307
275
|
),
|
|
308
|
-
)
|
|
309
|
-
return
|
|
276
|
+
)
|
|
277
|
+
return
|
|
310
278
|
}
|
|
311
|
-
if (typeof props.afterRead ===
|
|
312
|
-
props.afterRead(file, getDetail())
|
|
279
|
+
if (typeof props.afterRead === 'function') {
|
|
280
|
+
props.afterRead(file, getDetail())
|
|
313
281
|
}
|
|
314
282
|
emit(
|
|
315
|
-
|
|
283
|
+
'afterRead',
|
|
316
284
|
Object.assign(
|
|
317
285
|
{
|
|
318
286
|
file,
|
|
319
287
|
},
|
|
320
288
|
getDetail(),
|
|
321
289
|
),
|
|
322
|
-
)
|
|
323
|
-
}
|
|
290
|
+
)
|
|
291
|
+
}
|
|
324
292
|
|
|
325
293
|
/**
|
|
326
294
|
* @description 删除文件
|
|
327
295
|
* */
|
|
328
296
|
const deleteItem = (index: number) => {
|
|
329
|
-
fileList.value.splice(index, 1)
|
|
330
|
-
isInCount.value = lists.value.length < maxCount.value
|
|
297
|
+
fileList.value.splice(index, 1)
|
|
298
|
+
isInCount.value = lists.value.length < maxCount.value
|
|
331
299
|
emit(
|
|
332
|
-
|
|
300
|
+
'delete',
|
|
333
301
|
Object.assign(Object.assign({}, getDetail(index)), {
|
|
334
302
|
file: fileList.value[index],
|
|
335
303
|
}),
|
|
336
|
-
)
|
|
337
|
-
}
|
|
304
|
+
)
|
|
305
|
+
}
|
|
338
306
|
|
|
339
307
|
/**
|
|
340
308
|
* @description 预览图片
|
|
341
309
|
* */
|
|
342
310
|
const onPreviewImage = (previewItem: FileVo, index: number) => {
|
|
343
|
-
if (!previewItem.isImage || !previewFullImage.value) return
|
|
344
|
-
let current = 0
|
|
345
|
-
const urls = []
|
|
346
|
-
let imageIndex = 0
|
|
311
|
+
if (!previewItem.isImage || !previewFullImage.value) return
|
|
312
|
+
let current = 0
|
|
313
|
+
const urls = []
|
|
314
|
+
let imageIndex = 0
|
|
347
315
|
for (var i = 0; i < lists.value.length; i++) {
|
|
348
|
-
const item: FileVo = lists.value[i]
|
|
349
|
-
if (item.isImage || (item.type && item.type ===
|
|
350
|
-
urls.push(item.url || item.thumb)
|
|
316
|
+
const item: FileVo = lists.value[i]
|
|
317
|
+
if (item.isImage || (item.type && item.type === 'image')) {
|
|
318
|
+
urls.push(item.url || item.thumb)
|
|
351
319
|
if (i === index) {
|
|
352
|
-
current = imageIndex
|
|
320
|
+
current = imageIndex
|
|
353
321
|
}
|
|
354
|
-
imageIndex += 1
|
|
322
|
+
imageIndex += 1
|
|
355
323
|
}
|
|
356
324
|
}
|
|
357
325
|
if (urls.length < 1) {
|
|
358
|
-
return
|
|
326
|
+
return
|
|
359
327
|
}
|
|
360
328
|
uni.previewImage({
|
|
361
329
|
urls: urls,
|
|
362
330
|
current: current,
|
|
363
331
|
fail() {
|
|
364
|
-
uni.showToast({ title:
|
|
332
|
+
uni.showToast({ title: '预览图片失败' })
|
|
365
333
|
},
|
|
366
|
-
})
|
|
367
|
-
}
|
|
334
|
+
})
|
|
335
|
+
}
|
|
368
336
|
|
|
369
337
|
/**
|
|
370
338
|
* @description 预览视频
|
|
371
339
|
* */
|
|
372
340
|
const onPreviewVideo = (index: number) => {
|
|
373
|
-
if (!previewFullImage.value) return
|
|
374
|
-
let current = 0
|
|
375
|
-
const sources: any[] = []
|
|
376
|
-
let videoIndex = 0
|
|
341
|
+
if (!previewFullImage.value) return
|
|
342
|
+
let current = 0
|
|
343
|
+
const sources: any[] = []
|
|
344
|
+
let videoIndex = 0
|
|
377
345
|
for (let i = 0; i < lists.value.length; i++) {
|
|
378
|
-
const item: FileVo = lists.value[i]
|
|
379
|
-
if (item.isVideo || (item.type && item.type ===
|
|
346
|
+
const item: FileVo = lists.value[i]
|
|
347
|
+
if (item.isVideo || (item.type && item.type === 'video')) {
|
|
380
348
|
sources.push(
|
|
381
349
|
Object.assign(Object.assign({}, item), {
|
|
382
|
-
type:
|
|
350
|
+
type: 'video',
|
|
383
351
|
}),
|
|
384
|
-
)
|
|
352
|
+
)
|
|
385
353
|
if (i === index) {
|
|
386
|
-
current = videoIndex
|
|
354
|
+
current = videoIndex
|
|
387
355
|
}
|
|
388
|
-
videoIndex += 1
|
|
356
|
+
videoIndex += 1
|
|
389
357
|
}
|
|
390
358
|
}
|
|
391
359
|
if (sources.length < 1) {
|
|
392
|
-
return
|
|
360
|
+
return
|
|
393
361
|
}
|
|
394
362
|
// #ifdef MP-WEIXIN
|
|
395
363
|
wx.previewMedia({
|
|
396
364
|
sources: sources,
|
|
397
365
|
current: current,
|
|
398
366
|
fail() {
|
|
399
|
-
uni.showToast({ title:
|
|
367
|
+
uni.showToast({ title: '预览视频失败' })
|
|
400
368
|
},
|
|
401
|
-
})
|
|
369
|
+
})
|
|
402
370
|
// #endif
|
|
403
|
-
}
|
|
371
|
+
}
|
|
404
372
|
|
|
405
373
|
const onClickPreview = (item: FileVo, index: number) => {
|
|
406
|
-
if (!previewFullImage.value) return
|
|
374
|
+
if (!previewFullImage.value) return
|
|
407
375
|
switch (item.type) {
|
|
408
|
-
case
|
|
409
|
-
onPreviewVideo(index)
|
|
410
|
-
break
|
|
376
|
+
case 'video':
|
|
377
|
+
onPreviewVideo(index)
|
|
378
|
+
break
|
|
411
379
|
default:
|
|
412
|
-
break
|
|
380
|
+
break
|
|
413
381
|
}
|
|
414
|
-
emit(
|
|
415
|
-
|
|
416
|
-
Object.assign(Object.assign({}, item), getDetail(index)),
|
|
417
|
-
);
|
|
418
|
-
};
|
|
382
|
+
emit('clickPreview', Object.assign(Object.assign({}, item), getDetail(index)))
|
|
383
|
+
}
|
|
419
384
|
</script>
|
|
420
385
|
|
|
421
386
|
<style lang="scss" scoped>
|
|
422
|
-
@import
|
|
387
|
+
@import './index.scss';
|
|
423
388
|
</style>
|