@eternalheart/vue-file-preview 1.6.11 → 1.6.13
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 +9 -1
- package/lib/FilePreviewEmbed.vue.d.ts +4 -1
- package/lib/FilePreviewModal.vue.d.ts +4 -1
- package/lib/chunks/EmptyState.vue_vue_type_script_setup_true_lang-C7qk6wj0.mjs +20 -0
- package/lib/chunks/RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs +32 -0
- package/lib/chunks/{avifLoader-CAUzjn-d-Bv80osgL.mjs → avifLoader-CAUzjn-d-C0KRpetN.mjs} +1 -1
- package/lib/chunks/{heicLoader-D_9PukkA-c40agcEu.mjs → heicLoader-D_9PukkA-Czof_5FJ.mjs} +1 -1
- package/lib/chunks/{index-CO713RPO.mjs → index--612Smof.mjs} +118 -118
- package/lib/chunks/{index-Dw6YZA28.mjs → index-8Vpbg2kS.mjs} +2 -2
- package/lib/chunks/index-B21EAyWz.mjs +137 -0
- package/lib/chunks/{index-CrLeFRdr.mjs → index-BASg1cr4.mjs} +2 -2
- package/lib/chunks/index-BB0i4QqI.mjs +117 -0
- package/lib/chunks/{index-C92b547K.mjs → index-BVdrGK3Q.mjs} +80 -80
- package/lib/chunks/index-BlrFFeqc.mjs +330 -0
- package/lib/chunks/index-Bp9CuvMZ.mjs +157 -0
- package/lib/chunks/index-BuqPb5mP.mjs +306 -0
- package/lib/chunks/{index-Df-1MbYj.mjs → index-BvBqDq3O.mjs} +2 -2
- package/lib/chunks/{index-BkqPtbFz.mjs → index-Bxpf9v5j.mjs} +29 -29
- package/lib/chunks/{index-DpY9eMSI.mjs → index-C9mAajbD.mjs} +231 -226
- package/lib/chunks/{index-DTZVumT8.mjs → index-CDg6vIbT.mjs} +14 -14
- package/lib/chunks/{index-By8q8XPn.mjs → index-CWE-hKSs.mjs} +10 -10
- package/lib/chunks/{index-DbOpSm8f.mjs → index-CY3xzGgt.mjs} +19 -19
- package/lib/chunks/{index-C8pOqpTq.mjs → index-CxKZKUJj.mjs} +521 -523
- package/lib/chunks/{index-Cyg4lWK-.mjs → index-D30L8tm9.mjs} +12 -12
- package/lib/chunks/{index-DfC_cA90.mjs → index-DN4Ui0Gh.mjs} +24 -24
- package/lib/chunks/{index-B3uQ1OoT.mjs → index-DZZN3kYi.mjs} +832 -812
- package/lib/chunks/{index-BpKvjFVp.mjs → index-Dkro_8Fy.mjs} +20 -20
- package/lib/chunks/{index-B35jLxPz.mjs → index-VdzIFJJW.mjs} +26 -26
- package/lib/chunks/{index--D2MwF_x.mjs → index-aoXgVLBb.mjs} +10 -10
- package/lib/chunks/{jp2Loader-Dig19xyo-82PXw2fC.mjs → jp2Loader-Dig19xyo-CKUaGhPl.mjs} +1 -1
- package/lib/chunks/{psdLoader-C0tKUXXl-DRn7RYLA.mjs → psdLoader-C0tKUXXl-CYWoQis5.mjs} +1 -1
- package/lib/chunks/{rawLoader-C-tPeFAB-DP397Cnq.mjs → rawLoader-C-tPeFAB-C35zC8nZ.mjs} +1 -1
- package/lib/chunks/{tiffLoader-BlhByX8w-BC52z4Tf.mjs → tiffLoader-BlhByX8w-BOxg_Du5.mjs} +1 -1
- package/lib/chunks/{useShikiHighlight-DSyCygls.mjs → useShikiHighlight-BPmcxA-h.mjs} +1 -1
- package/lib/index.cjs +63 -63
- package/lib/index.css +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.mjs +6 -6
- package/lib/renderers/Cad/toolbar.d.ts +1 -0
- package/lib/renderers/EmptyState.vue.d.ts +2 -0
- package/lib/renderers/Json/index.vue.d.ts +5 -0
- package/lib/renderers/Pptx/index.vue.d.ts +3 -0
- package/lib/renderers/Text/index.vue.d.ts +3 -0
- package/lib/renderers/Xlsx/index.vue.d.ts +3 -0
- package/lib/renderers/registry.d.ts +3 -1
- package/package.json +1 -1
- package/lib/chunks/RendererError.vue_vue_type_script_setup_true_lang-BNoENOWX.mjs +0 -30
- package/lib/chunks/index-2xdBoG-I.mjs +0 -141
- package/lib/chunks/index-B2xLxhp0.mjs +0 -133
- package/lib/chunks/index-DKJ_iQ70.mjs +0 -295
- package/lib/chunks/index-DMwZXKa4.mjs +0 -322
- package/lib/chunks/index-DyP3rhuf.mjs +0 -113
package/README.md
CHANGED
|
@@ -382,6 +382,7 @@ Differences from `FilePreviewModal`:
|
|
|
382
382
|
| `showClose` | `boolean` | ❌ | Whether to show the close button (default `true` for modal) |
|
|
383
383
|
| `showNavigation` | `boolean` | ❌ | Whether to show file navigation arrows (default `true`) |
|
|
384
384
|
| `loopNavigation` | `boolean` | ❌ | Whether file navigation wraps around (default `false`) |
|
|
385
|
+
| `emptyHint` | `'auto' \| 'always' \| 'never'` | ❌ | Empty-file hint policy: text types stay blank, structured types show hint (default `auto`) |
|
|
385
386
|
|
|
386
387
|
### FilePreviewModal Events
|
|
387
388
|
|
|
@@ -407,6 +408,7 @@ Differences from `FilePreviewModal`:
|
|
|
407
408
|
| `showClose` | `boolean` | ❌ | `false` | Whether to show the close button (default `false` for embed) |
|
|
408
409
|
| `showNavigation` | `boolean` | ❌ | `true` | Whether to show file navigation arrows |
|
|
409
410
|
| `loopNavigation` | `boolean` | ❌ | `false` | Whether file navigation wraps around |
|
|
411
|
+
| `emptyHint` | `'auto' \| 'always' \| 'never'` | ❌ | `'auto'` | Empty-file hint policy: text types stay blank, structured types show hint |
|
|
410
412
|
|
|
411
413
|
### FilePreviewEmbed Events
|
|
412
414
|
|
package/README.zh-CN.md
CHANGED
|
@@ -382,6 +382,7 @@ const files = [
|
|
|
382
382
|
| `showClose` | `boolean` | ❌ | 是否显示关闭按钮(modal 模式默认 `true`) |
|
|
383
383
|
| `showNavigation` | `boolean` | ❌ | 是否显示文件导航箭头(默认 `true`) |
|
|
384
384
|
| `loopNavigation` | `boolean` | ❌ | 是否循环导航文件(默认 `false`) |
|
|
385
|
+
| `emptyHint` | `'auto' \| 'always' \| 'never'` | ❌ | 空内容提示策略(默认 `auto`):文本类保持空白,结构化类型显示提示 |
|
|
385
386
|
|
|
386
387
|
### FilePreviewModal 事件
|
|
387
388
|
|
|
@@ -407,6 +408,7 @@ const files = [
|
|
|
407
408
|
| `showClose` | `boolean` | ❌ | `false` | 是否显示关闭按钮(embed 模式默认 `false`) |
|
|
408
409
|
| `showNavigation` | `boolean` | ❌ | `true` | 是否显示文件导航箭头 |
|
|
409
410
|
| `loopNavigation` | `boolean` | ❌ | `false` | 是否循环导航文件 |
|
|
411
|
+
| `emptyHint` | `'auto' \| 'always' \| 'never'` | ❌ | `'auto'` | 空内容提示策略:文本类保持空白,结构化类型显示提示 |
|
|
410
412
|
|
|
411
413
|
### FilePreviewEmbed 事件
|
|
412
414
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PreviewFile, type PreviewFileInput, type Locale, type Messages, type Theme, type CustomRendererEventPayload, type RequestHandler, type RequestInitFactory, type ShouldFetchAsBlob } from '@eternalheart/file-preview-core';
|
|
1
|
+
import { type PreviewFile, type PreviewFileInput, type Locale, type Messages, type Theme, type CustomRendererEventPayload, type RequestHandler, type RequestInitFactory, type ShouldFetchAsBlob, type EmptyHintMode } from '@eternalheart/file-preview-core';
|
|
2
2
|
import type { CustomRenderer } from './types';
|
|
3
3
|
interface Props {
|
|
4
4
|
files: PreviewFileInput[];
|
|
@@ -34,6 +34,13 @@ interface Props {
|
|
|
34
34
|
showNavigation?: boolean;
|
|
35
35
|
/** 是否循环导航文件,默认 false */
|
|
36
36
|
loopNavigation?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* 空内容提示策略,默认 'auto'
|
|
39
|
+
* - 'auto':文本类(text/json)保持原生空白;结构化类型(xlsx/pptx)显示空提示
|
|
40
|
+
* - 'always':全部显示空提示,文案取 `messages['file.empty']`
|
|
41
|
+
* - 'never':一律保持空白
|
|
42
|
+
*/
|
|
43
|
+
emptyHint?: EmptyHintMode;
|
|
37
44
|
}
|
|
38
45
|
declare const _default: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
39
46
|
close: () => any;
|
|
@@ -47,6 +54,7 @@ declare const _default: import("vue").DefineComponent<Props, {}, {}, {}, {}, imp
|
|
|
47
54
|
requestInit: RequestInitFactory;
|
|
48
55
|
requestHandler: RequestHandler;
|
|
49
56
|
mode: "modal" | "embed";
|
|
57
|
+
emptyHint: EmptyHintMode;
|
|
50
58
|
onClose: () => void;
|
|
51
59
|
theme: Theme;
|
|
52
60
|
customRenderers: CustomRenderer[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PreviewFile, PreviewFileInput, Locale, Messages, Theme, CustomRendererEventPayload, RequestHandler, RequestInitFactory, ShouldFetchAsBlob } from '@eternalheart/file-preview-core';
|
|
1
|
+
import type { PreviewFile, PreviewFileInput, EmptyHintMode, Locale, Messages, Theme, CustomRendererEventPayload, RequestHandler, RequestInitFactory, ShouldFetchAsBlob } from '@eternalheart/file-preview-core';
|
|
2
2
|
import type { CustomRenderer } from './types';
|
|
3
3
|
interface Props {
|
|
4
4
|
files: PreviewFileInput[];
|
|
@@ -34,6 +34,8 @@ interface Props {
|
|
|
34
34
|
showNavigation?: boolean;
|
|
35
35
|
/** 是否循环导航文件,默认 false */
|
|
36
36
|
loopNavigation?: boolean;
|
|
37
|
+
/** 空内容提示策略,默认 'auto'(文本类空白、结构化类型提示) */
|
|
38
|
+
emptyHint?: EmptyHintMode;
|
|
37
39
|
}
|
|
38
40
|
declare const _default: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
39
41
|
close: () => any;
|
|
@@ -48,6 +50,7 @@ declare const _default: import("vue").DefineComponent<Props, {}, {}, {}, {}, imp
|
|
|
48
50
|
requestHandler: RequestHandler;
|
|
49
51
|
height: number | string;
|
|
50
52
|
width: number | string;
|
|
53
|
+
emptyHint: EmptyHintMode;
|
|
51
54
|
onClose: () => void;
|
|
52
55
|
theme: Theme;
|
|
53
56
|
currentIndex: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PreviewFile, PreviewFileInput, Locale, Messages, Theme, CustomRendererEventPayload, RequestHandler, RequestInitFactory, ShouldFetchAsBlob } from '@eternalheart/file-preview-core';
|
|
1
|
+
import type { PreviewFile, PreviewFileInput, EmptyHintMode, Locale, Messages, Theme, CustomRendererEventPayload, RequestHandler, RequestInitFactory, ShouldFetchAsBlob } from '@eternalheart/file-preview-core';
|
|
2
2
|
import type { CustomRenderer } from './types';
|
|
3
3
|
interface Props {
|
|
4
4
|
files: PreviewFileInput[];
|
|
@@ -29,6 +29,8 @@ interface Props {
|
|
|
29
29
|
showNavigation?: boolean;
|
|
30
30
|
/** 是否循环导航文件,默认 false */
|
|
31
31
|
loopNavigation?: boolean;
|
|
32
|
+
/** 空内容提示策略,默认 'auto'(文本类空白、结构化类型提示) */
|
|
33
|
+
emptyHint?: EmptyHintMode;
|
|
32
34
|
}
|
|
33
35
|
declare const _default: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
34
36
|
close: () => any;
|
|
@@ -41,6 +43,7 @@ declare const _default: import("vue").DefineComponent<Props, {}, {}, {}, {}, imp
|
|
|
41
43
|
}>, {
|
|
42
44
|
requestInit: RequestInitFactory;
|
|
43
45
|
requestHandler: RequestHandler;
|
|
46
|
+
emptyHint: EmptyHintMode;
|
|
44
47
|
theme: Theme;
|
|
45
48
|
customRenderers: CustomRenderer[];
|
|
46
49
|
locale: Locale;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineComponent as s, openBlock as o, createElementBlock as p, createElementVNode as e, createVNode as n, unref as t, toDisplayString as f } from "vue";
|
|
2
|
+
import { FileMinus as c } from "lucide-vue-next";
|
|
3
|
+
import { u as i } from "./index-DZZN3kYi.mjs";
|
|
4
|
+
const a = { class: "vfp-renderer-empty" }, m = { class: "vfp-renderer-empty-content" }, _ = { class: "vfp-w-12 vfp-h-12 vfp-rounded-full vfp-bg-surface-2 vfp-flex vfp-items-center vfp-justify-center" }, l = { class: "vfp-renderer-empty-text" }, g = /* @__PURE__ */ s({
|
|
5
|
+
__name: "EmptyState",
|
|
6
|
+
setup(v) {
|
|
7
|
+
const { t: r } = i();
|
|
8
|
+
return (d, u) => (o(), p("div", a, [
|
|
9
|
+
e("div", m, [
|
|
10
|
+
e("div", _, [
|
|
11
|
+
n(t(c), { class: "vfp-w-6 vfp-h-6 vfp-text-fg-tertiary" })
|
|
12
|
+
]),
|
|
13
|
+
e("p", l, f(t(r)("file.empty")), 1)
|
|
14
|
+
])
|
|
15
|
+
]));
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
export {
|
|
19
|
+
g as _
|
|
20
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { defineComponent as c, openBlock as r, createElementBlock as t, createElementVNode as o, createVNode as d, unref as l, createCommentVNode as n, toDisplayString as s } from "vue";
|
|
2
|
+
import { AlertCircle as a } from "lucide-vue-next";
|
|
3
|
+
const f = { class: "vfp-renderer-error" }, i = { class: "vfp-renderer-error-content" }, p = {
|
|
4
|
+
key: 0,
|
|
5
|
+
class: "vfp-w-12 vfp-h-12 vfp-rounded-full vfp-bg-red-500/10 vfp-flex vfp-items-center vfp-justify-center"
|
|
6
|
+
}, v = { class: "vfp-renderer-error-text" }, m = {
|
|
7
|
+
key: 0,
|
|
8
|
+
class: "vfp-renderer-error-detail"
|
|
9
|
+
}, y = /* @__PURE__ */ c({
|
|
10
|
+
__name: "RendererError",
|
|
11
|
+
props: {
|
|
12
|
+
message: {},
|
|
13
|
+
detail: {},
|
|
14
|
+
showIcon: { type: Boolean, default: !0 }
|
|
15
|
+
},
|
|
16
|
+
setup(e) {
|
|
17
|
+
return (u, _) => (r(), t("div", f, [
|
|
18
|
+
o("div", i, [
|
|
19
|
+
e.showIcon ? (r(), t("div", p, [
|
|
20
|
+
d(l(a), { class: "vfp-w-6 vfp-h-6 vfp-text-red-400" })
|
|
21
|
+
])) : n("", !0),
|
|
22
|
+
o("div", null, [
|
|
23
|
+
o("p", v, s(e.message), 1),
|
|
24
|
+
e.detail ? (r(), t("p", m, s(e.detail), 1)) : n("", !0)
|
|
25
|
+
])
|
|
26
|
+
])
|
|
27
|
+
]));
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
export {
|
|
31
|
+
y as _
|
|
32
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { defineComponent as Me, ref as s, watch as
|
|
2
|
-
import { u as Ee,
|
|
3
|
-
import { ZoomOut as Xe, ZoomIn as
|
|
4
|
-
import { _ as ie } from "./RendererError.vue_vue_type_script_setup_true_lang-
|
|
5
|
-
import { T as
|
|
6
|
-
const
|
|
1
|
+
import { defineComponent as Me, ref as s, watch as Z, onBeforeUnmount as te, onMounted as Re, computed as ae, openBlock as w, createElementBlock as U, normalizeStyle as le, createElementVNode as _, createTextVNode as Le, toDisplayString as b, unref as W, createCommentVNode as E, createBlock as ne, normalizeClass as ke } from "vue";
|
|
2
|
+
import { u as Ee, V as Ce, a as Te, k as Ue, n as Ye, R as ze, W as oe, s as Se } from "./index-DZZN3kYi.mjs";
|
|
3
|
+
import { ZoomOut as Xe, ZoomIn as We, Scan as Be, Maximize2 as De, RotateCcw as Oe, RotateCw as Pe, RefreshCw as $e } from "lucide-vue-next";
|
|
4
|
+
import { _ as ie } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
|
|
5
|
+
import { T as je } from "./base.types-DaftHyg7.mjs";
|
|
6
|
+
const He = {
|
|
7
7
|
key: 0,
|
|
8
8
|
class: "vfp-absolute vfp-inset-0 vfp-renderer-loading vfp-bg-surface-1/80 vfp-z-10"
|
|
9
|
-
},
|
|
9
|
+
}, Ze = { class: "vfp-renderer-loading-content" }, Ve = { class: "vfp-renderer-loading-text" }, Ne = { key: 0 }, Ge = {
|
|
10
10
|
key: 2,
|
|
11
11
|
class: "vfp-renderer-loading"
|
|
12
12
|
}, Ie = { class: "vfp-renderer-loading-content" }, Qe = { class: "vfp-renderer-loading-text" }, Ae = ["src"], Fe = {
|
|
@@ -23,10 +23,10 @@ const je = {
|
|
|
23
23
|
file: {}
|
|
24
24
|
},
|
|
25
25
|
setup(se, { expose: ue }) {
|
|
26
|
-
const
|
|
27
|
-
let
|
|
26
|
+
const f = se, G = new je(), { t: i } = Ee(), u = s(1), C = s(0), T = s(!1), M = s(null), p = s(!1), B = s(0), R = s(null), L = s(""), k = s(1), Y = s(1), I = s(!1), l = s({ x: 0, y: 0 }), y = s(!1);
|
|
27
|
+
let z = { x: 0, y: 0 };
|
|
28
28
|
const m = s(1), v = s({ width: 0, height: 0 });
|
|
29
|
-
|
|
29
|
+
Z([u, C], () => {
|
|
30
30
|
G.notify();
|
|
31
31
|
}), ue({
|
|
32
32
|
getToolbarGroups: () => [
|
|
@@ -46,7 +46,7 @@ const je = {
|
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
48
|
type: "button",
|
|
49
|
-
icon:
|
|
49
|
+
icon: We,
|
|
50
50
|
tooltip: i.value("toolbar.zoom_in"),
|
|
51
51
|
action: re,
|
|
52
52
|
disabled: u.value >= 10
|
|
@@ -57,15 +57,15 @@ const je = {
|
|
|
57
57
|
items: [
|
|
58
58
|
{
|
|
59
59
|
type: "button",
|
|
60
|
-
icon:
|
|
60
|
+
icon: Be,
|
|
61
61
|
tooltip: i.value("toolbar.fit_to_window"),
|
|
62
62
|
action: Q
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
65
|
type: "button",
|
|
66
|
-
icon:
|
|
66
|
+
icon: De,
|
|
67
67
|
tooltip: i.value("toolbar.original_size"),
|
|
68
|
-
action:
|
|
68
|
+
action: fe
|
|
69
69
|
}
|
|
70
70
|
]
|
|
71
71
|
},
|
|
@@ -73,13 +73,13 @@ const je = {
|
|
|
73
73
|
items: [
|
|
74
74
|
{
|
|
75
75
|
type: "button",
|
|
76
|
-
icon:
|
|
76
|
+
icon: Oe,
|
|
77
77
|
tooltip: i.value("toolbar.rotate_left"),
|
|
78
|
-
action:
|
|
78
|
+
action: de
|
|
79
79
|
},
|
|
80
80
|
{
|
|
81
81
|
type: "button",
|
|
82
|
-
icon:
|
|
82
|
+
icon: Pe,
|
|
83
83
|
tooltip: i.value("toolbar.rotate_right"),
|
|
84
84
|
action: ve
|
|
85
85
|
}
|
|
@@ -89,7 +89,7 @@ const je = {
|
|
|
89
89
|
items: [
|
|
90
90
|
{
|
|
91
91
|
type: "button",
|
|
92
|
-
icon:
|
|
92
|
+
icon: $e,
|
|
93
93
|
tooltip: i.value("toolbar.reset"),
|
|
94
94
|
action: he
|
|
95
95
|
}
|
|
@@ -104,9 +104,9 @@ const je = {
|
|
|
104
104
|
u.value = Math.max(u.value - 0.1, 0.01);
|
|
105
105
|
}, ve = () => {
|
|
106
106
|
C.value = (C.value + 90) % 360;
|
|
107
|
-
}, fe = () => {
|
|
108
|
-
C.value = (C.value - 90 + 360) % 360;
|
|
109
107
|
}, de = () => {
|
|
108
|
+
C.value = (C.value - 90 + 360) % 360;
|
|
109
|
+
}, fe = () => {
|
|
110
110
|
u.value = 1, C.value = 0, l.value = { x: 0, y: 0 };
|
|
111
111
|
}, he = () => {
|
|
112
112
|
Q();
|
|
@@ -116,69 +116,69 @@ const je = {
|
|
|
116
116
|
u.value = Math.max(0.01, Math.min(10, Math.min(a, r))), l.value = { x: 0, y: 0 };
|
|
117
117
|
}
|
|
118
118
|
}, pe = s(null), h = s(null);
|
|
119
|
-
let S = null,
|
|
119
|
+
let S = null, D = null, O = null;
|
|
120
120
|
const g = /* @__PURE__ */ new Map();
|
|
121
|
-
let
|
|
122
|
-
|
|
123
|
-
() => [
|
|
121
|
+
let P = !1, $ = 0, A = 1, V = { x: 0, y: 0 }, F = 0;
|
|
122
|
+
Z(
|
|
123
|
+
() => [f.url, f.file],
|
|
124
124
|
async () => {
|
|
125
|
-
if (L.value = "",
|
|
126
|
-
L.value =
|
|
125
|
+
if (L.value = "", T.value = !1, M.value = null, p.value = !1, R.value = null, B.value = 0, l.value = { x: 0, y: 0 }, m.value = 1, u.value = 1, k.value = 1, Y.value = 1, I.value = !1, S && (URL.revokeObjectURL(S), S = null), g.forEach((e) => URL.revokeObjectURL(e)), g.clear(), D = null, O = null, !f.file) {
|
|
126
|
+
L.value = f.url;
|
|
127
127
|
return;
|
|
128
128
|
}
|
|
129
129
|
try {
|
|
130
|
-
const e = await Ce(
|
|
130
|
+
const e = await Ce(f.file), t = await Te(e);
|
|
131
131
|
if (!t || !await t.needsDecode(e)) {
|
|
132
|
-
L.value =
|
|
132
|
+
L.value = f.url;
|
|
133
133
|
return;
|
|
134
134
|
}
|
|
135
135
|
p.value = !0;
|
|
136
136
|
let a;
|
|
137
|
-
if (
|
|
138
|
-
a =
|
|
139
|
-
else if (
|
|
140
|
-
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
141
|
else {
|
|
142
|
-
const
|
|
143
|
-
if (!
|
|
144
|
-
a = await
|
|
142
|
+
const o = await fetch(f.url);
|
|
143
|
+
if (!o.ok) throw new Ue("file.load_failed");
|
|
144
|
+
a = await o.blob();
|
|
145
145
|
}
|
|
146
|
-
if (
|
|
146
|
+
if (D = a, O = t, e.startsWith("image/x-") && (I.value = !0), t.getMetadata)
|
|
147
147
|
try {
|
|
148
|
-
const
|
|
149
|
-
|
|
148
|
+
const o = await t.getMetadata(a);
|
|
149
|
+
o.pageCount && o.pageCount > 1 && (Y.value = o.pageCount);
|
|
150
150
|
} catch {
|
|
151
151
|
}
|
|
152
152
|
const c = {
|
|
153
153
|
page: 1,
|
|
154
154
|
fullQuality: !1,
|
|
155
|
-
onProgress: (
|
|
156
|
-
|
|
155
|
+
onProgress: (o) => {
|
|
156
|
+
B.value = o;
|
|
157
157
|
}
|
|
158
158
|
};
|
|
159
|
-
let
|
|
160
|
-
if (
|
|
159
|
+
let n;
|
|
160
|
+
if (Ye(e))
|
|
161
161
|
try {
|
|
162
|
-
|
|
162
|
+
n = await ze(
|
|
163
163
|
e,
|
|
164
164
|
await a.arrayBuffer(),
|
|
165
165
|
{ page: 1, fullQuality: !1 }
|
|
166
166
|
);
|
|
167
167
|
} catch {
|
|
168
|
-
|
|
168
|
+
n = await t.decode(a, c);
|
|
169
169
|
}
|
|
170
170
|
else
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
S =
|
|
171
|
+
n = await t.decode(a, c);
|
|
172
|
+
const d = typeof n == "string" ? n : URL.createObjectURL(n);
|
|
173
|
+
S = d, g.set(1, d), L.value = d, p.value = !1;
|
|
174
174
|
} catch (e) {
|
|
175
|
-
R.value =
|
|
175
|
+
R.value = oe(i.value, e) || i.value("image.decode_failed"), p.value = !1;
|
|
176
176
|
}
|
|
177
177
|
},
|
|
178
178
|
{ immediate: !0 }
|
|
179
179
|
);
|
|
180
180
|
const K = async (e) => {
|
|
181
|
-
if (!
|
|
181
|
+
if (!D || !O || e < 1 || e > Y.value) return;
|
|
182
182
|
const t = g.get(e);
|
|
183
183
|
if (t) {
|
|
184
184
|
k.value = e, L.value = t;
|
|
@@ -186,104 +186,104 @@ const je = {
|
|
|
186
186
|
}
|
|
187
187
|
p.value = !0;
|
|
188
188
|
try {
|
|
189
|
-
const a = await
|
|
189
|
+
const a = await O.decode(D, { page: e }), r = typeof a == "string" ? a : URL.createObjectURL(a);
|
|
190
190
|
if (g.size >= 10) {
|
|
191
191
|
const c = g.keys().next().value;
|
|
192
192
|
if (c !== void 0) {
|
|
193
|
-
const
|
|
194
|
-
|
|
193
|
+
const n = g.get(c);
|
|
194
|
+
n && URL.revokeObjectURL(n), g.delete(c);
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
g.set(e, r), k.value = e, L.value = r, p.value = !1;
|
|
198
198
|
} catch (a) {
|
|
199
|
-
R.value =
|
|
199
|
+
R.value = oe(i.value, a) || i.value("image.page_decode_failed"), p.value = !1;
|
|
200
200
|
}
|
|
201
201
|
};
|
|
202
202
|
te(() => {
|
|
203
203
|
S && URL.revokeObjectURL(S), g.forEach((t) => URL.revokeObjectURL(t)), g.clear();
|
|
204
204
|
const e = h.value;
|
|
205
|
-
e && e.removeEventListener("wheel",
|
|
206
|
-
}),
|
|
205
|
+
e && e.removeEventListener("wheel", N);
|
|
206
|
+
}), Z(u, (e) => {
|
|
207
207
|
m.value = e;
|
|
208
|
-
}),
|
|
208
|
+
}), Z(m, (e) => {
|
|
209
209
|
u.value = e;
|
|
210
210
|
});
|
|
211
|
-
const
|
|
211
|
+
const j = (e, t) => {
|
|
212
212
|
const a = h.value;
|
|
213
213
|
if (!a || v.value.width === 0) return e;
|
|
214
|
-
const r = a.clientWidth, c = a.clientHeight,
|
|
214
|
+
const r = a.clientWidth, c = a.clientHeight, n = v.value.width * t, d = v.value.height * t, o = Math.min(80, r * 0.15, c * 0.15), x = (r + n) / 2 - o, X = (c + d) / 2 - o;
|
|
215
215
|
return {
|
|
216
216
|
x: x > 0 ? Math.max(-x, Math.min(x, e.x)) : 0,
|
|
217
217
|
y: X > 0 ? Math.max(-X, Math.min(X, e.y)) : 0
|
|
218
218
|
};
|
|
219
219
|
}, me = (e) => {
|
|
220
|
-
|
|
220
|
+
T.value = !0;
|
|
221
221
|
const t = e.currentTarget;
|
|
222
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, r = h.value.clientHeight, c = a / v.value.width,
|
|
224
|
-
u.value = Math.max(0.01, Math.min(10,
|
|
223
|
+
const a = h.value.clientWidth, r = h.value.clientHeight, c = a / v.value.width, n = r / v.value.height, d = Math.min(c, n);
|
|
224
|
+
u.value = Math.max(0.01, Math.min(10, d)), l.value = { x: 0, y: 0 };
|
|
225
225
|
}
|
|
226
226
|
}, ge = () => {
|
|
227
|
-
M.value = i.value("image.load_failed"),
|
|
228
|
-
},
|
|
227
|
+
M.value = i.value("image.load_failed"), T.value = !0;
|
|
228
|
+
}, be = () => {
|
|
229
229
|
l.value = { x: 0, y: 0 }, u.value = 1;
|
|
230
|
-
},
|
|
230
|
+
}, N = (e) => {
|
|
231
231
|
e.preventDefault(), e.stopPropagation();
|
|
232
232
|
const t = h.value;
|
|
233
233
|
if (!t) return;
|
|
234
|
-
const a = t.getBoundingClientRect(), r = e.clientX - a.left - a.width / 2, c = e.clientY - a.top - a.height / 2,
|
|
235
|
-
l.value =
|
|
234
|
+
const a = t.getBoundingClientRect(), r = e.clientX - a.left - a.width / 2, c = e.clientY - a.top - a.height / 2, n = e.deltaY > 0 ? -0.05 : 0.05, d = m.value, o = Math.max(0.01, Math.min(10, d + n)), x = o / d;
|
|
235
|
+
l.value = j(
|
|
236
236
|
{
|
|
237
237
|
x: r - x * (r - l.value.x),
|
|
238
238
|
y: c - x * (c - l.value.y)
|
|
239
239
|
},
|
|
240
|
-
|
|
241
|
-
), m.value =
|
|
240
|
+
o
|
|
241
|
+
), m.value = o;
|
|
242
242
|
};
|
|
243
243
|
Re(() => {
|
|
244
244
|
const e = h.value;
|
|
245
|
-
e && (e.addEventListener("wheel",
|
|
245
|
+
e && (e.addEventListener("wheel", N, { passive: !1 }), e.addEventListener("touchstart", J, { passive: !1 }), e.addEventListener("touchmove", ee, { passive: !1 }), e.addEventListener("touchend", H), e.addEventListener("touchcancel", H));
|
|
246
246
|
}), te(() => {
|
|
247
247
|
const e = h.value;
|
|
248
|
-
e && (e.removeEventListener("wheel",
|
|
248
|
+
e && (e.removeEventListener("wheel", N), e.removeEventListener("touchstart", J), e.removeEventListener("touchmove", ee), e.removeEventListener("touchend", H), e.removeEventListener("touchcancel", H));
|
|
249
249
|
});
|
|
250
|
-
const
|
|
251
|
-
|
|
250
|
+
const ye = (e) => {
|
|
251
|
+
P || e.button === 0 && (y.value = !0, z = {
|
|
252
252
|
x: e.clientX - l.value.x,
|
|
253
253
|
y: e.clientY - l.value.y
|
|
254
254
|
});
|
|
255
255
|
}, xe = (e) => {
|
|
256
|
-
|
|
256
|
+
P || y.value && (l.value = j(
|
|
257
257
|
{
|
|
258
|
-
x: e.clientX -
|
|
259
|
-
y: e.clientY -
|
|
258
|
+
x: e.clientX - z.x,
|
|
259
|
+
y: e.clientY - z.y
|
|
260
260
|
},
|
|
261
261
|
m.value
|
|
262
262
|
));
|
|
263
263
|
}, q = () => {
|
|
264
|
-
|
|
264
|
+
P || (y.value = !1);
|
|
265
265
|
}, J = (e) => {
|
|
266
|
-
|
|
266
|
+
P = !0, e.preventDefault();
|
|
267
267
|
const t = e.touches;
|
|
268
268
|
if (t.length === 1) {
|
|
269
|
-
|
|
269
|
+
y.value = !0, z = {
|
|
270
270
|
x: t[0].clientX - l.value.x,
|
|
271
271
|
y: t[0].clientY - l.value.y
|
|
272
272
|
};
|
|
273
273
|
const a = Date.now();
|
|
274
274
|
a - F < 300 && (l.value = { x: 0, y: 0 }, u.value = 1), F = a;
|
|
275
|
-
} else t.length === 2 && (
|
|
275
|
+
} else t.length === 2 && (y.value = !1, $ = Math.hypot(
|
|
276
276
|
t[1].clientX - t[0].clientX,
|
|
277
277
|
t[1].clientY - t[0].clientY
|
|
278
|
-
), A = m.value,
|
|
278
|
+
), A = m.value, V = { ...l.value });
|
|
279
279
|
}, ee = (e) => {
|
|
280
280
|
e.preventDefault();
|
|
281
281
|
const t = e.touches;
|
|
282
|
-
if (t.length === 1 &&
|
|
283
|
-
l.value =
|
|
282
|
+
if (t.length === 1 && y.value)
|
|
283
|
+
l.value = j(
|
|
284
284
|
{
|
|
285
|
-
x: t[0].clientX -
|
|
286
|
-
y: t[0].clientY -
|
|
285
|
+
x: t[0].clientX - z.x,
|
|
286
|
+
y: t[0].clientY - z.y
|
|
287
287
|
},
|
|
288
288
|
m.value
|
|
289
289
|
);
|
|
@@ -294,86 +294,86 @@ const je = {
|
|
|
294
294
|
t[1].clientX - t[0].clientX,
|
|
295
295
|
t[1].clientY - t[0].clientY
|
|
296
296
|
);
|
|
297
|
-
if (Math.abs(r -
|
|
298
|
-
const c = r /
|
|
299
|
-
l.value =
|
|
297
|
+
if (Math.abs(r - $) < 5) return;
|
|
298
|
+
const c = r / $, n = Math.max(0.01, Math.min(10, A * c)), d = a.getBoundingClientRect(), o = (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, X = n / m.value;
|
|
299
|
+
l.value = j(
|
|
300
300
|
{
|
|
301
|
-
x:
|
|
302
|
-
y: x - X * (x -
|
|
301
|
+
x: o - X * (o - V.x),
|
|
302
|
+
y: x - X * (x - V.y)
|
|
303
303
|
},
|
|
304
|
-
|
|
305
|
-
), m.value =
|
|
304
|
+
n
|
|
305
|
+
), m.value = n;
|
|
306
306
|
}
|
|
307
|
-
},
|
|
308
|
-
|
|
307
|
+
}, H = () => {
|
|
308
|
+
y.value = !1, $ = 0;
|
|
309
309
|
}, we = ae(() => ({
|
|
310
310
|
transform: `translate(${l.value.x}px, ${l.value.y}px) scale(${m.value}) rotate(${C.value}deg)`,
|
|
311
311
|
transformOrigin: "center",
|
|
312
|
-
transition:
|
|
313
|
-
opacity:
|
|
314
|
-
})), _e = ae(() =>
|
|
315
|
-
return (e, t) => (w(),
|
|
312
|
+
transition: y.value ? "none" : "transform 0.3s ease-out",
|
|
313
|
+
opacity: T.value && !M.value && !R.value ? 1 : 0
|
|
314
|
+
})), _e = ae(() => f.fileSize == null ? "" : ` · ${Se(f.fileSize)}`);
|
|
315
|
+
return (e, t) => (w(), U("div", {
|
|
316
316
|
ref_key: "containerRef",
|
|
317
317
|
ref: h,
|
|
318
318
|
class: "vfp-relative vfp-flex vfp-items-center vfp-justify-center vfp-w-full vfp-h-full vfp-overflow-hidden",
|
|
319
|
-
style: le({ cursor:
|
|
320
|
-
onMousedown:
|
|
319
|
+
style: le({ cursor: y.value ? "grabbing" : "grab", touchAction: "none" }),
|
|
320
|
+
onMousedown: ye,
|
|
321
321
|
onMousemove: xe,
|
|
322
322
|
onMouseup: q,
|
|
323
323
|
onMouseleave: q
|
|
324
324
|
}, [
|
|
325
|
-
p.value ? (w(),
|
|
326
|
-
_("div",
|
|
325
|
+
p.value ? (w(), U("div", He, [
|
|
326
|
+
_("div", Ze, [
|
|
327
327
|
t[2] || (t[2] = _("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
328
|
-
_("p",
|
|
329
|
-
Le(
|
|
330
|
-
|
|
328
|
+
_("p", Ve, [
|
|
329
|
+
Le(b(W(i)("image.decoding")) + " ", 1),
|
|
330
|
+
B.value > 0 ? (w(), U("span", Ne, b(Math.round(B.value)) + "%", 1)) : E("", !0)
|
|
331
331
|
])
|
|
332
332
|
])
|
|
333
333
|
])) : E("", !0),
|
|
334
|
-
R.value ? (w(),
|
|
334
|
+
R.value ? (w(), ne(ie, {
|
|
335
335
|
key: 1,
|
|
336
|
-
message:
|
|
336
|
+
message: W(i)("image.decode_failed"),
|
|
337
337
|
detail: R.value
|
|
338
338
|
}, null, 8, ["message", "detail"])) : E("", !0),
|
|
339
|
-
!
|
|
339
|
+
!T.value && !M.value && !p.value && !R.value ? (w(), U("div", Ge, [
|
|
340
340
|
_("div", Ie, [
|
|
341
341
|
t[3] || (t[3] = _("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
342
|
-
_("span", Qe,
|
|
342
|
+
_("span", Qe, b(W(i)("common.loading")), 1)
|
|
343
343
|
])
|
|
344
344
|
])) : E("", !0),
|
|
345
|
-
M.value ? (w(),
|
|
345
|
+
M.value ? (w(), ne(ie, {
|
|
346
346
|
key: 3,
|
|
347
347
|
message: M.value
|
|
348
348
|
}, null, 8, ["message"])) : E("", !0),
|
|
349
|
-
L.value ? (w(),
|
|
349
|
+
L.value ? (w(), U("img", {
|
|
350
350
|
key: 4,
|
|
351
351
|
ref_key: "imgRef",
|
|
352
352
|
ref: pe,
|
|
353
353
|
src: L.value,
|
|
354
354
|
alt: "Preview",
|
|
355
|
-
class: ke(["vfp-max-w-none vfp-select-none", (!
|
|
355
|
+
class: ke(["vfp-max-w-none vfp-select-none", (!T.value || M.value || R.value) && "vfp-hidden"]),
|
|
356
356
|
style: le(we.value),
|
|
357
357
|
draggable: !1,
|
|
358
358
|
onLoad: me,
|
|
359
359
|
onError: ge,
|
|
360
|
-
onDblclick:
|
|
360
|
+
onDblclick: be
|
|
361
361
|
}, null, 46, Ae)) : E("", !0),
|
|
362
|
-
|
|
363
|
-
|
|
362
|
+
T.value && !M.value && v.value.width > 0 ? (w(), U("div", Fe, b(v.value.width) + " × " + b(v.value.height) + b(_e.value), 1)) : E("", !0),
|
|
363
|
+
Y.value > 1 ? (w(), U("div", Ke, [
|
|
364
364
|
_("button", {
|
|
365
365
|
type: "button",
|
|
366
366
|
disabled: k.value <= 1 || p.value,
|
|
367
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
368
|
onClick: t[0] || (t[0] = (a) => K(k.value - 1))
|
|
369
|
-
},
|
|
370
|
-
_("span", Je,
|
|
369
|
+
}, b(W(i)("toolbar.prev_page")), 9, qe),
|
|
370
|
+
_("span", Je, b(k.value) + " / " + b(Y.value), 1),
|
|
371
371
|
_("button", {
|
|
372
372
|
type: "button",
|
|
373
|
-
disabled: k.value >=
|
|
373
|
+
disabled: k.value >= Y.value || p.value,
|
|
374
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
375
|
onClick: t[1] || (t[1] = (a) => K(k.value + 1))
|
|
376
|
-
},
|
|
376
|
+
}, b(W(i)("toolbar.next_page")), 9, et)
|
|
377
377
|
])) : E("", !0)
|
|
378
378
|
], 36));
|
|
379
379
|
}
|