@nutui/nutui 3.2.5-beta.1 → 3.2.6-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/nutui.es.js +4214 -4444
- package/dist/nutui.umd.js +4213 -4543
- package/dist/packages/_es/ActionSheet.js +18 -19
- package/dist/packages/_es/Address.js +94 -85
- package/dist/packages/_es/AddressList.js +25 -12
- package/dist/packages/_es/Animate.js +3 -3
- package/dist/packages/_es/Audio.js +9 -2
- package/dist/packages/_es/AudioOperate.js +5 -1
- package/dist/packages/_es/Avatar.js +10 -10
- package/dist/packages/_es/AvatarGroup.js +5 -5
- package/dist/packages/_es/BackTop.js +55 -108
- package/dist/packages/_es/Badge.js +6 -4
- package/dist/packages/_es/Barrage.js +79 -103
- package/dist/packages/_es/Button.js +5 -3
- package/dist/packages/_es/Calendar.js +36 -23
- package/dist/packages/_es/CalendarItem.js +4 -3
- package/dist/packages/_es/Card.js +15 -5
- package/dist/packages/_es/Cascader.js +12 -11
- package/dist/packages/_es/Category.js +13 -12
- package/dist/packages/_es/CategoryPane.js +17 -13
- package/dist/packages/_es/Cell.js +9 -12
- package/dist/packages/_es/CellGroup.js +4 -2
- package/dist/packages/_es/Checkbox.js +1 -1
- package/dist/packages/_es/CheckboxGroup.js +2 -2
- package/dist/packages/_es/CircleProgress.js +98 -82
- package/dist/packages/_es/Col.js +1 -1
- package/dist/packages/_es/Collapse.js +65 -34
- package/dist/packages/_es/CollapseItem.js +93 -60
- package/dist/packages/_es/Comment.js +43 -19
- package/dist/packages/_es/ConfigProvider.js +1 -1
- package/dist/packages/_es/CountDown.js +3 -3
- package/dist/packages/_es/CountUp.js +47 -52
- package/dist/packages/_es/DatePicker.js +37 -54
- package/dist/packages/_es/Dialog.js +9 -88
- package/dist/packages/_es/Divider.js +3 -3
- package/dist/packages/_es/Drag.js +75 -49
- package/dist/packages/_es/Ecard.js +20 -18
- package/dist/packages/_es/Elevator.js +101 -76
- package/dist/packages/_es/Ellipsis.js +140 -100
- package/dist/packages/_es/Empty.js +6 -4
- package/dist/packages/_es/FixedNav.js +11 -6
- package/dist/packages/_es/Form.js +4 -4
- package/dist/packages/_es/FormItem.js +3 -1
- package/dist/packages/_es/Grid.js +1 -1
- package/dist/packages/_es/GridItem.js +10 -27
- package/dist/packages/_es/Icon.js +1 -1
- package/dist/packages/_es/Image.js +13 -114
- package/dist/packages/_es/ImagePreview.js +154 -400
- package/dist/packages/_es/Indicator.js +3 -3
- package/dist/packages/_es/InfiniteLoading.js +103 -115
- package/dist/packages/_es/Input.js +54 -26
- package/dist/packages/_es/InputNumber.js +25 -16
- package/dist/packages/_es/Invoice.js +6 -5
- package/dist/packages/_es/Layout.js +1 -1
- package/dist/packages/_es/List.js +47 -34
- package/dist/packages/_es/Menu.js +35 -35
- package/dist/packages/_es/MenuItem.js +56 -29
- package/dist/packages/_es/Navbar.js +49 -39
- package/dist/packages/_es/NoticeBar.js +52 -41
- package/dist/packages/_es/Notify.js +37 -166
- package/dist/packages/_es/NumberKeyboard.js +15 -20
- package/dist/packages/_es/OldPicker.js +130 -116
- package/dist/packages/_es/OverLay.js +5 -28
- package/dist/packages/_es/Pagination.js +8 -5
- package/dist/packages/_es/Picker.js +196 -65
- package/dist/packages/_es/Popover.js +201 -881
- package/dist/packages/_es/Popup.js +28 -84
- package/dist/packages/_es/Price.js +22 -6
- package/dist/packages/_es/Progress.js +18 -11
- package/dist/packages/_es/PullRefresh.js +4 -2
- package/dist/packages/_es/Radio.js +3 -3
- package/dist/packages/_es/RadioGroup.js +1 -1
- package/dist/packages/_es/Range.js +48 -34
- package/dist/packages/_es/Rate.js +15 -14
- package/dist/packages/_es/Row.js +1 -1
- package/dist/packages/_es/SearchBar.js +39 -36
- package/dist/packages/_es/ShortPassword.js +97 -66
- package/dist/packages/_es/SideNavBar.js +7 -18
- package/dist/packages/_es/SideNavBarItem.js +1 -1
- package/dist/packages/_es/Signature.js +113 -80
- package/dist/packages/_es/Skeleton.js +12 -11
- package/dist/packages/_es/Sku.js +63 -38
- package/dist/packages/_es/Step.js +7 -2
- package/dist/packages/_es/Steps.js +1 -1
- package/dist/packages/_es/Sticky.js +33 -23
- package/dist/packages/_es/SubSideNavBar.js +4 -2
- package/dist/packages/_es/Swipe.js +41 -26
- package/dist/packages/_es/Swiper.js +38 -21
- package/dist/packages/_es/SwiperItem.js +2 -2
- package/dist/packages/_es/Switch.js +8 -8
- package/dist/packages/_es/TabPane.js +1 -1
- package/dist/packages/_es/Tabbar.js +40 -9
- package/dist/packages/_es/TabbarItem.js +24 -30
- package/dist/packages/_es/Table.js +22 -17
- package/dist/packages/_es/Tabs.js +49 -16
- package/dist/packages/_es/Tag.js +6 -5
- package/dist/packages/_es/TextArea.js +114 -49
- package/dist/packages/_es/TimeDetail.js +4 -3
- package/dist/packages/_es/TimePannel.js +3 -3
- package/dist/packages/_es/TimeSelect.js +12 -10
- package/dist/packages/_es/Toast.js +53 -164
- package/dist/packages/_es/TrendArrow.js +6 -4
- package/dist/packages/_es/Uploader.js +141 -140
- package/dist/packages/_es/Video.js +72 -5
- package/dist/packages/_es/WaterMark.js +22 -14
- package/dist/packages/_es/common.js +1 -1
- package/dist/packages/_es/component.js +1 -1
- package/dist/packages/_es/index.js +44 -6
- package/dist/packages/_es/{index5.js → index.taro.js} +167 -154
- package/dist/packages/_es/index2.js +8 -31
- package/dist/packages/_es/index3.js +64 -7
- package/dist/packages/_es/index4.js +424 -62
- package/dist/packages/_es/plugin-vue_export-helper.js +1 -1
- package/dist/packages/_es/pxCheck.js +1 -1
- package/dist/packages/_es/raf.js +1 -1
- package/dist/packages/_es/style.css +21 -3
- package/dist/packages/_es/use-lock-scroll.js +23 -0
- package/dist/packages/locale/lang/baseLang.js +1 -1
- package/dist/packages/locale/lang/en-US.js +1 -1
- package/dist/packages/locale/lang/id-ID.js +1 -1
- package/dist/packages/locale/lang/index.js +1 -1
- package/dist/packages/locale/lang/zh-CN.js +1 -1
- package/dist/packages/locale/lang/zh-TW.js +1 -1
- package/dist/packages/signature/index.scss +4 -1
- package/dist/packages/swiperitem/index.scss +1 -1
- package/dist/smartips/attributes.json +4 -0
- package/dist/smartips/tags.json +2 -1
- package/dist/smartips/web-types.json +10 -1
- package/dist/style.css +1 -1
- package/dist/styles/themes/default.scss +44 -44
- package/dist/styles/themes/jdb.scss +44 -44
- package/dist/styles/themes/jddkh.scss +44 -44
- package/dist/styles/themes/jdt.scss +44 -44
- package/dist/types/__VUE/actionsheet/{index.vue.d.ts → index.taro.vue.d.ts} +9 -9
- package/dist/types/__VUE/address/{index.vue.d.ts → index.taro.vue.d.ts} +73 -33
- package/dist/types/__VUE/addresslist/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/animate/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/avatar/{index.vue.d.ts → index.taro.vue.d.ts} +6 -6
- package/dist/types/__VUE/avatargroup/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/backtop/{index.vue.d.ts → index.taro.vue.d.ts} +15 -37
- package/dist/types/__VUE/badge/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/barrage/{index.vue.d.ts → index.taro.vue.d.ts} +2 -2
- package/dist/types/__VUE/button/index.taro.vue.d.ts +116 -0
- package/dist/types/__VUE/button/index.vue.d.ts +1 -1
- package/dist/types/__VUE/calendar/{index.vue.d.ts → index.taro.vue.d.ts} +13 -1
- package/dist/types/__VUE/calendaritem/{index.vue.d.ts → index.taro.vue.d.ts} +17 -17
- package/dist/types/__VUE/card/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/cascader/{index.vue.d.ts → index.taro.vue.d.ts} +1 -1
- package/dist/types/__VUE/category/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/categorypane/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/cell/{index.vue.d.ts → index.taro.vue.d.ts} +13 -6
- package/dist/types/__VUE/checkbox/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/circleprogress/{index.vue.d.ts → index.taro.vue.d.ts} +14 -15
- package/dist/types/__VUE/collapse/{index.vue.d.ts → index.taro.vue.d.ts} +1 -1
- package/dist/types/__VUE/collapseitem/{index.vue.d.ts → index.taro.vue.d.ts} +2 -10
- package/dist/types/__VUE/comment/{index.vue.d.ts → index.taro.vue.d.ts} +1 -2
- package/dist/types/__VUE/configprovider/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/countdown/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/countup/{index.vue.d.ts → index.taro.vue.d.ts} +5 -7
- package/dist/types/__VUE/datepicker/{index.vue.d.ts → index.taro.vue.d.ts} +5 -5
- package/dist/types/__VUE/dialog/{index.vue.d.ts → index.taro.vue.d.ts} +9 -12
- package/dist/types/__VUE/divider/{index.vue.d.ts → index.taro.vue.d.ts} +1 -1
- package/dist/types/__VUE/drag/{index.vue.d.ts → index.taro.vue.d.ts} +2 -1
- package/dist/types/__VUE/ecard/{index.vue.d.ts → index.taro.vue.d.ts} +3 -3
- package/dist/types/__VUE/elevator/{index.vue.d.ts → index.taro.vue.d.ts} +11 -2
- package/dist/types/__VUE/ellipsis/{index.vue.d.ts → index.taro.vue.d.ts} +4 -0
- package/dist/types/__VUE/empty/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/fixednav/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/form/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/grid/{index.vue.d.ts → index.taro.vue.d.ts} +1 -1
- package/dist/types/__VUE/griditem/{index.vue.d.ts → index.taro.vue.d.ts} +2 -27
- package/dist/types/__VUE/icon/index.taro.vue.d.ts +74 -0
- package/dist/types/__VUE/image/index.taro.vue.d.ts +33 -0
- package/dist/types/__VUE/imagepreview/{index.vue.d.ts → index.taro.vue.d.ts} +40 -42
- package/dist/types/__VUE/indicator/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/infiniteloading/{index.vue.d.ts → index.taro.vue.d.ts} +15 -8
- package/dist/types/__VUE/input/{index.vue.d.ts → index.taro.vue.d.ts} +34 -16
- package/dist/types/__VUE/inputnumber/{index.vue.d.ts → index.taro.vue.d.ts} +2 -2
- package/dist/types/__VUE/invoice/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/layout/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/list/{index.vue.d.ts → index.taro.vue.d.ts} +2 -2
- package/dist/types/__VUE/menu/{index.vue.d.ts → index.taro.vue.d.ts} +1 -0
- package/dist/types/__VUE/menuitem/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/navbar/{index.vue.d.ts → index.taro.vue.d.ts} +1 -2
- package/dist/types/__VUE/noticebar/{index.vue.d.ts → index.taro.vue.d.ts} +4 -3
- package/dist/types/__VUE/notify/{index.vue.d.ts → index.taro.vue.d.ts} +10 -25
- package/dist/types/__VUE/numberkeyboard/{index.vue.d.ts → index.taro.vue.d.ts} +5 -29
- package/dist/types/__VUE/oldpicker/{Column.vue.d.ts → ColumnTaro.vue.d.ts} +28 -17
- package/dist/types/__VUE/oldpicker/{index.vue.d.ts → index.taro.vue.d.ts} +64 -44
- package/dist/types/__VUE/overlay/index.taro.vue.d.ts +85 -0
- package/dist/types/__VUE/pagination/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/picker/{Column.vue.d.ts → ColumnTaro.vue.d.ts} +16 -4
- package/dist/types/__VUE/picker/{index.vue.d.ts → index.taro.vue.d.ts} +53 -28
- package/dist/types/__VUE/popover/{index.vue.d.ts → index.taro.vue.d.ts} +15 -13
- package/dist/types/__VUE/popup/index.taro.vue.d.ts +1728 -0
- package/dist/types/__VUE/popup/index.vue.d.ts +1 -1
- package/dist/types/__VUE/price/{index.vue.d.ts → index.taro.vue.d.ts} +1 -0
- package/dist/types/__VUE/progress/{index.vue.d.ts → index.taro.vue.d.ts} +1 -1
- package/dist/types/__VUE/radio/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/range/{index.vue.d.ts → index.taro.vue.d.ts} +8 -7
- package/dist/types/__VUE/rate/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/searchbar/{index.vue.d.ts → index.taro.vue.d.ts} +19 -19
- package/dist/types/__VUE/shortpassword/{index.vue.d.ts → index.taro.vue.d.ts} +6 -21
- package/dist/types/__VUE/sidenavbar/{index.vue.d.ts → index.taro.vue.d.ts} +0 -5
- package/dist/types/__VUE/signature/{index.vue.d.ts → index.taro.vue.d.ts} +8 -5
- package/dist/types/__VUE/skeleton/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/sku/{index.vue.d.ts → index.taro.vue.d.ts} +54 -182
- package/dist/types/__VUE/step/index.vue.d.ts +1 -1
- package/dist/types/__VUE/steps/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/sticky/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/swipe/{index.vue.d.ts → index.taro.vue.d.ts} +2 -1
- package/dist/types/__VUE/swiper/{index.vue.d.ts → index.taro.vue.d.ts} +2 -1
- package/dist/types/__VUE/swiperitem/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/switch/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/tabbar/{index.vue.d.ts → index.taro.vue.d.ts} +10 -0
- package/dist/types/__VUE/tabbaritem/{index.vue.d.ts → index.taro.vue.d.ts} +9 -9
- package/dist/types/__VUE/table/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/tabs/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/tag/{index.vue.d.ts → index.taro.vue.d.ts} +4 -4
- package/dist/types/__VUE/textarea/{index.vue.d.ts → index.taro.vue.d.ts} +5 -3
- package/dist/types/__VUE/timedetail/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/timepannel/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/timeselect/{index.vue.d.ts → index.taro.vue.d.ts} +7 -8
- package/dist/types/__VUE/toast/{index.vue.d.ts → index.taro.vue.d.ts} +44 -22
- package/dist/types/__VUE/trendarrow/{index.vue.d.ts → index.taro.vue.d.ts} +0 -0
- package/dist/types/__VUE/uploader/{index.vue.d.ts → index.taro.vue.d.ts} +22 -13
- package/dist/types/__VUE/video/index.vue.d.ts +3 -1
- package/dist/types/__VUE/watermark/{index.vue.d.ts → index.taro.vue.d.ts} +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/nutui.d.ts +89 -89
- package/package.json +1 -1
- package/dist/types/__VUE/dialog/index.d.ts +0 -48
- package/dist/types/__VUE/image/index.vue.d.ts +0 -117
- package/dist/types/__VUE/image/type.d.ts +0 -6
- package/dist/types/__VUE/imagepreview/imagePreviewItem.vue.d.ts +0 -108
- package/dist/types/__VUE/imagepreview/index.d.ts +0 -25
- package/dist/types/__VUE/notify/index.d.ts +0 -26
- package/dist/types/__VUE/tag/type.d.ts +0 -5
- package/dist/types/__VUE/toast/index.d.ts +0 -16
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.2.
|
|
2
|
+
* @nutui/nutui v3.2.6-beta.1 Mon Oct 31 2022 19:38:22 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2022 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import { reactive, computed, resolveComponent, openBlock, createElementBlock, normalizeClass, renderSlot,
|
|
6
|
+
import { reactive, computed, onMounted, resolveComponent, openBlock, createElementBlock, normalizeClass, renderSlot, createTextVNode, createBlock, createCommentVNode, Fragment, renderList, createElementVNode, toDisplayString, createVNode, mergeProps } from "vue";
|
|
7
7
|
import { c as createComponent, i as isPromise } from "./component.js";
|
|
8
|
+
import Taro from "@tarojs/taro";
|
|
8
9
|
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
9
10
|
import "../locale/lang";
|
|
10
11
|
class UploadOptions {
|
|
@@ -118,6 +119,14 @@ const _sfc_main = create({
|
|
|
118
119
|
props: {
|
|
119
120
|
name: { type: String, default: "file" },
|
|
120
121
|
url: { type: String, default: "" },
|
|
122
|
+
sizeType: {
|
|
123
|
+
type: Array,
|
|
124
|
+
default: () => ["original", "compressed"]
|
|
125
|
+
},
|
|
126
|
+
sourceType: {
|
|
127
|
+
type: Array,
|
|
128
|
+
default: () => ["album", "camera"]
|
|
129
|
+
},
|
|
121
130
|
timeout: { type: [Number, String], default: 1e3 * 30 },
|
|
122
131
|
fileList: { type: Array, default: () => [] },
|
|
123
132
|
isPreview: { type: Boolean, default: true },
|
|
@@ -126,7 +135,7 @@ const _sfc_main = create({
|
|
|
126
135
|
method: { type: String, default: "post" },
|
|
127
136
|
capture: { type: Boolean, default: false },
|
|
128
137
|
maximize: { type: [Number, String], default: Number.MAX_VALUE },
|
|
129
|
-
maximum: { type: [Number, String], default:
|
|
138
|
+
maximum: { type: [Number, String], default: 9 },
|
|
130
139
|
clearInput: { type: Boolean, default: true },
|
|
131
140
|
accept: { type: String, default: "*" },
|
|
132
141
|
headers: { type: Object, default: {} },
|
|
@@ -134,8 +143,7 @@ const _sfc_main = create({
|
|
|
134
143
|
uploadIcon: { type: String, default: "photograph" },
|
|
135
144
|
uploadIconSize: { type: [String, Number], default: "" },
|
|
136
145
|
xhrState: { type: [Number, String], default: 200 },
|
|
137
|
-
|
|
138
|
-
multiple: { type: Boolean, default: false },
|
|
146
|
+
multiple: { type: Boolean, default: true },
|
|
139
147
|
disabled: { type: Boolean, default: false },
|
|
140
148
|
autoUpload: { type: Boolean, default: true },
|
|
141
149
|
beforeUpload: {
|
|
@@ -174,60 +182,69 @@ const _sfc_main = create({
|
|
|
174
182
|
[prefixCls]: true
|
|
175
183
|
};
|
|
176
184
|
});
|
|
177
|
-
const
|
|
178
|
-
|
|
185
|
+
const chooseImage = () => {
|
|
186
|
+
if (props.disabled) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
Taro.chooseImage({
|
|
190
|
+
count: props.multiple ? props.maximum * 1 - props.fileList.length : 1,
|
|
191
|
+
sizeType: props.sizeType,
|
|
192
|
+
sourceType: props.sourceType,
|
|
193
|
+
success: onChange
|
|
194
|
+
});
|
|
179
195
|
};
|
|
180
196
|
const fileItemClick = (fileItem) => {
|
|
181
197
|
emit("file-item-click", { fileItem });
|
|
182
198
|
};
|
|
183
|
-
const executeUpload = (fileItem,
|
|
199
|
+
const executeUpload = (fileItem, index) => {
|
|
184
200
|
const uploadOption = new UploadOptions();
|
|
201
|
+
uploadOption.name = props.name;
|
|
185
202
|
uploadOption.url = props.url;
|
|
203
|
+
uploadOption.fileType = fileItem.type;
|
|
186
204
|
uploadOption.formData = fileItem.formData;
|
|
187
205
|
uploadOption.timeout = props.timeout * 1;
|
|
188
206
|
uploadOption.method = props.method;
|
|
189
207
|
uploadOption.xhrState = props.xhrState;
|
|
208
|
+
uploadOption.method = props.method;
|
|
190
209
|
uploadOption.headers = props.headers;
|
|
191
|
-
uploadOption.
|
|
210
|
+
uploadOption.taroFilePath = fileItem.path;
|
|
192
211
|
uploadOption.beforeXhrUpload = props.beforeXhrUpload;
|
|
193
|
-
try {
|
|
194
|
-
uploadOption.sourceFile = fileItem.formData.get(props.name);
|
|
195
|
-
} catch (error) {
|
|
196
|
-
}
|
|
197
212
|
uploadOption.onStart = (option) => {
|
|
198
213
|
fileItem.status = "ready";
|
|
199
214
|
fileItem.message = translate("readyUpload");
|
|
200
|
-
clearUploadQueue(
|
|
215
|
+
clearUploadQueue(index);
|
|
201
216
|
emit("start", option);
|
|
202
217
|
};
|
|
203
218
|
uploadOption.onProgress = (event, option) => {
|
|
204
219
|
fileItem.status = "uploading";
|
|
205
220
|
fileItem.message = translate("uploading");
|
|
206
|
-
fileItem.percentage =
|
|
221
|
+
fileItem.percentage = event.progress;
|
|
207
222
|
emit("progress", { event, option, percentage: fileItem.percentage });
|
|
208
223
|
};
|
|
209
|
-
uploadOption.onSuccess = (
|
|
224
|
+
uploadOption.onSuccess = (data, option) => {
|
|
210
225
|
fileItem.status = "success";
|
|
211
226
|
fileItem.message = translate("success");
|
|
212
227
|
emit("success", {
|
|
213
|
-
|
|
228
|
+
data,
|
|
229
|
+
responseText: data,
|
|
214
230
|
option,
|
|
215
231
|
fileItem
|
|
216
232
|
});
|
|
217
233
|
emit("update:fileList", fileList);
|
|
218
234
|
};
|
|
219
|
-
uploadOption.onFailure = (
|
|
235
|
+
uploadOption.onFailure = (data, option) => {
|
|
220
236
|
fileItem.status = "error";
|
|
221
237
|
fileItem.message = translate("error");
|
|
222
238
|
emit("failure", {
|
|
223
|
-
|
|
239
|
+
data,
|
|
240
|
+
responseText: data,
|
|
224
241
|
option,
|
|
225
242
|
fileItem
|
|
226
243
|
});
|
|
227
244
|
};
|
|
228
245
|
let task = new Uploader(uploadOption);
|
|
229
246
|
if (props.autoUpload) {
|
|
230
|
-
task.
|
|
247
|
+
task.uploadTaro(Taro.uploadFile, Taro.getEnv());
|
|
231
248
|
} else {
|
|
232
249
|
uploadQueue.push(
|
|
233
250
|
new Promise((resolve, reject) => {
|
|
@@ -236,9 +253,9 @@ const _sfc_main = create({
|
|
|
236
253
|
);
|
|
237
254
|
}
|
|
238
255
|
};
|
|
239
|
-
const clearUploadQueue = (
|
|
240
|
-
if (
|
|
241
|
-
uploadQueue.splice(
|
|
256
|
+
const clearUploadQueue = (index = -1) => {
|
|
257
|
+
if (index > -1) {
|
|
258
|
+
uploadQueue.splice(index, 1);
|
|
242
259
|
} else {
|
|
243
260
|
uploadQueue = [];
|
|
244
261
|
fileList.splice(0, fileList.length);
|
|
@@ -246,33 +263,40 @@ const _sfc_main = create({
|
|
|
246
263
|
};
|
|
247
264
|
const submit = () => {
|
|
248
265
|
Promise.all(uploadQueue).then((res) => {
|
|
249
|
-
res.forEach((i) => i.
|
|
266
|
+
res.forEach((i) => i.uploadTaro(Taro.uploadFile, Taro.getEnv()));
|
|
250
267
|
});
|
|
251
268
|
};
|
|
252
269
|
const readFile = (files) => {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
formData.append(props.name, file);
|
|
270
|
+
const imgReg = /\.(png|jpeg|jpg|webp|gif)$/i;
|
|
271
|
+
files.forEach((file, index) => {
|
|
272
|
+
var _a, _b;
|
|
273
|
+
let fileType = file.type;
|
|
259
274
|
const fileItem = reactive(new FileItem());
|
|
260
|
-
|
|
275
|
+
if (!fileType && imgReg.test(file.path)) {
|
|
276
|
+
fileType = "image";
|
|
277
|
+
}
|
|
278
|
+
fileItem.path = file.path;
|
|
279
|
+
fileItem.name = file.path;
|
|
261
280
|
fileItem.status = "ready";
|
|
262
|
-
fileItem.type = file.type;
|
|
263
|
-
fileItem.formData = formData;
|
|
264
281
|
fileItem.message = translate("waitingUpload");
|
|
265
|
-
|
|
266
|
-
if (
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
282
|
+
fileItem.type = fileType;
|
|
283
|
+
if (Taro.getEnv() == "WEB") {
|
|
284
|
+
const formData = new FormData();
|
|
285
|
+
for (const [key, value] of Object.entries(props.data)) {
|
|
286
|
+
formData.append(key, value);
|
|
287
|
+
}
|
|
288
|
+
formData.append(props.name, file.originalFileObj);
|
|
289
|
+
fileItem.name = (_a = file.originalFileObj) == null ? void 0 : _a.name;
|
|
290
|
+
fileItem.type = (_b = file.originalFileObj) == null ? void 0 : _b.type;
|
|
291
|
+
fileItem.formData = formData;
|
|
273
292
|
} else {
|
|
274
|
-
|
|
293
|
+
fileItem.formData = props.data;
|
|
294
|
+
}
|
|
295
|
+
if (props.isPreview) {
|
|
296
|
+
fileItem.url = file.path;
|
|
275
297
|
}
|
|
298
|
+
fileList.push(fileItem);
|
|
299
|
+
executeUpload(fileItem, index);
|
|
276
300
|
});
|
|
277
301
|
};
|
|
278
302
|
const filterFiles = (files) => {
|
|
@@ -296,59 +320,61 @@ const _sfc_main = create({
|
|
|
296
320
|
}
|
|
297
321
|
return files;
|
|
298
322
|
};
|
|
299
|
-
const deleted = (file,
|
|
300
|
-
fileList.splice(
|
|
323
|
+
const deleted = (file, index) => {
|
|
324
|
+
fileList.splice(index, 1);
|
|
301
325
|
emit("delete", {
|
|
302
326
|
file,
|
|
303
327
|
fileList,
|
|
304
|
-
index
|
|
328
|
+
index
|
|
305
329
|
});
|
|
306
330
|
};
|
|
307
|
-
const onDelete = (file,
|
|
308
|
-
clearUploadQueue(
|
|
331
|
+
const onDelete = (file, index) => {
|
|
332
|
+
clearUploadQueue(index);
|
|
309
333
|
let fn = props.beforeDelete(file, fileList);
|
|
310
334
|
if (isPromise(fn)) {
|
|
311
335
|
fn.then((res) => {
|
|
312
336
|
if (res) {
|
|
313
|
-
deleted(file,
|
|
337
|
+
deleted(file, index);
|
|
314
338
|
}
|
|
315
339
|
}).catch((error) => {
|
|
316
340
|
console.log(error, "\u7528\u6237\u963B\u6B62\u4E86\u5220\u9664\uFF01");
|
|
317
341
|
});
|
|
318
342
|
} else if (fn) {
|
|
319
|
-
deleted(file,
|
|
343
|
+
deleted(file, index);
|
|
320
344
|
} else {
|
|
321
345
|
console.log("\u7528\u6237\u963B\u6B62\u4E86\u5220\u9664\uFF01");
|
|
322
346
|
}
|
|
323
347
|
};
|
|
324
|
-
const onChange = (
|
|
325
|
-
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
const $el = event.target;
|
|
329
|
-
let { files } = $el;
|
|
348
|
+
const onChange = (res) => {
|
|
349
|
+
const { tempFilePaths, tempFiles } = res;
|
|
330
350
|
if (props.beforeUpload) {
|
|
331
|
-
props.beforeUpload(
|
|
332
|
-
const _files = filterFiles(
|
|
351
|
+
props.beforeUpload(tempFiles).then((f) => {
|
|
352
|
+
const _files = filterFiles(f);
|
|
333
353
|
readFile(_files);
|
|
334
354
|
});
|
|
335
355
|
} else {
|
|
336
|
-
const _files = filterFiles(
|
|
356
|
+
const _files = filterFiles(tempFiles);
|
|
337
357
|
readFile(_files);
|
|
338
358
|
}
|
|
339
359
|
emit("change", {
|
|
340
|
-
fileList
|
|
341
|
-
event
|
|
360
|
+
fileList
|
|
342
361
|
});
|
|
343
|
-
if (props.clearInput) {
|
|
344
|
-
clearInput($el);
|
|
345
|
-
}
|
|
346
362
|
};
|
|
363
|
+
onMounted(() => {
|
|
364
|
+
if (Taro.getEnv() == "WEB") {
|
|
365
|
+
const obj = document.createElement("input");
|
|
366
|
+
obj.setAttribute("type", "file");
|
|
367
|
+
obj.setAttribute("id", "taroChooseImage");
|
|
368
|
+
obj.setAttribute("accept", props.accept);
|
|
369
|
+
obj.setAttribute("style", "position: fixed; top: -4000px; left: -3000px; z-index: -300;");
|
|
370
|
+
document.body.appendChild(obj);
|
|
371
|
+
}
|
|
372
|
+
});
|
|
347
373
|
return {
|
|
348
|
-
onChange,
|
|
349
374
|
onDelete,
|
|
350
375
|
fileList,
|
|
351
376
|
classes,
|
|
377
|
+
chooseImage,
|
|
352
378
|
fileItemClick,
|
|
353
379
|
clearUploadQueue,
|
|
354
380
|
submit
|
|
@@ -359,37 +385,34 @@ const _hoisted_1 = {
|
|
|
359
385
|
key: 0,
|
|
360
386
|
class: "nut-uploader__slot"
|
|
361
387
|
};
|
|
362
|
-
const _hoisted_2 =
|
|
363
|
-
const _hoisted_3 = ["accept", "multiple", "name", "disabled"];
|
|
364
|
-
const _hoisted_4 = {
|
|
388
|
+
const _hoisted_2 = {
|
|
365
389
|
key: 0,
|
|
366
390
|
class: "nut-uploader__preview-img"
|
|
367
391
|
};
|
|
368
|
-
const
|
|
392
|
+
const _hoisted_3 = {
|
|
369
393
|
key: 0,
|
|
370
394
|
class: "nut-uploader__preview__progress"
|
|
371
395
|
};
|
|
372
|
-
const
|
|
373
|
-
const
|
|
396
|
+
const _hoisted_4 = { class: "nut-uploader__preview__progress__msg" };
|
|
397
|
+
const _hoisted_5 = {
|
|
374
398
|
key: 1,
|
|
375
399
|
class: "nut-uploader__preview__progress"
|
|
376
400
|
};
|
|
377
|
-
const
|
|
378
|
-
const
|
|
379
|
-
const
|
|
401
|
+
const _hoisted_6 = { class: "nut-uploader__preview__progress__msg" };
|
|
402
|
+
const _hoisted_7 = ["onClick", "src"];
|
|
403
|
+
const _hoisted_8 = {
|
|
380
404
|
key: 4,
|
|
381
405
|
class: "nut-uploader__preview-img__file"
|
|
382
406
|
};
|
|
383
|
-
const
|
|
384
|
-
const
|
|
385
|
-
const
|
|
407
|
+
const _hoisted_9 = ["onClick"];
|
|
408
|
+
const _hoisted_10 = { class: "tips" };
|
|
409
|
+
const _hoisted_11 = {
|
|
386
410
|
key: 1,
|
|
387
411
|
class: "nut-uploader__preview-list"
|
|
388
412
|
};
|
|
389
|
-
const
|
|
390
|
-
const _hoisted_15 = ["accept", "multiple", "name", "disabled"];
|
|
391
|
-
const _hoisted_16 = ["accept", "multiple", "name", "disabled"];
|
|
413
|
+
const _hoisted_12 = ["onClick"];
|
|
392
414
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
415
|
+
const _component_nut_button = resolveComponent("nut-button");
|
|
393
416
|
const _component_nut_icon = resolveComponent("nut-icon");
|
|
394
417
|
const _component_nut_progress = resolveComponent("nut-progress");
|
|
395
418
|
return openBlock(), createElementBlock("view", {
|
|
@@ -397,82 +420,74 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
397
420
|
}, [
|
|
398
421
|
_ctx.$slots.default ? (openBlock(), createElementBlock("view", _hoisted_1, [
|
|
399
422
|
renderSlot(_ctx.$slots, "default"),
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
accept: _ctx.accept,
|
|
407
|
-
multiple: _ctx.multiple,
|
|
408
|
-
name: _ctx.name,
|
|
409
|
-
disabled: _ctx.disabled,
|
|
410
|
-
onChange: _cache[0] || (_cache[0] = (...args) => _ctx.onChange && _ctx.onChange(...args))
|
|
411
|
-
}, null, 40, _hoisted_2)) : (openBlock(), createElementBlock("input", {
|
|
412
|
-
key: 1,
|
|
413
|
-
class: "nut-uploader__input",
|
|
414
|
-
type: "file",
|
|
415
|
-
accept: _ctx.accept,
|
|
416
|
-
multiple: _ctx.multiple,
|
|
417
|
-
name: _ctx.name,
|
|
418
|
-
disabled: _ctx.disabled,
|
|
419
|
-
onChange: _cache[1] || (_cache[1] = (...args) => _ctx.onChange && _ctx.onChange(...args))
|
|
420
|
-
}, null, 40, _hoisted_3))
|
|
421
|
-
], 64)) : createCommentVNode("", true)
|
|
423
|
+
createTextVNode(),
|
|
424
|
+
_ctx.maximum - _ctx.fileList.length ? (openBlock(), createBlock(_component_nut_button, {
|
|
425
|
+
key: 0,
|
|
426
|
+
class: "nut-uploader__input",
|
|
427
|
+
onClick: _ctx.chooseImage
|
|
428
|
+
}, null, 8, ["onClick"])) : createCommentVNode("", true)
|
|
422
429
|
])) : createCommentVNode("", true),
|
|
423
|
-
(
|
|
430
|
+
createTextVNode(),
|
|
431
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.fileList, (item, index) => {
|
|
432
|
+
var _a;
|
|
424
433
|
return openBlock(), createElementBlock("view", {
|
|
425
434
|
class: normalizeClass(["nut-uploader__preview", [_ctx.listType]]),
|
|
426
435
|
key: item.uid
|
|
427
436
|
}, [
|
|
428
|
-
_ctx.listType == "picture" && !_ctx.$slots.default ? (openBlock(), createElementBlock("view",
|
|
429
|
-
item.status == "ready" ? (openBlock(), createElementBlock("view",
|
|
430
|
-
createElementVNode("view",
|
|
431
|
-
])) : item.status != "success" ? (openBlock(), createElementBlock("view",
|
|
437
|
+
_ctx.listType == "picture" && !_ctx.$slots.default ? (openBlock(), createElementBlock("view", _hoisted_2, [
|
|
438
|
+
item.status == "ready" ? (openBlock(), createElementBlock("view", _hoisted_3, [
|
|
439
|
+
createElementVNode("view", _hoisted_4, toDisplayString(item.message), 1)
|
|
440
|
+
])) : item.status != "success" ? (openBlock(), createElementBlock("view", _hoisted_5, [
|
|
432
441
|
createVNode(_component_nut_icon, {
|
|
433
442
|
color: "#fff",
|
|
434
443
|
name: item.status == "error" ? "failure" : "loading"
|
|
435
444
|
}, null, 8, ["name"]),
|
|
436
|
-
|
|
445
|
+
createTextVNode(),
|
|
446
|
+
createElementVNode("view", _hoisted_6, toDisplayString(item.message), 1)
|
|
437
447
|
])) : createCommentVNode("", true),
|
|
448
|
+
createTextVNode(),
|
|
438
449
|
_ctx.isDeletable ? (openBlock(), createBlock(_component_nut_icon, {
|
|
439
450
|
key: 2,
|
|
440
|
-
onClick: ($event) => _ctx.onDelete(item,
|
|
451
|
+
onClick: ($event) => _ctx.onDelete(item, index),
|
|
441
452
|
class: "close",
|
|
442
453
|
name: "failure"
|
|
443
454
|
}, null, 8, ["onClick"])) : createCommentVNode("", true),
|
|
444
|
-
|
|
455
|
+
createTextVNode(),
|
|
456
|
+
((_a = item.type) == null ? void 0 : _a.includes("image")) && item.url ? (openBlock(), createElementBlock("img", {
|
|
445
457
|
key: 3,
|
|
446
458
|
class: "nut-uploader__preview-img__c",
|
|
447
459
|
onClick: ($event) => _ctx.fileItemClick(item),
|
|
448
460
|
src: item.url
|
|
449
|
-
}, null, 8,
|
|
461
|
+
}, null, 8, _hoisted_7)) : (openBlock(), createElementBlock("view", _hoisted_8, [
|
|
450
462
|
createElementVNode("view", {
|
|
451
|
-
|
|
452
|
-
|
|
463
|
+
class: "nut-uploader__preview-img__file__name",
|
|
464
|
+
onClick: ($event) => _ctx.fileItemClick(item)
|
|
453
465
|
}, [
|
|
454
466
|
createVNode(_component_nut_icon, {
|
|
455
467
|
color: "#808080",
|
|
456
468
|
name: "link"
|
|
457
469
|
}),
|
|
458
470
|
createTextVNode("\xA0" + toDisplayString(item.name), 1)
|
|
459
|
-
], 8,
|
|
471
|
+
], 8, _hoisted_9)
|
|
460
472
|
])),
|
|
461
|
-
|
|
462
|
-
|
|
473
|
+
createTextVNode(),
|
|
474
|
+
createElementVNode("view", _hoisted_10, toDisplayString(item.name), 1)
|
|
475
|
+
])) : _ctx.listType == "list" ? (openBlock(), createElementBlock("view", _hoisted_11, [
|
|
463
476
|
createElementVNode("view", {
|
|
464
|
-
|
|
465
|
-
|
|
477
|
+
class: normalizeClass(["nut-uploader__preview-img__file__name", [item.status]]),
|
|
478
|
+
onClick: ($event) => _ctx.fileItemClick(item)
|
|
466
479
|
}, [
|
|
467
480
|
createVNode(_component_nut_icon, { name: "link" }),
|
|
468
481
|
createTextVNode("\xA0" + toDisplayString(item.name), 1)
|
|
469
|
-
], 10,
|
|
482
|
+
], 10, _hoisted_12),
|
|
483
|
+
createTextVNode(),
|
|
470
484
|
createVNode(_component_nut_icon, {
|
|
471
485
|
class: "nut-uploader__preview-img__file__del",
|
|
472
|
-
onClick: ($event) => _ctx.onDelete(item,
|
|
486
|
+
onClick: ($event) => _ctx.onDelete(item, index),
|
|
473
487
|
color: "#808080",
|
|
474
488
|
name: "del"
|
|
475
489
|
}, null, 8, ["onClick"]),
|
|
490
|
+
createTextVNode(),
|
|
476
491
|
item.status == "uploading" ? (openBlock(), createBlock(_component_nut_progress, {
|
|
477
492
|
key: 0,
|
|
478
493
|
size: "small",
|
|
@@ -483,6 +498,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
483
498
|
])) : createCommentVNode("", true)
|
|
484
499
|
], 2);
|
|
485
500
|
}), 128)),
|
|
501
|
+
createTextVNode(),
|
|
486
502
|
_ctx.listType == "picture" && !_ctx.$slots.default && _ctx.maximum - _ctx.fileList.length ? (openBlock(), createElementBlock("view", {
|
|
487
503
|
key: 1,
|
|
488
504
|
class: normalizeClass(["nut-uploader__upload", [_ctx.listType]])
|
|
@@ -492,28 +508,13 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
492
508
|
color: "#808080",
|
|
493
509
|
name: _ctx.uploadIcon
|
|
494
510
|
}), null, 16, ["size", "name"]),
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
class: "nut-uploader__input",
|
|
498
|
-
type: "file",
|
|
499
|
-
capture: "camera",
|
|
500
|
-
accept: _ctx.accept,
|
|
501
|
-
multiple: _ctx.multiple,
|
|
502
|
-
name: _ctx.name,
|
|
503
|
-
disabled: _ctx.disabled,
|
|
504
|
-
onChange: _cache[2] || (_cache[2] = (...args) => _ctx.onChange && _ctx.onChange(...args))
|
|
505
|
-
}, null, 40, _hoisted_15)) : (openBlock(), createElementBlock("input", {
|
|
506
|
-
key: 1,
|
|
511
|
+
createTextVNode(),
|
|
512
|
+
createVNode(_component_nut_button, {
|
|
507
513
|
class: "nut-uploader__input",
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
multiple: _ctx.multiple,
|
|
511
|
-
name: _ctx.name,
|
|
512
|
-
disabled: _ctx.disabled,
|
|
513
|
-
onChange: _cache[3] || (_cache[3] = (...args) => _ctx.onChange && _ctx.onChange(...args))
|
|
514
|
-
}, null, 40, _hoisted_16))
|
|
514
|
+
onClick: _ctx.chooseImage
|
|
515
|
+
}, null, 8, ["onClick"])
|
|
515
516
|
], 2)) : createCommentVNode("", true)
|
|
516
517
|
], 2);
|
|
517
518
|
}
|
|
518
|
-
var
|
|
519
|
-
export {
|
|
519
|
+
var index_taro = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
520
|
+
export { index_taro as default };
|
|
@@ -1,12 +1,37 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.2.
|
|
2
|
+
* @nutui/nutui v3.2.6-beta.1 Mon Oct 31 2022 19:38:22 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2022 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import { reactive, ref, computed, watch, nextTick, onMounted, toRefs, openBlock, createElementBlock, createElementVNode, createCommentVNode, withDirectives, vShow, normalizeClass, toDisplayString, normalizeStyle, withModifiers } from "vue";
|
|
6
|
+
import { reactive, ref, computed, watch, nextTick, onMounted, toRefs, openBlock, createElementBlock, createElementVNode, createTextVNode, createCommentVNode, withDirectives, vShow, normalizeClass, toDisplayString, normalizeStyle, withModifiers } from "vue";
|
|
7
7
|
import { c as createComponent } from "./component.js";
|
|
8
8
|
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
9
9
|
import "../locale/lang";
|
|
10
|
+
const throttle = (func, wait, type) => {
|
|
11
|
+
if (type === 1) {
|
|
12
|
+
var previous = 0;
|
|
13
|
+
} else if (type === 2) {
|
|
14
|
+
var timeout;
|
|
15
|
+
}
|
|
16
|
+
return function() {
|
|
17
|
+
let context = this;
|
|
18
|
+
let args = arguments;
|
|
19
|
+
if (type === 1) {
|
|
20
|
+
let now = Date.now();
|
|
21
|
+
if (now - previous > wait) {
|
|
22
|
+
func.apply(context, args);
|
|
23
|
+
previous = now;
|
|
24
|
+
}
|
|
25
|
+
} else if (type === 2) {
|
|
26
|
+
if (!timeout) {
|
|
27
|
+
timeout = setTimeout(() => {
|
|
28
|
+
timeout = null;
|
|
29
|
+
func.apply(context, args);
|
|
30
|
+
}, wait);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
};
|
|
10
35
|
const { create, translate } = createComponent("video");
|
|
11
36
|
const _sfc_main = create({
|
|
12
37
|
props: {
|
|
@@ -36,7 +61,7 @@ const _sfc_main = create({
|
|
|
36
61
|
}
|
|
37
62
|
},
|
|
38
63
|
components: {},
|
|
39
|
-
emits: ["click", "play", "pause", "playend"],
|
|
64
|
+
emits: ["click", "play", "pause", "playend", "time"],
|
|
40
65
|
setup(props, { emit }) {
|
|
41
66
|
const state = reactive({
|
|
42
67
|
videoElm: null,
|
|
@@ -122,6 +147,7 @@ const _sfc_main = create({
|
|
|
122
147
|
emit("pause", state.videoElm);
|
|
123
148
|
});
|
|
124
149
|
state.videoElm.addEventListener("ended", playEnded);
|
|
150
|
+
state.videoElm.addEventListener("timeupdate", throttle(getPlayTime, 1e3, 1));
|
|
125
151
|
}
|
|
126
152
|
};
|
|
127
153
|
const customerInit = () => {
|
|
@@ -147,6 +173,7 @@ const _sfc_main = create({
|
|
|
147
173
|
state.videoElm.addEventListener("progress", () => {
|
|
148
174
|
getLoadTime();
|
|
149
175
|
});
|
|
176
|
+
state.videoElm.addEventListener("timeupdate", throttle(getPlayTime, 1e3, 1));
|
|
150
177
|
state.videoElm.addEventListener("ended", playEnded);
|
|
151
178
|
emit("play", state.videoElm);
|
|
152
179
|
} catch (e) {
|
|
@@ -158,10 +185,38 @@ const _sfc_main = create({
|
|
|
158
185
|
}
|
|
159
186
|
}
|
|
160
187
|
};
|
|
188
|
+
const timeFormat = (t) => {
|
|
189
|
+
var h = Math.floor(t / 3600);
|
|
190
|
+
if (h < 10) {
|
|
191
|
+
h = "0" + h;
|
|
192
|
+
}
|
|
193
|
+
var m = Math.floor(t % 3600 / 60);
|
|
194
|
+
if (m < 10) {
|
|
195
|
+
m = "0" + m;
|
|
196
|
+
}
|
|
197
|
+
var s = Math.round(t % 3600 % 60);
|
|
198
|
+
if (s < 10) {
|
|
199
|
+
s = "0" + s;
|
|
200
|
+
}
|
|
201
|
+
var str = "";
|
|
202
|
+
if (h != 0) {
|
|
203
|
+
str = h + ":" + m + ":" + s;
|
|
204
|
+
} else {
|
|
205
|
+
str = m + ":" + s;
|
|
206
|
+
}
|
|
207
|
+
return str;
|
|
208
|
+
};
|
|
161
209
|
const getLoadTime = () => {
|
|
162
210
|
if (state.videoSet.loaded)
|
|
163
211
|
state.videoSet.loaded = state.videoElm.buffered.end(0) / state.videoElm.duration * 100;
|
|
164
212
|
};
|
|
213
|
+
const getPlayTime = () => {
|
|
214
|
+
const percent = state.videoElm.currentTime / state.videoElm.duration;
|
|
215
|
+
state.videoSet.progress.current = Math.round(state.videoSet.progress.width * percent);
|
|
216
|
+
state.videoSet.totalTime = timeFormat(state.videoElm.duration);
|
|
217
|
+
state.videoSet.displayTime = timeFormat(state.videoElm.currentTime);
|
|
218
|
+
emit("time", state.videoSet.displayTime, state.videoSet.totalTime);
|
|
219
|
+
};
|
|
165
220
|
const playEnded = () => {
|
|
166
221
|
state.state.playing = false;
|
|
167
222
|
state.state.isEnd = true;
|
|
@@ -279,12 +334,14 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
279
334
|
type: _ctx.source.type
|
|
280
335
|
}, null, 8, _hoisted_3)
|
|
281
336
|
], 40, _hoisted_2),
|
|
337
|
+
createTextVNode(),
|
|
282
338
|
_ctx.showToolbox && !_ctx.isDisabled ? (openBlock(), createElementBlock("div", {
|
|
283
339
|
key: 0,
|
|
284
340
|
class: "playing-mask",
|
|
285
341
|
ref: "touchMask",
|
|
286
342
|
onClick: _cache[1] || (_cache[1] = (...args) => _ctx.play && _ctx.play(...args))
|
|
287
343
|
}, null, 512)) : createCommentVNode("", true),
|
|
344
|
+
createTextVNode(),
|
|
288
345
|
_ctx.showToolbox && !_ctx.isDisabled ? withDirectives((openBlock(), createElementBlock("div", {
|
|
289
346
|
key: 1,
|
|
290
347
|
class: "nut-video-play-btn",
|
|
@@ -293,6 +350,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
293
350
|
}, null, 512)), [
|
|
294
351
|
[vShow, !_ctx.state.playing]
|
|
295
352
|
]) : createCommentVNode("", true),
|
|
353
|
+
createTextVNode(),
|
|
296
354
|
withDirectives(createElementVNode("div", {
|
|
297
355
|
class: normalizeClass(["nut-video-controller", { "show-control": !_ctx.state.playing, "hide-control": _ctx.state.playing }])
|
|
298
356
|
}, [
|
|
@@ -300,13 +358,16 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
300
358
|
class: "control-play-btn",
|
|
301
359
|
onClick: _cache[3] || (_cache[3] = (...args) => _ctx.play && _ctx.play(...args))
|
|
302
360
|
}),
|
|
361
|
+
createTextVNode(),
|
|
303
362
|
createElementVNode("div", _hoisted_4, toDisplayString(_ctx.videoSet.displayTime), 1),
|
|
363
|
+
createTextVNode(),
|
|
304
364
|
createElementVNode("div", _hoisted_5, [
|
|
305
365
|
createElementVNode("div", _hoisted_6, [
|
|
306
366
|
createElementVNode("div", {
|
|
307
367
|
class: "buffered",
|
|
308
368
|
style: normalizeStyle({ width: `${_ctx.videoSet.loaded}%` })
|
|
309
369
|
}, null, 4),
|
|
370
|
+
createTextVNode(),
|
|
310
371
|
createElementVNode("div", {
|
|
311
372
|
class: "video-ball",
|
|
312
373
|
style: normalizeStyle({
|
|
@@ -316,14 +377,18 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
316
377
|
onTouchstart: _cache[5] || (_cache[5] = withModifiers(($event) => _ctx.touchSlidSrart($event), ["stop"])),
|
|
317
378
|
onTouchend: _cache[6] || (_cache[6] = withModifiers(($event) => _ctx.touchSlidEnd($event), ["stop"]))
|
|
318
379
|
}, _hoisted_8, 36),
|
|
380
|
+
createTextVNode(),
|
|
319
381
|
createElementVNode("div", _hoisted_9, null, 512)
|
|
320
382
|
], 512)
|
|
321
383
|
]),
|
|
384
|
+
createTextVNode(),
|
|
322
385
|
createElementVNode("div", _hoisted_10, toDisplayString(_ctx.videoSet.totalTime), 1),
|
|
386
|
+
createTextVNode(),
|
|
323
387
|
createElementVNode("div", {
|
|
324
388
|
class: normalizeClass(["volume", { muted: _ctx.state.isMuted }]),
|
|
325
389
|
onClick: _cache[7] || (_cache[7] = (...args) => _ctx.handleMuted && _ctx.handleMuted(...args))
|
|
326
390
|
}, null, 2),
|
|
391
|
+
createTextVNode(),
|
|
327
392
|
createElementVNode("div", {
|
|
328
393
|
class: "fullscreen-icon",
|
|
329
394
|
onClick: _cache[8] || (_cache[8] = (...args) => _ctx.fullScreen && _ctx.fullScreen(...args))
|
|
@@ -331,8 +396,10 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
331
396
|
], 2), [
|
|
332
397
|
[vShow, _ctx.showToolbox && !_ctx.isDisabled]
|
|
333
398
|
]),
|
|
399
|
+
createTextVNode(),
|
|
334
400
|
withDirectives(createElementVNode("div", _hoisted_11, [
|
|
335
401
|
createElementVNode("p", _hoisted_12, toDisplayString(_ctx.translate("errorTip")), 1),
|
|
402
|
+
createTextVNode(),
|
|
336
403
|
createElementVNode("p", {
|
|
337
404
|
class: "retry",
|
|
338
405
|
onClick: _cache[9] || (_cache[9] = (...args) => _ctx.retry && _ctx.retry(...args))
|
|
@@ -342,5 +409,5 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
342
409
|
])
|
|
343
410
|
], 512);
|
|
344
411
|
}
|
|
345
|
-
var
|
|
346
|
-
export {
|
|
412
|
+
var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
413
|
+
export { index as default };
|