@jt-home/mfe-components 1.0.22 → 1.0.24
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 -1
- package/dist/JtAttachmentPreview/index.mjs +360 -337
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +1397 -1406
- package/dist/style.css +1 -1
- package/dist/types/components/form/item/JtCascader/cascaderProps.d.ts +0 -1
- package/dist/types/components/form/item/JtSelect/types.d.ts +0 -2
- package/dist/types/components/form/types.d.ts +0 -2
- package/dist/types/components/table/types.d.ts +2 -2
- package/package.json +93 -92
- package/readme.md +20 -39
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { ElIcon as
|
|
1
|
+
import { defineComponent as D, openBlock as J, createElementBlock as O, createElementVNode as I, ref as x, watch as F, onBeforeUnmount as T, h as a, computed as E, onMounted as K, nextTick as oe, render as X } from "vue";
|
|
2
|
+
import { ElIcon as P } from "element-plus";
|
|
3
3
|
/*! Element Plus Icons Vue v2.3.2 */
|
|
4
|
-
var
|
|
4
|
+
var ie = /* @__PURE__ */ D({
|
|
5
5
|
name: "Download",
|
|
6
6
|
__name: "download",
|
|
7
7
|
setup(e) {
|
|
8
|
-
return (
|
|
8
|
+
return (n, t) => (J(), O("svg", {
|
|
9
9
|
xmlns: "http://www.w3.org/2000/svg",
|
|
10
10
|
viewBox: "0 0 1024 1024"
|
|
11
11
|
}, [
|
|
12
|
-
|
|
12
|
+
I("path", {
|
|
13
13
|
fill: "currentColor",
|
|
14
14
|
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"
|
|
15
15
|
})
|
|
16
16
|
]));
|
|
17
17
|
}
|
|
18
|
-
}),
|
|
18
|
+
}), ce = ie, se = /* @__PURE__ */ D({
|
|
19
19
|
name: "RefreshLeft",
|
|
20
20
|
__name: "refresh-left",
|
|
21
21
|
setup(e) {
|
|
22
|
-
return (
|
|
22
|
+
return (n, t) => (J(), O("svg", {
|
|
23
23
|
xmlns: "http://www.w3.org/2000/svg",
|
|
24
24
|
viewBox: "0 0 1024 1024"
|
|
25
25
|
}, [
|
|
26
|
-
|
|
26
|
+
I("path", {
|
|
27
27
|
fill: "currentColor",
|
|
28
28
|
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"
|
|
29
29
|
})
|
|
30
30
|
]));
|
|
31
31
|
}
|
|
32
|
-
}),
|
|
32
|
+
}), le = se, ue = /* @__PURE__ */ D({
|
|
33
33
|
name: "ZoomIn",
|
|
34
34
|
__name: "zoom-in",
|
|
35
35
|
setup(e) {
|
|
36
|
-
return (
|
|
36
|
+
return (n, t) => (J(), O("svg", {
|
|
37
37
|
xmlns: "http://www.w3.org/2000/svg",
|
|
38
38
|
viewBox: "0 0 1024 1024"
|
|
39
39
|
}, [
|
|
40
|
-
|
|
40
|
+
I("path", {
|
|
41
41
|
fill: "currentColor",
|
|
42
42
|
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"
|
|
43
43
|
})
|
|
44
44
|
]));
|
|
45
45
|
}
|
|
46
|
-
}),
|
|
46
|
+
}), de = ue, ve = /* @__PURE__ */ D({
|
|
47
47
|
name: "ZoomOut",
|
|
48
48
|
__name: "zoom-out",
|
|
49
49
|
setup(e) {
|
|
50
|
-
return (
|
|
50
|
+
return (n, t) => (J(), O("svg", {
|
|
51
51
|
xmlns: "http://www.w3.org/2000/svg",
|
|
52
52
|
viewBox: "0 0 1024 1024"
|
|
53
53
|
}, [
|
|
54
|
-
|
|
54
|
+
I("path", {
|
|
55
55
|
fill: "currentColor",
|
|
56
56
|
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"
|
|
57
57
|
})
|
|
58
58
|
]));
|
|
59
59
|
}
|
|
60
|
-
}),
|
|
61
|
-
const
|
|
60
|
+
}), me = ve;
|
|
61
|
+
const fe = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANgAAADYCAMAAAC+/t3fAAAAaVBMVEUAAABWapNVapKeqsLJztx3hKnGzN2yu8////9XapWcqMGps8lXapVYa5RWaZWps8lfcJjS1+KjrsVXapWapr////9sfaKrtMrV2uWBj7B4iKqWob1wgaXr7fOBj6/Ax9dhc5yhq8OKl7Wba+6tAAAAE3RSTlMAgGDuDyVLoYDe2XuXRb68cy6e4BCQEAAAAyZJREFUeNrt29tyokAUheGOQjIoeMhuCQ4e0Pd/yCE1STU4mGq7bXqzZ/23ufoqYblTqkIIIYQQQggNlM42Lzctf5nMD22bKQYVOQ30sTPt6dEO74mKXLoiCgDTi1RFbUMUBhZXluQUDKbnWxWtjMLB2pYqUjmFg8WUzSg0TL+rCKVZeJheRJj9DYWHRRnHbBSYnr+qcSsoKCyeLKcfK/emc2UqH4LFGMcVWVftTC4w/TbmhGQjwvR6RBmNAbMYx4nD7k/I1GF3ZZOH3RtHAbDhcZQAG5SJgOn1Vt0mAzYwIUJgvjJ/2OVo2pcmcoQZWehxpBGue5sJEQTryyTBeuMoCtadEFmwjkwYzIyjNJief02IONj3OAqE/ZVJhJnZj3RS1c4nld04ijiC/5EJhbUyobBWJhT2OY5CYa1MKKyVCYXpdSIUphdbobB2HIXCWplQmJGFhZUn07kyNaFgbUsx1/1tb1Jh+i1hDmu0Y+uEN4xqV9ki5Q27atfmKWtYqd1lW84wqj1kr5xhB+3RkjGMrl4yxrCm9pG984V5ytZJINjpY7hmLNki5XjdP0fGFkZ0qL1kfGEt7erzgsYY1lYefrtWsIZ5NAMMMBNg9gEGmD3sejbVnRpyjAvs5rr3DzDAAOsEmH2AAQZYJ8Ds4wJrSlN1NE3+CDYJu+5NgNkHGGCAdQLMPsAAA0zuEQyYbYABBlgnwOwDDDDAOvVhl5NJ1Fu1O6lHMGA/xQl2rPodpcBq6gfYYIABBpgJsAdiBDvX/cTAxF4egNkEWGDY5Q5s8v9onoZdR3KNC4yOg7AzOccFNvi36POJIy4wqgZgF/KIC6yporuCwNrq/nNW7ckzLjCi/bO//MEF9mCAAQYYYDwCDDAmAQYYkwADjEmAAcYkwABjEmCAMQkwwJgEGGBMAgwwJgEGGJMAA4xJgAHGJMD+B1hGE6hwgK1oAqUOsJz4lymHCuJfrpTM9SicYC/EvUw5lRD3Psde4lP29YSJG8bse+ulvZZ5uFTCV5YZl6hpXKXKs5TlL22jnlCaM7uHV7NEPam02LwwaVYkCiGEEEIIITTUH1Fqd5V0WMtQAAAAAElFTkSuQmCC", we = "data:image/png;base64,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", pe = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "webp", "bmp", "svg", "avif", "ico"]), he = /* @__PURE__ */ new Set(["mp4", "webm", "ogg", "ogv", "mov", "m4v"]), ge = /* @__PURE__ */ new Set(["mp3", "wav", "ogg", "oga", "m4a", "aac", "flac"]), ye = /* @__PURE__ */ new Set(["html", "htm", "txt", "json", "xml", "csv", "md", "log"]), Ae = /* @__PURE__ */ new Set([
|
|
62
62
|
"doc",
|
|
63
63
|
"docx",
|
|
64
64
|
"xls",
|
|
@@ -69,116 +69,116 @@ const ve = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANgAAADYCAMAAAC+/t3fAA
|
|
|
69
69
|
"rar",
|
|
70
70
|
"7z"
|
|
71
71
|
]);
|
|
72
|
-
let
|
|
73
|
-
async function
|
|
72
|
+
let A = null, U = null, N = null;
|
|
73
|
+
async function _e() {
|
|
74
74
|
return U || (U = Promise.all([
|
|
75
75
|
import("../pdf-BmBuG7of.js"),
|
|
76
76
|
import("../pdf.worker.min-4PI-nNLo.js")
|
|
77
|
-
]).then(([e,
|
|
77
|
+
]).then(([e, n]) => (e.GlobalWorkerOptions.workerSrc = n.default, e))), U;
|
|
78
78
|
}
|
|
79
|
-
function
|
|
79
|
+
function be(e) {
|
|
80
80
|
return typeof e == "string" ? { url: e } : e;
|
|
81
81
|
}
|
|
82
|
-
function
|
|
83
|
-
const [
|
|
84
|
-
return
|
|
82
|
+
function Z(e) {
|
|
83
|
+
const [n] = e.split(/[?#]/);
|
|
84
|
+
return n ?? "";
|
|
85
85
|
}
|
|
86
|
-
function
|
|
87
|
-
if (
|
|
88
|
-
const
|
|
89
|
-
if (!
|
|
86
|
+
function Q(e, n) {
|
|
87
|
+
if (n?.trim()) return n.trim();
|
|
88
|
+
const t = Z(e).split("/").filter(Boolean).pop();
|
|
89
|
+
if (!t) return "附件预览";
|
|
90
90
|
try {
|
|
91
|
-
return decodeURIComponent(
|
|
91
|
+
return decodeURIComponent(t);
|
|
92
92
|
} catch {
|
|
93
|
-
return
|
|
93
|
+
return t;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
function
|
|
97
|
-
return
|
|
96
|
+
function R(e) {
|
|
97
|
+
return Z(e).match(/\.([a-z0-9]+)$/i)?.[1]?.toLowerCase() ?? "";
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function je(e) {
|
|
100
100
|
return e?.trim().replace(/^\./, "").toLowerCase() ?? "";
|
|
101
101
|
}
|
|
102
|
-
function
|
|
103
|
-
const
|
|
104
|
-
return
|
|
102
|
+
function Ee(e) {
|
|
103
|
+
const n = je(e);
|
|
104
|
+
return pe.has(n) ? "image" : n === "pdf" ? "pdf" : he.has(n) ? "video" : ge.has(n) ? "audio" : ye.has(n) ? "iframe" : Ae.has(n) ? "unsupported" : "unknown";
|
|
105
105
|
}
|
|
106
|
-
function
|
|
107
|
-
const
|
|
108
|
-
return
|
|
106
|
+
function q(e) {
|
|
107
|
+
const n = e.toLowerCase().split(";")[0]?.trim() ?? "";
|
|
108
|
+
return n.startsWith("image/") ? "image" : n === "application/pdf" ? "pdf" : n.startsWith("video/") ? "video" : n.startsWith("audio/") ? "audio" : n.startsWith("text/") ? "iframe" : "unknown";
|
|
109
109
|
}
|
|
110
|
-
function
|
|
110
|
+
function $(e) {
|
|
111
111
|
if (!e.url.trim()) return "empty";
|
|
112
112
|
if (e.mode && e.mode !== "auto") return e.mode;
|
|
113
113
|
if (e.mimeType) {
|
|
114
|
-
const
|
|
115
|
-
if (
|
|
114
|
+
const t = q(e.mimeType);
|
|
115
|
+
if (t !== "unknown") return t;
|
|
116
116
|
}
|
|
117
|
-
const
|
|
118
|
-
e.extension ||
|
|
117
|
+
const n = Ee(
|
|
118
|
+
e.extension || R(e.name || "") || R(e.url)
|
|
119
119
|
);
|
|
120
|
-
return
|
|
120
|
+
return n !== "unknown" ? n : "unknown";
|
|
121
121
|
}
|
|
122
|
-
async function
|
|
122
|
+
async function xe(e) {
|
|
123
123
|
try {
|
|
124
|
-
const
|
|
125
|
-
return
|
|
124
|
+
const t = (await fetch(e, { method: "HEAD" })).headers.get("content-type") ?? "";
|
|
125
|
+
return q(t);
|
|
126
126
|
} catch {
|
|
127
127
|
return "unknown";
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
async function
|
|
131
|
-
const
|
|
132
|
-
if (!
|
|
133
|
-
return
|
|
130
|
+
async function ee(e) {
|
|
131
|
+
const n = await fetch(e);
|
|
132
|
+
if (!n.ok) throw new Error(`fetch failed: ${n.status}`);
|
|
133
|
+
return n.blob();
|
|
134
134
|
}
|
|
135
|
-
function
|
|
136
|
-
const
|
|
137
|
-
return
|
|
135
|
+
function De(e, n) {
|
|
136
|
+
const t = R(n);
|
|
137
|
+
return t === "doc" || t === "docx" ? "W" : t === "xls" || t === "xlsx" ? "X" : t === "ppt" || t === "pptx" ? "P" : t === "zip" || t === "rar" || t === "7z" ? "ZIP" : e === "pdf" ? "PDF" : "FILE";
|
|
138
138
|
}
|
|
139
|
-
function
|
|
140
|
-
return
|
|
139
|
+
function te(e, n, t) {
|
|
140
|
+
return a(
|
|
141
141
|
"button",
|
|
142
142
|
{
|
|
143
|
-
class:
|
|
143
|
+
class: t,
|
|
144
144
|
type: "button",
|
|
145
145
|
onClick: () => {
|
|
146
|
-
|
|
146
|
+
ae(e, n);
|
|
147
147
|
}
|
|
148
148
|
},
|
|
149
149
|
[
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
a(P, { class: "jt-attachment-preview-service__download-icon" }, () => a(ce)),
|
|
151
|
+
a("span", { class: "jt-attachment-preview-service__download-text" }, "下载")
|
|
152
152
|
]
|
|
153
153
|
);
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function H(e) {
|
|
156
156
|
return e === "image" || e === "pdf";
|
|
157
157
|
}
|
|
158
|
-
function
|
|
159
|
-
return
|
|
160
|
-
|
|
158
|
+
function ne(e) {
|
|
159
|
+
return a("div", { class: "jt-attachment-preview-service__preview-fallback" }, [
|
|
160
|
+
a("img", {
|
|
161
161
|
class: "jt-attachment-preview-service__preview-fallback-icon",
|
|
162
162
|
src: e.icon,
|
|
163
163
|
alt: ""
|
|
164
164
|
}),
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
a("div", { class: "jt-attachment-preview-service__unsupported-text" }, "暂不支持预览此类型的文件"),
|
|
166
|
+
a("div", { class: "jt-attachment-preview-service__file-name", title: e.name }, e.name)
|
|
167
167
|
]);
|
|
168
168
|
}
|
|
169
|
-
function
|
|
170
|
-
const
|
|
171
|
-
|
|
169
|
+
function z(e, n) {
|
|
170
|
+
const t = document.createElement("a");
|
|
171
|
+
t.href = e, t.download = n, t.style.display = "none", document.body.appendChild(t), t.click(), t.remove();
|
|
172
172
|
}
|
|
173
|
-
async function
|
|
173
|
+
async function ae(e, n) {
|
|
174
174
|
try {
|
|
175
|
-
const
|
|
176
|
-
|
|
175
|
+
const t = await ee(e), c = URL.createObjectURL(t);
|
|
176
|
+
z(c, n), URL.revokeObjectURL(c);
|
|
177
177
|
} catch {
|
|
178
|
-
|
|
178
|
+
z(e, n);
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
-
const
|
|
181
|
+
const ke = D({
|
|
182
182
|
name: "JtAttachmentPreviewPdfCanvas",
|
|
183
183
|
props: {
|
|
184
184
|
url: {
|
|
@@ -202,121 +202,121 @@ const xe = k({
|
|
|
202
202
|
previewLoad: (e) => e instanceof Event,
|
|
203
203
|
previewError: (e) => e instanceof Event
|
|
204
204
|
},
|
|
205
|
-
setup(e, { emit:
|
|
206
|
-
const
|
|
207
|
-
let d = null,
|
|
208
|
-
async function
|
|
209
|
-
if (!
|
|
210
|
-
const
|
|
211
|
-
return !Array.isArray(
|
|
205
|
+
setup(e, { emit: n }) {
|
|
206
|
+
const t = x("loading"), c = x([]), o = x([]), i = /* @__PURE__ */ new Map(), u = x("");
|
|
207
|
+
let d = null, w = [], m = 0;
|
|
208
|
+
async function v(r, l) {
|
|
209
|
+
if (!l) return null;
|
|
210
|
+
const f = typeof l == "string" ? await r.getDestination(l) : l;
|
|
211
|
+
return !Array.isArray(f) || !f[0] ? null : await r.getPageIndex(f[0]) + 1;
|
|
212
212
|
}
|
|
213
|
-
async function
|
|
214
|
-
if (!
|
|
215
|
-
const
|
|
216
|
-
for (const
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
title:
|
|
220
|
-
pageNumber:
|
|
221
|
-
level:
|
|
213
|
+
async function _(r, l, f = 0) {
|
|
214
|
+
if (!l?.length) return [];
|
|
215
|
+
const b = [];
|
|
216
|
+
for (const j of l) {
|
|
217
|
+
const k = await v(r, j.dest);
|
|
218
|
+
b.push({
|
|
219
|
+
title: j.title || "未命名标题",
|
|
220
|
+
pageNumber: k,
|
|
221
|
+
level: f
|
|
222
222
|
});
|
|
223
|
-
const g = await
|
|
224
|
-
|
|
223
|
+
const g = await _(r, j.items, f + 1);
|
|
224
|
+
b.push(...g);
|
|
225
225
|
}
|
|
226
|
-
return
|
|
226
|
+
return b;
|
|
227
227
|
}
|
|
228
|
-
function
|
|
229
|
-
|
|
230
|
-
for (const
|
|
231
|
-
|
|
232
|
-
|
|
228
|
+
function h() {
|
|
229
|
+
m += 1;
|
|
230
|
+
for (const r of w)
|
|
231
|
+
r.cancel();
|
|
232
|
+
w = [], d?.destroy(), d = null, i.clear();
|
|
233
233
|
}
|
|
234
|
-
async function
|
|
235
|
-
|
|
236
|
-
const
|
|
237
|
-
|
|
234
|
+
async function C() {
|
|
235
|
+
h();
|
|
236
|
+
const r = m;
|
|
237
|
+
t.value = "loading", u.value = "", c.value = [], o.value = [];
|
|
238
238
|
try {
|
|
239
|
-
const
|
|
240
|
-
if (
|
|
241
|
-
d =
|
|
242
|
-
const
|
|
243
|
-
if (
|
|
244
|
-
|
|
245
|
-
const
|
|
246
|
-
for (const
|
|
247
|
-
if (
|
|
248
|
-
const g = await
|
|
249
|
-
if (!y || !
|
|
250
|
-
const G = g.getViewport({ scale: 1 }), S = Math.min(
|
|
251
|
-
y.width = Math.floor(
|
|
252
|
-
const
|
|
239
|
+
const l = await _e();
|
|
240
|
+
if (r !== m) return;
|
|
241
|
+
d = l.getDocument({ url: e.url });
|
|
242
|
+
const f = await d.promise;
|
|
243
|
+
if (r !== m) return;
|
|
244
|
+
c.value = Array.from({ length: f.numPages }, (k, g) => g + 1), o.value = await _(f, await f.getOutline()), await oe();
|
|
245
|
+
const b = i.values().next().value, j = Math.max((b?.parentElement?.clientWidth ?? 800) - 32, 320);
|
|
246
|
+
for (const k of c.value) {
|
|
247
|
+
if (r !== m) return;
|
|
248
|
+
const g = await f.getPage(k), y = i.get(k), L = y?.getContext("2d");
|
|
249
|
+
if (!y || !L) continue;
|
|
250
|
+
const G = g.getViewport({ scale: 1 }), S = Math.min(j / G.width, 2), s = g.getViewport({ scale: S }), B = window.devicePixelRatio || 1;
|
|
251
|
+
y.width = Math.floor(s.width * B), y.height = Math.floor(s.height * B), y.style.width = `${Math.floor(s.width)}px`, y.style.height = `${Math.floor(s.height)}px`, L.setTransform(B, 0, 0, B, 0, 0);
|
|
252
|
+
const V = g.render({
|
|
253
253
|
canvas: y,
|
|
254
|
-
canvasContext:
|
|
255
|
-
viewport:
|
|
254
|
+
canvasContext: L,
|
|
255
|
+
viewport: s
|
|
256
256
|
});
|
|
257
|
-
|
|
257
|
+
w.push(V), await V.promise;
|
|
258
258
|
}
|
|
259
|
-
if (
|
|
260
|
-
|
|
261
|
-
} catch (
|
|
262
|
-
if (
|
|
263
|
-
|
|
259
|
+
if (r !== m) return;
|
|
260
|
+
t.value = "ready", n("previewLoad", new Event("load"));
|
|
261
|
+
} catch (l) {
|
|
262
|
+
if (r !== m) return;
|
|
263
|
+
t.value = "error", u.value = l instanceof Error ? l.message : "PDF 加载失败", n("previewError", new Event("error"));
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
|
-
|
|
267
|
-
function
|
|
268
|
-
if (!
|
|
269
|
-
|
|
266
|
+
F(() => e.url, C, { immediate: !0 }), T(h);
|
|
267
|
+
function p(r) {
|
|
268
|
+
if (!r) return;
|
|
269
|
+
i.get(r)?.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
270
270
|
}
|
|
271
|
-
return () =>
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
icon:
|
|
271
|
+
return () => a("div", { class: "jt-attachment-preview-service__pdf-viewer" }, [
|
|
272
|
+
t.value === "loading" ? a("div", { class: "jt-attachment-preview-service__pdf-state" }, "PDF 加载中...") : null,
|
|
273
|
+
t.value === "error" ? a("div", { class: "jt-attachment-preview-service__pdf-state" }, [
|
|
274
|
+
ne({
|
|
275
|
+
icon: we,
|
|
276
276
|
name: e.name
|
|
277
277
|
})
|
|
278
278
|
]) : null,
|
|
279
279
|
null,
|
|
280
280
|
null,
|
|
281
|
-
|
|
281
|
+
a(
|
|
282
282
|
"div",
|
|
283
283
|
{
|
|
284
284
|
class: [
|
|
285
285
|
"jt-attachment-preview-service__pdf-layout",
|
|
286
|
-
|
|
286
|
+
t.value !== "ready" ? "jt-attachment-preview-service__pdf-layout--hidden" : ""
|
|
287
287
|
]
|
|
288
288
|
},
|
|
289
289
|
[
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
290
|
+
o.value.length ? a("aside", { class: "jt-attachment-preview-service__pdf-outline" }, [
|
|
291
|
+
a("div", { class: "jt-attachment-preview-service__pdf-outline-title" }, "目录"),
|
|
292
|
+
a(
|
|
293
293
|
"div",
|
|
294
294
|
{ class: "jt-attachment-preview-service__pdf-outline-list" },
|
|
295
|
-
|
|
296
|
-
(
|
|
295
|
+
o.value.map(
|
|
296
|
+
(r, l) => a(
|
|
297
297
|
"button",
|
|
298
298
|
{
|
|
299
|
-
key: `${
|
|
299
|
+
key: `${r.title}-${l}`,
|
|
300
300
|
class: "jt-attachment-preview-service__pdf-outline-item",
|
|
301
|
-
style: { paddingLeft: `${12 +
|
|
301
|
+
style: { paddingLeft: `${12 + r.level * 14}px` },
|
|
302
302
|
type: "button",
|
|
303
|
-
disabled: !
|
|
304
|
-
title:
|
|
305
|
-
onClick: () =>
|
|
303
|
+
disabled: !r.pageNumber,
|
|
304
|
+
title: r.title,
|
|
305
|
+
onClick: () => p(r.pageNumber)
|
|
306
306
|
},
|
|
307
|
-
|
|
307
|
+
r.title
|
|
308
308
|
)
|
|
309
309
|
)
|
|
310
310
|
)
|
|
311
311
|
]) : null,
|
|
312
|
-
|
|
312
|
+
a(
|
|
313
313
|
"div",
|
|
314
314
|
{ class: "jt-attachment-preview-service__pdf-pages" },
|
|
315
|
-
|
|
316
|
-
(
|
|
317
|
-
key:
|
|
318
|
-
ref: (
|
|
319
|
-
|
|
315
|
+
c.value.map(
|
|
316
|
+
(r) => a("canvas", {
|
|
317
|
+
key: r,
|
|
318
|
+
ref: (l) => {
|
|
319
|
+
l instanceof HTMLCanvasElement && i.set(r, l);
|
|
320
320
|
},
|
|
321
321
|
class: "jt-attachment-preview-service__pdf-page"
|
|
322
322
|
})
|
|
@@ -326,7 +326,7 @@ const xe = k({
|
|
|
326
326
|
)
|
|
327
327
|
]);
|
|
328
328
|
}
|
|
329
|
-
}),
|
|
329
|
+
}), Le = D({
|
|
330
330
|
name: "JtAttachmentPreviewImageTransform",
|
|
331
331
|
props: {
|
|
332
332
|
url: {
|
|
@@ -354,114 +354,114 @@ const xe = k({
|
|
|
354
354
|
previewLoad: (e) => e instanceof Event,
|
|
355
355
|
previewError: (e) => e instanceof Event
|
|
356
356
|
},
|
|
357
|
-
setup(e, { emit:
|
|
358
|
-
const
|
|
359
|
-
let
|
|
360
|
-
const
|
|
357
|
+
setup(e, { emit: n }) {
|
|
358
|
+
const t = x(null), c = x("ready"), o = x(1), i = x(!1);
|
|
359
|
+
let u = 0, d = 0, w = 0, m = 0, v = 0, _ = 0, h = 0;
|
|
360
|
+
const C = E(() => ({
|
|
361
361
|
"--jt-attachment-preview-service-image-fit": e.fit,
|
|
362
|
-
transform: `translate(${
|
|
362
|
+
transform: `translate(${u}px, ${d}px) scale(${o.value})`
|
|
363
363
|
}));
|
|
364
|
-
function
|
|
365
|
-
|
|
364
|
+
function p() {
|
|
365
|
+
t.value && (t.value.style.transform = `translate(${u}px, ${d}px) scale(${o.value})`);
|
|
366
366
|
}
|
|
367
|
-
function
|
|
368
|
-
|
|
369
|
-
|
|
367
|
+
function r() {
|
|
368
|
+
h || (h = window.requestAnimationFrame(() => {
|
|
369
|
+
h = 0, p();
|
|
370
370
|
}));
|
|
371
371
|
}
|
|
372
|
-
function
|
|
373
|
-
|
|
372
|
+
function l(s) {
|
|
373
|
+
o.value = Math.min(Math.max(Number(s.toFixed(2)), 0.2), 5), o.value <= 1 && (u = 0, d = 0), p();
|
|
374
|
+
}
|
|
375
|
+
function f() {
|
|
376
|
+
l(o.value + 0.2);
|
|
374
377
|
}
|
|
375
|
-
function
|
|
376
|
-
|
|
378
|
+
function b() {
|
|
379
|
+
const s = Math.max(Number((o.value - 0.2).toFixed(2)), 0.2);
|
|
380
|
+
o.value = s, s <= 1 && (u = 0, d = 0), p();
|
|
377
381
|
}
|
|
378
382
|
function j() {
|
|
379
|
-
|
|
380
|
-
r.value = c, c <= 1 && (l = 0, d = 0), f();
|
|
381
|
-
}
|
|
382
|
-
function E() {
|
|
383
|
-
l = 0, d = 0, u(1);
|
|
383
|
+
u = 0, d = 0, l(1);
|
|
384
384
|
}
|
|
385
|
-
function
|
|
386
|
-
|
|
385
|
+
function k(s) {
|
|
386
|
+
c.value = "ready", n("previewLoad", s);
|
|
387
387
|
}
|
|
388
|
-
function g(
|
|
389
|
-
|
|
388
|
+
function g(s) {
|
|
389
|
+
c.value = "error", n("previewError", s);
|
|
390
390
|
}
|
|
391
|
-
function y(
|
|
392
|
-
|
|
391
|
+
function y(s) {
|
|
392
|
+
o.value <= 1 || (s.preventDefault(), i.value = !0, w = s.clientX, m = s.clientY, v = u, _ = d, window.addEventListener("pointermove", L), window.addEventListener("pointerup", G, { once: !0 }));
|
|
393
393
|
}
|
|
394
|
-
function
|
|
395
|
-
|
|
394
|
+
function L(s) {
|
|
395
|
+
i.value && (u = v + s.clientX - w, d = _ + s.clientY - m, r());
|
|
396
396
|
}
|
|
397
397
|
function G() {
|
|
398
|
-
|
|
398
|
+
i.value = !1, window.removeEventListener("pointermove", L);
|
|
399
399
|
}
|
|
400
|
-
function S(
|
|
401
|
-
|
|
400
|
+
function S(s) {
|
|
401
|
+
s.preventDefault(), l(o.value + (s.deltaY < 0 ? 0.1 : -0.1));
|
|
402
402
|
}
|
|
403
|
-
return
|
|
404
|
-
|
|
403
|
+
return K(p), F(() => e.url, () => {
|
|
404
|
+
c.value = "ready", j();
|
|
405
405
|
}), T(() => {
|
|
406
|
-
window.removeEventListener("pointermove",
|
|
407
|
-
}), () =>
|
|
408
|
-
icon:
|
|
406
|
+
window.removeEventListener("pointermove", L), h && window.cancelAnimationFrame(h);
|
|
407
|
+
}), () => a("div", { class: "jt-attachment-preview-service__image-viewer" }, c.value === "error" ? ne({
|
|
408
|
+
icon: fe,
|
|
409
409
|
name: e.name
|
|
410
410
|
}) : [
|
|
411
|
-
|
|
412
|
-
ref:
|
|
411
|
+
a("img", {
|
|
412
|
+
ref: t,
|
|
413
413
|
class: [
|
|
414
414
|
"jt-attachment-preview-service__media",
|
|
415
415
|
"jt-attachment-preview-service__image",
|
|
416
|
-
|
|
417
|
-
|
|
416
|
+
o.value > 1 ? "jt-attachment-preview-service__image--draggable" : "",
|
|
417
|
+
i.value ? "jt-attachment-preview-service__image--dragging" : ""
|
|
418
418
|
],
|
|
419
419
|
src: e.url,
|
|
420
420
|
alt: e.name,
|
|
421
|
-
style:
|
|
422
|
-
onLoad:
|
|
421
|
+
style: C.value,
|
|
422
|
+
onLoad: k,
|
|
423
423
|
onError: g,
|
|
424
424
|
onPointerdown: y,
|
|
425
425
|
onWheel: S,
|
|
426
|
-
onDragstart: (
|
|
426
|
+
onDragstart: (s) => s.preventDefault(),
|
|
427
427
|
draggable: !1
|
|
428
428
|
}),
|
|
429
|
-
|
|
430
|
-
|
|
429
|
+
a("div", { class: "jt-attachment-preview-service__image-toolbar" }, [
|
|
430
|
+
a(
|
|
431
431
|
"button",
|
|
432
432
|
{
|
|
433
433
|
class: "jt-attachment-preview-service__image-tool",
|
|
434
434
|
type: "button",
|
|
435
435
|
title: "缩小",
|
|
436
|
-
onClick:
|
|
436
|
+
onClick: b
|
|
437
437
|
},
|
|
438
|
-
[
|
|
438
|
+
[a(P, () => a(me))]
|
|
439
439
|
),
|
|
440
|
-
|
|
441
|
-
|
|
440
|
+
a("span", { class: "jt-attachment-preview-service__image-scale" }, `${Math.round(o.value * 100)}%`),
|
|
441
|
+
a(
|
|
442
442
|
"button",
|
|
443
443
|
{
|
|
444
444
|
class: "jt-attachment-preview-service__image-tool",
|
|
445
445
|
type: "button",
|
|
446
446
|
title: "放大",
|
|
447
|
-
onClick:
|
|
447
|
+
onClick: f
|
|
448
448
|
},
|
|
449
|
-
[
|
|
449
|
+
[a(P, () => a(de))]
|
|
450
450
|
),
|
|
451
|
-
|
|
451
|
+
a(
|
|
452
452
|
"button",
|
|
453
453
|
{
|
|
454
454
|
class: "jt-attachment-preview-service__image-tool",
|
|
455
455
|
type: "button",
|
|
456
456
|
title: "复位",
|
|
457
|
-
onClick:
|
|
457
|
+
onClick: j
|
|
458
458
|
},
|
|
459
|
-
[
|
|
459
|
+
[a(P, () => a(le))]
|
|
460
460
|
)
|
|
461
461
|
])
|
|
462
462
|
]);
|
|
463
463
|
}
|
|
464
|
-
}),
|
|
464
|
+
}), Ce = D({
|
|
465
465
|
name: "JtAttachmentPreviewService",
|
|
466
466
|
props: {
|
|
467
467
|
options: {
|
|
@@ -474,64 +474,64 @@ const xe = k({
|
|
|
474
474
|
}
|
|
475
475
|
},
|
|
476
476
|
setup(e) {
|
|
477
|
-
const
|
|
477
|
+
const n = E(() => Q(e.options.url, e.options.name)), t = E(() => e.options.downloadName || n.value), c = E(() => $(e.options)), o = E(() => De(c.value, e.options.url)), i = E(() => ({
|
|
478
478
|
zIndex: e.options.zIndex ?? 3e3,
|
|
479
479
|
"--jt-attachment-preview-service-image-fit": e.options.fit ?? "contain"
|
|
480
480
|
}));
|
|
481
|
-
function
|
|
481
|
+
function u() {
|
|
482
482
|
e.options.onClose?.(), e.onDestroy();
|
|
483
483
|
}
|
|
484
|
-
function d(
|
|
485
|
-
|
|
484
|
+
function d(v) {
|
|
485
|
+
v.key === "Escape" && e.options.closeOnPressEscape !== !1 && u();
|
|
486
486
|
}
|
|
487
|
-
function
|
|
488
|
-
e.options.onLoad?.(
|
|
487
|
+
function w(v) {
|
|
488
|
+
e.options.onLoad?.(v);
|
|
489
489
|
}
|
|
490
|
-
function v
|
|
491
|
-
e.options.onError?.(
|
|
490
|
+
function m(v) {
|
|
491
|
+
e.options.onError?.(v);
|
|
492
492
|
}
|
|
493
|
-
return
|
|
493
|
+
return K(() => {
|
|
494
494
|
document.addEventListener("keydown", d), document.body.classList.add("jt-attachment-preview-service-lock");
|
|
495
495
|
}), T(() => {
|
|
496
496
|
document.removeEventListener("keydown", d), document.body.classList.remove("jt-attachment-preview-service-lock");
|
|
497
497
|
}), () => {
|
|
498
|
-
const
|
|
499
|
-
return
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
...
|
|
505
|
-
|
|
498
|
+
const v = e.options.downloadable === !1 ? [] : [te(e.options.url, t.value, "jt-attachment-preview-service__top-download")];
|
|
499
|
+
return a("div", { class: "jt-attachment-preview-service", style: i.value }, [
|
|
500
|
+
a("div", { class: "jt-attachment-preview-service__modal" }, [
|
|
501
|
+
a("div", { class: "jt-attachment-preview-service__header" }, [
|
|
502
|
+
a("div", { class: "jt-attachment-preview-service__filename", title: n.value }, n.value),
|
|
503
|
+
a("div", { class: "jt-attachment-preview-service__header-actions" }, [
|
|
504
|
+
...v,
|
|
505
|
+
a(
|
|
506
506
|
"button",
|
|
507
507
|
{
|
|
508
508
|
class: "jt-attachment-preview-service__close",
|
|
509
509
|
type: "button",
|
|
510
510
|
"aria-label": "关闭",
|
|
511
|
-
onClick:
|
|
511
|
+
onClick: u
|
|
512
512
|
},
|
|
513
513
|
"×"
|
|
514
514
|
)
|
|
515
515
|
])
|
|
516
516
|
]),
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
type:
|
|
517
|
+
a("div", { class: "jt-attachment-preview-service__body" }, [
|
|
518
|
+
Me({
|
|
519
|
+
type: c.value,
|
|
520
520
|
url: e.options.url,
|
|
521
|
-
name:
|
|
522
|
-
downloadName:
|
|
521
|
+
name: n.value,
|
|
522
|
+
downloadName: t.value,
|
|
523
523
|
sandbox: e.options.sandbox,
|
|
524
|
-
iconText:
|
|
524
|
+
iconText: o.value,
|
|
525
525
|
downloadable: e.options.downloadable !== !1,
|
|
526
|
-
onLoad:
|
|
527
|
-
onError:
|
|
526
|
+
onLoad: w,
|
|
527
|
+
onError: m
|
|
528
528
|
})
|
|
529
529
|
])
|
|
530
530
|
])
|
|
531
531
|
]);
|
|
532
532
|
};
|
|
533
533
|
}
|
|
534
|
-
}), Y =
|
|
534
|
+
}), Y = D({
|
|
535
535
|
name: "JtAttachmentPreviewDetectingService",
|
|
536
536
|
props: {
|
|
537
537
|
options: {
|
|
@@ -556,205 +556,228 @@ const xe = k({
|
|
|
556
556
|
}
|
|
557
557
|
},
|
|
558
558
|
setup(e) {
|
|
559
|
-
const
|
|
559
|
+
const n = E(() => Q(e.options.url, e.options.name)), t = E(() => ({
|
|
560
560
|
zIndex: e.options.zIndex ?? 3e3
|
|
561
561
|
}));
|
|
562
|
-
function
|
|
562
|
+
function c() {
|
|
563
563
|
e.options.onClose?.(), e.onDestroy();
|
|
564
564
|
}
|
|
565
|
-
function
|
|
566
|
-
|
|
565
|
+
function o(i) {
|
|
566
|
+
i.key === "Escape" && e.options.closeOnPressEscape !== !1 && c();
|
|
567
567
|
}
|
|
568
|
-
return
|
|
569
|
-
document.addEventListener("keydown",
|
|
568
|
+
return K(() => {
|
|
569
|
+
document.addEventListener("keydown", o), document.body.classList.add("jt-attachment-preview-service-lock");
|
|
570
570
|
}), T(() => {
|
|
571
|
-
document.removeEventListener("keydown",
|
|
572
|
-
}), () =>
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
571
|
+
document.removeEventListener("keydown", o), document.body.classList.remove("jt-attachment-preview-service-lock");
|
|
572
|
+
}), () => a("div", { class: "jt-attachment-preview-service", style: t.value }, [
|
|
573
|
+
a("div", { class: "jt-attachment-preview-service__modal" }, [
|
|
574
|
+
a("div", { class: "jt-attachment-preview-service__header" }, [
|
|
575
|
+
a("div", { class: "jt-attachment-preview-service__filename", title: n.value }, n.value),
|
|
576
|
+
a("div", { class: "jt-attachment-preview-service__header-actions" }, [
|
|
577
|
+
a(
|
|
578
578
|
"button",
|
|
579
579
|
{
|
|
580
580
|
class: "jt-attachment-preview-service__close",
|
|
581
581
|
type: "button",
|
|
582
582
|
"aria-label": "关闭",
|
|
583
|
-
onClick:
|
|
583
|
+
onClick: c
|
|
584
584
|
},
|
|
585
585
|
"×"
|
|
586
586
|
)
|
|
587
587
|
])
|
|
588
588
|
]),
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
e.spinning ?
|
|
592
|
-
|
|
593
|
-
|
|
589
|
+
a("div", { class: "jt-attachment-preview-service__body" }, [
|
|
590
|
+
a("div", { class: "jt-attachment-preview-service__detecting" }, [
|
|
591
|
+
e.spinning ? a("span", { class: "jt-attachment-preview-service__detecting-spinner" }) : null,
|
|
592
|
+
a("span", { class: "jt-attachment-preview-service__detecting-title" }, e.title),
|
|
593
|
+
a("span", { class: "jt-attachment-preview-service__detecting-desc" }, e.desc)
|
|
594
594
|
])
|
|
595
595
|
])
|
|
596
596
|
])
|
|
597
597
|
]);
|
|
598
598
|
}
|
|
599
599
|
});
|
|
600
|
-
function
|
|
601
|
-
return e.type === "empty" ?
|
|
600
|
+
function Me(e) {
|
|
601
|
+
return e.type === "empty" ? a("div", { class: "jt-attachment-preview-service__empty" }, "暂无附件") : e.type === "image" ? a(Le, {
|
|
602
602
|
url: e.url,
|
|
603
603
|
name: e.name,
|
|
604
604
|
downloadName: e.downloadName,
|
|
605
605
|
downloadable: e.downloadable,
|
|
606
606
|
onPreviewLoad: e.onLoad,
|
|
607
607
|
onPreviewError: e.onError
|
|
608
|
-
}) : e.type === "video" ?
|
|
608
|
+
}) : e.type === "video" ? a("video", {
|
|
609
609
|
class: "jt-attachment-preview-service__media",
|
|
610
610
|
src: e.url,
|
|
611
611
|
controls: !0,
|
|
612
612
|
onLoadeddata: e.onLoad,
|
|
613
613
|
onError: e.onError
|
|
614
|
-
}) : e.type === "audio" ?
|
|
614
|
+
}) : e.type === "audio" ? a("audio", {
|
|
615
615
|
class: "jt-attachment-preview-service__audio",
|
|
616
616
|
src: e.url,
|
|
617
617
|
controls: !0,
|
|
618
618
|
onLoadeddata: e.onLoad,
|
|
619
619
|
onError: e.onError
|
|
620
|
-
}) : e.type === "pdf" ?
|
|
620
|
+
}) : e.type === "pdf" ? a(ke, {
|
|
621
621
|
url: e.url,
|
|
622
622
|
name: e.name,
|
|
623
623
|
downloadName: e.downloadName,
|
|
624
624
|
downloadable: e.downloadable,
|
|
625
625
|
onPreviewLoad: e.onLoad,
|
|
626
626
|
onPreviewError: e.onError
|
|
627
|
-
}) : e.type === "iframe" ?
|
|
627
|
+
}) : e.type === "iframe" ? a("iframe", {
|
|
628
628
|
class: "jt-attachment-preview-service__iframe",
|
|
629
629
|
src: e.url,
|
|
630
630
|
title: e.name,
|
|
631
631
|
sandbox: e.sandbox || void 0,
|
|
632
632
|
onLoad: e.onLoad
|
|
633
|
-
}) :
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
633
|
+
}) : a("div", { class: "jt-attachment-preview-service__unsupported" }, [
|
|
634
|
+
a("div", { class: "jt-attachment-preview-service__file-card" }, [
|
|
635
|
+
a("div", { class: "jt-attachment-preview-service__file-icon" }, e.iconText),
|
|
636
|
+
a("div", { class: "jt-attachment-preview-service__unsupported-text" }, "暂不支持预览此类型的文件")
|
|
637
637
|
]),
|
|
638
|
-
|
|
639
|
-
e.downloadable ?
|
|
638
|
+
a("div", { class: "jt-attachment-preview-service__file-name", title: e.name }, e.name),
|
|
639
|
+
e.downloadable ? te(e.url, e.downloadName, "jt-attachment-preview-service__primary-download") : null
|
|
640
640
|
]);
|
|
641
641
|
}
|
|
642
|
-
function
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
642
|
+
function M(e, n) {
|
|
643
|
+
try {
|
|
644
|
+
X(e, n);
|
|
645
|
+
} catch (t) {
|
|
646
|
+
console.error("[JtAttachmentPreview] render failed", t);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
function W(e) {
|
|
650
|
+
window.setTimeout(() => {
|
|
651
|
+
try {
|
|
652
|
+
X(null, e);
|
|
653
|
+
} catch (n) {
|
|
654
|
+
console.error("[JtAttachmentPreview] unmount failed", n);
|
|
655
|
+
}
|
|
656
|
+
e.remove();
|
|
657
|
+
}, 0);
|
|
658
|
+
}
|
|
659
|
+
function re(e, n) {
|
|
660
|
+
const t = be(e), c = t.downloadName || Q(t.url, t.name);
|
|
661
|
+
let o = !1, i = n?.container ?? null, u = null;
|
|
662
|
+
const d = () => {
|
|
663
|
+
o || (o = !0, i && (W(i), i = null), u && (URL.revokeObjectURL(u), u = null), n?.onClose?.(), A?.close === d && (A = null));
|
|
651
664
|
};
|
|
652
|
-
function
|
|
653
|
-
|
|
665
|
+
function w() {
|
|
666
|
+
o || (i || (i = document.createElement("div"), document.body.appendChild(i)), M(a(Ce, { options: t, onDestroy: d }), i));
|
|
654
667
|
}
|
|
655
|
-
function
|
|
656
|
-
|
|
668
|
+
function m() {
|
|
669
|
+
o || (i || (i = document.createElement("div"), document.body.appendChild(i)), M(a(Y, { options: t, onDestroy: d }), i));
|
|
657
670
|
}
|
|
658
671
|
function v() {
|
|
659
|
-
|
|
672
|
+
i && (W(i), i = null, n?.onClose?.());
|
|
660
673
|
}
|
|
661
|
-
function
|
|
662
|
-
|
|
674
|
+
function _() {
|
|
675
|
+
o || ae(t.url, c);
|
|
663
676
|
}
|
|
664
|
-
function
|
|
665
|
-
if (
|
|
666
|
-
const
|
|
667
|
-
|
|
677
|
+
function h(p) {
|
|
678
|
+
if (o) return;
|
|
679
|
+
const r = URL.createObjectURL(p);
|
|
680
|
+
z(r, c), URL.revokeObjectURL(r);
|
|
668
681
|
}
|
|
669
|
-
const
|
|
670
|
-
return
|
|
671
|
-
if (!
|
|
672
|
-
if (
|
|
673
|
-
t.mode =
|
|
682
|
+
const C = $(t);
|
|
683
|
+
return H(C) ? w() : C === "unknown" ? (m(), xe(t.url).then(async (p) => {
|
|
684
|
+
if (!o) {
|
|
685
|
+
if (H(p)) {
|
|
686
|
+
t.mode = p, w();
|
|
674
687
|
return;
|
|
675
688
|
}
|
|
676
689
|
try {
|
|
677
|
-
const
|
|
678
|
-
if (
|
|
679
|
-
|
|
690
|
+
const r = await ee(t.url), l = q(r.type);
|
|
691
|
+
if (H(l)) {
|
|
692
|
+
u = URL.createObjectURL(r), t.url = u, t.mode = l, w();
|
|
680
693
|
return;
|
|
681
694
|
}
|
|
682
|
-
v(),
|
|
695
|
+
v(), h(r);
|
|
683
696
|
} catch {
|
|
684
|
-
v(),
|
|
697
|
+
v(), _();
|
|
685
698
|
}
|
|
686
699
|
}
|
|
687
|
-
})) :
|
|
700
|
+
})) : (v(), _()), A = { close: d }, A;
|
|
688
701
|
}
|
|
689
|
-
function
|
|
690
|
-
|
|
702
|
+
function Ye(e) {
|
|
703
|
+
return typeof document > "u" ? { close: () => {
|
|
704
|
+
} } : (A?.close(), re(e));
|
|
691
705
|
}
|
|
692
|
-
function
|
|
706
|
+
function Be(e) {
|
|
707
|
+
N = e;
|
|
708
|
+
}
|
|
709
|
+
function Pe(e) {
|
|
693
710
|
if (typeof document > "u")
|
|
694
711
|
return { close: () => {
|
|
695
712
|
} };
|
|
696
|
-
|
|
697
|
-
let
|
|
698
|
-
document.body.appendChild(
|
|
699
|
-
const
|
|
700
|
-
|
|
701
|
-
},
|
|
702
|
-
return
|
|
703
|
-
|
|
713
|
+
A?.close();
|
|
714
|
+
let n = !1, t = document.createElement("div");
|
|
715
|
+
document.body.appendChild(t);
|
|
716
|
+
const c = () => {
|
|
717
|
+
n || (n = !0, t && (W(t), t = null), A?.close === c && (A = null));
|
|
718
|
+
}, o = { close: c };
|
|
719
|
+
return A = o, N ? (M(
|
|
720
|
+
a(Y, {
|
|
704
721
|
options: { url: "", name: "附件预览" },
|
|
705
722
|
title: "正在获取文件信息",
|
|
706
723
|
desc: "请稍候,获取完成后将自动预览或下载",
|
|
707
724
|
spinning: !0,
|
|
708
|
-
onDestroy:
|
|
725
|
+
onDestroy: c
|
|
709
726
|
}),
|
|
710
|
-
|
|
711
|
-
),
|
|
712
|
-
if (
|
|
713
|
-
const
|
|
714
|
-
if (!
|
|
715
|
-
|
|
716
|
-
|
|
727
|
+
t
|
|
728
|
+
), N.request(e).then((i) => {
|
|
729
|
+
if (n) return;
|
|
730
|
+
const u = N?.mapResponse(i, e);
|
|
731
|
+
if (!u?.url) {
|
|
732
|
+
M(
|
|
733
|
+
a(Y, {
|
|
717
734
|
options: { url: "", name: "附件预览" },
|
|
718
735
|
title: "文件信息缺少 URL",
|
|
719
736
|
desc: "请检查 mapResponse 是否返回了 url 字段",
|
|
720
737
|
spinning: !1,
|
|
721
|
-
onDestroy:
|
|
738
|
+
onDestroy: c
|
|
722
739
|
}),
|
|
723
|
-
|
|
740
|
+
t
|
|
724
741
|
);
|
|
725
742
|
return;
|
|
726
743
|
}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
744
|
+
const d = re(u, {
|
|
745
|
+
container: t,
|
|
746
|
+
onClose: () => {
|
|
747
|
+
n = !0, t = null;
|
|
748
|
+
}
|
|
749
|
+
});
|
|
750
|
+
o.close = d.close;
|
|
751
|
+
}).catch((i) => {
|
|
752
|
+
if (n) return;
|
|
753
|
+
const u = i instanceof Error ? i.message : "接口请求失败";
|
|
754
|
+
M(
|
|
755
|
+
a(Y, {
|
|
733
756
|
options: { url: "", name: "附件预览" },
|
|
734
757
|
title: "文件信息获取失败",
|
|
735
|
-
desc:
|
|
758
|
+
desc: u,
|
|
736
759
|
spinning: !1,
|
|
737
|
-
onDestroy:
|
|
760
|
+
onDestroy: c
|
|
738
761
|
}),
|
|
739
|
-
|
|
762
|
+
t
|
|
740
763
|
);
|
|
741
|
-
}),
|
|
742
|
-
|
|
764
|
+
}), o) : (M(
|
|
765
|
+
a(Y, {
|
|
743
766
|
options: { url: "", name: "附件预览" },
|
|
744
767
|
title: "附件预览未初始化",
|
|
745
768
|
desc: "请先调用 setupJtAttachmentPreview 注册请求配置",
|
|
746
769
|
spinning: !1,
|
|
747
|
-
onDestroy:
|
|
770
|
+
onDestroy: c
|
|
748
771
|
}),
|
|
749
|
-
|
|
750
|
-
),
|
|
772
|
+
t
|
|
773
|
+
), o);
|
|
751
774
|
}
|
|
752
|
-
const
|
|
753
|
-
openByParams:
|
|
754
|
-
setup:
|
|
775
|
+
const Oe = Object.assign(Ye, {
|
|
776
|
+
openByParams: Pe,
|
|
777
|
+
setup: Be
|
|
755
778
|
});
|
|
756
779
|
export {
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
780
|
+
Oe as JtAttachmentPreview,
|
|
781
|
+
Pe as JtAttachmentPreviewByParams,
|
|
782
|
+
Be as setupJtAttachmentPreview
|
|
760
783
|
};
|