@eternalheart/vue-file-preview 1.6.13 → 1.7.0
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/README.md +2 -0
- package/README.zh-CN.md +2 -0
- package/lib/FilePreviewContent.vue.d.ts +17 -6
- package/lib/FilePreviewEmbed.vue.d.ts +14 -6
- package/lib/FilePreviewModal.vue.d.ts +14 -6
- package/lib/chunks/{EmptyState.vue_vue_type_script_setup_true_lang-C7qk6wj0.mjs → EmptyState.vue_vue_type_script_setup_true_lang--ZOobbGi.mjs} +1 -1
- package/lib/chunks/{avifLoader-CAUzjn-d-C0KRpetN.mjs → avifLoader-CAUzjn-d-CnJpGYJ2.mjs} +1 -1
- package/lib/chunks/{heicLoader-D_9PukkA-Czof_5FJ.mjs → heicLoader-D_9PukkA-g_dLrWLP.mjs} +1 -1
- package/lib/chunks/index-6XZXYqbp.mjs +125 -0
- package/lib/chunks/{index-B21EAyWz.mjs → index-BPSzwMOC.mjs} +51 -51
- package/lib/chunks/index-BYQ9S7Mk.mjs +104 -0
- package/lib/chunks/{index-8Vpbg2kS.mjs → index-Bf94DwQu.mjs} +105 -104
- package/lib/chunks/index-BfOWoMpY.mjs +359 -0
- package/lib/chunks/index-Bg8poMIm.mjs +117 -0
- package/lib/chunks/index-BzwJ0VWu.mjs +108 -0
- package/lib/chunks/index-C41YET0_.mjs +51 -0
- package/lib/chunks/{index-BvBqDq3O.mjs → index-C4hIk6pa.mjs} +2023 -2023
- package/lib/chunks/{index-BASg1cr4.mjs → index-C8lyQPe3.mjs} +1018 -1018
- package/lib/chunks/{index-C9mAajbD.mjs → index-CWPdNhoe.mjs} +200 -200
- package/lib/chunks/{index-BuqPb5mP.mjs → index-CrVQPnFj.mjs} +112 -112
- package/lib/chunks/{index-D30L8tm9.mjs → index-D5IF9F-D.mjs} +57 -57
- package/lib/chunks/{index-DN4Ui0Gh.mjs → index-DFeKS8tR.mjs} +120 -120
- package/lib/chunks/index-DM8Dfl-m.mjs +52 -0
- package/lib/chunks/index-DZe0BxAB.mjs +90 -0
- package/lib/chunks/{index-BlrFFeqc.mjs → index-GFcSJEwj.mjs} +75 -75
- package/lib/chunks/{index-Dkro_8Fy.mjs → index-LPGxJDnT.mjs} +32 -32
- package/lib/chunks/index-aKiIuKKx.mjs +157 -0
- package/lib/chunks/{index-DZZN3kYi.mjs → index-c-pYJEmH.mjs} +1589 -1394
- package/lib/chunks/{index-CxKZKUJj.mjs → index-z9RqL2wI.mjs} +1651 -1651
- package/lib/chunks/index-zLQlyNR2.mjs +383 -0
- package/lib/chunks/{jp2Loader-Dig19xyo-CKUaGhPl.mjs → jp2Loader-Dig19xyo-fCO1knZ0.mjs} +1 -1
- package/lib/chunks/{psdLoader-C0tKUXXl-CYWoQis5.mjs → psdLoader-C0tKUXXl-DihMskai.mjs} +1 -1
- package/lib/chunks/{rawLoader-C-tPeFAB-C35zC8nZ.mjs → rawLoader-C-tPeFAB-BSfDPl-z.mjs} +5 -5
- package/lib/chunks/{tiffLoader-BlhByX8w-BOxg_Du5.mjs → tiffLoader-BlhByX8w-JY5DaTre.mjs} +1 -1
- package/lib/chunks/{useShikiHighlight-BPmcxA-h.mjs → useShikiHighlight-C-ztcJBE.mjs} +1 -1
- package/lib/composables/useAudioPlayer.d.ts +1 -1
- package/lib/composables/usePreviewEvents.d.ts +27 -0
- package/lib/composables/useRequest.d.ts +16 -4
- package/lib/composables/useThemeMode.d.ts +1 -1
- package/lib/composables/useTranslator.d.ts +2 -2
- package/lib/core/events.d.ts +52 -0
- package/lib/core/i18n/index.d.ts +29 -0
- package/lib/core/i18n/messages/en-US.d.ts +5 -0
- package/lib/core/i18n/messages/index.d.ts +9 -0
- package/lib/core/i18n/messages/zh-CN.d.ts +5 -0
- package/lib/core/i18n/types.d.ts +23 -0
- package/lib/core/index.d.ts +34 -0
- package/lib/core/loaders/avifLoader.d.ts +22 -0
- package/lib/core/loaders/heicLoader.d.ts +21 -0
- package/lib/core/loaders/jp2Loader.d.ts +16 -0
- package/lib/core/loaders/jp2Worker.d.ts +1 -0
- package/lib/core/loaders/psdLoader.d.ts +14 -0
- package/lib/core/loaders/rawLoader.d.ts +14 -0
- package/lib/core/loaders/registry.d.ts +32 -0
- package/lib/core/loaders/tiffLoader.d.ts +28 -0
- package/lib/core/loaders/types.d.ts +56 -0
- package/lib/core/types.d.ts +89 -0
- package/lib/core/utils/csvParser.d.ts +31 -0
- package/lib/core/utils/emptyState.d.ts +28 -0
- package/lib/core/utils/excelDataConverter.d.ts +61 -0
- package/lib/core/utils/fileNormalizer.d.ts +21 -0
- package/lib/core/utils/fileType.d.ts +21 -0
- package/lib/core/utils/legacy-office/doc.d.ts +25 -0
- package/lib/core/utils/legacy-office/index.d.ts +8 -0
- package/lib/core/utils/legacy-office/ole.d.ts +8 -0
- package/lib/core/utils/legacy-office/ppt.d.ts +79 -0
- package/lib/core/utils/legacy-office/xls.d.ts +28 -0
- package/lib/core/utils/mimeTypes.d.ts +29 -0
- package/lib/core/utils/ooxml/docx.d.ts +17 -0
- package/lib/core/utils/ooxml/index.d.ts +4 -0
- package/lib/core/utils/ooxml/pptx.d.ts +7 -0
- package/lib/core/utils/ooxml/xml.d.ts +15 -0
- package/lib/core/utils/ooxml/zip.d.ts +3 -0
- package/lib/core/utils/pdfWorker.d.ts +61 -0
- package/lib/core/utils/previewMode.d.ts +7 -0
- package/lib/core/utils/request.d.ts +49 -0
- package/lib/core/utils/subtitleParser.d.ts +44 -0
- package/lib/core/utils/textDecoder.d.ts +30 -0
- package/lib/core/utils/uint8ArrayPolyfill.d.ts +18 -0
- package/lib/core/utils/zipReader.d.ts +51 -0
- package/lib/core/workers/imageDecoder.worker.d.ts +31 -0
- package/lib/core/workers/workerClient.d.ts +14 -0
- package/lib/i18n/localeKey.d.ts +1 -1
- package/lib/index.cjs +60 -60
- package/lib/index.css +1 -1
- package/lib/index.d.ts +11 -9
- package/lib/index.mjs +15 -12
- package/lib/renderers/Audio/index.vue.d.ts +1 -1
- package/lib/renderers/Cad/index.vue.d.ts +1 -1
- package/lib/renderers/Cad/toolbar.d.ts +2 -2
- package/lib/renderers/Csv/index.vue.d.ts +1 -1
- package/lib/renderers/Doc/index.vue.d.ts +1 -1
- package/lib/renderers/Docx/index.vue.d.ts +1 -1
- package/lib/renderers/Epub/index.vue.d.ts +1 -1
- package/lib/renderers/Font/index.vue.d.ts +1 -1
- package/lib/renderers/Image/index.vue.d.ts +2 -2
- package/lib/renderers/Json/index.vue.d.ts +2 -2
- package/lib/renderers/Markdown/index.vue.d.ts +1 -1
- package/lib/renderers/Mobi/index.vue.d.ts +1 -1
- package/lib/renderers/Msg/index.vue.d.ts +1 -1
- package/lib/renderers/Pdf/index.vue.d.ts +1 -1
- package/lib/renderers/Ppt/index.vue.d.ts +1 -1
- package/lib/renderers/Pptx/index.vue.d.ts +2 -2
- package/lib/renderers/Subtitle/index.vue.d.ts +1 -1
- package/lib/renderers/Text/index.vue.d.ts +2 -2
- package/lib/renderers/Unsupported/index.vue.d.ts +1 -1
- package/lib/renderers/Video/index.vue.d.ts +1 -1
- package/lib/renderers/Xlsx/index.vue.d.ts +2 -2
- package/lib/renderers/Xml/index.vue.d.ts +1 -1
- package/lib/renderers/Zip/TreeItem.vue.d.ts +1 -1
- package/lib/renderers/Zip/index.vue.d.ts +1 -1
- package/lib/renderers/base.types.d.ts +1 -1
- package/lib/renderers/registry.d.ts +1 -1
- package/lib/types.d.ts +3 -3
- package/package.json +2 -2
- package/lib/chunks/index--612Smof.mjs +0 -383
- package/lib/chunks/index-BB0i4QqI.mjs +0 -117
- package/lib/chunks/index-BVdrGK3Q.mjs +0 -356
- package/lib/chunks/index-Bp9CuvMZ.mjs +0 -157
- package/lib/chunks/index-Bxpf9v5j.mjs +0 -104
- package/lib/chunks/index-CDg6vIbT.mjs +0 -51
- package/lib/chunks/index-CWE-hKSs.mjs +0 -90
- package/lib/chunks/index-CY3xzGgt.mjs +0 -108
- package/lib/chunks/index-VdzIFJJW.mjs +0 -118
- package/lib/chunks/index-aoXgVLBb.mjs +0 -52
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import { defineComponent as ke, ref as s, watch as N, onBeforeUnmount as ae, onMounted as Ee, computed as le, openBlock as w, createElementBlock as U, normalizeStyle as oe, createElementVNode as _, createTextVNode as Ce, toDisplayString as b, unref as B, createCommentVNode as E, createBlock as ne, normalizeClass as Te } from "vue";
|
|
2
|
+
import { u as Ue, a as Xe, b as Ye, q as ze, v as Se, J as ie, _ as Be, $ as De, p as se, X as Oe } from "./index-c-pYJEmH.mjs";
|
|
3
|
+
import { ZoomOut as We, ZoomIn as $e, Scan as Pe, Maximize2 as je, RotateCcw as He, RotateCw as Ze, RefreshCw as Ne } from "lucide-vue-next";
|
|
4
|
+
import { _ as re } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
|
|
5
|
+
import { T as qe } from "./base.types-DaftHyg7.mjs";
|
|
6
|
+
const Ve = {
|
|
7
|
+
key: 0,
|
|
8
|
+
class: "vfp-absolute vfp-inset-0 vfp-renderer-loading vfp-bg-surface-1/80 vfp-z-10"
|
|
9
|
+
}, Fe = { class: "vfp-renderer-loading-content" }, Ge = { class: "vfp-renderer-loading-text" }, Ie = { key: 0 }, Qe = {
|
|
10
|
+
key: 2,
|
|
11
|
+
class: "vfp-renderer-loading"
|
|
12
|
+
}, Ae = { class: "vfp-renderer-loading-content" }, Je = { class: "vfp-renderer-loading-text" }, Ke = ["src"], et = {
|
|
13
|
+
key: 5,
|
|
14
|
+
class: "vfp-absolute vfp-bottom-2 vfp-right-3 vfp-text-[10px] vfp-text-fg-disabled hover:vfp-text-fg-secondary vfp-transition-colors vfp-pointer-events-auto vfp-select-none vfp-cursor-default"
|
|
15
|
+
}, tt = {
|
|
16
|
+
key: 6,
|
|
17
|
+
class: "vfp-absolute vfp-bottom-2 vfp-left-1/2 -vfp-translate-x-1/2 vfp-flex vfp-items-center vfp-gap-2 vfp-px-3 vfp-py-1.5 vfp-bg-surface-toolbar vfp-border vfp-border-line vfp-rounded-lg vfp-text-sm vfp-text-fg-primary vfp-shadow-md"
|
|
18
|
+
}, at = ["disabled"], lt = { class: "vfp-text-fg-secondary vfp-tabular-nums" }, ot = ["disabled"], vt = /* @__PURE__ */ ke({
|
|
19
|
+
__name: "index",
|
|
20
|
+
props: {
|
|
21
|
+
url: {},
|
|
22
|
+
fileSize: {},
|
|
23
|
+
file: {}
|
|
24
|
+
},
|
|
25
|
+
setup(ue, { expose: ce }) {
|
|
26
|
+
const f = ue, F = new qe(), { t: i } = Ue(), ve = Xe(), D = Ye(), r = s(1), C = s(0), T = s(!1), M = s(null), p = s(!1), O = s(0), R = s(null), L = s(""), k = s(1), X = s(1), G = s(!1), l = s({ x: 0, y: 0 }), y = s(!1);
|
|
27
|
+
let Y = { x: 0, y: 0 };
|
|
28
|
+
const m = s(1), v = s({ width: 0, height: 0 });
|
|
29
|
+
N([r, C], () => {
|
|
30
|
+
F.notify();
|
|
31
|
+
}), ce({
|
|
32
|
+
getToolbarGroups: () => [
|
|
33
|
+
{
|
|
34
|
+
items: [
|
|
35
|
+
{
|
|
36
|
+
type: "button",
|
|
37
|
+
icon: We,
|
|
38
|
+
tooltip: i.value("toolbar.zoom_out"),
|
|
39
|
+
action: fe,
|
|
40
|
+
disabled: r.value <= 0.01
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: "text",
|
|
44
|
+
content: `${Math.round(r.value * 100)}%`,
|
|
45
|
+
minWidth: "3rem"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
type: "button",
|
|
49
|
+
icon: $e,
|
|
50
|
+
tooltip: i.value("toolbar.zoom_in"),
|
|
51
|
+
action: de,
|
|
52
|
+
disabled: r.value >= 10
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
items: [
|
|
58
|
+
{
|
|
59
|
+
type: "button",
|
|
60
|
+
icon: Pe,
|
|
61
|
+
tooltip: i.value("toolbar.fit_to_window"),
|
|
62
|
+
action: I
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
type: "button",
|
|
66
|
+
icon: je,
|
|
67
|
+
tooltip: i.value("toolbar.original_size"),
|
|
68
|
+
action: me
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
items: [
|
|
74
|
+
{
|
|
75
|
+
type: "button",
|
|
76
|
+
icon: He,
|
|
77
|
+
tooltip: i.value("toolbar.rotate_left"),
|
|
78
|
+
action: pe
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
type: "button",
|
|
82
|
+
icon: Ze,
|
|
83
|
+
tooltip: i.value("toolbar.rotate_right"),
|
|
84
|
+
action: he
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
items: [
|
|
90
|
+
{
|
|
91
|
+
type: "button",
|
|
92
|
+
icon: Ne,
|
|
93
|
+
tooltip: i.value("toolbar.reset"),
|
|
94
|
+
action: ge
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
onToolbarChange: (e) => F.subscribe(e)
|
|
100
|
+
});
|
|
101
|
+
const de = () => {
|
|
102
|
+
r.value = Math.min(r.value + 0.1, 10);
|
|
103
|
+
}, fe = () => {
|
|
104
|
+
r.value = Math.max(r.value - 0.1, 0.01);
|
|
105
|
+
}, he = () => {
|
|
106
|
+
C.value = (C.value + 90) % 360;
|
|
107
|
+
}, pe = () => {
|
|
108
|
+
C.value = (C.value - 90 + 360) % 360;
|
|
109
|
+
}, me = () => {
|
|
110
|
+
r.value = 1, C.value = 0, l.value = { x: 0, y: 0 };
|
|
111
|
+
}, ge = () => {
|
|
112
|
+
I();
|
|
113
|
+
}, I = () => {
|
|
114
|
+
if (h.value && v.value.width > 0 && v.value.height > 0) {
|
|
115
|
+
const e = h.value.clientWidth, t = h.value.clientHeight, a = e / v.value.width, u = t / v.value.height;
|
|
116
|
+
r.value = Math.max(0.01, Math.min(10, Math.min(a, u))), l.value = { x: 0, y: 0 };
|
|
117
|
+
}
|
|
118
|
+
}, be = s(null), h = s(null);
|
|
119
|
+
let z = null, W = null, $ = null;
|
|
120
|
+
const g = /* @__PURE__ */ new Map();
|
|
121
|
+
let P = !1, j = 0, Q = 1, q = { x: 0, y: 0 }, A = 0;
|
|
122
|
+
N(
|
|
123
|
+
() => [f.url, f.file],
|
|
124
|
+
async () => {
|
|
125
|
+
if (D.begin(f.url), L.value = "", T.value = !1, M.value = null, p.value = !1, R.value = null, O.value = 0, l.value = { x: 0, y: 0 }, m.value = 1, r.value = 1, k.value = 1, X.value = 1, G.value = !1, z && (URL.revokeObjectURL(z), z = null), g.forEach((e) => URL.revokeObjectURL(e)), g.clear(), W = null, $ = null, !f.file) {
|
|
126
|
+
L.value = f.url;
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
const e = await ze(f.file), t = await Se(e);
|
|
131
|
+
if (!t || !await t.needsDecode(e)) {
|
|
132
|
+
L.value = f.url;
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
p.value = !0;
|
|
136
|
+
let a;
|
|
137
|
+
if (f.file instanceof Blob)
|
|
138
|
+
a = f.file;
|
|
139
|
+
else if (f.file.file instanceof Blob)
|
|
140
|
+
a = f.file.file;
|
|
141
|
+
else {
|
|
142
|
+
const n = await ve.value(f.url);
|
|
143
|
+
if (!n.ok) throw new ie("file.load_failed");
|
|
144
|
+
a = await n.blob();
|
|
145
|
+
}
|
|
146
|
+
if (W = a, $ = t, e.startsWith("image/x-") && (G.value = !0), t.getMetadata)
|
|
147
|
+
try {
|
|
148
|
+
const n = await t.getMetadata(a);
|
|
149
|
+
n.pageCount && n.pageCount > 1 && (X.value = n.pageCount);
|
|
150
|
+
} catch {
|
|
151
|
+
}
|
|
152
|
+
const c = {
|
|
153
|
+
page: 1,
|
|
154
|
+
fullQuality: !1,
|
|
155
|
+
onProgress: (n) => {
|
|
156
|
+
O.value = n;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
let o;
|
|
160
|
+
if (Be(e))
|
|
161
|
+
try {
|
|
162
|
+
o = await De(
|
|
163
|
+
e,
|
|
164
|
+
await a.arrayBuffer(),
|
|
165
|
+
{ page: 1, fullQuality: !1 }
|
|
166
|
+
);
|
|
167
|
+
} catch {
|
|
168
|
+
o = await t.decode(a, c);
|
|
169
|
+
}
|
|
170
|
+
else
|
|
171
|
+
o = await t.decode(a, c);
|
|
172
|
+
const d = typeof o == "string" ? o : URL.createObjectURL(o);
|
|
173
|
+
z = d, g.set(1, d), L.value = d, p.value = !1;
|
|
174
|
+
} catch (e) {
|
|
175
|
+
R.value = se(i.value, e) || i.value("image.decode_failed"), p.value = !1, D.error(e);
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
{ immediate: !0 }
|
|
179
|
+
);
|
|
180
|
+
const J = async (e) => {
|
|
181
|
+
if (!W || !$ || e < 1 || e > X.value) return;
|
|
182
|
+
const t = g.get(e);
|
|
183
|
+
if (t) {
|
|
184
|
+
k.value = e, L.value = t;
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
p.value = !0;
|
|
188
|
+
try {
|
|
189
|
+
const a = await $.decode(W, { page: e }), u = typeof a == "string" ? a : URL.createObjectURL(a);
|
|
190
|
+
if (g.size >= 10) {
|
|
191
|
+
const c = g.keys().next().value;
|
|
192
|
+
if (c !== void 0) {
|
|
193
|
+
const o = g.get(c);
|
|
194
|
+
o && URL.revokeObjectURL(o), g.delete(c);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
g.set(e, u), k.value = e, L.value = u, p.value = !1;
|
|
198
|
+
} catch (a) {
|
|
199
|
+
R.value = se(i.value, a) || i.value("image.page_decode_failed"), p.value = !1, D.error(a, "render");
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
ae(() => {
|
|
203
|
+
z && URL.revokeObjectURL(z), g.forEach((t) => URL.revokeObjectURL(t)), g.clear();
|
|
204
|
+
const e = h.value;
|
|
205
|
+
e && e.removeEventListener("wheel", V);
|
|
206
|
+
}), N(r, (e) => {
|
|
207
|
+
m.value = e;
|
|
208
|
+
}), N(m, (e) => {
|
|
209
|
+
r.value = e;
|
|
210
|
+
});
|
|
211
|
+
const H = (e, t) => {
|
|
212
|
+
const a = h.value;
|
|
213
|
+
if (!a || v.value.width === 0) return e;
|
|
214
|
+
const u = a.clientWidth, c = a.clientHeight, o = v.value.width * t, d = v.value.height * t, n = Math.min(80, u * 0.15, c * 0.15), x = (u + o) / 2 - n, S = (c + d) / 2 - n;
|
|
215
|
+
return {
|
|
216
|
+
x: x > 0 ? Math.max(-x, Math.min(x, e.x)) : 0,
|
|
217
|
+
y: S > 0 ? Math.max(-S, Math.min(S, e.y)) : 0
|
|
218
|
+
};
|
|
219
|
+
}, ye = (e) => {
|
|
220
|
+
T.value = !0;
|
|
221
|
+
const t = e.currentTarget;
|
|
222
|
+
if (v.value = { width: t.naturalWidth, height: t.naturalHeight }, h.value && v.value.width > 0 && v.value.height > 0) {
|
|
223
|
+
const a = h.value.clientWidth, u = h.value.clientHeight, c = a / v.value.width, o = u / v.value.height, d = Math.min(c, o);
|
|
224
|
+
r.value = Math.max(0.01, Math.min(10, d)), l.value = { x: 0, y: 0 };
|
|
225
|
+
}
|
|
226
|
+
}, xe = () => {
|
|
227
|
+
M.value = i.value("image.load_failed"), T.value = !0, D.error(new ie("image.load_failed"), "request");
|
|
228
|
+
}, we = () => {
|
|
229
|
+
l.value = { x: 0, y: 0 }, r.value = 1;
|
|
230
|
+
}, V = (e) => {
|
|
231
|
+
e.preventDefault(), e.stopPropagation();
|
|
232
|
+
const t = h.value;
|
|
233
|
+
if (!t) return;
|
|
234
|
+
const a = t.getBoundingClientRect(), u = e.clientX - a.left - a.width / 2, c = e.clientY - a.top - a.height / 2, o = e.deltaY > 0 ? -0.05 : 0.05, d = m.value, n = Math.max(0.01, Math.min(10, d + o)), x = n / d;
|
|
235
|
+
l.value = H(
|
|
236
|
+
{
|
|
237
|
+
x: u - x * (u - l.value.x),
|
|
238
|
+
y: c - x * (c - l.value.y)
|
|
239
|
+
},
|
|
240
|
+
n
|
|
241
|
+
), m.value = n;
|
|
242
|
+
};
|
|
243
|
+
Ee(() => {
|
|
244
|
+
const e = h.value;
|
|
245
|
+
e && (e.addEventListener("wheel", V, { passive: !1 }), e.addEventListener("touchstart", ee, { passive: !1 }), e.addEventListener("touchmove", te, { passive: !1 }), e.addEventListener("touchend", Z), e.addEventListener("touchcancel", Z));
|
|
246
|
+
}), ae(() => {
|
|
247
|
+
const e = h.value;
|
|
248
|
+
e && (e.removeEventListener("wheel", V), e.removeEventListener("touchstart", ee), e.removeEventListener("touchmove", te), e.removeEventListener("touchend", Z), e.removeEventListener("touchcancel", Z));
|
|
249
|
+
});
|
|
250
|
+
const _e = (e) => {
|
|
251
|
+
P || e.button === 0 && (y.value = !0, Y = {
|
|
252
|
+
x: e.clientX - l.value.x,
|
|
253
|
+
y: e.clientY - l.value.y
|
|
254
|
+
});
|
|
255
|
+
}, Me = (e) => {
|
|
256
|
+
P || y.value && (l.value = H(
|
|
257
|
+
{
|
|
258
|
+
x: e.clientX - Y.x,
|
|
259
|
+
y: e.clientY - Y.y
|
|
260
|
+
},
|
|
261
|
+
m.value
|
|
262
|
+
));
|
|
263
|
+
}, K = () => {
|
|
264
|
+
P || (y.value = !1);
|
|
265
|
+
}, ee = (e) => {
|
|
266
|
+
P = !0, e.preventDefault();
|
|
267
|
+
const t = e.touches;
|
|
268
|
+
if (t.length === 1) {
|
|
269
|
+
y.value = !0, Y = {
|
|
270
|
+
x: t[0].clientX - l.value.x,
|
|
271
|
+
y: t[0].clientY - l.value.y
|
|
272
|
+
};
|
|
273
|
+
const a = Date.now();
|
|
274
|
+
a - A < 300 && (l.value = { x: 0, y: 0 }, r.value = 1), A = a;
|
|
275
|
+
} else t.length === 2 && (y.value = !1, j = Math.hypot(
|
|
276
|
+
t[1].clientX - t[0].clientX,
|
|
277
|
+
t[1].clientY - t[0].clientY
|
|
278
|
+
), Q = m.value, q = { ...l.value });
|
|
279
|
+
}, te = (e) => {
|
|
280
|
+
e.preventDefault();
|
|
281
|
+
const t = e.touches;
|
|
282
|
+
if (t.length === 1 && y.value)
|
|
283
|
+
l.value = H(
|
|
284
|
+
{
|
|
285
|
+
x: t[0].clientX - Y.x,
|
|
286
|
+
y: t[0].clientY - Y.y
|
|
287
|
+
},
|
|
288
|
+
m.value
|
|
289
|
+
);
|
|
290
|
+
else if (t.length === 2) {
|
|
291
|
+
const a = h.value;
|
|
292
|
+
if (!a) return;
|
|
293
|
+
const u = Math.hypot(
|
|
294
|
+
t[1].clientX - t[0].clientX,
|
|
295
|
+
t[1].clientY - t[0].clientY
|
|
296
|
+
);
|
|
297
|
+
if (Math.abs(u - j) < 5) return;
|
|
298
|
+
const c = u / j, o = Math.max(0.01, Math.min(10, Q * c)), d = a.getBoundingClientRect(), n = (t[0].clientX + t[1].clientX) / 2 - d.left - d.width / 2, x = (t[0].clientY + t[1].clientY) / 2 - d.top - d.height / 2, S = o / m.value;
|
|
299
|
+
l.value = H(
|
|
300
|
+
{
|
|
301
|
+
x: n - S * (n - q.x),
|
|
302
|
+
y: x - S * (x - q.y)
|
|
303
|
+
},
|
|
304
|
+
o
|
|
305
|
+
), m.value = o;
|
|
306
|
+
}
|
|
307
|
+
}, Z = () => {
|
|
308
|
+
y.value = !1, j = 0;
|
|
309
|
+
}, Re = le(() => ({
|
|
310
|
+
transform: `translate(${l.value.x}px, ${l.value.y}px) scale(${m.value}) rotate(${C.value}deg)`,
|
|
311
|
+
transformOrigin: "center",
|
|
312
|
+
transition: y.value ? "none" : "transform 0.3s ease-out",
|
|
313
|
+
opacity: T.value && !M.value && !R.value ? 1 : 0
|
|
314
|
+
})), Le = le(() => f.fileSize == null ? "" : ` · ${Oe(f.fileSize)}`);
|
|
315
|
+
return (e, t) => (w(), U("div", {
|
|
316
|
+
ref_key: "containerRef",
|
|
317
|
+
ref: h,
|
|
318
|
+
class: "vfp-relative vfp-flex vfp-items-center vfp-justify-center vfp-w-full vfp-h-full vfp-overflow-hidden",
|
|
319
|
+
style: oe({ cursor: y.value ? "grabbing" : "grab", touchAction: "none" }),
|
|
320
|
+
onMousedown: _e,
|
|
321
|
+
onMousemove: Me,
|
|
322
|
+
onMouseup: K,
|
|
323
|
+
onMouseleave: K
|
|
324
|
+
}, [
|
|
325
|
+
p.value ? (w(), U("div", Ve, [
|
|
326
|
+
_("div", Fe, [
|
|
327
|
+
t[2] || (t[2] = _("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
328
|
+
_("p", Ge, [
|
|
329
|
+
Ce(b(B(i)("image.decoding")) + " ", 1),
|
|
330
|
+
O.value > 0 ? (w(), U("span", Ie, b(Math.round(O.value)) + "%", 1)) : E("", !0)
|
|
331
|
+
])
|
|
332
|
+
])
|
|
333
|
+
])) : E("", !0),
|
|
334
|
+
R.value ? (w(), ne(re, {
|
|
335
|
+
key: 1,
|
|
336
|
+
message: B(i)("image.decode_failed"),
|
|
337
|
+
detail: R.value
|
|
338
|
+
}, null, 8, ["message", "detail"])) : E("", !0),
|
|
339
|
+
!T.value && !M.value && !p.value && !R.value ? (w(), U("div", Qe, [
|
|
340
|
+
_("div", Ae, [
|
|
341
|
+
t[3] || (t[3] = _("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
342
|
+
_("span", Je, b(B(i)("common.loading")), 1)
|
|
343
|
+
])
|
|
344
|
+
])) : E("", !0),
|
|
345
|
+
M.value ? (w(), ne(re, {
|
|
346
|
+
key: 3,
|
|
347
|
+
message: M.value
|
|
348
|
+
}, null, 8, ["message"])) : E("", !0),
|
|
349
|
+
L.value ? (w(), U("img", {
|
|
350
|
+
key: 4,
|
|
351
|
+
ref_key: "imgRef",
|
|
352
|
+
ref: be,
|
|
353
|
+
src: L.value,
|
|
354
|
+
alt: "Preview",
|
|
355
|
+
class: Te(["vfp-max-w-none vfp-select-none", (!T.value || M.value || R.value) && "vfp-hidden"]),
|
|
356
|
+
style: oe(Re.value),
|
|
357
|
+
draggable: !1,
|
|
358
|
+
onLoad: ye,
|
|
359
|
+
onError: xe,
|
|
360
|
+
onDblclick: we
|
|
361
|
+
}, null, 46, Ke)) : E("", !0),
|
|
362
|
+
T.value && !M.value && v.value.width > 0 ? (w(), U("div", et, b(v.value.width) + " × " + b(v.value.height) + b(Le.value), 1)) : E("", !0),
|
|
363
|
+
X.value > 1 ? (w(), U("div", tt, [
|
|
364
|
+
_("button", {
|
|
365
|
+
type: "button",
|
|
366
|
+
disabled: k.value <= 1 || p.value,
|
|
367
|
+
class: "vfp-px-2 vfp-py-0.5 vfp-rounded hover:vfp-bg-surface-nav-hover disabled:vfp-opacity-40 disabled:vfp-cursor-not-allowed",
|
|
368
|
+
onClick: t[0] || (t[0] = (a) => J(k.value - 1))
|
|
369
|
+
}, b(B(i)("toolbar.prev_page")), 9, at),
|
|
370
|
+
_("span", lt, b(k.value) + " / " + b(X.value), 1),
|
|
371
|
+
_("button", {
|
|
372
|
+
type: "button",
|
|
373
|
+
disabled: k.value >= X.value || p.value,
|
|
374
|
+
class: "vfp-px-2 vfp-py-0.5 vfp-rounded hover:vfp-bg-surface-nav-hover disabled:vfp-opacity-40 disabled:vfp-cursor-not-allowed",
|
|
375
|
+
onClick: t[1] || (t[1] = (a) => J(k.value + 1))
|
|
376
|
+
}, b(B(i)("toolbar.next_page")), 9, ot)
|
|
377
|
+
])) : E("", !0)
|
|
378
|
+
], 36));
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
export {
|
|
382
|
+
vt as default
|
|
383
|
+
};
|