@7niao/doc-previewer 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +15 -0
- package/README.md +217 -2
- package/dist/assets/ArchiveRenderer-BZsm87A2.js +514 -0
- package/dist/assets/CadRenderer-DQiBmk71.js +1838 -0
- package/dist/assets/DocxRenderer-6BCR0R9L.js +3173 -0
- package/dist/assets/GisRenderer-BQ_T-z1A.js +9758 -0
- package/dist/assets/ImageRenderer-D1SFZkV3.js +24 -0
- package/dist/assets/MediaRenderer-DKj0V7cL.js +66 -0
- package/dist/assets/Model3dRenderer-DDk-HsYP.js +1966 -0
- package/dist/assets/OfdRenderer-1kDqHPDa.js +67 -0
- package/dist/assets/PdfRenderer-DuZpWPAu.js +16370 -0
- package/dist/assets/PptxRenderer-BSoVSGOz.js +48492 -0
- package/dist/assets/TextRenderer-pKpgA2wF.js +38 -0
- package/dist/assets/UnsupportedRenderer-CnjuGXg3.js +29 -0
- package/dist/assets/XlsxRenderer-Bohk5iIA.js +16257 -0
- package/dist/assets/_plugin-vue_export-helper-Djzt4Yr7.js +7 -0
- package/dist/assets/createLucideIcon-C_l8giLP.js +91 -0
- package/dist/assets/dom-Ba50_9e0.js +93 -0
- package/dist/assets/dwg2dxf-wasm-DO6Y5cnM.js +2148 -0
- package/dist/assets/file-question-mark-D7iJe3UN.js +21 -0
- package/dist/assets/jszip.min-OjSHaKmg.js +3039 -0
- package/dist/assets/ofd.es-CauEO04U.js +24255 -0
- package/dist/assets/rolldown-runtime-CwxnZyOB.js +22 -0
- package/dist/assets/three.module-B04XcvCz.js +12454 -0
- package/dist/assets/types-CVtHVd2P.js +168 -0
- package/dist/index.js +725 -0
- package/dist/libarchive/libarchive.wasm +0 -0
- package/dist/libarchive/worker-bundle.js +6 -0
- package/dist/style.css +2 -0
- package/dist/types/FileViewer.vue.d.ts +48 -0
- package/dist/types/components/PreviewToolbar.vue.d.ts +33 -0
- package/dist/types/composables/useFullscreen.d.ts +6 -0
- package/dist/types/composables/usePreviewSource.d.ts +14 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/renderers/ArchiveRenderer.vue.d.ts +18 -0
- package/dist/types/renderers/CadRenderer.vue.d.ts +29 -0
- package/dist/types/renderers/DocxRenderer.vue.d.ts +16 -0
- package/dist/types/renderers/GisRenderer.vue.d.ts +26 -0
- package/dist/types/renderers/ImageRenderer.vue.d.ts +16 -0
- package/dist/types/renderers/MediaRenderer.vue.d.ts +17 -0
- package/dist/types/renderers/Model3dRenderer.vue.d.ts +29 -0
- package/dist/types/renderers/OfdRenderer.vue.d.ts +16 -0
- package/dist/types/renderers/PdfRenderer.vue.d.ts +16 -0
- package/dist/types/renderers/PptxRenderer.vue.d.ts +16 -0
- package/dist/types/renderers/TextRenderer.vue.d.ts +16 -0
- package/dist/types/renderers/UnsupportedRenderer.vue.d.ts +14 -0
- package/dist/types/renderers/XlsxRenderer.vue.d.ts +16 -0
- package/dist/types/types.d.ts +51 -0
- package/dist/types/utils/detect.d.ts +10 -0
- package/dist/types/utils/dom.d.ts +13 -0
- package/dist/types/vendor/asn1js-stub.d.ts +10 -0
- package/package.json +77 -3
package/dist/index.js
ADDED
|
@@ -0,0 +1,725 @@
|
|
|
1
|
+
import { n as e } from "./assets/rolldown-runtime-CwxnZyOB.js";
|
|
2
|
+
import { t } from "./assets/file-question-mark-D7iJe3UN.js";
|
|
3
|
+
import { a as n, i as r, n as i, o as a, r as o, s, t as c } from "./assets/types-CVtHVd2P.js";
|
|
4
|
+
import { t as l } from "./assets/createLucideIcon-C_l8giLP.js";
|
|
5
|
+
import { t as u } from "./assets/_plugin-vue_export-helper-Djzt4Yr7.js";
|
|
6
|
+
import { a as d, n as f, r as p, t as m } from "./assets/dom-Ba50_9e0.js";
|
|
7
|
+
import { Fragment as h, Teleport as ee, computed as g, createBlock as _, createCommentVNode as v, createElementBlock as y, createElementVNode as b, createVNode as x, defineAsyncComponent as S, defineComponent as te, mergeProps as ne, nextTick as re, normalizeClass as ie, normalizeStyle as ae, onBeforeUnmount as oe, onMounted as se, openBlock as C, ref as w, resolveDynamicComponent as ce, shallowRef as le, toDisplayString as T, unref as E, watch as D, withModifiers as ue } from "vue";
|
|
8
|
+
var de = l({
|
|
9
|
+
name: "download",
|
|
10
|
+
size: 24,
|
|
11
|
+
node: [
|
|
12
|
+
["path", {
|
|
13
|
+
d: "M12 15V3",
|
|
14
|
+
key: "m9g1x1"
|
|
15
|
+
}],
|
|
16
|
+
["path", {
|
|
17
|
+
d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",
|
|
18
|
+
key: "ih7n3h"
|
|
19
|
+
}],
|
|
20
|
+
["path", {
|
|
21
|
+
d: "m7 10 5 5 5-5",
|
|
22
|
+
key: "brsn70"
|
|
23
|
+
}]
|
|
24
|
+
]
|
|
25
|
+
}), fe = l({
|
|
26
|
+
name: "maximize-2",
|
|
27
|
+
size: 24,
|
|
28
|
+
node: [
|
|
29
|
+
["path", {
|
|
30
|
+
d: "M15 3h6v6",
|
|
31
|
+
key: "1q9fwt"
|
|
32
|
+
}],
|
|
33
|
+
["path", {
|
|
34
|
+
d: "m21 3-7 7",
|
|
35
|
+
key: "1l2asr"
|
|
36
|
+
}],
|
|
37
|
+
["path", {
|
|
38
|
+
d: "m3 21 7-7",
|
|
39
|
+
key: "tjx5ai"
|
|
40
|
+
}],
|
|
41
|
+
["path", {
|
|
42
|
+
d: "M9 21H3v-6",
|
|
43
|
+
key: "wtvkvv"
|
|
44
|
+
}]
|
|
45
|
+
]
|
|
46
|
+
}), pe = l({
|
|
47
|
+
name: "minimize-2",
|
|
48
|
+
size: 24,
|
|
49
|
+
node: [
|
|
50
|
+
["path", {
|
|
51
|
+
d: "m14 10 7-7",
|
|
52
|
+
key: "oa77jy"
|
|
53
|
+
}],
|
|
54
|
+
["path", {
|
|
55
|
+
d: "M20 10h-6V4",
|
|
56
|
+
key: "mjg0md"
|
|
57
|
+
}],
|
|
58
|
+
["path", {
|
|
59
|
+
d: "m3 21 7-7",
|
|
60
|
+
key: "tjx5ai"
|
|
61
|
+
}],
|
|
62
|
+
["path", {
|
|
63
|
+
d: "M4 14h6v6",
|
|
64
|
+
key: "rmj7iw"
|
|
65
|
+
}]
|
|
66
|
+
]
|
|
67
|
+
}), me = l({
|
|
68
|
+
name: "printer",
|
|
69
|
+
size: 24,
|
|
70
|
+
node: [
|
|
71
|
+
["path", {
|
|
72
|
+
d: "M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",
|
|
73
|
+
key: "143wyd"
|
|
74
|
+
}],
|
|
75
|
+
["path", {
|
|
76
|
+
d: "M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",
|
|
77
|
+
key: "1itne7"
|
|
78
|
+
}],
|
|
79
|
+
["rect", {
|
|
80
|
+
x: "6",
|
|
81
|
+
y: "14",
|
|
82
|
+
width: "12",
|
|
83
|
+
height: "8",
|
|
84
|
+
rx: "1",
|
|
85
|
+
key: "1ue0tg"
|
|
86
|
+
}]
|
|
87
|
+
]
|
|
88
|
+
}), he = l({
|
|
89
|
+
name: "rotate-ccw",
|
|
90
|
+
size: 24,
|
|
91
|
+
node: [["path", {
|
|
92
|
+
d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",
|
|
93
|
+
key: "1357e3"
|
|
94
|
+
}], ["path", {
|
|
95
|
+
d: "M3 3v5h5",
|
|
96
|
+
key: "1xhq8a"
|
|
97
|
+
}]]
|
|
98
|
+
}), ge = l({
|
|
99
|
+
name: "rotate-cw",
|
|
100
|
+
size: 24,
|
|
101
|
+
node: [["path", {
|
|
102
|
+
d: "M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",
|
|
103
|
+
key: "1p45f6"
|
|
104
|
+
}], ["path", {
|
|
105
|
+
d: "M21 3v5h-5",
|
|
106
|
+
key: "1q7to0"
|
|
107
|
+
}]]
|
|
108
|
+
}), _e = l({
|
|
109
|
+
name: "x",
|
|
110
|
+
size: 24,
|
|
111
|
+
node: [["path", {
|
|
112
|
+
d: "M18 6 6 18",
|
|
113
|
+
key: "1bl5f8"
|
|
114
|
+
}], ["path", {
|
|
115
|
+
d: "m6 6 12 12",
|
|
116
|
+
key: "d8bk6v"
|
|
117
|
+
}]]
|
|
118
|
+
}), ve = l({
|
|
119
|
+
name: "zoom-in",
|
|
120
|
+
size: 24,
|
|
121
|
+
node: [
|
|
122
|
+
["circle", {
|
|
123
|
+
cx: "11",
|
|
124
|
+
cy: "11",
|
|
125
|
+
r: "8",
|
|
126
|
+
key: "4ej97u"
|
|
127
|
+
}],
|
|
128
|
+
["line", {
|
|
129
|
+
x1: "21",
|
|
130
|
+
x2: "16.65",
|
|
131
|
+
y1: "21",
|
|
132
|
+
y2: "16.65",
|
|
133
|
+
key: "13gj7c"
|
|
134
|
+
}],
|
|
135
|
+
["line", {
|
|
136
|
+
x1: "11",
|
|
137
|
+
x2: "11",
|
|
138
|
+
y1: "8",
|
|
139
|
+
y2: "14",
|
|
140
|
+
key: "1vmskp"
|
|
141
|
+
}],
|
|
142
|
+
["line", {
|
|
143
|
+
x1: "8",
|
|
144
|
+
x2: "14",
|
|
145
|
+
y1: "11",
|
|
146
|
+
y2: "11",
|
|
147
|
+
key: "durymu"
|
|
148
|
+
}]
|
|
149
|
+
]
|
|
150
|
+
}), ye = l({
|
|
151
|
+
name: "zoom-out",
|
|
152
|
+
size: 24,
|
|
153
|
+
node: [
|
|
154
|
+
["circle", {
|
|
155
|
+
cx: "11",
|
|
156
|
+
cy: "11",
|
|
157
|
+
r: "8",
|
|
158
|
+
key: "4ej97u"
|
|
159
|
+
}],
|
|
160
|
+
["line", {
|
|
161
|
+
x1: "21",
|
|
162
|
+
x2: "16.65",
|
|
163
|
+
y1: "21",
|
|
164
|
+
y2: "16.65",
|
|
165
|
+
key: "13gj7c"
|
|
166
|
+
}],
|
|
167
|
+
["line", {
|
|
168
|
+
x1: "8",
|
|
169
|
+
x2: "14",
|
|
170
|
+
y1: "11",
|
|
171
|
+
y2: "11",
|
|
172
|
+
key: "durymu"
|
|
173
|
+
}]
|
|
174
|
+
]
|
|
175
|
+
}), be = { class: "fv-toolbar" }, xe = {
|
|
176
|
+
key: 0,
|
|
177
|
+
class: "fv-file"
|
|
178
|
+
}, Se = { class: "fv-file-badge" }, O = { class: "fv-file-text" }, k = ["title"], A = {
|
|
179
|
+
key: 0,
|
|
180
|
+
class: "fv-file-size"
|
|
181
|
+
}, Ce = { class: "fv-actions" }, we = { class: "fv-group" }, j = ["disabled"], Te = ["disabled"], M = ["disabled"], Ee = { class: "fv-group" }, N = ["disabled"], P = ["disabled"], F = { class: "fv-group" }, I = ["disabled"], L = ["disabled"], R = ["title", "aria-label"], De = /*#__PURE__*/ u(/* @__PURE__ */ te({
|
|
182
|
+
__name: "PreviewToolbar",
|
|
183
|
+
props: {
|
|
184
|
+
name: {},
|
|
185
|
+
kindLabel: {},
|
|
186
|
+
sizeText: {},
|
|
187
|
+
zoomPercent: {},
|
|
188
|
+
canZoom: { type: Boolean },
|
|
189
|
+
canRotate: { type: Boolean },
|
|
190
|
+
canPrint: { type: Boolean },
|
|
191
|
+
canDownload: { type: Boolean },
|
|
192
|
+
showFileInfo: { type: Boolean },
|
|
193
|
+
isFullscreen: { type: Boolean }
|
|
194
|
+
},
|
|
195
|
+
emits: [
|
|
196
|
+
"zoom-in",
|
|
197
|
+
"zoom-out",
|
|
198
|
+
"reset",
|
|
199
|
+
"rotate-left",
|
|
200
|
+
"rotate-right",
|
|
201
|
+
"download",
|
|
202
|
+
"print",
|
|
203
|
+
"toggle-fullscreen"
|
|
204
|
+
],
|
|
205
|
+
setup(e, { emit: t }) {
|
|
206
|
+
let n = t;
|
|
207
|
+
return (t, r) => (C(), y("header", be, [e.showFileInfo ? (C(), y("div", xe, [b("span", Se, T(e.kindLabel), 1), b("span", O, [b("span", {
|
|
208
|
+
class: "fv-file-name",
|
|
209
|
+
title: e.name
|
|
210
|
+
}, T(e.name), 9, k), e.sizeText ? (C(), y("span", A, T(e.sizeText), 1)) : v("", !0)])])) : v("", !0), b("div", Ce, [
|
|
211
|
+
b("div", we, [
|
|
212
|
+
b("button", {
|
|
213
|
+
type: "button",
|
|
214
|
+
class: "fv-btn",
|
|
215
|
+
title: "缩小",
|
|
216
|
+
"aria-label": "缩小",
|
|
217
|
+
disabled: !e.canZoom,
|
|
218
|
+
onClick: r[0] ||= (e) => n("zoom-out")
|
|
219
|
+
}, [x(E(ye), { size: 17 })], 8, j),
|
|
220
|
+
b("button", {
|
|
221
|
+
type: "button",
|
|
222
|
+
class: "fv-zoom-value",
|
|
223
|
+
title: "重置缩放",
|
|
224
|
+
"aria-label": "重置缩放",
|
|
225
|
+
disabled: !e.canZoom,
|
|
226
|
+
onClick: r[1] ||= (e) => n("reset")
|
|
227
|
+
}, T(e.canZoom ? `${e.zoomPercent}%` : "—"), 9, Te),
|
|
228
|
+
b("button", {
|
|
229
|
+
type: "button",
|
|
230
|
+
class: "fv-btn",
|
|
231
|
+
title: "放大",
|
|
232
|
+
"aria-label": "放大",
|
|
233
|
+
disabled: !e.canZoom,
|
|
234
|
+
onClick: r[2] ||= (e) => n("zoom-in")
|
|
235
|
+
}, [x(E(ve), { size: 17 })], 8, M)
|
|
236
|
+
]),
|
|
237
|
+
r[8] ||= b("span", { class: "fv-divider" }, null, -1),
|
|
238
|
+
b("div", Ee, [b("button", {
|
|
239
|
+
type: "button",
|
|
240
|
+
class: "fv-btn",
|
|
241
|
+
title: "向左旋转 90°",
|
|
242
|
+
"aria-label": "向左旋转",
|
|
243
|
+
disabled: !e.canRotate,
|
|
244
|
+
onClick: r[3] ||= (e) => n("rotate-left")
|
|
245
|
+
}, [x(E(he), { size: 17 })], 8, N), b("button", {
|
|
246
|
+
type: "button",
|
|
247
|
+
class: "fv-btn",
|
|
248
|
+
title: "向右旋转 90°",
|
|
249
|
+
"aria-label": "向右旋转",
|
|
250
|
+
disabled: !e.canRotate,
|
|
251
|
+
onClick: r[4] ||= (e) => n("rotate-right")
|
|
252
|
+
}, [x(E(ge), { size: 17 })], 8, P)]),
|
|
253
|
+
r[9] ||= b("span", { class: "fv-divider" }, null, -1),
|
|
254
|
+
b("div", F, [
|
|
255
|
+
b("button", {
|
|
256
|
+
type: "button",
|
|
257
|
+
class: "fv-btn",
|
|
258
|
+
title: "下载原文件",
|
|
259
|
+
disabled: !e.canDownload,
|
|
260
|
+
onClick: r[5] ||= (e) => n("download")
|
|
261
|
+
}, [x(E(de), { size: 17 })], 8, I),
|
|
262
|
+
b("button", {
|
|
263
|
+
type: "button",
|
|
264
|
+
class: "fv-btn",
|
|
265
|
+
title: "打印",
|
|
266
|
+
disabled: !e.canPrint,
|
|
267
|
+
onClick: r[6] ||= (e) => n("print")
|
|
268
|
+
}, [x(E(me), { size: 17 })], 8, L),
|
|
269
|
+
b("button", {
|
|
270
|
+
type: "button",
|
|
271
|
+
class: "fv-btn",
|
|
272
|
+
title: e.isFullscreen ? "退出全屏" : "全屏",
|
|
273
|
+
"aria-label": e.isFullscreen ? "退出全屏" : "全屏",
|
|
274
|
+
onClick: r[7] ||= (e) => n("toggle-fullscreen")
|
|
275
|
+
}, [e.isFullscreen ? (C(), _(E(pe), {
|
|
276
|
+
key: 0,
|
|
277
|
+
size: 17
|
|
278
|
+
})) : (C(), _(E(fe), {
|
|
279
|
+
key: 1,
|
|
280
|
+
size: 17
|
|
281
|
+
}))], 8, R)
|
|
282
|
+
])
|
|
283
|
+
])]));
|
|
284
|
+
}
|
|
285
|
+
}), [["__scopeId", "data-v-6c5f04a9"]]);
|
|
286
|
+
// src/components/file-viewer/composables/useFullscreen.ts
|
|
287
|
+
function Oe(e) {
|
|
288
|
+
let t = w(!1), n = w(!1), r = g(() => t.value || n.value);
|
|
289
|
+
function i() {
|
|
290
|
+
t.value = !!document.fullscreenElement && document.fullscreenElement === e.value;
|
|
291
|
+
}
|
|
292
|
+
function a(e) {
|
|
293
|
+
e.key === "Escape" && n.value && (n.value = !1);
|
|
294
|
+
}
|
|
295
|
+
async function o() {
|
|
296
|
+
let t = e.value;
|
|
297
|
+
if (t) {
|
|
298
|
+
if (typeof t.requestFullscreen == "function") try {
|
|
299
|
+
await t.requestFullscreen();
|
|
300
|
+
return;
|
|
301
|
+
} catch {}
|
|
302
|
+
n.value = !0;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
async function s() {
|
|
306
|
+
if (document.fullscreenElement) try {
|
|
307
|
+
await document.exitFullscreen();
|
|
308
|
+
} catch {}
|
|
309
|
+
n.value = !1;
|
|
310
|
+
}
|
|
311
|
+
async function c() {
|
|
312
|
+
r.value ? await s() : await o();
|
|
313
|
+
}
|
|
314
|
+
return se(() => {
|
|
315
|
+
document.addEventListener("fullscreenchange", i), window.addEventListener("keydown", a);
|
|
316
|
+
}), oe(() => {
|
|
317
|
+
document.removeEventListener("fullscreenchange", i), window.removeEventListener("keydown", a), document.fullscreenElement === e.value && document.exitFullscreen().catch(() => void 0), n.value = !1;
|
|
318
|
+
}), {
|
|
319
|
+
isFullscreen: r,
|
|
320
|
+
toggle: c
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
// src/components/file-viewer/composables/usePreviewSource.ts
|
|
324
|
+
function z(e) {
|
|
325
|
+
if (e.startsWith("data:")) return "file";
|
|
326
|
+
try {
|
|
327
|
+
let t = new URL(e, window.location.href).pathname.split("/").filter(Boolean).pop();
|
|
328
|
+
return t ? decodeURIComponent(t) : "file";
|
|
329
|
+
} catch {
|
|
330
|
+
return "file";
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
function B(e, t) {
|
|
334
|
+
return t ? r(e) ? e : `${e}.${t}` : e;
|
|
335
|
+
}
|
|
336
|
+
function ke(e) {
|
|
337
|
+
let t = le(null), i = null;
|
|
338
|
+
function o() {
|
|
339
|
+
i &&= (URL.revokeObjectURL(i), null);
|
|
340
|
+
}
|
|
341
|
+
function s() {
|
|
342
|
+
o();
|
|
343
|
+
let s = null, c = "", l = "", u = e.mimeType || "", d = 0;
|
|
344
|
+
typeof e.src == "string" ? (c = e.src, l = e.fileName || z(c), d = 0) : (s = e.src, c = URL.createObjectURL(s), i = c, l = e.fileName || (s instanceof File ? s.name : ""), u ||= s.type, d = s.size), l ||= "file";
|
|
345
|
+
let f = r(l);
|
|
346
|
+
f || (f = n(u || s?.type || ""), l = B(l, f)), u ||= a(f);
|
|
347
|
+
let p = s, m = null, h = async () => {
|
|
348
|
+
if (p) return p;
|
|
349
|
+
let e = await fetch(c);
|
|
350
|
+
if (!e.ok) throw Error(`文件下载失败(HTTP ${e.status})`);
|
|
351
|
+
return p = await e.blob(), u ||= p.type, p;
|
|
352
|
+
}, ee = {
|
|
353
|
+
name: l,
|
|
354
|
+
ext: f,
|
|
355
|
+
mime: u,
|
|
356
|
+
size: d,
|
|
357
|
+
url: c,
|
|
358
|
+
getBlob: h,
|
|
359
|
+
getArrayBuffer: async () => (m ||= await (await h()).arrayBuffer(), m),
|
|
360
|
+
getText: async () => new TextDecoder("utf-8").decode(await ee.getArrayBuffer())
|
|
361
|
+
};
|
|
362
|
+
t.value = ee;
|
|
363
|
+
}
|
|
364
|
+
return D(() => [
|
|
365
|
+
e.src,
|
|
366
|
+
e.fileName,
|
|
367
|
+
e.mimeType
|
|
368
|
+
], s, { immediate: !0 }), oe(o), { source: t };
|
|
369
|
+
}
|
|
370
|
+
// src/components/file-viewer/FileViewer.vue?vue&type=script&setup=true&lang.ts
|
|
371
|
+
var Ae = {
|
|
372
|
+
key: 1,
|
|
373
|
+
class: "fv-canvas"
|
|
374
|
+
}, je = {
|
|
375
|
+
key: 0,
|
|
376
|
+
class: "fv-overlay"
|
|
377
|
+
}, Me = {
|
|
378
|
+
key: 1,
|
|
379
|
+
class: "fv-overlay fv-overlay--error"
|
|
380
|
+
}, Ne = { class: "fv-error-text" }, Pe = {
|
|
381
|
+
key: 1,
|
|
382
|
+
class: "fv-overlay fv-overlay--empty"
|
|
383
|
+
}, Fe = {
|
|
384
|
+
key: 1,
|
|
385
|
+
class: "fv-native-error"
|
|
386
|
+
}, Ie = { class: "fv-modal-panel" }, Le = { class: "fv-modal-head" }, Re = ["title"], ze = 56, V = /*@__PURE__*/ te({
|
|
387
|
+
__name: "FileViewer",
|
|
388
|
+
props: {
|
|
389
|
+
src: {},
|
|
390
|
+
fileName: {},
|
|
391
|
+
mimeType: {},
|
|
392
|
+
kind: {},
|
|
393
|
+
options: {}
|
|
394
|
+
},
|
|
395
|
+
emits: [
|
|
396
|
+
"ready",
|
|
397
|
+
"error",
|
|
398
|
+
"zoom-change",
|
|
399
|
+
"download",
|
|
400
|
+
"print",
|
|
401
|
+
"fullscreen-change"
|
|
402
|
+
],
|
|
403
|
+
setup(e, { expose: n, emit: r }) {
|
|
404
|
+
let i = e, a = r, l = S(() => import("./assets/ImageRenderer-D1SFZkV3.js")), u = S(() => import("./assets/MediaRenderer-DKj0V7cL.js")), te = S(() => import("./assets/PdfRenderer-DuZpWPAu.js")), de = S(() => import("./assets/DocxRenderer-6BCR0R9L.js")), fe = S(() => import("./assets/XlsxRenderer-Bohk5iIA.js")), pe = S(() => import("./assets/PptxRenderer-BSoVSGOz.js")), me = S(() => import("./assets/OfdRenderer-1kDqHPDa.js")), he = S(() => import("./assets/ArchiveRenderer-BZsm87A2.js")), ge = S(() => import("./assets/CadRenderer-DQiBmk71.js")), ve = S(() => import("./assets/Model3dRenderer-DDk-HsYP.js")), ye = S(() => import("./assets/GisRenderer-BQ_T-z1A.js")), be = S(() => import("./assets/TextRenderer-pKpgA2wF.js")), xe = S(() => import("./assets/UnsupportedRenderer-CnjuGXg3.js")), Se = S(() => Promise.resolve().then(() => Be)), O = g(() => ({
|
|
405
|
+
height: "640px",
|
|
406
|
+
toolbar: !0,
|
|
407
|
+
showFileInfo: !0,
|
|
408
|
+
...i.options,
|
|
409
|
+
zoom: {
|
|
410
|
+
min: .1,
|
|
411
|
+
max: 10,
|
|
412
|
+
step: .2,
|
|
413
|
+
...i.options?.zoom
|
|
414
|
+
}
|
|
415
|
+
})), { source: k } = ke(i), A = g(() => o(k.value?.name || "", k.value?.mime || "", i.kind)), Ce = g(() => c[A.value]), we = [
|
|
416
|
+
"video",
|
|
417
|
+
"audio",
|
|
418
|
+
"cad",
|
|
419
|
+
"model3d",
|
|
420
|
+
"gis"
|
|
421
|
+
], j = g(() => we.includes(A.value)), Te = g(() => {
|
|
422
|
+
switch (A.value) {
|
|
423
|
+
case "image": return l;
|
|
424
|
+
case "video":
|
|
425
|
+
case "audio": return u;
|
|
426
|
+
case "pdf": return te;
|
|
427
|
+
case "word": return de;
|
|
428
|
+
case "excel": return fe;
|
|
429
|
+
case "ppt": return pe;
|
|
430
|
+
case "ofd": return me;
|
|
431
|
+
case "archive": return he;
|
|
432
|
+
case "cad": return ge;
|
|
433
|
+
case "model3d": return ve;
|
|
434
|
+
case "gis": return ye;
|
|
435
|
+
case "text": return be;
|
|
436
|
+
default: return xe;
|
|
437
|
+
}
|
|
438
|
+
}), M = g(() => ({
|
|
439
|
+
source: k.value,
|
|
440
|
+
options: O.value,
|
|
441
|
+
viewportWidth: L.value,
|
|
442
|
+
viewportHeight: R.value,
|
|
443
|
+
isVideo: A.value === "video"
|
|
444
|
+
})), Ee = w(null), N = w(null), P = w(null), F = w(null), I = w(null), L = w(800), R = w(560), z = w(0), B = w(0), V = w(1), H = w(0), Ve = w(100), U = w(!1), W = w(""), G = w(!1), K = w(!1), q = le(null), { isFullscreen: He, toggle: Ue } = Oe(Ee), J = null, Y = null, We = g(() => j.value ? A.value !== "video" && A.value !== "audio" && !!F.value : A.value !== "unsupported"), Ge = g(() => A.value === "cad" || A.value === "model3d" || !j.value && [
|
|
445
|
+
"image",
|
|
446
|
+
"pdf",
|
|
447
|
+
"word",
|
|
448
|
+
"excel",
|
|
449
|
+
"ppt",
|
|
450
|
+
"ofd",
|
|
451
|
+
"text"
|
|
452
|
+
].includes(A.value)), Ke = g(() => ![
|
|
453
|
+
"video",
|
|
454
|
+
"audio",
|
|
455
|
+
"unsupported"
|
|
456
|
+
].includes(A.value)), qe = g(() => !!k.value), Je = g(() => j.value ? Ve.value : Math.round(V.value * 100)), Ye = g(() => {
|
|
457
|
+
let e = H.value % 180 != 0;
|
|
458
|
+
return Math.round((e ? B.value : z.value) * V.value);
|
|
459
|
+
}), Xe = g(() => {
|
|
460
|
+
let e = H.value % 180 != 0;
|
|
461
|
+
return Math.round((e ? z.value : B.value) * V.value);
|
|
462
|
+
}), Ze = g(() => ({
|
|
463
|
+
width: `${Ye.value}px`,
|
|
464
|
+
height: `${Xe.value}px`
|
|
465
|
+
})), Qe = g(() => ({ transform: `translate(-50%, -50%) rotate(${H.value}deg) scale(${V.value})` })), $e = g(() => z.value === 0), et = g(() => j.value || !k.value ? !1 : Ye.value + ze > L.value || Xe.value + ze > R.value), X = w(!1), Z = null, Q = !1;
|
|
466
|
+
function tt(e) {
|
|
467
|
+
if (e.button !== 0 || !et.value || e.target?.closest("a, button, input, textarea, select, label, video, audio, iframe")) return;
|
|
468
|
+
let t = N.value;
|
|
469
|
+
if (!t) return;
|
|
470
|
+
let n = t.getBoundingClientRect();
|
|
471
|
+
e.clientX > n.left + t.clientWidth || e.clientY > n.top + t.clientHeight || (Z = {
|
|
472
|
+
id: e.pointerId,
|
|
473
|
+
x: e.clientX,
|
|
474
|
+
y: e.clientY,
|
|
475
|
+
left: t.scrollLeft,
|
|
476
|
+
top: t.scrollTop
|
|
477
|
+
}, Q = !1, t.setPointerCapture(e.pointerId));
|
|
478
|
+
}
|
|
479
|
+
function nt(e) {
|
|
480
|
+
let t = N.value, n = Z;
|
|
481
|
+
if (!t || !n || n.id !== e.pointerId) return;
|
|
482
|
+
let r = e.clientX - n.x, i = e.clientY - n.y;
|
|
483
|
+
if (!Q) {
|
|
484
|
+
if (Math.abs(r) < 4 && Math.abs(i) < 4) return;
|
|
485
|
+
Q = !0, X.value = !0, document.getSelection()?.removeAllRanges();
|
|
486
|
+
}
|
|
487
|
+
e.preventDefault(), t.scrollLeft = n.left - r, t.scrollTop = n.top - i;
|
|
488
|
+
}
|
|
489
|
+
function rt(e) {
|
|
490
|
+
let t = N.value;
|
|
491
|
+
t?.hasPointerCapture(e.pointerId) && t.releasePointerCapture(e.pointerId), Z = null, Q = !1, X.value = !1;
|
|
492
|
+
}
|
|
493
|
+
function it() {
|
|
494
|
+
a("zoom-change", Je.value);
|
|
495
|
+
}
|
|
496
|
+
function $(e, t = !1) {
|
|
497
|
+
let n = O.value.zoom?.min ?? .1, r = O.value.zoom?.max ?? 10;
|
|
498
|
+
V.value = Math.min(r, Math.max(n, Number.isFinite(e) ? e : 1)), t && (K.value = !0), it();
|
|
499
|
+
}
|
|
500
|
+
function at() {
|
|
501
|
+
let e = z.value, t = B.value;
|
|
502
|
+
if (!e || !t) return;
|
|
503
|
+
let n = Math.max(120, L.value - 64), r = Math.max(120, R.value - 64), i = [
|
|
504
|
+
"pdf",
|
|
505
|
+
"word",
|
|
506
|
+
"excel",
|
|
507
|
+
"ppt",
|
|
508
|
+
"ofd",
|
|
509
|
+
"text",
|
|
510
|
+
"archive"
|
|
511
|
+
].includes(A.value), a = 1;
|
|
512
|
+
A.value === "image" ? a = Math.min(1, n / e, r / t) : i && (a = Math.min(1, n / e)), $(a), G.value = !0;
|
|
513
|
+
}
|
|
514
|
+
function ot() {
|
|
515
|
+
j.value ? F.value?.zoomIn?.() : $(V.value * (1 + (O.value.zoom?.step ?? .2)), !0);
|
|
516
|
+
}
|
|
517
|
+
function st() {
|
|
518
|
+
j.value ? F.value?.zoomOut?.() : $(V.value / (1 + (O.value.zoom?.step ?? .2)), !0);
|
|
519
|
+
}
|
|
520
|
+
function ct() {
|
|
521
|
+
j.value ? (F.value?.resetZoom?.(), it()) : $(1, !0);
|
|
522
|
+
}
|
|
523
|
+
function lt() {
|
|
524
|
+
j.value ? F.value?.rotate?.(-Math.PI / 2) : H.value = (H.value + 270) % 360;
|
|
525
|
+
}
|
|
526
|
+
function ut() {
|
|
527
|
+
j.value ? F.value?.rotate?.(Math.PI / 2) : H.value = (H.value + 90) % 360;
|
|
528
|
+
}
|
|
529
|
+
async function dt() {
|
|
530
|
+
let e = k.value;
|
|
531
|
+
if (e) try {
|
|
532
|
+
m(await e.getBlob(), e.name), a("download", e.name);
|
|
533
|
+
} catch (e) {
|
|
534
|
+
W.value = e instanceof Error ? e.message : "下载失败";
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
function ft() {
|
|
538
|
+
let e = k.value;
|
|
539
|
+
if (e) {
|
|
540
|
+
if (a("print"), A.value === "pdf" && /^(blob:|http)/.test(e.url)) d(e.url);
|
|
541
|
+
else if (j.value) {
|
|
542
|
+
if (F.value?.print) {
|
|
543
|
+
F.value.print();
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
I.value && p(I.value, { title: e.name });
|
|
547
|
+
} else P.value && p(P.value, { title: e.name });
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
function pt() {
|
|
551
|
+
U.value = !0, W.value = "", a("ready", A.value);
|
|
552
|
+
}
|
|
553
|
+
function mt(e) {
|
|
554
|
+
U.value = !0, W.value = e, a("error", e);
|
|
555
|
+
}
|
|
556
|
+
function ht(e) {
|
|
557
|
+
Ve.value = e, it();
|
|
558
|
+
}
|
|
559
|
+
function gt(e) {
|
|
560
|
+
q.value = e;
|
|
561
|
+
}
|
|
562
|
+
function _t() {
|
|
563
|
+
q.value = null;
|
|
564
|
+
}
|
|
565
|
+
function vt(e) {
|
|
566
|
+
e.key === "Escape" && q.value && _t();
|
|
567
|
+
}
|
|
568
|
+
function yt() {
|
|
569
|
+
let e = P.value;
|
|
570
|
+
if (!e) return;
|
|
571
|
+
let t = e.offsetWidth, n = e.offsetHeight;
|
|
572
|
+
z.value = t, B.value = n, !G.value && t > 0 && n > 0 && at();
|
|
573
|
+
}
|
|
574
|
+
function bt() {
|
|
575
|
+
Y?.disconnect(), Y = null, P.value && (Y = new ResizeObserver(() => yt()), Y.observe(P.value), yt());
|
|
576
|
+
}
|
|
577
|
+
return D(P, () => bt(), { flush: "post" }), D(() => [
|
|
578
|
+
i.src,
|
|
579
|
+
i.fileName,
|
|
580
|
+
i.mimeType,
|
|
581
|
+
i.kind
|
|
582
|
+
], () => {
|
|
583
|
+
U.value = !1, W.value = "", G.value = !1, K.value = !1, V.value = 1, H.value = 0, Ve.value = 100, z.value = 0, B.value = 0, q.value = null, Z = null, Q = !1, X.value = !1, re(() => bt());
|
|
584
|
+
}), D(A, () => {
|
|
585
|
+
U.value = !1, W.value = "", G.value = !1, K.value = !1, V.value = 1, H.value = 0, z.value = 0, B.value = 0, Z = null, Q = !1, X.value = !1, re(() => bt());
|
|
586
|
+
}), D(He, (e) => a("fullscreen-change", e)), se(() => {
|
|
587
|
+
let e = N.value;
|
|
588
|
+
e && (L.value = e.clientWidth || L.value, R.value = e.clientHeight || R.value, J = new ResizeObserver(() => {
|
|
589
|
+
let t = e.clientWidth, n = e.clientHeight;
|
|
590
|
+
t && n && (L.value = t, R.value = n, !K.value && !j.value && at());
|
|
591
|
+
}), J.observe(e)), window.addEventListener("keydown", vt);
|
|
592
|
+
}), oe(() => {
|
|
593
|
+
J?.disconnect(), Y?.disconnect(), J = null, Y = null, window.removeEventListener("keydown", vt);
|
|
594
|
+
}), n({
|
|
595
|
+
zoomIn: ot,
|
|
596
|
+
zoomOut: st,
|
|
597
|
+
resetZoom: ct,
|
|
598
|
+
rotateLeft: lt,
|
|
599
|
+
rotateRight: ut,
|
|
600
|
+
download: dt,
|
|
601
|
+
print: ft,
|
|
602
|
+
toggleFullscreen: Ue,
|
|
603
|
+
getKind: () => A.value,
|
|
604
|
+
getSource: () => k.value
|
|
605
|
+
}), (e, n) => (C(), y("div", {
|
|
606
|
+
ref_key: "shell",
|
|
607
|
+
ref: Ee,
|
|
608
|
+
class: ie(["fv-root", { "fv-root--fullscreen": E(He) }]),
|
|
609
|
+
style: ae({ height: O.value.height })
|
|
610
|
+
}, [
|
|
611
|
+
O.value.toolbar ? (C(), _(De, {
|
|
612
|
+
key: 0,
|
|
613
|
+
name: E(k)?.name || "未选择文件",
|
|
614
|
+
"kind-label": Ce.value,
|
|
615
|
+
"size-text": E(f)(E(k)?.size || 0),
|
|
616
|
+
"zoom-percent": Je.value,
|
|
617
|
+
"can-zoom": We.value,
|
|
618
|
+
"can-rotate": Ge.value,
|
|
619
|
+
"can-print": Ke.value,
|
|
620
|
+
"can-download": qe.value,
|
|
621
|
+
"show-file-info": O.value.showFileInfo,
|
|
622
|
+
"is-fullscreen": E(He),
|
|
623
|
+
onZoomIn: ot,
|
|
624
|
+
onZoomOut: st,
|
|
625
|
+
onReset: ct,
|
|
626
|
+
onRotateLeft: lt,
|
|
627
|
+
onRotateRight: ut,
|
|
628
|
+
onDownload: dt,
|
|
629
|
+
onPrint: ft,
|
|
630
|
+
onToggleFullscreen: E(Ue)
|
|
631
|
+
}, null, 8, [
|
|
632
|
+
"name",
|
|
633
|
+
"kind-label",
|
|
634
|
+
"size-text",
|
|
635
|
+
"zoom-percent",
|
|
636
|
+
"can-zoom",
|
|
637
|
+
"can-rotate",
|
|
638
|
+
"can-print",
|
|
639
|
+
"can-download",
|
|
640
|
+
"show-file-info",
|
|
641
|
+
"is-fullscreen",
|
|
642
|
+
"onToggleFullscreen"
|
|
643
|
+
])) : v("", !0),
|
|
644
|
+
b("div", {
|
|
645
|
+
ref_key: "viewport",
|
|
646
|
+
ref: N,
|
|
647
|
+
class: ie(["fv-viewport", {
|
|
648
|
+
"fv-viewport--native": j.value,
|
|
649
|
+
"fv-viewport--pannable": et.value,
|
|
650
|
+
"fv-viewport--panning": X.value
|
|
651
|
+
}]),
|
|
652
|
+
onPointerdown: tt,
|
|
653
|
+
onPointermove: nt,
|
|
654
|
+
onPointerup: rt,
|
|
655
|
+
onPointercancel: rt,
|
|
656
|
+
onDragstart: n[0] ||= ue(() => {}, ["prevent"])
|
|
657
|
+
}, [E(k) ? (C(), y(h, { key: 0 }, [j.value ? (C(), y("div", {
|
|
658
|
+
key: 0,
|
|
659
|
+
ref_key: "nativeEl",
|
|
660
|
+
ref: I,
|
|
661
|
+
class: "fv-native-host"
|
|
662
|
+
}, [(C(), _(ce(Te.value), ne({
|
|
663
|
+
key: `native-${E(k).name}`,
|
|
664
|
+
ref_key: "rendererRef",
|
|
665
|
+
ref: F
|
|
666
|
+
}, M.value, {
|
|
667
|
+
class: "fv-native",
|
|
668
|
+
onReady: pt,
|
|
669
|
+
onError: mt,
|
|
670
|
+
onZoomChange: ht,
|
|
671
|
+
onOpenEntry: gt
|
|
672
|
+
}), null, 16))], 512)) : (C(), y("div", Ae, [b("div", {
|
|
673
|
+
class: ie(["fv-stage", { "fv-hidden": $e.value }]),
|
|
674
|
+
style: ae(Ze.value)
|
|
675
|
+
}, [b("div", {
|
|
676
|
+
ref_key: "contentEl",
|
|
677
|
+
ref: P,
|
|
678
|
+
class: "fv-content",
|
|
679
|
+
style: ae(Qe.value)
|
|
680
|
+
}, [(C(), _(ce(Te.value), ne({ key: `content-${E(k).name}` }, M.value, {
|
|
681
|
+
onReady: pt,
|
|
682
|
+
onError: mt,
|
|
683
|
+
onOpenEntry: gt
|
|
684
|
+
}), null, 16))], 4)], 6)])), j.value ? v("", !0) : (C(), y(h, { key: 2 }, [!U.value && !W.value ? (C(), y("div", je, [x(E(s), {
|
|
685
|
+
size: 20,
|
|
686
|
+
class: "fv-spinner"
|
|
687
|
+
}), n[1] ||= b("span", null, "正在加载预览…", -1)])) : W.value ? (C(), y("div", Me, [
|
|
688
|
+
x(E(t), { size: 26 }),
|
|
689
|
+
b("span", Ne, T(W.value), 1),
|
|
690
|
+
b("button", {
|
|
691
|
+
type: "button",
|
|
692
|
+
class: "fv-retry",
|
|
693
|
+
onClick: dt
|
|
694
|
+
}, "下载文件")
|
|
695
|
+
])) : v("", !0)], 64))], 64)) : (C(), y("div", Pe, [x(E(t), { size: 26 }), n[2] ||= b("span", null, "暂无文件", -1)]))], 34),
|
|
696
|
+
j.value && E(k) && W.value ? (C(), y("div", Fe, [b("span", null, T(W.value), 1)])) : v("", !0),
|
|
697
|
+
(C(), _(ee, { to: "body" }, [q.value ? (C(), y("div", {
|
|
698
|
+
key: 0,
|
|
699
|
+
class: "fv-modal",
|
|
700
|
+
onClick: ue(_t, ["self"])
|
|
701
|
+
}, [b("div", Ie, [b("header", Le, [b("span", {
|
|
702
|
+
class: "fv-modal-title",
|
|
703
|
+
title: q.value.path
|
|
704
|
+
}, T(q.value.path), 9, Re), b("button", {
|
|
705
|
+
type: "button",
|
|
706
|
+
class: "fv-modal-close",
|
|
707
|
+
"aria-label": "关闭",
|
|
708
|
+
onClick: _t
|
|
709
|
+
}, [x(E(_e), { size: 16 })])]), x(E(Se), {
|
|
710
|
+
class: "fv-modal-viewer",
|
|
711
|
+
src: q.value.file,
|
|
712
|
+
"file-name": q.value.path.split("/").pop() || q.value.path,
|
|
713
|
+
options: {
|
|
714
|
+
...O.value,
|
|
715
|
+
height: "100%"
|
|
716
|
+
}
|
|
717
|
+
}, null, 8, [
|
|
718
|
+
"src",
|
|
719
|
+
"file-name",
|
|
720
|
+
"options"
|
|
721
|
+
])])])) : v("", !0)]))
|
|
722
|
+
], 6));
|
|
723
|
+
}
|
|
724
|
+
}), Be = /* @__PURE__ */ e({ default: () => H }), H = /*#__PURE__*/ u(V, [["__scopeId", "data-v-435341fa"]]);
|
|
725
|
+
export { H as FileViewer, H as default, c as KIND_LABELS, i as PREVIEW_ACCEPT, o as detectKind, m as downloadBlob, f as formatBytes, r as getExtension, n as guessExtension, a as mimeForExtension };
|