zartui 3.1.93 → 3.1.94
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/es/composables/use-media-download.d.ts +20 -0
- package/es/composables/use-media-download.mjs +111 -0
- package/es/image-preview/ImagePreview.d.ts +2 -5
- package/es/image-preview/ImagePreview.mjs +32 -79
- package/es/image-preview/function-call.mjs +4 -1
- package/es/image-preview/index.css +1 -1
- package/es/image-preview/index.d.ts +1 -2
- package/es/image-preview/style/index.mjs +2 -0
- package/es/image-preview/types.d.ts +3 -1
- package/es/index.d.ts +1 -1
- package/es/index.mjs +1 -1
- package/es/media-picker/MediaPicker.d.ts +1 -1
- package/es/media-picker/MediaPicker.mjs +54 -36
- package/es/media-picker/index.d.ts +2 -2
- package/es/media-picker/style/index.mjs +3 -1
- package/es/media-player/MediaPlayer.d.ts +21 -0
- package/es/media-player/MediaPlayer.mjs +25 -2
- package/es/media-player/index.css +1 -1
- package/es/media-player/index.d.ts +14 -0
- package/es/media-player/style/index.mjs +4 -0
- package/es/photo-picker/index.d.ts +2 -2
- package/es/photo-picker/style/index.mjs +2 -0
- package/es/uploader/style/index.mjs +2 -0
- package/lib/composables/use-media-download.d.ts +20 -0
- package/lib/composables/use-media-download.js +138 -0
- package/lib/image-preview/ImagePreview.d.ts +2 -5
- package/lib/image-preview/ImagePreview.js +32 -79
- package/lib/image-preview/function-call.js +4 -1
- package/lib/image-preview/index.css +1 -1
- package/lib/image-preview/index.d.ts +1 -2
- package/lib/image-preview/style/index.js +2 -0
- package/lib/image-preview/types.d.ts +3 -1
- package/lib/index.css +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/media-picker/MediaPicker.d.ts +1 -1
- package/lib/media-picker/MediaPicker.js +51 -35
- package/lib/media-picker/index.d.ts +2 -2
- package/lib/media-picker/style/index.js +3 -1
- package/lib/media-player/MediaPlayer.d.ts +21 -0
- package/lib/media-player/MediaPlayer.js +25 -2
- package/lib/media-player/index.css +1 -1
- package/lib/media-player/index.d.ts +14 -0
- package/lib/media-player/style/index.js +4 -0
- package/lib/photo-picker/index.d.ts +2 -2
- package/lib/photo-picker/style/index.js +2 -0
- package/lib/uploader/style/index.js +2 -0
- package/lib/web-types.json +1 -1
- package/lib/zartui.cjs.js +196 -105
- package/lib/zartui.es.js +196 -105
- package/lib/zartui.js +204 -113
- package/lib/zartui.min.js +2 -2
- package/package.json +2 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type DownloadActionParams = {
|
|
2
|
+
index: number;
|
|
3
|
+
url?: string;
|
|
4
|
+
title?: string;
|
|
5
|
+
fileName?: string;
|
|
6
|
+
};
|
|
7
|
+
export type FileDownloadOptions = {
|
|
8
|
+
url: string;
|
|
9
|
+
fileName?: string;
|
|
10
|
+
title?: string;
|
|
11
|
+
index?: number;
|
|
12
|
+
};
|
|
13
|
+
export declare function useMediaDownload(props: {
|
|
14
|
+
showDownload: boolean;
|
|
15
|
+
downloadAction?: (params: DownloadActionParams) => boolean;
|
|
16
|
+
}): {
|
|
17
|
+
downloading: import("vue").Ref<boolean, boolean>;
|
|
18
|
+
download: (params: DownloadActionParams, confirm?: boolean) => Promise<void>;
|
|
19
|
+
downloadFile: (options: FileDownloadOptions) => Promise<void>;
|
|
20
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __async = (__this, __arguments, generator) => {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
var fulfilled = (value) => {
|
|
23
|
+
try {
|
|
24
|
+
step(generator.next(value));
|
|
25
|
+
} catch (e) {
|
|
26
|
+
reject(e);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var rejected = (value) => {
|
|
30
|
+
try {
|
|
31
|
+
step(generator.throw(value));
|
|
32
|
+
} catch (e) {
|
|
33
|
+
reject(e);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
import { ref } from "vue";
|
|
41
|
+
import { showConfirmDialog } from "../dialog/index.mjs";
|
|
42
|
+
import { closeToast, showFailToast, showLoadingToast, showSuccessToast } from "../toast/index.mjs";
|
|
43
|
+
function useMediaDownload(props) {
|
|
44
|
+
const downloading = ref(false);
|
|
45
|
+
const downloadInBrowser = (params) => {
|
|
46
|
+
const link = document.createElement("a");
|
|
47
|
+
link.href = params.url;
|
|
48
|
+
link.download = params.fileName || "";
|
|
49
|
+
document.body.appendChild(link);
|
|
50
|
+
link.click();
|
|
51
|
+
link.remove();
|
|
52
|
+
};
|
|
53
|
+
const download = (params, confirm = false) => __async(this, null, function* () {
|
|
54
|
+
var _a, _b, _c;
|
|
55
|
+
if (!props.showDownload || downloading.value || !params.url || params.url.startsWith("data:")) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
downloading.value = true;
|
|
59
|
+
try {
|
|
60
|
+
if (confirm) {
|
|
61
|
+
try {
|
|
62
|
+
yield showConfirmDialog({ message: "\u9644\u4EF6\u683C\u5F0F\u6682\u4E0D\u652F\u6301\u9884\u89C8\uFF0C\u662F\u5426\u4E0B\u8F7D\u539F\u6587\u4EF6" });
|
|
63
|
+
} catch (action) {
|
|
64
|
+
if (action !== "cancel") {
|
|
65
|
+
throw action;
|
|
66
|
+
}
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (!props.showDownload || ((_a = props.downloadAction) == null ? void 0 : _a.call(props, params))) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
let file;
|
|
74
|
+
try {
|
|
75
|
+
const sdk = yield import("@egova/universal-js-sdk");
|
|
76
|
+
file = (_b = sdk.getJSI()) == null ? void 0 : _b.file;
|
|
77
|
+
} catch (e) {
|
|
78
|
+
downloadInBrowser(params);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (!(file == null ? void 0 : file.download)) {
|
|
82
|
+
downloadInBrowser(params);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
showLoadingToast({ message: "\u4E0B\u8F7D\u4E2D...", forbidClick: true, duration: 0 });
|
|
86
|
+
try {
|
|
87
|
+
const result = yield file.download({ url: params.url });
|
|
88
|
+
const displayPath = (_c = result == null ? void 0 : result.tempFilePath) == null ? void 0 : _c.replace(/^\/storage\/emulated\/0\//, "");
|
|
89
|
+
closeToast();
|
|
90
|
+
showSuccessToast({
|
|
91
|
+
message: displayPath ? `\u4E0B\u8F7D\u6210\u529F
|
|
92
|
+
\u4FDD\u5B58\u8DEF\u5F84\uFF1A${displayPath}` : "\u4E0B\u8F7D\u6210\u529F",
|
|
93
|
+
duration: 5e3
|
|
94
|
+
});
|
|
95
|
+
} catch (e) {
|
|
96
|
+
closeToast();
|
|
97
|
+
showFailToast("\u4E0B\u8F7D\u5931\u8D25");
|
|
98
|
+
}
|
|
99
|
+
} finally {
|
|
100
|
+
downloading.value = false;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
const downloadFile = (options) => {
|
|
104
|
+
var _a;
|
|
105
|
+
return download(__spreadProps(__spreadValues({}, options), { index: (_a = options.index) != null ? _a : -1 }), true);
|
|
106
|
+
};
|
|
107
|
+
return { downloading, download, downloadFile };
|
|
108
|
+
}
|
|
109
|
+
export {
|
|
110
|
+
useMediaDownload
|
|
111
|
+
};
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import type { PropType, CSSProperties, ExtractPropTypes } from 'vue';
|
|
2
2
|
import { Interceptor } from '../utils';
|
|
3
3
|
import { PopupCloseIconPosition } from '../popup';
|
|
4
|
+
import type { DownloadActionParams } from '../composables/use-media-download';
|
|
4
5
|
import { ImageItem } from './types';
|
|
5
|
-
export type DownloadActionParams
|
|
6
|
-
index: number;
|
|
7
|
-
url?: string;
|
|
8
|
-
title?: string;
|
|
9
|
-
};
|
|
6
|
+
export type { DownloadActionParams, FileDownloadOptions } from '../composables/use-media-download';
|
|
10
7
|
export declare const imagePreviewProps: {
|
|
11
8
|
show: BooleanConstructor;
|
|
12
9
|
loop: {
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
var __async = (__this, __arguments, generator) => {
|
|
2
|
-
return new Promise((resolve, reject) => {
|
|
3
|
-
var fulfilled = (value) => {
|
|
4
|
-
try {
|
|
5
|
-
step(generator.next(value));
|
|
6
|
-
} catch (e) {
|
|
7
|
-
reject(e);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var rejected = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
step(generator.throw(value));
|
|
13
|
-
} catch (e) {
|
|
14
|
-
reject(e);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
1
|
import { ref, watch, nextTick, reactive, onMounted, defineComponent, createVNode as _createVNode, mergeProps as _mergeProps } from "vue";
|
|
22
2
|
import { pick, truthProp, unknownProp, windowWidth, windowHeight, makeArrayProp, makeStringProp, makeNumericProp, callInterceptor, createNamespace, HAPTICS_FEEDBACK } from "../utils/index.mjs";
|
|
23
3
|
import { useRect } from "@zartui/use";
|
|
@@ -26,8 +6,7 @@ import { Icon } from "../icon/index.mjs";
|
|
|
26
6
|
import { Swipe } from "../swipe/index.mjs";
|
|
27
7
|
import { Popup } from "../popup/index.mjs";
|
|
28
8
|
import ImagePreviewItem from "./ImagePreviewItem.mjs";
|
|
29
|
-
import {
|
|
30
|
-
import { closeToast, showFailToast, showLoadingToast, showSuccessToast } from "../toast/index.mjs";
|
|
9
|
+
import { useMediaDownload } from "../composables/use-media-download.mjs";
|
|
31
10
|
const [name, bem] = createNamespace("image-preview");
|
|
32
11
|
const popupProps = ["show", "transition", "overlayStyle", "closeOnPopstate", "teleport"];
|
|
33
12
|
const imagePreviewProps = {
|
|
@@ -64,8 +43,13 @@ var stdin_default = defineComponent({
|
|
|
64
43
|
slots
|
|
65
44
|
}) {
|
|
66
45
|
const swipeRef = ref();
|
|
46
|
+
const {
|
|
47
|
+
downloading,
|
|
48
|
+
download,
|
|
49
|
+
downloadFile
|
|
50
|
+
} = useMediaDownload(props);
|
|
67
51
|
const state = reactive({
|
|
68
|
-
active:
|
|
52
|
+
active: +props.startPosition,
|
|
69
53
|
rootWidth: 0,
|
|
70
54
|
rootHeight: 0,
|
|
71
55
|
disableZoom: false
|
|
@@ -103,71 +87,38 @@ var stdin_default = defineComponent({
|
|
|
103
87
|
}, [props.images[state.active].title]);
|
|
104
88
|
}
|
|
105
89
|
};
|
|
106
|
-
const onDownload = () =>
|
|
90
|
+
const onDownload = () => {
|
|
107
91
|
var _a, _b, _c;
|
|
108
|
-
|
|
92
|
+
return download({
|
|
109
93
|
index: state.active,
|
|
110
94
|
url: (_a = props.images[state.active]) == null ? void 0 : _a.url,
|
|
111
|
-
title: (_b = props.images[state.active]) == null ? void 0 : _b.title
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
message: "\u4E0B\u8F7D\u4E2D...",
|
|
126
|
-
forbidClick: true,
|
|
127
|
-
duration: 0
|
|
128
|
-
});
|
|
129
|
-
fileJsi.download({
|
|
130
|
-
url: downloadParams.url
|
|
131
|
-
}).then(({
|
|
132
|
-
tempFilePath
|
|
133
|
-
}) => {
|
|
134
|
-
closeToast();
|
|
135
|
-
showSuccessToast("\u4E0B\u8F7D\u6210\u529F");
|
|
136
|
-
}).catch(() => {
|
|
137
|
-
closeToast();
|
|
138
|
-
showFailToast("\u4E0B\u8F7D\u5931\u8D25");
|
|
139
|
-
});
|
|
140
|
-
return;
|
|
141
|
-
} else {
|
|
142
|
-
showFailToast("\u5F53\u524D\u73AF\u5883\u6682\u4E0D\u652F\u6301\u4E0B\u8F7D");
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
} catch (e) {
|
|
146
|
-
console.log(e.message);
|
|
147
|
-
}
|
|
148
|
-
});
|
|
95
|
+
title: (_b = props.images[state.active]) == null ? void 0 : _b.title,
|
|
96
|
+
fileName: (_c = props.images[state.active]) == null ? void 0 : _c.fileName
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
const renderDownloadIcon = () => _createVNode("button", {
|
|
100
|
+
"type": "button",
|
|
101
|
+
"class": bem("download-icon"),
|
|
102
|
+
"aria-label": "\u4E0B\u8F7D\u539F\u56FE",
|
|
103
|
+
"disabled": downloading.value,
|
|
104
|
+
"onClick": onDownload
|
|
105
|
+
}, [_createVNode(Icon, {
|
|
106
|
+
"name": "download",
|
|
107
|
+
"size": "24"
|
|
108
|
+
}, null)]);
|
|
149
109
|
const renderIndex = () => {
|
|
150
110
|
const image = props.images[state.active];
|
|
151
|
-
const showDownload = props.showDownload && !image.url.startsWith("data:");
|
|
111
|
+
const showDownload = props.showDownload && (image == null ? void 0 : image.url) && !image.url.startsWith("data:");
|
|
152
112
|
if (props.showIndex || showDownload) {
|
|
153
|
-
if (props.showIndex && slots.index) {
|
|
154
|
-
return _createVNode("div", {
|
|
155
|
-
"class": bem("index")
|
|
156
|
-
}, [slots.index({
|
|
157
|
-
index: state.active
|
|
158
|
-
})]);
|
|
159
|
-
}
|
|
160
113
|
return _createVNode("div", {
|
|
161
114
|
"class": bem("index")
|
|
162
|
-
}, [props.showIndex &&
|
|
115
|
+
}, [props.showIndex && _createVNode("div", {
|
|
116
|
+
"class": bem("index-content")
|
|
117
|
+
}, [slots.index ? slots.index({
|
|
118
|
+
index: state.active
|
|
119
|
+
}) : [renderIndexText(), renderImageTitle()]]), showDownload && renderDownloadIcon()]);
|
|
163
120
|
}
|
|
164
121
|
};
|
|
165
|
-
const renderDownloadIcon = () => {
|
|
166
|
-
return _createVNode("div", {
|
|
167
|
-
"class": bem("download-icon"),
|
|
168
|
-
"onClick": onDownload
|
|
169
|
-
}, [Download(bem)]);
|
|
170
|
-
};
|
|
171
122
|
const renderCover = () => {
|
|
172
123
|
if (slots.cover) {
|
|
173
124
|
return _createVNode("div", {
|
|
@@ -229,7 +180,8 @@ var stdin_default = defineComponent({
|
|
|
229
180
|
return (_a = swipeRef.value) == null ? void 0 : _a.swipeTo(index, options);
|
|
230
181
|
};
|
|
231
182
|
useExpose({
|
|
232
|
-
swipeTo
|
|
183
|
+
swipeTo,
|
|
184
|
+
downloadFile
|
|
233
185
|
});
|
|
234
186
|
onMounted(() => {
|
|
235
187
|
resize();
|
|
@@ -259,6 +211,7 @@ var stdin_default = defineComponent({
|
|
|
259
211
|
return () => _createVNode(Popup, _mergeProps({
|
|
260
212
|
"class": [bem(), props.className],
|
|
261
213
|
"overlayClass": [bem("overlay"), props.overlayClass],
|
|
214
|
+
"onClick": (event) => event.stopPropagation(),
|
|
262
215
|
"onClosed": onClosed,
|
|
263
216
|
"onUpdate:show": updateShow
|
|
264
217
|
}, pick(props, popupProps)), {
|
|
@@ -15,6 +15,8 @@ const defaultConfig = {
|
|
|
15
15
|
className: "",
|
|
16
16
|
showIndex: true,
|
|
17
17
|
closeable: false,
|
|
18
|
+
showDownload: false,
|
|
19
|
+
downloadAction: void 0,
|
|
18
20
|
closeIcon: "clear",
|
|
19
21
|
transition: void 0,
|
|
20
22
|
beforeClose: void 0,
|
|
@@ -63,7 +65,8 @@ const showImagePreview = (options, startPosition = 0) => {
|
|
|
63
65
|
}
|
|
64
66
|
return {
|
|
65
67
|
url: opt.url,
|
|
66
|
-
title: opt.title || ""
|
|
68
|
+
title: opt.title || "",
|
|
69
|
+
fileName: opt.fileName
|
|
67
70
|
};
|
|
68
71
|
}),
|
|
69
72
|
startPosition
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:root{--zt-image-preview-index-height: 48px;--zt-image-preview-index-background: var(--zt-gray-a4);--zt-image-preview-index-text-color: var(--zt-white);--zt-image-preview-overlay-background: rgba(0, 0, 0, .9);--zt-image-preview-close-icon-color: var(--zt-gray-5);--zt-image-preview-close-icon-margin: var(--zt-padding-md);--zt-image-preview-close-icon-z-index: 1;--zt-image-preview-error-font-size: 36px}:root[zt-theme-size=large]{--zt-image-preview-error-font-size: 42px}.zt-image-preview{position:fixed;top:0;left:0;width:100%;height:100%;max-width:none;background-color:transparent;transform:none}.zt-image-preview__swipe{height:100%}.zt-image-preview__swipe-item{display:flex;align-items:center;justify-content:center;overflow:hidden}.zt-image-preview__cover{position:absolute;top:0;left:0}.zt-image-preview__image,.zt-image-preview__image-wrap{width:100%;transition-property:transform}.zt-image-preview__image--vertical,.zt-image-preview__image-wrap--vertical{width:auto;height:100%}.zt-image-preview__image img,.zt-image-preview__image-wrap img,.zt-image-preview__image video,.zt-image-preview__image-wrap video{-webkit-user-drag:none}.zt-image-preview__image .zt-image__error,.zt-image-preview__image-wrap .zt-image__error{top:30%;height:40%}.zt-image-preview__image .zt-image__error-icon,.zt-image-preview__image-wrap .zt-image__error-icon{font-size:var(--zt-image-preview-error-font-size)}.zt-image-preview__image .zt-image__loading,.zt-image-preview__image-wrap .zt-image__loading{background-color:transparent}.zt-image-preview__index{box-sizing:border-box;display:flex;align-items:center;position:absolute;bottom:0;left:0;width:100%;height:var(--zt-image-preview-index-height);padding:0 16px;background-color:var(--zt-image-preview-index-background);color:var(--zt-image-preview-index-text-color);overflow:hidden}.zt-image-preview__index-number{height:var(--zt-line-height-xl);background:rgba(45,75,115,.8);border-radius:2px;font-size:var(--zt-font-size-sm);text-align:center;line-height:var(--zt-line-height-xl);padding:0 8px}.zt-image-preview__title{flex-shrink:0;margin-left:8px;margin-right:8px;font-size:var(--zt-font-size-md);line-height:var(--zt-line-height-md)}.zt-image-
|
|
1
|
+
:root{--zt-image-preview-index-height: 48px;--zt-image-preview-index-background: var(--zt-gray-a4);--zt-image-preview-index-text-color: var(--zt-white);--zt-image-preview-overlay-background: rgba(0, 0, 0, .9);--zt-image-preview-close-icon-color: var(--zt-gray-5);--zt-image-preview-close-icon-margin: var(--zt-padding-md);--zt-image-preview-close-icon-z-index: 1;--zt-image-preview-error-font-size: 36px}:root[zt-theme-size=large]{--zt-image-preview-error-font-size: 42px}.zt-image-preview{position:fixed;top:0;left:0;width:100%;height:100%;max-width:none;background-color:transparent;transform:none}.zt-image-preview__swipe{height:100%}.zt-image-preview__swipe-item{display:flex;align-items:center;justify-content:center;overflow:hidden}.zt-image-preview__cover{position:absolute;top:0;left:0}.zt-image-preview__image,.zt-image-preview__image-wrap{width:100%;transition-property:transform}.zt-image-preview__image--vertical,.zt-image-preview__image-wrap--vertical{width:auto;height:100%}.zt-image-preview__image img,.zt-image-preview__image-wrap img,.zt-image-preview__image video,.zt-image-preview__image-wrap video{-webkit-user-drag:none}.zt-image-preview__image .zt-image__error,.zt-image-preview__image-wrap .zt-image__error{top:30%;height:40%}.zt-image-preview__image .zt-image__error-icon,.zt-image-preview__image-wrap .zt-image__error-icon{font-size:var(--zt-image-preview-error-font-size)}.zt-image-preview__image .zt-image__loading,.zt-image-preview__image-wrap .zt-image__loading{background-color:transparent}.zt-image-preview__index{box-sizing:border-box;display:flex;align-items:center;position:absolute;bottom:0;left:0;width:100%;height:var(--zt-image-preview-index-height);padding:0 16px;background-color:var(--zt-image-preview-index-background);color:var(--zt-image-preview-index-text-color);overflow:hidden}.zt-image-preview__index-number{height:var(--zt-line-height-xl);background:rgba(45,75,115,.8);border-radius:2px;font-size:var(--zt-font-size-sm);text-align:center;line-height:var(--zt-line-height-xl);padding:0 8px}.zt-image-preview__title{flex-shrink:0;margin-left:8px;margin-right:8px;font-size:var(--zt-font-size-md);line-height:var(--zt-line-height-md)}.zt-image-preview__index-content{display:flex;align-items:center;flex:1;min-width:0;height:100%;overflow:hidden}.zt-image-preview__download-icon{display:flex;align-items:center;border:0;background:transparent;color:inherit;flex-shrink:0;margin-left:auto;padding:4px;cursor:pointer}.zt-image-preview__overlay{background:var(--zt-image-preview-overlay-background)}.zt-image-preview__close-icon{position:absolute;z-index:var(--zt-image-preview-close-icon-z-index);color:var(--zt-image-preview-close-icon-color);font-size:var(--zt-font-size-xxxl)}.zt-image-preview__close-icon--top-left{top:var(--zt-image-preview-close-icon-margin);left:var(--zt-image-preview-close-icon-margin)}.zt-image-preview__close-icon--top-right{top:var(--zt-image-preview-close-icon-margin);right:var(--zt-image-preview-close-icon-margin)}.zt-image-preview__close-icon--bottom-left{bottom:var(--zt-image-preview-close-icon-margin);left:var(--zt-image-preview-close-icon-margin)}.zt-image-preview__close-icon--bottom-right{right:var(--zt-image-preview-close-icon-margin);bottom:var(--zt-image-preview-close-icon-margin)}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ImagePreviewProps } from './ImagePreview';
|
|
2
1
|
export declare const ImagePreview: import("../utils").WithInstall<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
3
2
|
show: BooleanConstructor;
|
|
4
3
|
loop: {
|
|
@@ -148,7 +147,7 @@ export declare const ImagePreview: import("../utils").WithInstall<import("vue").
|
|
|
148
147
|
export default ImagePreview;
|
|
149
148
|
export { imagePreviewProps } from './ImagePreview';
|
|
150
149
|
export { showImagePreview } from './function-call';
|
|
151
|
-
export type { ImagePreviewProps };
|
|
150
|
+
export type { ImagePreviewProps, DownloadActionParams, FileDownloadOptions } from './ImagePreview';
|
|
152
151
|
export type { ImageItem, ImagePreviewOptions, ImagePreviewInstance, ImagePreviewScaleEventParams, ImagePreviewThemeVars, } from './types';
|
|
153
152
|
declare module 'vue' {
|
|
154
153
|
interface GlobalComponents {
|
|
@@ -6,6 +6,8 @@ import "../../overlay/index.css";
|
|
|
6
6
|
import "../../popup/index.css";
|
|
7
7
|
import "../../loading/index.css";
|
|
8
8
|
import "../../toast/index.css";
|
|
9
|
+
import "../../button/index.css";
|
|
10
|
+
import "../../dialog/index.css";
|
|
9
11
|
import "../../swipe/index.css";
|
|
10
12
|
import "../../swipe-item/index.css";
|
|
11
13
|
import "../index.css";
|
|
@@ -2,10 +2,11 @@ import type { CSSProperties, TeleportProps, ComponentPublicInstance } from 'vue'
|
|
|
2
2
|
import type { Interceptor } from '../utils';
|
|
3
3
|
import type { SwipeToOptions } from '../swipe';
|
|
4
4
|
import type { PopupCloseIconPosition } from '../popup';
|
|
5
|
-
import type { DownloadActionParams, ImagePreviewProps } from './ImagePreview';
|
|
5
|
+
import type { DownloadActionParams, FileDownloadOptions, ImagePreviewProps } from './ImagePreview';
|
|
6
6
|
export type ImageItem = {
|
|
7
7
|
url: string;
|
|
8
8
|
title?: string;
|
|
9
|
+
fileName?: string;
|
|
9
10
|
};
|
|
10
11
|
export type ImagePreviewOptions = {
|
|
11
12
|
loop?: boolean;
|
|
@@ -41,6 +42,7 @@ export type ImagePreviewScaleEventParams = {
|
|
|
41
42
|
index: number;
|
|
42
43
|
};
|
|
43
44
|
export type ImagePreviewExpose = {
|
|
45
|
+
downloadFile: (options: FileDownloadOptions) => Promise<void>;
|
|
44
46
|
swipeTo: (index: number, options?: SwipeToOptions) => void;
|
|
45
47
|
};
|
|
46
48
|
export type ImagePreviewInstance = ComponentPublicInstance<ImagePreviewProps, ImagePreviewExpose>;
|
package/es/index.d.ts
CHANGED
package/es/index.mjs
CHANGED
|
@@ -79,7 +79,7 @@ import { Timeline } from "./timeline/index.mjs";
|
|
|
79
79
|
import { Toast } from "./toast/index.mjs";
|
|
80
80
|
import { Uploader } from "./uploader/index.mjs";
|
|
81
81
|
import { Video } from "./video/index.mjs";
|
|
82
|
-
const version = "3.1.
|
|
82
|
+
const version = "3.1.94";
|
|
83
83
|
function install(app) {
|
|
84
84
|
const components = [
|
|
85
85
|
ActionSheet,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentPublicInstance, ExtractPropTypes, PropType } from 'vue';
|
|
2
2
|
import type { Media, MediaAddType, MediaAfterRead, MediaBeforeDelete, MediaBeforeRead, MediaPick, MediaPreview, MediaSizeType, MediaType } from './type';
|
|
3
3
|
import { MediaPlayerProps } from '../media-player';
|
|
4
|
-
import { DownloadActionParams } from '../
|
|
4
|
+
import type { DownloadActionParams } from '../composables/use-media-download';
|
|
5
5
|
declare const mediaPickerProps: {
|
|
6
6
|
sortable: {
|
|
7
7
|
type: BooleanConstructor;
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1
20
|
var __async = (__this, __arguments, generator) => {
|
|
2
21
|
return new Promise((resolve, reject) => {
|
|
3
22
|
var fulfilled = (value) => {
|
|
@@ -21,7 +40,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
21
40
|
import { createVNode as _createVNode, mergeProps as _mergeProps, vShow as _vShow, withDirectives as _withDirectives } from "vue";
|
|
22
41
|
import { createNamespace, isDef, isWeixin, makeArrayProp, makeNumberProp, makeStringProp, truthProp } from "../utils/index.mjs";
|
|
23
42
|
import { computed, defineComponent, nextTick, onBeforeUnmount, ref, watch } from "vue";
|
|
24
|
-
import { showFailToast
|
|
43
|
+
import { showFailToast } from "../toast/index.mjs";
|
|
25
44
|
import DeleteIcon from "./image/DeleteIcon.mjs";
|
|
26
45
|
import { fileTypeFromBuffer } from "file-type";
|
|
27
46
|
import ZtGrid from "../grid/index.mjs";
|
|
@@ -46,6 +65,7 @@ import { isEmptyValue } from "../field/utils.mjs";
|
|
|
46
65
|
import { wxUploadImage } from "./util/wx-util.mjs";
|
|
47
66
|
import { useExpose } from "../composables/use-expose.mjs";
|
|
48
67
|
import Sortable from "sortablejs";
|
|
68
|
+
import { useMediaDownload } from "../composables/use-media-download.mjs";
|
|
49
69
|
const [name, bem] = createNamespace("media-picker");
|
|
50
70
|
const FILE_SIZE_LIMIT = 100;
|
|
51
71
|
const COMPATIBLE_TYPE_MAPPINGS = {
|
|
@@ -131,6 +151,9 @@ var stdin_default = defineComponent({
|
|
|
131
151
|
emit,
|
|
132
152
|
slots
|
|
133
153
|
}) {
|
|
154
|
+
const {
|
|
155
|
+
downloadFile
|
|
156
|
+
} = useMediaDownload(props);
|
|
134
157
|
const videoOptionsVisible = ref(false);
|
|
135
158
|
const audioOptionsVisible = ref(false);
|
|
136
159
|
const photoOptionsVisible = ref(false);
|
|
@@ -138,6 +161,8 @@ var stdin_default = defineComponent({
|
|
|
138
161
|
const mediaPlayerVisible = ref(false);
|
|
139
162
|
const mediaTypeToPlay = ref("file");
|
|
140
163
|
const mediaUrlToPlay = ref("");
|
|
164
|
+
const mediaFileNameToPlay = ref("");
|
|
165
|
+
const mediaIndexToPlay = ref(0);
|
|
141
166
|
const cameraInputRef = ref();
|
|
142
167
|
const imageInputRef = ref();
|
|
143
168
|
const camcorderInputRef = ref();
|
|
@@ -823,7 +848,6 @@ var stdin_default = defineComponent({
|
|
|
823
848
|
deleteMedia(media, index);
|
|
824
849
|
});
|
|
825
850
|
const previewMedia = (index) => __async(this, null, function* () {
|
|
826
|
-
var _a;
|
|
827
851
|
if (props.preview && (yield props.preview(props.mediaList, index))) {
|
|
828
852
|
return;
|
|
829
853
|
}
|
|
@@ -832,7 +856,9 @@ var stdin_default = defineComponent({
|
|
|
832
856
|
const imageIndex = imageList.value.indexOf(media);
|
|
833
857
|
showImagePreview({
|
|
834
858
|
images: imageList.value.map((image) => ({
|
|
835
|
-
url: image.url || image.showSrc || ""
|
|
859
|
+
url: image.url || image.showSrc || "",
|
|
860
|
+
title: image.label,
|
|
861
|
+
fileName: image.originalName || image.fileName
|
|
836
862
|
})),
|
|
837
863
|
showDownload: props.showDownload,
|
|
838
864
|
downloadAction: props.downloadAction,
|
|
@@ -844,45 +870,28 @@ var stdin_default = defineComponent({
|
|
|
844
870
|
showFailToast("\u6587\u4EF6\u53C2\u6570\u7F3A\u5931");
|
|
845
871
|
} else {
|
|
846
872
|
mediaTypeToPlay.value = media.type;
|
|
873
|
+
mediaFileNameToPlay.value = media.originalName || media.fileName;
|
|
874
|
+
mediaIndexToPlay.value = index;
|
|
847
875
|
mediaUrlToPlay.value = media.url || (URL || webkitURL).createObjectURL(media.file);
|
|
848
876
|
mediaPlayerVisible.value = true;
|
|
849
877
|
}
|
|
850
878
|
} else if (media.type === "file") {
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
url: media.url
|
|
863
|
-
}).then(({
|
|
864
|
-
tempFilePath
|
|
865
|
-
}) => {
|
|
866
|
-
if (fileJsi && fileJsi.openDocument) {
|
|
867
|
-
fileJsi.openDocument({
|
|
868
|
-
localFilePath: tempFilePath
|
|
869
|
-
}).finally(() => {
|
|
870
|
-
closeToast();
|
|
871
|
-
});
|
|
872
|
-
} else {
|
|
873
|
-
closeToast();
|
|
874
|
-
}
|
|
875
|
-
}).catch(() => {
|
|
876
|
-
closeToast();
|
|
877
|
-
showFailToast("\u4E0B\u8F7D\u5931\u8D25");
|
|
878
|
-
});
|
|
879
|
-
return;
|
|
879
|
+
if (props.showDownload) {
|
|
880
|
+
const url = media.url || (media.file ? URL.createObjectURL(media.file) : "");
|
|
881
|
+
try {
|
|
882
|
+
yield downloadFile({
|
|
883
|
+
url,
|
|
884
|
+
fileName: media.originalName || media.fileName,
|
|
885
|
+
index
|
|
886
|
+
});
|
|
887
|
+
} finally {
|
|
888
|
+
if (!media.url && url) {
|
|
889
|
+
URL.revokeObjectURL(url);
|
|
880
890
|
}
|
|
881
891
|
}
|
|
882
|
-
}
|
|
883
|
-
|
|
892
|
+
} else {
|
|
893
|
+
showFailToast("\u6682\u4E0D\u652F\u6301\u6B64\u7C7B\u6587\u4EF6\u7684\u9884\u89C8");
|
|
884
894
|
}
|
|
885
|
-
showFailToast("\u6682\u4E0D\u652F\u6301\u6B64\u7C7B\u6587\u4EF6\u7684\u9884\u89C8");
|
|
886
895
|
}
|
|
887
896
|
});
|
|
888
897
|
const renderMediaListPlaceholder = () => {
|
|
@@ -949,7 +958,16 @@ var stdin_default = defineComponent({
|
|
|
949
958
|
"mediaType": mediaTypeToPlay.value,
|
|
950
959
|
"mediaUrl": mediaUrlToPlay.value,
|
|
951
960
|
"teleport": "body"
|
|
952
|
-
}, props.mediaPlayerProps
|
|
961
|
+
}, props.mediaPlayerProps, {
|
|
962
|
+
"showDownload": props.showDownload,
|
|
963
|
+
"fileName": mediaFileNameToPlay.value,
|
|
964
|
+
"downloadAction": (params) => {
|
|
965
|
+
var _a, _b, _c;
|
|
966
|
+
return (_c = (_b = props.downloadAction || ((_a = props.mediaPlayerProps) == null ? void 0 : _a.downloadAction)) == null ? void 0 : _b(__spreadProps(__spreadValues({}, params), {
|
|
967
|
+
index: mediaIndexToPlay.value
|
|
968
|
+
}))) != null ? _c : false;
|
|
969
|
+
}
|
|
970
|
+
}), null), _createVNode(ZtActionSheet, {
|
|
953
971
|
"show": actionVisible.value,
|
|
954
972
|
"onUpdate:show": ($event) => actionVisible.value = $event,
|
|
955
973
|
"actions": actionOptions.value,
|
|
@@ -6,7 +6,7 @@ export declare const MediaPicker: import("../utils").WithInstall<import("vue").D
|
|
|
6
6
|
disabled: BooleanConstructor;
|
|
7
7
|
showTitle: BooleanConstructor;
|
|
8
8
|
showDownload: BooleanConstructor;
|
|
9
|
-
downloadAction: import("vue").PropType<(params: import("
|
|
9
|
+
downloadAction: import("vue").PropType<(params: import("..").DownloadActionParams) => boolean>;
|
|
10
10
|
useFileNameAsLabel: BooleanConstructor;
|
|
11
11
|
title: {
|
|
12
12
|
type: import("vue").PropType<string>;
|
|
@@ -84,7 +84,7 @@ export declare const MediaPicker: import("../utils").WithInstall<import("vue").D
|
|
|
84
84
|
disabled: BooleanConstructor;
|
|
85
85
|
showTitle: BooleanConstructor;
|
|
86
86
|
showDownload: BooleanConstructor;
|
|
87
|
-
downloadAction: import("vue").PropType<(params: import("
|
|
87
|
+
downloadAction: import("vue").PropType<(params: import("..").DownloadActionParams) => boolean>;
|
|
88
88
|
useFileNameAsLabel: BooleanConstructor;
|
|
89
89
|
title: {
|
|
90
90
|
type: import("vue").PropType<string>;
|
|
@@ -4,9 +4,11 @@ import "../../icon/index.css";
|
|
|
4
4
|
import "../../image/index.css";
|
|
5
5
|
import "../../overlay/index.css";
|
|
6
6
|
import "../../popup/index.css";
|
|
7
|
-
import "../../media-player/index.css";
|
|
8
7
|
import "../../loading/index.css";
|
|
9
8
|
import "../../toast/index.css";
|
|
9
|
+
import "../../button/index.css";
|
|
10
|
+
import "../../dialog/index.css";
|
|
11
|
+
import "../../media-player/index.css";
|
|
10
12
|
import "../../action-sheet/index.css";
|
|
11
13
|
import "../../swipe/index.css";
|
|
12
14
|
import "../../swipe-item/index.css";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { MediaType } from '../media-picker/type';
|
|
2
2
|
import { ExtractPropTypes, PropType } from 'vue';
|
|
3
|
+
import type { DownloadActionParams } from '../composables/use-media-download';
|
|
3
4
|
declare const mediaPlayerProps: {
|
|
4
5
|
show: BooleanConstructor;
|
|
5
6
|
mediaType: {
|
|
@@ -10,6 +11,12 @@ declare const mediaPlayerProps: {
|
|
|
10
11
|
type: PropType<string>;
|
|
11
12
|
default: string;
|
|
12
13
|
};
|
|
14
|
+
fileName: {
|
|
15
|
+
type: PropType<string>;
|
|
16
|
+
default: string;
|
|
17
|
+
};
|
|
18
|
+
showDownload: BooleanConstructor;
|
|
19
|
+
downloadAction: PropType<(params: DownloadActionParams) => boolean>;
|
|
13
20
|
/** 视频播放时的控件展示列表,参考:https://wicg.github.io/controls-list/explainer.html */
|
|
14
21
|
controlsList: {
|
|
15
22
|
type: PropType<string[]>;
|
|
@@ -28,6 +35,12 @@ declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
|
|
|
28
35
|
type: PropType<string>;
|
|
29
36
|
default: string;
|
|
30
37
|
};
|
|
38
|
+
fileName: {
|
|
39
|
+
type: PropType<string>;
|
|
40
|
+
default: string;
|
|
41
|
+
};
|
|
42
|
+
showDownload: BooleanConstructor;
|
|
43
|
+
downloadAction: PropType<(params: DownloadActionParams) => boolean>;
|
|
31
44
|
/** 视频播放时的控件展示列表,参考:https://wicg.github.io/controls-list/explainer.html */
|
|
32
45
|
controlsList: {
|
|
33
46
|
type: PropType<string[]>;
|
|
@@ -44,6 +57,12 @@ declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
|
|
|
44
57
|
type: PropType<string>;
|
|
45
58
|
default: string;
|
|
46
59
|
};
|
|
60
|
+
fileName: {
|
|
61
|
+
type: PropType<string>;
|
|
62
|
+
default: string;
|
|
63
|
+
};
|
|
64
|
+
showDownload: BooleanConstructor;
|
|
65
|
+
downloadAction: PropType<(params: DownloadActionParams) => boolean>;
|
|
47
66
|
/** 视频播放时的控件展示列表,参考:https://wicg.github.io/controls-list/explainer.html */
|
|
48
67
|
controlsList: {
|
|
49
68
|
type: PropType<string[]>;
|
|
@@ -55,7 +74,9 @@ declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
|
|
|
55
74
|
}>, {
|
|
56
75
|
show: boolean;
|
|
57
76
|
controlsList: string[];
|
|
77
|
+
showDownload: boolean;
|
|
58
78
|
mediaType: MediaType;
|
|
59
79
|
mediaUrl: string;
|
|
80
|
+
fileName: string;
|
|
60
81
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
61
82
|
export default _default;
|