@jt-home/mfe-components 1.0.62-beta.0 → 1.0.62
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/dist/JtAttachmentPreview/index.cjs +1 -2
- package/dist/JtAttachmentPreview/index.mjs +1118 -8
- package/dist/JtAttachmentPreview/style.css +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +1678 -1680
- package/dist/locale/index.cjs +1 -0
- package/dist/locale/index.mjs +629 -0
- package/dist/pdf-BmBuG7of.js +18058 -0
- package/dist/pdf-Da0bm_Ya.cjs +55 -0
- package/dist/pdf.worker.min-4PI-nNLo.js +4 -0
- package/dist/pdf.worker.min-BAJUPwg6.cjs +1 -0
- package/dist/style.css +1 -1
- package/dist/types/components/JtAttachmentPreview/index.d.ts +3 -3
- package/dist/types/components/JtAttachmentPreview/types.d.ts +4 -6
- package/dist/types/components/form/types.d.ts +4 -1
- package/dist/types/components/globalInfo/model/slotIdentity.d.ts +1 -1
- package/dist/types/components/globalInfo/model/types.d.ts +1 -1
- package/dist/types/locale/index.d.ts +2 -1
- package/dist/types/locale/types.d.ts +1 -2
- package/dist/types/main.d.ts +1 -5
- package/package.json +32 -28
- package/readme.md +694 -694
- package/dist/index-BdgCXrMw.js +0 -1542
- package/dist/index-DtqPcdZG.cjs +0 -1
|
@@ -1,10 +1,1120 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import "
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { t as c } from "../locale/index.mjs";
|
|
2
|
+
import { defineComponent as L, openBlock as q, createElementBlock as N, createElementVNode as S, ref as B, watch as ne, onBeforeUnmount as G, h as r, computed as x, onMounted as V, nextTick as ue, render as j } from "vue";
|
|
3
|
+
import { ElIcon as U } from "element-plus";
|
|
4
|
+
/*! Element Plus Icons Vue v2.3.2 */
|
|
5
|
+
var de = /* @__PURE__ */ L({
|
|
6
|
+
name: "Download",
|
|
7
|
+
__name: "download",
|
|
8
|
+
setup(e) {
|
|
9
|
+
return (t, n) => (q(), N("svg", {
|
|
10
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
11
|
+
viewBox: "0 0 1024 1024"
|
|
12
|
+
}, [
|
|
13
|
+
S("path", {
|
|
14
|
+
fill: "currentColor",
|
|
15
|
+
d: "M160 832h704a32 32 0 1 1 0 64H160a32 32 0 1 1 0-64m384-253.696 236.288-236.352 45.248 45.248L508.8 704 192 387.2l45.248-45.248L480 584.704V128h64z"
|
|
16
|
+
})
|
|
17
|
+
]));
|
|
18
|
+
}
|
|
19
|
+
}), me = de, ve = /* @__PURE__ */ L({
|
|
20
|
+
name: "RefreshLeft",
|
|
21
|
+
__name: "refresh-left",
|
|
22
|
+
setup(e) {
|
|
23
|
+
return (t, n) => (q(), N("svg", {
|
|
24
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
25
|
+
viewBox: "0 0 1024 1024"
|
|
26
|
+
}, [
|
|
27
|
+
S("path", {
|
|
28
|
+
fill: "currentColor",
|
|
29
|
+
d: "M289.088 296.704h92.992a32 32 0 0 1 0 64H232.96a32 32 0 0 1-32-32V179.712a32 32 0 0 1 64 0v50.56a384 384 0 0 1 643.84 282.88 384 384 0 0 1-383.936 384 384 384 0 0 1-384-384h64a320 320 0 1 0 640 0 320 320 0 0 0-555.712-216.448z"
|
|
30
|
+
})
|
|
31
|
+
]));
|
|
32
|
+
}
|
|
33
|
+
}), fe = ve, we = /* @__PURE__ */ L({
|
|
34
|
+
name: "ZoomIn",
|
|
35
|
+
__name: "zoom-in",
|
|
36
|
+
setup(e) {
|
|
37
|
+
return (t, n) => (q(), N("svg", {
|
|
38
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
39
|
+
viewBox: "0 0 1024 1024"
|
|
40
|
+
}, [
|
|
41
|
+
S("path", {
|
|
42
|
+
fill: "currentColor",
|
|
43
|
+
d: "m795.904 750.72 124.992 124.928a32 32 0 0 1-45.248 45.248L750.656 795.904a416 416 0 1 1 45.248-45.248zM480 832a352 352 0 1 0 0-704 352 352 0 0 0 0 704m-32-384v-96a32 32 0 0 1 64 0v96h96a32 32 0 0 1 0 64h-96v96a32 32 0 0 1-64 0v-96h-96a32 32 0 0 1 0-64z"
|
|
44
|
+
})
|
|
45
|
+
]));
|
|
46
|
+
}
|
|
47
|
+
}), pe = we, he = /* @__PURE__ */ L({
|
|
48
|
+
name: "ZoomOut",
|
|
49
|
+
__name: "zoom-out",
|
|
50
|
+
setup(e) {
|
|
51
|
+
return (t, n) => (q(), N("svg", {
|
|
52
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
53
|
+
viewBox: "0 0 1024 1024"
|
|
54
|
+
}, [
|
|
55
|
+
S("path", {
|
|
56
|
+
fill: "currentColor",
|
|
57
|
+
d: "m795.904 750.72 124.992 124.928a32 32 0 0 1-45.248 45.248L750.656 795.904a416 416 0 1 1 45.248-45.248zM480 832a352 352 0 1 0 0-704 352 352 0 0 0 0 704M352 448h256a32 32 0 0 1 0 64H352a32 32 0 0 1 0-64"
|
|
58
|
+
})
|
|
59
|
+
]));
|
|
60
|
+
}
|
|
61
|
+
}), ge = he;
|
|
62
|
+
const ye = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANgAAADYCAMAAAC+/t3fAAAAaVBMVEUAAABWapNVapKeqsLJztx3hKnGzN2yu8////9XapWcqMGps8lXapVYa5RWaZWps8lfcJjS1+KjrsVXapWapr////9sfaKrtMrV2uWBj7B4iKqWob1wgaXr7fOBj6/Ax9dhc5yhq8OKl7Wba+6tAAAAE3RSTlMAgGDuDyVLoYDe2XuXRb68cy6e4BCQEAAAAyZJREFUeNrt29tyokAUheGOQjIoeMhuCQ4e0Pd/yCE1STU4mGq7bXqzZ/23ufoqYblTqkIIIYQQQggNlM42Lzctf5nMD22bKQYVOQ30sTPt6dEO74mKXLoiCgDTi1RFbUMUBhZXluQUDKbnWxWtjMLB2pYqUjmFg8WUzSg0TL+rCKVZeJheRJj9DYWHRRnHbBSYnr+qcSso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
+
"png",
|
|
66
|
+
"gif",
|
|
67
|
+
"webp",
|
|
68
|
+
"bmp",
|
|
69
|
+
"svg",
|
|
70
|
+
"avif",
|
|
71
|
+
"ico"
|
|
72
|
+
]), _e = /* @__PURE__ */ new Set(["mp4", "webm", "ogg", "ogv", "mov", "m4v"]), je = /* @__PURE__ */ new Set([
|
|
73
|
+
"mp3",
|
|
74
|
+
"wav",
|
|
75
|
+
"ogg",
|
|
76
|
+
"oga",
|
|
77
|
+
"m4a",
|
|
78
|
+
"aac",
|
|
79
|
+
"flac"
|
|
80
|
+
]), Ee = /* @__PURE__ */ new Set([
|
|
81
|
+
"html",
|
|
82
|
+
"htm",
|
|
83
|
+
"txt",
|
|
84
|
+
"json",
|
|
85
|
+
"xml",
|
|
86
|
+
"csv",
|
|
87
|
+
"md",
|
|
88
|
+
"log"
|
|
89
|
+
]), De = /* @__PURE__ */ new Set([
|
|
90
|
+
"doc",
|
|
91
|
+
"docx",
|
|
92
|
+
"xls",
|
|
93
|
+
"xlsx",
|
|
94
|
+
"ppt",
|
|
95
|
+
"pptx",
|
|
96
|
+
"zip",
|
|
97
|
+
"rar",
|
|
98
|
+
"7z"
|
|
99
|
+
]), K = {
|
|
100
|
+
component: "JtAttachmentPreview",
|
|
101
|
+
marker: "2026-06-25-download-error-detail",
|
|
102
|
+
source: "@jt-home/mfe-components/src/components/JtAttachmentPreview/index.ts",
|
|
103
|
+
pdfLoadMode: "fetch-bytes-then-pdfjs-data",
|
|
104
|
+
previewDownloadMode: "openByParams-uses-registered-downloadRequest",
|
|
105
|
+
downloadResponseMode: "supports-blob-and-axios-response-data-blob"
|
|
106
|
+
};
|
|
107
|
+
function f(e, t) {
|
|
108
|
+
console.info(`[JtAttachmentPreview DEBUG ${K.marker}] ${e}`, {
|
|
109
|
+
...K,
|
|
110
|
+
...t
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
typeof window < "u" && (window.__JT_ATTACHMENT_PREVIEW_DEBUG__ = K, f("module-loaded"));
|
|
114
|
+
let E = null, H = null, D = null;
|
|
115
|
+
async function ke() {
|
|
116
|
+
return H || (H = Promise.all([
|
|
117
|
+
import("../pdf-BmBuG7of.js"),
|
|
118
|
+
import("../pdf.worker.min-4PI-nNLo.js")
|
|
119
|
+
]).then(([e, t]) => (e.GlobalWorkerOptions.workerSrc = t.default, e))), H;
|
|
120
|
+
}
|
|
121
|
+
function xe(e) {
|
|
122
|
+
return typeof e == "string" ? { url: e } : e;
|
|
123
|
+
}
|
|
124
|
+
function ae(e) {
|
|
125
|
+
const [t] = e.split(/[?#]/);
|
|
126
|
+
return t ?? "";
|
|
127
|
+
}
|
|
128
|
+
function F(e, t) {
|
|
129
|
+
if (t?.trim()) return t.trim();
|
|
130
|
+
const n = ae(e).split("/").filter(Boolean).pop();
|
|
131
|
+
if (!n) return c("common.附件预览");
|
|
132
|
+
try {
|
|
133
|
+
return decodeURIComponent(n);
|
|
134
|
+
} catch {
|
|
135
|
+
return n;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function Q(e) {
|
|
139
|
+
return ae(e).match(/\.([a-z0-9]+)$/i)?.[1]?.toLowerCase() ?? "";
|
|
140
|
+
}
|
|
141
|
+
function Be(e) {
|
|
142
|
+
return e?.trim().replace(/^\./, "").toLowerCase() ?? "";
|
|
143
|
+
}
|
|
144
|
+
function Le(e) {
|
|
145
|
+
const t = Be(e);
|
|
146
|
+
return Ae.has(t) ? "image" : t === "pdf" ? "pdf" : _e.has(t) ? "video" : je.has(t) ? "audio" : Ee.has(t) ? "iframe" : De.has(t) ? "unsupported" : "unknown";
|
|
147
|
+
}
|
|
148
|
+
function X(e) {
|
|
149
|
+
const t = e.toLowerCase().split(";")[0]?.trim() ?? "";
|
|
150
|
+
return t.startsWith("image/") ? "image" : t === "application/pdf" ? "pdf" : t.startsWith("video/") ? "video" : t.startsWith("audio/") ? "audio" : t.startsWith("text/") ? "iframe" : "unknown";
|
|
151
|
+
}
|
|
152
|
+
function re(e) {
|
|
153
|
+
if (!e.url.trim()) return "empty";
|
|
154
|
+
if (e.mode && e.mode !== "auto") return e.mode;
|
|
155
|
+
if (e.mimeType) {
|
|
156
|
+
const n = X(e.mimeType);
|
|
157
|
+
if (n !== "unknown") return n;
|
|
158
|
+
}
|
|
159
|
+
const t = Le(
|
|
160
|
+
e.extension || Q(e.name || "") || Q(e.url)
|
|
161
|
+
);
|
|
162
|
+
return t !== "unknown" ? t : "unknown";
|
|
163
|
+
}
|
|
164
|
+
async function Ce(e) {
|
|
165
|
+
try {
|
|
166
|
+
const n = (await fetch(e, { method: "HEAD" })).headers.get("content-type") ?? "";
|
|
167
|
+
return X(n);
|
|
168
|
+
} catch {
|
|
169
|
+
return "unknown";
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async function oe(e, t) {
|
|
173
|
+
const n = await fetch(e, t);
|
|
174
|
+
if (!n.ok) throw new Error(`fetch failed: ${n.status}`);
|
|
175
|
+
return n.blob();
|
|
176
|
+
}
|
|
177
|
+
async function Me(e) {
|
|
178
|
+
f("fetch-pdf-bytes-start", {
|
|
179
|
+
url: e
|
|
180
|
+
});
|
|
181
|
+
const t = await fetch(e);
|
|
182
|
+
if (!t.ok) throw new Error(`fetch failed: ${t.status}`);
|
|
183
|
+
const n = new Uint8Array(await t.arrayBuffer());
|
|
184
|
+
return f("fetch-pdf-bytes-done", {
|
|
185
|
+
url: e,
|
|
186
|
+
byteLength: n.byteLength,
|
|
187
|
+
contentType: t.headers.get("content-type") ?? ""
|
|
188
|
+
}), n;
|
|
189
|
+
}
|
|
190
|
+
function Pe(e, t) {
|
|
191
|
+
const n = Q(t);
|
|
192
|
+
return n === "doc" || n === "docx" ? "W" : n === "xls" || n === "xlsx" ? "X" : n === "ppt" || n === "pptx" ? "P" : n === "zip" || n === "rar" || n === "7z" ? "ZIP" : e === "pdf" ? "PDF" : "FILE";
|
|
193
|
+
}
|
|
194
|
+
function ie(e, t, n, o = !1) {
|
|
195
|
+
return r(
|
|
196
|
+
"button",
|
|
197
|
+
{
|
|
198
|
+
class: n,
|
|
199
|
+
type: "button",
|
|
200
|
+
onClick: () => {
|
|
201
|
+
f("download-button-click", {
|
|
202
|
+
url: e.url,
|
|
203
|
+
downloadName: t,
|
|
204
|
+
fallbackToRawUrl: o
|
|
205
|
+
}), ce(e, t, {
|
|
206
|
+
fallbackToRawUrl: o
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
[
|
|
211
|
+
r(
|
|
212
|
+
U,
|
|
213
|
+
{ class: "jt-attachment-preview-service__download-icon" },
|
|
214
|
+
() => r(me)
|
|
215
|
+
),
|
|
216
|
+
r(
|
|
217
|
+
"span",
|
|
218
|
+
{ class: "jt-attachment-preview-service__download-text" },
|
|
219
|
+
c("common.下载")
|
|
220
|
+
)
|
|
221
|
+
]
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
function W(e) {
|
|
225
|
+
return e === "image" || e === "pdf";
|
|
226
|
+
}
|
|
227
|
+
function le(e) {
|
|
228
|
+
return r(
|
|
229
|
+
"div",
|
|
230
|
+
{ class: "jt-attachment-preview-service__preview-fallback" },
|
|
231
|
+
[
|
|
232
|
+
r("img", {
|
|
233
|
+
class: "jt-attachment-preview-service__preview-fallback-icon",
|
|
234
|
+
src: e.icon,
|
|
235
|
+
alt: ""
|
|
236
|
+
}),
|
|
237
|
+
r(
|
|
238
|
+
"div",
|
|
239
|
+
{ class: "jt-attachment-preview-service__unsupported-text" },
|
|
240
|
+
c("common.暂不支持预览此类型的文件")
|
|
241
|
+
),
|
|
242
|
+
r(
|
|
243
|
+
"div",
|
|
244
|
+
{
|
|
245
|
+
class: "jt-attachment-preview-service__file-name",
|
|
246
|
+
title: e.name
|
|
247
|
+
},
|
|
248
|
+
e.name
|
|
249
|
+
)
|
|
250
|
+
]
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
function Z(e, t) {
|
|
254
|
+
const n = document.createElement("a");
|
|
255
|
+
n.href = e, n.download = t, n.style.display = "none", document.body.appendChild(n), n.click(), n.remove();
|
|
256
|
+
}
|
|
257
|
+
function $(e, t) {
|
|
258
|
+
const n = URL.createObjectURL(e);
|
|
259
|
+
Z(n, t), window.setTimeout(() => URL.revokeObjectURL(n), 1e3);
|
|
260
|
+
}
|
|
261
|
+
function J(e) {
|
|
262
|
+
return e instanceof Blob || Object.prototype.toString.call(e) === "[object Blob]";
|
|
263
|
+
}
|
|
264
|
+
function Re(e, t) {
|
|
265
|
+
if (J(e))
|
|
266
|
+
return e;
|
|
267
|
+
if (e && typeof e == "object") {
|
|
268
|
+
const n = e;
|
|
269
|
+
if (J(n.data)) {
|
|
270
|
+
const o = n.data;
|
|
271
|
+
return {
|
|
272
|
+
blob: n.data,
|
|
273
|
+
name: n.fileName || n.name || o.name || t
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
279
|
+
async function Te(e, t, n = {}) {
|
|
280
|
+
f("download-start", {
|
|
281
|
+
url: e,
|
|
282
|
+
downloadName: t,
|
|
283
|
+
fallbackToRawUrl: !!n.fallbackToRawUrl,
|
|
284
|
+
hasRequestInit: !!n.requestInit
|
|
285
|
+
});
|
|
286
|
+
try {
|
|
287
|
+
const o = await oe(e, n.requestInit);
|
|
288
|
+
f("download-blob-ready", {
|
|
289
|
+
url: e,
|
|
290
|
+
downloadName: t,
|
|
291
|
+
blobType: o.type,
|
|
292
|
+
blobSize: o.size
|
|
293
|
+
}), $(o, t);
|
|
294
|
+
} catch {
|
|
295
|
+
f("download-blob-failed", {
|
|
296
|
+
url: e,
|
|
297
|
+
downloadName: t,
|
|
298
|
+
fallbackToRawUrl: !!n.fallbackToRawUrl
|
|
299
|
+
}), n.fallbackToRawUrl && Z(e, t);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
function te(e, t) {
|
|
303
|
+
return e instanceof Blob ? { blob: e, name: t } : e ? {
|
|
304
|
+
url: e.url,
|
|
305
|
+
blob: e.blob,
|
|
306
|
+
name: e.name || t,
|
|
307
|
+
requestInit: e.requestInit,
|
|
308
|
+
fallbackToRawUrl: e.fallbackToRawUrl
|
|
309
|
+
} : null;
|
|
310
|
+
}
|
|
311
|
+
async function ce(e, t, n = {}) {
|
|
312
|
+
const o = {
|
|
313
|
+
url: e.url,
|
|
314
|
+
name: t,
|
|
315
|
+
params: e.requestParams,
|
|
316
|
+
options: e
|
|
317
|
+
};
|
|
318
|
+
try {
|
|
319
|
+
let a = null;
|
|
320
|
+
if (f("download-resolve-start", {
|
|
321
|
+
url: e.url,
|
|
322
|
+
downloadName: t,
|
|
323
|
+
hasCustomDownload: !!e.download,
|
|
324
|
+
hasRegisteredDownload: !!D?.downloadRequest,
|
|
325
|
+
useRegisteredDownload: !!e.useRegisteredDownload,
|
|
326
|
+
hasRequestParams: Object.prototype.hasOwnProperty.call(
|
|
327
|
+
e,
|
|
328
|
+
"requestParams"
|
|
329
|
+
)
|
|
330
|
+
}), e.download) {
|
|
331
|
+
f("download-custom-handler-start", {
|
|
332
|
+
url: e.url,
|
|
333
|
+
downloadName: t
|
|
334
|
+
});
|
|
335
|
+
const i = await e.download(o);
|
|
336
|
+
if (a = te(i, t), !a) {
|
|
337
|
+
f("download-custom-handler-done", {
|
|
338
|
+
url: e.url,
|
|
339
|
+
downloadName: t
|
|
340
|
+
});
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
} else if (e.useRegisteredDownload && D?.downloadRequest) {
|
|
344
|
+
f("download-setup-request-start", {
|
|
345
|
+
url: e.url,
|
|
346
|
+
downloadName: t,
|
|
347
|
+
params: e.requestParams
|
|
348
|
+
});
|
|
349
|
+
const i = await D.downloadRequest(
|
|
350
|
+
e.requestParams
|
|
351
|
+
);
|
|
352
|
+
f("download-request-response", {
|
|
353
|
+
isBlob: J(i),
|
|
354
|
+
isDataBlob: !!i && typeof i == "object" && J(i.data),
|
|
355
|
+
responseType: Object.prototype.toString.call(i)
|
|
356
|
+
});
|
|
357
|
+
const p = Re(i, t), v = p || (D.mapDownloadResponse ? D.mapDownloadResponse(
|
|
358
|
+
i,
|
|
359
|
+
e.requestParams
|
|
360
|
+
) : i);
|
|
361
|
+
a = te(v, t);
|
|
362
|
+
}
|
|
363
|
+
if (a?.blob) {
|
|
364
|
+
f("download-result-blob", {
|
|
365
|
+
downloadName: a.name,
|
|
366
|
+
blobType: a.blob.type,
|
|
367
|
+
blobSize: a.blob.size
|
|
368
|
+
}), $(a.blob, a.name);
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
const s = a?.url || e.downloadUrl || e.url, u = a?.name || t;
|
|
372
|
+
await Te(s, u, {
|
|
373
|
+
requestInit: a?.requestInit || e.downloadRequestInit,
|
|
374
|
+
fallbackToRawUrl: a?.fallbackToRawUrl ?? e.downloadFallbackToRawUrl ?? n.fallbackToRawUrl
|
|
375
|
+
});
|
|
376
|
+
} catch (a) {
|
|
377
|
+
f("download-handler-failed", {
|
|
378
|
+
url: e.url,
|
|
379
|
+
downloadName: t,
|
|
380
|
+
errorName: a instanceof Error ? a.name : "",
|
|
381
|
+
errorMessage: a instanceof Error ? a.message : String(a),
|
|
382
|
+
errorStack: a instanceof Error ? a.stack : "",
|
|
383
|
+
errorResponseStatus: a && typeof a == "object" ? a.response?.status : void 0,
|
|
384
|
+
errorResponseType: a && typeof a == "object" ? Object.prototype.toString.call(
|
|
385
|
+
a.response?.data
|
|
386
|
+
) : void 0,
|
|
387
|
+
errorResponseDataType: a && typeof a == "object" ? a.response?.data?.type : void 0
|
|
388
|
+
}), n.fallbackToRawUrl && Z(e.downloadUrl || e.url, t);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
const Ye = L({
|
|
392
|
+
name: "JtAttachmentPreviewPdfCanvas",
|
|
393
|
+
props: {
|
|
394
|
+
url: {
|
|
395
|
+
type: String,
|
|
396
|
+
required: !0
|
|
397
|
+
},
|
|
398
|
+
name: {
|
|
399
|
+
type: String,
|
|
400
|
+
required: !0
|
|
401
|
+
},
|
|
402
|
+
downloadName: {
|
|
403
|
+
type: String,
|
|
404
|
+
required: !0
|
|
405
|
+
},
|
|
406
|
+
downloadable: {
|
|
407
|
+
type: Boolean,
|
|
408
|
+
required: !0
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
emits: {
|
|
412
|
+
previewLoad: (e) => e instanceof Event,
|
|
413
|
+
previewError: (e) => e instanceof Event
|
|
414
|
+
},
|
|
415
|
+
setup(e, { emit: t }) {
|
|
416
|
+
const n = B("loading"), o = B([]), a = B([]), s = /* @__PURE__ */ new Map(), u = B("");
|
|
417
|
+
let i = null, p = [], v = 0;
|
|
418
|
+
async function w(l, d) {
|
|
419
|
+
if (!d) return null;
|
|
420
|
+
const g = typeof d == "string" ? await l.getDestination(d) : d;
|
|
421
|
+
return !Array.isArray(g) || !g[0] ? null : await l.getPageIndex(g[0]) + 1;
|
|
422
|
+
}
|
|
423
|
+
async function A(l, d, g = 0) {
|
|
424
|
+
if (!d?.length) return [];
|
|
425
|
+
const y = [];
|
|
426
|
+
for (const k of d) {
|
|
427
|
+
const R = await w(l, k.dest);
|
|
428
|
+
y.push({
|
|
429
|
+
title: k.title || c("common.未命名标题"),
|
|
430
|
+
pageNumber: R,
|
|
431
|
+
level: g
|
|
432
|
+
});
|
|
433
|
+
const M = await A(l, k.items, g + 1);
|
|
434
|
+
y.push(...M);
|
|
435
|
+
}
|
|
436
|
+
return y;
|
|
437
|
+
}
|
|
438
|
+
function h() {
|
|
439
|
+
v += 1;
|
|
440
|
+
for (const l of p)
|
|
441
|
+
l.cancel();
|
|
442
|
+
p = [], i?.destroy(), i = null, s.clear();
|
|
443
|
+
}
|
|
444
|
+
async function C() {
|
|
445
|
+
h();
|
|
446
|
+
const l = v;
|
|
447
|
+
n.value = "loading", u.value = "", o.value = [], a.value = [];
|
|
448
|
+
try {
|
|
449
|
+
const d = await ke();
|
|
450
|
+
if (l !== v) return;
|
|
451
|
+
const g = await Me(e.url);
|
|
452
|
+
if (l !== v) return;
|
|
453
|
+
f("render-pdf-get-document-data", {
|
|
454
|
+
byteLength: g.byteLength
|
|
455
|
+
}), i = d.getDocument({ data: g });
|
|
456
|
+
const y = await i.promise;
|
|
457
|
+
if (l !== v) return;
|
|
458
|
+
o.value = Array.from(
|
|
459
|
+
{ length: y.numPages },
|
|
460
|
+
(M, P) => P + 1
|
|
461
|
+
), a.value = await A(
|
|
462
|
+
y,
|
|
463
|
+
await y.getOutline()
|
|
464
|
+
), await ue();
|
|
465
|
+
const k = s.values().next().value, R = Math.max(
|
|
466
|
+
(k?.parentElement?.clientWidth ?? 800) - 32,
|
|
467
|
+
320
|
|
468
|
+
);
|
|
469
|
+
for (const M of o.value) {
|
|
470
|
+
if (l !== v) return;
|
|
471
|
+
const P = await y.getPage(M), b = s.get(M), T = b?.getContext("2d");
|
|
472
|
+
if (!b || !T) continue;
|
|
473
|
+
const z = P.getViewport({ scale: 1 }), m = Math.min(R / z.width, 2), Y = P.getViewport({ scale: m }), O = window.devicePixelRatio || 1;
|
|
474
|
+
b.width = Math.floor(Y.width * O), b.height = Math.floor(Y.height * O), b.style.width = `${Math.floor(Y.width)}px`, b.style.height = `${Math.floor(Y.height)}px`, T.setTransform(O, 0, 0, O, 0, 0);
|
|
475
|
+
const ee = P.render({
|
|
476
|
+
canvas: b,
|
|
477
|
+
canvasContext: T,
|
|
478
|
+
viewport: Y
|
|
479
|
+
});
|
|
480
|
+
p.push(ee), await ee.promise;
|
|
481
|
+
}
|
|
482
|
+
if (l !== v) return;
|
|
483
|
+
n.value = "ready", t("previewLoad", new Event("load"));
|
|
484
|
+
} catch (d) {
|
|
485
|
+
if (l !== v) return;
|
|
486
|
+
n.value = "error", u.value = d instanceof Error ? d.message : c("common.PDF加载失败"), t("previewError", new Event("error"));
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
ne(() => e.url, C, { immediate: !0 }), G(h);
|
|
490
|
+
function _(l) {
|
|
491
|
+
if (!l) return;
|
|
492
|
+
s.get(l)?.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
493
|
+
}
|
|
494
|
+
return () => r("div", { class: "jt-attachment-preview-service__pdf-viewer" }, [
|
|
495
|
+
n.value === "loading" ? r(
|
|
496
|
+
"div",
|
|
497
|
+
{ class: "jt-attachment-preview-service__pdf-state" },
|
|
498
|
+
c("common.PDF加载中___")
|
|
499
|
+
) : null,
|
|
500
|
+
n.value === "error" ? r("div", { class: "jt-attachment-preview-service__pdf-state" }, [
|
|
501
|
+
le({
|
|
502
|
+
icon: be,
|
|
503
|
+
name: e.name
|
|
504
|
+
})
|
|
505
|
+
]) : null,
|
|
506
|
+
null,
|
|
507
|
+
null,
|
|
508
|
+
r(
|
|
509
|
+
"div",
|
|
510
|
+
{
|
|
511
|
+
class: [
|
|
512
|
+
"jt-attachment-preview-service__pdf-layout",
|
|
513
|
+
n.value !== "ready" ? "jt-attachment-preview-service__pdf-layout--hidden" : ""
|
|
514
|
+
]
|
|
515
|
+
},
|
|
516
|
+
[
|
|
517
|
+
a.value.length ? r(
|
|
518
|
+
"aside",
|
|
519
|
+
{ class: "jt-attachment-preview-service__pdf-outline" },
|
|
520
|
+
[
|
|
521
|
+
r(
|
|
522
|
+
"div",
|
|
523
|
+
{
|
|
524
|
+
class: "jt-attachment-preview-service__pdf-outline-title"
|
|
525
|
+
},
|
|
526
|
+
c("common.目录")
|
|
527
|
+
),
|
|
528
|
+
r(
|
|
529
|
+
"div",
|
|
530
|
+
{
|
|
531
|
+
class: "jt-attachment-preview-service__pdf-outline-list"
|
|
532
|
+
},
|
|
533
|
+
a.value.map(
|
|
534
|
+
(l, d) => r(
|
|
535
|
+
"button",
|
|
536
|
+
{
|
|
537
|
+
key: `${l.title}-${d}`,
|
|
538
|
+
class: "jt-attachment-preview-service__pdf-outline-item",
|
|
539
|
+
style: { paddingLeft: `${12 + l.level * 14}px` },
|
|
540
|
+
type: "button",
|
|
541
|
+
disabled: !l.pageNumber,
|
|
542
|
+
title: l.title,
|
|
543
|
+
onClick: () => _(l.pageNumber)
|
|
544
|
+
},
|
|
545
|
+
l.title
|
|
546
|
+
)
|
|
547
|
+
)
|
|
548
|
+
)
|
|
549
|
+
]
|
|
550
|
+
) : null,
|
|
551
|
+
r(
|
|
552
|
+
"div",
|
|
553
|
+
{ class: "jt-attachment-preview-service__pdf-pages" },
|
|
554
|
+
o.value.map(
|
|
555
|
+
(l) => r("canvas", {
|
|
556
|
+
key: l,
|
|
557
|
+
ref: (d) => {
|
|
558
|
+
d instanceof HTMLCanvasElement && s.set(l, d);
|
|
559
|
+
},
|
|
560
|
+
class: "jt-attachment-preview-service__pdf-page"
|
|
561
|
+
})
|
|
562
|
+
)
|
|
563
|
+
)
|
|
564
|
+
]
|
|
565
|
+
)
|
|
566
|
+
]);
|
|
567
|
+
}
|
|
568
|
+
}), Ie = L({
|
|
569
|
+
name: "JtAttachmentPreviewImageTransform",
|
|
570
|
+
props: {
|
|
571
|
+
url: {
|
|
572
|
+
type: String,
|
|
573
|
+
required: !0
|
|
574
|
+
},
|
|
575
|
+
name: {
|
|
576
|
+
type: String,
|
|
577
|
+
required: !0
|
|
578
|
+
},
|
|
579
|
+
downloadName: {
|
|
580
|
+
type: String,
|
|
581
|
+
required: !0
|
|
582
|
+
},
|
|
583
|
+
downloadable: {
|
|
584
|
+
type: Boolean,
|
|
585
|
+
required: !0
|
|
586
|
+
},
|
|
587
|
+
fit: {
|
|
588
|
+
type: String,
|
|
589
|
+
default: "contain"
|
|
590
|
+
}
|
|
591
|
+
},
|
|
592
|
+
emits: {
|
|
593
|
+
previewLoad: (e) => e instanceof Event,
|
|
594
|
+
previewError: (e) => e instanceof Event
|
|
595
|
+
},
|
|
596
|
+
setup(e, { emit: t }) {
|
|
597
|
+
const n = B(null), o = B("ready"), a = B(1), s = B(!1);
|
|
598
|
+
let u = 0, i = 0, p = 0, v = 0, w = 0, A = 0, h = 0;
|
|
599
|
+
const C = x(
|
|
600
|
+
() => ({
|
|
601
|
+
"--jt-attachment-preview-service-image-fit": e.fit,
|
|
602
|
+
transform: `translate(${u}px, ${i}px) scale(${a.value})`
|
|
603
|
+
})
|
|
604
|
+
);
|
|
605
|
+
function _() {
|
|
606
|
+
n.value && (n.value.style.transform = `translate(${u}px, ${i}px) scale(${a.value})`);
|
|
607
|
+
}
|
|
608
|
+
function l() {
|
|
609
|
+
h || (h = window.requestAnimationFrame(() => {
|
|
610
|
+
h = 0, _();
|
|
611
|
+
}));
|
|
612
|
+
}
|
|
613
|
+
function d(m) {
|
|
614
|
+
a.value = Math.min(Math.max(Number(m.toFixed(2)), 0.2), 5), a.value <= 1 && (u = 0, i = 0), _();
|
|
615
|
+
}
|
|
616
|
+
function g() {
|
|
617
|
+
d(a.value + 0.2);
|
|
618
|
+
}
|
|
619
|
+
function y() {
|
|
620
|
+
const m = Math.max(Number((a.value - 0.2).toFixed(2)), 0.2);
|
|
621
|
+
a.value = m, m <= 1 && (u = 0, i = 0), _();
|
|
622
|
+
}
|
|
623
|
+
function k() {
|
|
624
|
+
u = 0, i = 0, d(1);
|
|
625
|
+
}
|
|
626
|
+
function R(m) {
|
|
627
|
+
o.value = "ready", t("previewLoad", m);
|
|
628
|
+
}
|
|
629
|
+
function M(m) {
|
|
630
|
+
o.value = "error", t("previewError", m);
|
|
631
|
+
}
|
|
632
|
+
function P(m) {
|
|
633
|
+
a.value <= 1 || (m.preventDefault(), s.value = !0, p = m.clientX, v = m.clientY, w = u, A = i, window.addEventListener("pointermove", b), window.addEventListener("pointerup", T, { once: !0 }));
|
|
634
|
+
}
|
|
635
|
+
function b(m) {
|
|
636
|
+
s.value && (u = w + m.clientX - p, i = A + m.clientY - v, l());
|
|
637
|
+
}
|
|
638
|
+
function T() {
|
|
639
|
+
s.value = !1, window.removeEventListener("pointermove", b);
|
|
640
|
+
}
|
|
641
|
+
function z(m) {
|
|
642
|
+
m.preventDefault(), d(a.value + (m.deltaY < 0 ? 0.1 : -0.1));
|
|
643
|
+
}
|
|
644
|
+
return V(_), ne(
|
|
645
|
+
() => e.url,
|
|
646
|
+
() => {
|
|
647
|
+
o.value = "ready", k();
|
|
648
|
+
}
|
|
649
|
+
), G(() => {
|
|
650
|
+
window.removeEventListener("pointermove", b), h && window.cancelAnimationFrame(h);
|
|
651
|
+
}), () => r(
|
|
652
|
+
"div",
|
|
653
|
+
{ class: "jt-attachment-preview-service__image-viewer" },
|
|
654
|
+
o.value === "error" ? le({
|
|
655
|
+
icon: ye,
|
|
656
|
+
name: e.name
|
|
657
|
+
}) : [
|
|
658
|
+
r("img", {
|
|
659
|
+
ref: n,
|
|
660
|
+
class: [
|
|
661
|
+
"jt-attachment-preview-service__media",
|
|
662
|
+
"jt-attachment-preview-service__image",
|
|
663
|
+
a.value > 1 ? "jt-attachment-preview-service__image--draggable" : "",
|
|
664
|
+
s.value ? "jt-attachment-preview-service__image--dragging" : ""
|
|
665
|
+
],
|
|
666
|
+
src: e.url,
|
|
667
|
+
alt: e.name,
|
|
668
|
+
style: C.value,
|
|
669
|
+
onLoad: R,
|
|
670
|
+
onError: M,
|
|
671
|
+
onPointerdown: P,
|
|
672
|
+
onWheel: z,
|
|
673
|
+
onDragstart: (m) => m.preventDefault(),
|
|
674
|
+
draggable: !1
|
|
675
|
+
}),
|
|
676
|
+
r(
|
|
677
|
+
"div",
|
|
678
|
+
{ class: "jt-attachment-preview-service__image-toolbar" },
|
|
679
|
+
[
|
|
680
|
+
r(
|
|
681
|
+
"button",
|
|
682
|
+
{
|
|
683
|
+
class: "jt-attachment-preview-service__image-tool",
|
|
684
|
+
type: "button",
|
|
685
|
+
title: c("common.缩小"),
|
|
686
|
+
onClick: y
|
|
687
|
+
},
|
|
688
|
+
[r(U, () => r(ge))]
|
|
689
|
+
),
|
|
690
|
+
r(
|
|
691
|
+
"span",
|
|
692
|
+
{ class: "jt-attachment-preview-service__image-scale" },
|
|
693
|
+
`${Math.round(a.value * 100)}%`
|
|
694
|
+
),
|
|
695
|
+
r(
|
|
696
|
+
"button",
|
|
697
|
+
{
|
|
698
|
+
class: "jt-attachment-preview-service__image-tool",
|
|
699
|
+
type: "button",
|
|
700
|
+
title: c("common.放大"),
|
|
701
|
+
onClick: g
|
|
702
|
+
},
|
|
703
|
+
[r(U, () => r(pe))]
|
|
704
|
+
),
|
|
705
|
+
r(
|
|
706
|
+
"button",
|
|
707
|
+
{
|
|
708
|
+
class: "jt-attachment-preview-service__image-tool",
|
|
709
|
+
type: "button",
|
|
710
|
+
title: c("common.复位"),
|
|
711
|
+
onClick: k
|
|
712
|
+
},
|
|
713
|
+
[r(U, () => r(fe))]
|
|
714
|
+
)
|
|
715
|
+
]
|
|
716
|
+
)
|
|
717
|
+
]
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
}), Oe = L({
|
|
721
|
+
name: "JtAttachmentPreviewService",
|
|
722
|
+
props: {
|
|
723
|
+
options: {
|
|
724
|
+
type: Object,
|
|
725
|
+
required: !0
|
|
726
|
+
},
|
|
727
|
+
onDestroy: {
|
|
728
|
+
type: Function,
|
|
729
|
+
required: !0
|
|
730
|
+
}
|
|
731
|
+
},
|
|
732
|
+
setup(e) {
|
|
733
|
+
const t = x(
|
|
734
|
+
() => F(e.options.url, e.options.name)
|
|
735
|
+
), n = x(
|
|
736
|
+
() => e.options.downloadName || t.value
|
|
737
|
+
), o = x(() => re(e.options)), a = x(
|
|
738
|
+
() => Pe(o.value, e.options.url)
|
|
739
|
+
), s = x(
|
|
740
|
+
() => ({
|
|
741
|
+
zIndex: e.options.zIndex ?? 3e3,
|
|
742
|
+
"--jt-attachment-preview-service-image-fit": e.options.fit ?? "contain"
|
|
743
|
+
})
|
|
744
|
+
);
|
|
745
|
+
function u() {
|
|
746
|
+
e.options.onClose?.(), e.onDestroy();
|
|
747
|
+
}
|
|
748
|
+
function i(w) {
|
|
749
|
+
w.key === "Escape" && e.options.closeOnPressEscape !== !1 && u();
|
|
750
|
+
}
|
|
751
|
+
function p(w) {
|
|
752
|
+
e.options.onLoad?.(w);
|
|
753
|
+
}
|
|
754
|
+
function v(w) {
|
|
755
|
+
e.options.onError?.(w);
|
|
756
|
+
}
|
|
757
|
+
return V(() => {
|
|
758
|
+
document.addEventListener("keydown", i), document.body.classList.add("jt-attachment-preview-service-lock");
|
|
759
|
+
}), G(() => {
|
|
760
|
+
document.removeEventListener("keydown", i), document.body.classList.remove("jt-attachment-preview-service-lock");
|
|
761
|
+
}), () => {
|
|
762
|
+
const w = e.options.downloadable === !1 ? [] : [
|
|
763
|
+
ie(
|
|
764
|
+
e.options,
|
|
765
|
+
n.value,
|
|
766
|
+
"jt-attachment-preview-service__top-download"
|
|
767
|
+
)
|
|
768
|
+
];
|
|
769
|
+
return r(
|
|
770
|
+
"div",
|
|
771
|
+
{ class: "jt-attachment-preview-service", style: s.value },
|
|
772
|
+
[
|
|
773
|
+
r("div", { class: "jt-attachment-preview-service__modal" }, [
|
|
774
|
+
r("div", { class: "jt-attachment-preview-service__header" }, [
|
|
775
|
+
r(
|
|
776
|
+
"div",
|
|
777
|
+
{
|
|
778
|
+
class: "jt-attachment-preview-service__filename",
|
|
779
|
+
title: t.value
|
|
780
|
+
},
|
|
781
|
+
t.value
|
|
782
|
+
),
|
|
783
|
+
r(
|
|
784
|
+
"div",
|
|
785
|
+
{ class: "jt-attachment-preview-service__header-actions" },
|
|
786
|
+
[
|
|
787
|
+
...w,
|
|
788
|
+
r(
|
|
789
|
+
"button",
|
|
790
|
+
{
|
|
791
|
+
class: "jt-attachment-preview-service__close",
|
|
792
|
+
type: "button",
|
|
793
|
+
"aria-label": c("common.关闭"),
|
|
794
|
+
onClick: u
|
|
795
|
+
},
|
|
796
|
+
"×"
|
|
797
|
+
)
|
|
798
|
+
]
|
|
799
|
+
)
|
|
800
|
+
]),
|
|
801
|
+
r("div", { class: "jt-attachment-preview-service__body" }, [
|
|
802
|
+
Ue({
|
|
803
|
+
type: o.value,
|
|
804
|
+
url: e.options.url,
|
|
805
|
+
name: t.value,
|
|
806
|
+
downloadName: n.value,
|
|
807
|
+
sourceOptions: e.options,
|
|
808
|
+
sandbox: e.options.sandbox,
|
|
809
|
+
iconText: a.value,
|
|
810
|
+
downloadable: e.options.downloadable !== !1,
|
|
811
|
+
onLoad: p,
|
|
812
|
+
onError: v
|
|
813
|
+
})
|
|
814
|
+
])
|
|
815
|
+
])
|
|
816
|
+
]
|
|
817
|
+
);
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
}), I = L({
|
|
821
|
+
name: "JtAttachmentPreviewDetectingService",
|
|
822
|
+
props: {
|
|
823
|
+
options: {
|
|
824
|
+
type: Object,
|
|
825
|
+
required: !0
|
|
826
|
+
},
|
|
827
|
+
onDestroy: {
|
|
828
|
+
type: Function,
|
|
829
|
+
required: !0
|
|
830
|
+
},
|
|
831
|
+
title: {
|
|
832
|
+
type: String,
|
|
833
|
+
default: c("common.正在识别文件类型")
|
|
834
|
+
},
|
|
835
|
+
desc: {
|
|
836
|
+
type: String,
|
|
837
|
+
default: c("common.请稍候,识别完成后将自动预览或下载")
|
|
838
|
+
},
|
|
839
|
+
spinning: {
|
|
840
|
+
type: Boolean,
|
|
841
|
+
default: !0
|
|
842
|
+
}
|
|
843
|
+
},
|
|
844
|
+
setup(e) {
|
|
845
|
+
const t = x(
|
|
846
|
+
() => F(e.options.url, e.options.name)
|
|
847
|
+
), n = x(() => ({
|
|
848
|
+
zIndex: e.options.zIndex ?? 3e3
|
|
849
|
+
}));
|
|
850
|
+
function o() {
|
|
851
|
+
e.options.onClose?.(), e.onDestroy();
|
|
852
|
+
}
|
|
853
|
+
function a(s) {
|
|
854
|
+
s.key === "Escape" && e.options.closeOnPressEscape !== !1 && o();
|
|
855
|
+
}
|
|
856
|
+
return V(() => {
|
|
857
|
+
document.addEventListener("keydown", a), document.body.classList.add("jt-attachment-preview-service-lock");
|
|
858
|
+
}), G(() => {
|
|
859
|
+
document.removeEventListener("keydown", a), document.body.classList.remove("jt-attachment-preview-service-lock");
|
|
860
|
+
}), () => r(
|
|
861
|
+
"div",
|
|
862
|
+
{ class: "jt-attachment-preview-service", style: n.value },
|
|
863
|
+
[
|
|
864
|
+
r("div", { class: "jt-attachment-preview-service__modal" }, [
|
|
865
|
+
r("div", { class: "jt-attachment-preview-service__header" }, [
|
|
866
|
+
r(
|
|
867
|
+
"div",
|
|
868
|
+
{
|
|
869
|
+
class: "jt-attachment-preview-service__filename",
|
|
870
|
+
title: t.value
|
|
871
|
+
},
|
|
872
|
+
t.value
|
|
873
|
+
),
|
|
874
|
+
r(
|
|
875
|
+
"div",
|
|
876
|
+
{ class: "jt-attachment-preview-service__header-actions" },
|
|
877
|
+
[
|
|
878
|
+
r(
|
|
879
|
+
"button",
|
|
880
|
+
{
|
|
881
|
+
class: "jt-attachment-preview-service__close",
|
|
882
|
+
type: "button",
|
|
883
|
+
"aria-label": c("common.关闭"),
|
|
884
|
+
onClick: o
|
|
885
|
+
},
|
|
886
|
+
"×"
|
|
887
|
+
)
|
|
888
|
+
]
|
|
889
|
+
)
|
|
890
|
+
]),
|
|
891
|
+
r("div", { class: "jt-attachment-preview-service__body" }, [
|
|
892
|
+
r("div", { class: "jt-attachment-preview-service__detecting" }, [
|
|
893
|
+
e.spinning ? r("span", {
|
|
894
|
+
class: "jt-attachment-preview-service__detecting-spinner"
|
|
895
|
+
}) : null,
|
|
896
|
+
r(
|
|
897
|
+
"span",
|
|
898
|
+
{ class: "jt-attachment-preview-service__detecting-title" },
|
|
899
|
+
e.title
|
|
900
|
+
),
|
|
901
|
+
r(
|
|
902
|
+
"span",
|
|
903
|
+
{ class: "jt-attachment-preview-service__detecting-desc" },
|
|
904
|
+
e.desc
|
|
905
|
+
)
|
|
906
|
+
])
|
|
907
|
+
])
|
|
908
|
+
])
|
|
909
|
+
]
|
|
910
|
+
);
|
|
911
|
+
}
|
|
912
|
+
});
|
|
913
|
+
function Ue(e) {
|
|
914
|
+
return e.type === "empty" ? r(
|
|
915
|
+
"div",
|
|
916
|
+
{ class: "jt-attachment-preview-service__empty" },
|
|
917
|
+
c("common.暂无附件")
|
|
918
|
+
) : e.type === "image" ? r(Ie, {
|
|
919
|
+
url: e.url,
|
|
920
|
+
name: e.name,
|
|
921
|
+
downloadName: e.downloadName,
|
|
922
|
+
downloadable: e.downloadable,
|
|
923
|
+
onPreviewLoad: e.onLoad,
|
|
924
|
+
onPreviewError: e.onError
|
|
925
|
+
}) : e.type === "video" ? r("video", {
|
|
926
|
+
class: "jt-attachment-preview-service__media",
|
|
927
|
+
src: e.url,
|
|
928
|
+
controls: !0,
|
|
929
|
+
onLoadeddata: e.onLoad,
|
|
930
|
+
onError: e.onError
|
|
931
|
+
}) : e.type === "audio" ? r("audio", {
|
|
932
|
+
class: "jt-attachment-preview-service__audio",
|
|
933
|
+
src: e.url,
|
|
934
|
+
controls: !0,
|
|
935
|
+
onLoadeddata: e.onLoad,
|
|
936
|
+
onError: e.onError
|
|
937
|
+
}) : e.type === "pdf" ? r(Ye, {
|
|
938
|
+
url: e.url,
|
|
939
|
+
name: e.name,
|
|
940
|
+
downloadName: e.downloadName,
|
|
941
|
+
downloadable: e.downloadable,
|
|
942
|
+
onPreviewLoad: e.onLoad,
|
|
943
|
+
onPreviewError: e.onError
|
|
944
|
+
}) : e.type === "iframe" ? r("iframe", {
|
|
945
|
+
class: "jt-attachment-preview-service__iframe",
|
|
946
|
+
src: e.url,
|
|
947
|
+
title: e.name,
|
|
948
|
+
sandbox: e.sandbox || void 0,
|
|
949
|
+
onLoad: e.onLoad
|
|
950
|
+
}) : r("div", { class: "jt-attachment-preview-service__unsupported" }, [
|
|
951
|
+
r("div", { class: "jt-attachment-preview-service__file-card" }, [
|
|
952
|
+
r(
|
|
953
|
+
"div",
|
|
954
|
+
{ class: "jt-attachment-preview-service__file-icon" },
|
|
955
|
+
e.iconText
|
|
956
|
+
),
|
|
957
|
+
r(
|
|
958
|
+
"div",
|
|
959
|
+
{ class: "jt-attachment-preview-service__unsupported-text" },
|
|
960
|
+
c("common.暂不支持预览此类型的文件")
|
|
961
|
+
)
|
|
962
|
+
]),
|
|
963
|
+
r(
|
|
964
|
+
"div",
|
|
965
|
+
{
|
|
966
|
+
class: "jt-attachment-preview-service__file-name",
|
|
967
|
+
title: e.name
|
|
968
|
+
},
|
|
969
|
+
e.name
|
|
970
|
+
),
|
|
971
|
+
e.downloadable ? ie(
|
|
972
|
+
e.sourceOptions,
|
|
973
|
+
e.downloadName,
|
|
974
|
+
"jt-attachment-preview-service__primary-download"
|
|
975
|
+
) : null
|
|
976
|
+
]);
|
|
977
|
+
}
|
|
978
|
+
function se(e) {
|
|
979
|
+
if (typeof document > "u")
|
|
980
|
+
return { close: () => {
|
|
981
|
+
} };
|
|
982
|
+
f("open-called", {
|
|
983
|
+
rawOptions: typeof e == "string" ? e : { ...e }
|
|
984
|
+
}), E?.close();
|
|
985
|
+
const t = xe(
|
|
986
|
+
e
|
|
987
|
+
), n = t.downloadName || F(t.url, t.name);
|
|
988
|
+
let o = !1, a = null, s = null;
|
|
989
|
+
const u = () => {
|
|
990
|
+
o = !0, a && (j(null, a), a.remove(), a = null), s && (URL.revokeObjectURL(s), s = null), E?.close === u && (E = null);
|
|
991
|
+
};
|
|
992
|
+
function i() {
|
|
993
|
+
o || (a || (a = document.createElement("div"), document.body.appendChild(a)), j(
|
|
994
|
+
r(Oe, {
|
|
995
|
+
options: t,
|
|
996
|
+
onDestroy: u
|
|
997
|
+
}),
|
|
998
|
+
a
|
|
999
|
+
));
|
|
1000
|
+
}
|
|
1001
|
+
function p() {
|
|
1002
|
+
o || (a || (a = document.createElement("div"), document.body.appendChild(a)), j(
|
|
1003
|
+
r(I, {
|
|
1004
|
+
options: t,
|
|
1005
|
+
onDestroy: u
|
|
1006
|
+
}),
|
|
1007
|
+
a
|
|
1008
|
+
));
|
|
1009
|
+
}
|
|
1010
|
+
function v() {
|
|
1011
|
+
a && (j(null, a), a.remove(), a = null);
|
|
1012
|
+
}
|
|
1013
|
+
function w() {
|
|
1014
|
+
o || ce(t, n, {
|
|
1015
|
+
fallbackToRawUrl: !0
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
const A = re(t);
|
|
1019
|
+
return f("type-resolved", {
|
|
1020
|
+
resolvedType: A,
|
|
1021
|
+
url: t.url,
|
|
1022
|
+
name: t.name,
|
|
1023
|
+
mode: t.mode,
|
|
1024
|
+
mimeType: t.mimeType,
|
|
1025
|
+
extension: t.extension
|
|
1026
|
+
}), W(A) ? i() : A === "unknown" ? (p(), Ce(t.url).then(async (h) => {
|
|
1027
|
+
if (!o) {
|
|
1028
|
+
if (W(h)) {
|
|
1029
|
+
t.mode = h, i();
|
|
1030
|
+
return;
|
|
1031
|
+
}
|
|
1032
|
+
try {
|
|
1033
|
+
const C = await oe(t.url), _ = X(C.type);
|
|
1034
|
+
if (W(_)) {
|
|
1035
|
+
s = URL.createObjectURL(C), t.url = s, t.mode = _, i();
|
|
1036
|
+
return;
|
|
1037
|
+
}
|
|
1038
|
+
v(), $(C, n);
|
|
1039
|
+
} catch {
|
|
1040
|
+
v(), w();
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
})) : w(), E = { close: u }, E;
|
|
1044
|
+
}
|
|
1045
|
+
function Je(e) {
|
|
1046
|
+
D = e;
|
|
1047
|
+
}
|
|
1048
|
+
function qe(e) {
|
|
1049
|
+
if (typeof document > "u")
|
|
1050
|
+
return { close: () => {
|
|
1051
|
+
} };
|
|
1052
|
+
E?.close();
|
|
1053
|
+
let t = !1, n = document.createElement("div");
|
|
1054
|
+
document.body.appendChild(n);
|
|
1055
|
+
const o = () => {
|
|
1056
|
+
t = !0, n && (j(null, n), n.remove(), n = null), E?.close === o && (E = null);
|
|
1057
|
+
}, a = { close: o };
|
|
1058
|
+
return E = a, D ? (j(
|
|
1059
|
+
r(I, {
|
|
1060
|
+
options: { url: "", name: c("common.附件预览") },
|
|
1061
|
+
title: c("common.正在获取文件信息"),
|
|
1062
|
+
desc: c("common.请稍候,获取完成后将自动预览或下载"),
|
|
1063
|
+
spinning: !0,
|
|
1064
|
+
onDestroy: o
|
|
1065
|
+
}),
|
|
1066
|
+
n
|
|
1067
|
+
), D.request(e).then((s) => {
|
|
1068
|
+
if (t) return;
|
|
1069
|
+
const u = D?.mapResponse(s, e);
|
|
1070
|
+
if (!u?.url) {
|
|
1071
|
+
j(
|
|
1072
|
+
r(I, {
|
|
1073
|
+
options: { url: "", name: c("common.附件预览") },
|
|
1074
|
+
title: c("common.文件信息缺少URL"),
|
|
1075
|
+
desc: c("common.请检查mapResponse是否返回了url字段"),
|
|
1076
|
+
spinning: !1,
|
|
1077
|
+
onDestroy: o
|
|
1078
|
+
}),
|
|
1079
|
+
n
|
|
1080
|
+
);
|
|
1081
|
+
return;
|
|
1082
|
+
}
|
|
1083
|
+
se({
|
|
1084
|
+
...u,
|
|
1085
|
+
requestParams: e,
|
|
1086
|
+
useRegisteredDownload: !0
|
|
1087
|
+
});
|
|
1088
|
+
}).catch((s) => {
|
|
1089
|
+
if (t) return;
|
|
1090
|
+
const u = s instanceof Error ? s.message : c("common.接口请求失败");
|
|
1091
|
+
j(
|
|
1092
|
+
r(I, {
|
|
1093
|
+
options: { url: "", name: c("common.附件预览") },
|
|
1094
|
+
title: c("common.文件信息获取失败"),
|
|
1095
|
+
desc: u,
|
|
1096
|
+
spinning: !1,
|
|
1097
|
+
onDestroy: o
|
|
1098
|
+
}),
|
|
1099
|
+
n
|
|
1100
|
+
);
|
|
1101
|
+
}), a) : (j(
|
|
1102
|
+
r(I, {
|
|
1103
|
+
options: { url: "", name: c("common.附件预览") },
|
|
1104
|
+
title: c("common.附件预览未初始化"),
|
|
1105
|
+
desc: c("common.请先调用setupJtAttachmentPreview注册请求配置"),
|
|
1106
|
+
spinning: !1,
|
|
1107
|
+
onDestroy: o
|
|
1108
|
+
}),
|
|
1109
|
+
n
|
|
1110
|
+
), a);
|
|
1111
|
+
}
|
|
1112
|
+
const ze = Object.assign(se, {
|
|
1113
|
+
openByParams: qe,
|
|
1114
|
+
setup: Je
|
|
1115
|
+
});
|
|
6
1116
|
export {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1117
|
+
ze as JtAttachmentPreview,
|
|
1118
|
+
qe as JtAttachmentPreviewByParams,
|
|
1119
|
+
Je as setupJtAttachmentPreview
|
|
10
1120
|
};
|