@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
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { defineComponent as ne, ref as z, onMounted as re, onUnmounted as ae, watch as se, openBlock as k, createElementBlock as H, createVNode as le, createCommentVNode as q, createElementVNode as U, toDisplayString as fe, unref as ue } from "vue";
|
|
2
|
+
import { u as de, c as ce, k as pe } from "./index-DZZN3kYi.mjs";
|
|
3
|
+
import * as o from "three";
|
|
4
|
+
import { OrbitControls as me } from "three/examples/jsm/controls/OrbitControls";
|
|
5
|
+
import { DXFLoader as ve } from "three-dxf-loader";
|
|
6
|
+
import { STLLoader as ge } from "three/examples/jsm/loaders/STLLoader";
|
|
7
|
+
import { OBJLoader as he } from "three/examples/jsm/loaders/OBJLoader";
|
|
8
|
+
import { GLTFLoader as we } from "three/examples/jsm/loaders/GLTFLoader";
|
|
9
|
+
import { _ as be } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
|
|
10
|
+
import { T as Me } from "./base.types-DaftHyg7.mjs";
|
|
11
|
+
import { RotateCcw as ye, Box as xe, Grid3x3 as Ce, Axis3d as Le } from "lucide-vue-next";
|
|
12
|
+
function _e(m) {
|
|
13
|
+
return [
|
|
14
|
+
{
|
|
15
|
+
items: [
|
|
16
|
+
{
|
|
17
|
+
type: "button",
|
|
18
|
+
icon: ye,
|
|
19
|
+
tooltip: m.t("toolbar.reset"),
|
|
20
|
+
action: () => {
|
|
21
|
+
var b;
|
|
22
|
+
return (b = m.cadRef) == null ? void 0 : b.resetView();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
items: [
|
|
29
|
+
...m.isDxf ? [] : [
|
|
30
|
+
{
|
|
31
|
+
type: "button",
|
|
32
|
+
icon: xe,
|
|
33
|
+
tooltip: m.wireframe ? m.t("cad.solid") : m.t("cad.wireframe"),
|
|
34
|
+
active: m.wireframe,
|
|
35
|
+
action: () => {
|
|
36
|
+
var b;
|
|
37
|
+
return (b = m.cadRef) == null ? void 0 : b.toggleWireframe();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
{
|
|
42
|
+
type: "button",
|
|
43
|
+
icon: Ce,
|
|
44
|
+
tooltip: m.t("cad.grid"),
|
|
45
|
+
active: m.showGrid,
|
|
46
|
+
action: () => {
|
|
47
|
+
var b;
|
|
48
|
+
return (b = m.cadRef) == null ? void 0 : b.toggleGrid();
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
type: "button",
|
|
53
|
+
icon: Le,
|
|
54
|
+
tooltip: m.t("cad.axes"),
|
|
55
|
+
active: m.showAxes,
|
|
56
|
+
action: () => {
|
|
57
|
+
var b;
|
|
58
|
+
return (b = m.cadRef) == null ? void 0 : b.toggleAxes();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
const Ae = {
|
|
66
|
+
key: 0,
|
|
67
|
+
class: "vfp-absolute vfp-inset-0 vfp-bg-surface-3 vfp-z-10"
|
|
68
|
+
}, Ee = {
|
|
69
|
+
key: 1,
|
|
70
|
+
class: "vfp-absolute vfp-inset-0 vfp-renderer-loading vfp-bg-surface-3 vfp-z-10"
|
|
71
|
+
}, Pe = { class: "vfp-renderer-loading-content" }, Re = { class: "vfp-renderer-loading-text" }, He = /* @__PURE__ */ ne({
|
|
72
|
+
__name: "index",
|
|
73
|
+
props: {
|
|
74
|
+
url: {},
|
|
75
|
+
file: {},
|
|
76
|
+
fileName: {},
|
|
77
|
+
baseUrl: {}
|
|
78
|
+
},
|
|
79
|
+
setup(m, { expose: b }) {
|
|
80
|
+
const J = (e) => {
|
|
81
|
+
if (!e || e.startsWith("blob:") || e.startsWith("data:")) return "";
|
|
82
|
+
try {
|
|
83
|
+
return new URL(".", new URL(e, document.baseURI)).href;
|
|
84
|
+
} catch {
|
|
85
|
+
return "";
|
|
86
|
+
}
|
|
87
|
+
}, V = (e, t, i, a) => {
|
|
88
|
+
const c = Math.max(a.x, a.y, a.z), g = Number.isFinite(c) && c > 0 ? c : 1;
|
|
89
|
+
if (e instanceof o.OrthographicCamera) {
|
|
90
|
+
const l = (e.right - e.left) / (e.top - e.bottom), h = (Math.max(a.y, a.x / l) || g) * 0.55;
|
|
91
|
+
e.left = -h * l, e.right = h * l, e.top = h, e.bottom = -h, e.near = 0, e.far = g * 4, e.zoom = 1, e.up.set(0, 1, 0), e.position.set(i.x, i.y, i.z + g * 2), e.lookAt(i), t.target.copy(i), t.update(), e.updateProjectionMatrix();
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const r = e.fov * (Math.PI / 180), s = Math.abs(g / 2 / Math.tan(r / 2)) * 1.5;
|
|
95
|
+
e.near = Math.max(g * 1e-3, 1e-4), e.far = Math.max(s * 4, i.length() * 2 + g * 4, e.near * 100), e.position.set(i.x + s, i.y + s, i.z + s), e.lookAt(i), t.target.copy(i), t.update(), e.updateProjectionMatrix();
|
|
96
|
+
}, v = m, { t: P } = de(), X = ce(), x = z(null), A = z(!0), E = z(null), T = z(!1), F = z(!0), G = z(!0);
|
|
97
|
+
let n = null, f = null, d = null, u = null, C = null, p = null, w = null, R = null, D = null, S = null, M = !1, L = !0;
|
|
98
|
+
const O = new Me(), N = (e, t, i) => {
|
|
99
|
+
var a, c, g;
|
|
100
|
+
return i != null && i.name ? ((a = i.name.split(".").pop()) == null ? void 0 : a.toLowerCase()) || "" : t ? ((c = t.split(".").pop()) == null ? void 0 : c.toLowerCase()) || "" : ((g = e.split(".").pop()) == null ? void 0 : g.toLowerCase().split("?")[0]) || "";
|
|
101
|
+
}, Y = () => {
|
|
102
|
+
if (!u || !f || !C) return;
|
|
103
|
+
const e = new o.Box3().setFromObject(C), t = e.getCenter(new o.Vector3()), i = e.getSize(new o.Vector3());
|
|
104
|
+
V(f, u, t, i), L = !0;
|
|
105
|
+
}, Z = () => {
|
|
106
|
+
T.value = !T.value, C && C.traverse((e) => {
|
|
107
|
+
if (e instanceof o.Mesh) {
|
|
108
|
+
const t = e.material;
|
|
109
|
+
t && (Array.isArray(t) ? t.forEach((i) => {
|
|
110
|
+
i.wireframe = T.value;
|
|
111
|
+
}) : t.wireframe = T.value);
|
|
112
|
+
}
|
|
113
|
+
}), L = !0, O.notify();
|
|
114
|
+
}, $ = () => {
|
|
115
|
+
F.value = !F.value, p && (p.visible = F.value), L = !0, O.notify();
|
|
116
|
+
}, K = () => {
|
|
117
|
+
G.value = !G.value, w && (w.visible = G.value), L = !0, O.notify();
|
|
118
|
+
}, Q = (e) => {
|
|
119
|
+
if (!n) return;
|
|
120
|
+
const t = e.getSize(new o.Vector3()), i = Math.max(t.x, t.y, t.z), a = Number.isFinite(i) && i > 0 ? i : 1, c = Math.max(
|
|
121
|
+
Math.abs(e.min.x),
|
|
122
|
+
Math.abs(e.max.x),
|
|
123
|
+
Math.abs(e.min.y),
|
|
124
|
+
Math.abs(e.max.y),
|
|
125
|
+
Math.abs(e.min.z),
|
|
126
|
+
Math.abs(e.max.z)
|
|
127
|
+
), g = Number.isFinite(c) ? c : a, r = Math.max(a, g * 1.25), s = f instanceof o.OrthographicCamera, l = s ? a * 2 : Math.max(a * 2, g * 2.5);
|
|
128
|
+
p && (p.geometry.dispose(), p.material.dispose(), n.remove(p)), w && (w.geometry.dispose(), w.material.dispose(), n.remove(w)), p = new o.GridHelper(l, 20, 4473924, 2236962), s && (p.rotation.x = Math.PI / 2, e.getCenter(p.position), p.position.z = e.min.z - a * 1e-3), p.visible = F.value, n.add(p), w = new o.AxesHelper(r), w.visible = G.value, n.add(w);
|
|
129
|
+
};
|
|
130
|
+
b({
|
|
131
|
+
getToolbarGroups: () => _e({
|
|
132
|
+
cadRef: { resetView: Y, toggleWireframe: Z, toggleGrid: $, toggleAxes: K },
|
|
133
|
+
isDxf: N(v.url, v.fileName, v.file) === "dxf",
|
|
134
|
+
wireframe: T.value,
|
|
135
|
+
showGrid: F.value,
|
|
136
|
+
showAxes: G.value,
|
|
137
|
+
t: P.value
|
|
138
|
+
}),
|
|
139
|
+
onToolbarChange: (e) => O.subscribe(e)
|
|
140
|
+
});
|
|
141
|
+
const ee = (e) => {
|
|
142
|
+
e.traverse((t) => {
|
|
143
|
+
t.geometry && t.geometry.dispose(), t.material && (Array.isArray(t.material) ? t.material.forEach((i) => {
|
|
144
|
+
W(i);
|
|
145
|
+
}) : W(t.material));
|
|
146
|
+
});
|
|
147
|
+
}, W = (e) => {
|
|
148
|
+
e.map && e.map.dispose(), e.lightMap && e.lightMap.dispose(), e.bumpMap && e.bumpMap.dispose(), e.normalMap && e.normalMap.dispose(), e.specularMap && e.specularMap.dispose(), e.envMap && e.envMap.dispose(), e.dispose();
|
|
149
|
+
}, j = () => {
|
|
150
|
+
if (!x.value) return;
|
|
151
|
+
M = !1, S = new AbortController();
|
|
152
|
+
const e = x.value, t = e.clientWidth, i = e.clientHeight;
|
|
153
|
+
n = new o.Scene(), n.background = new o.Color(1710618);
|
|
154
|
+
const a = N(v.url, v.fileName, v.file) === "dxf", c = Math.max(t, 1) / Math.max(i, 1);
|
|
155
|
+
f = a ? new o.OrthographicCamera(-c, c, 1, -1, 0, 1e6) : new o.PerspectiveCamera(45, c, 0.01, 1e6), f.position.set(100, 100, 100), d = new o.WebGLRenderer({ antialias: !0 }), d.setSize(t, i), d.setPixelRatio(Math.min(window.devicePixelRatio, 2)), L = !0, e.appendChild(d.domElement), u = new me(f, d.domElement), u.enableDamping = !0, u.dampingFactor = 0.05, a && (u.enableRotate = !1, u.screenSpacePanning = !0, u.mouseButtons.LEFT = o.MOUSE.PAN, u.touches.ONE = o.TOUCH.PAN, u.touches.TWO = o.TOUCH.DOLLY_PAN);
|
|
156
|
+
const g = new o.AmbientLight(16777215, 0.6);
|
|
157
|
+
n.add(g);
|
|
158
|
+
const r = new o.DirectionalLight(16777215, 0.8);
|
|
159
|
+
r.position.set(1, 1, 1), n.add(r);
|
|
160
|
+
const s = new o.DirectionalLight(16777215, 0.4);
|
|
161
|
+
s.position.set(-1, -1, -1), n.add(s), te();
|
|
162
|
+
const l = () => {
|
|
163
|
+
if (M) return;
|
|
164
|
+
D = requestAnimationFrame(l), ((u == null ? void 0 : u.update()) || L) && n && f && d && (d.render(n, f), L = !1);
|
|
165
|
+
};
|
|
166
|
+
l(), R = new ResizeObserver(oe), R.observe(e);
|
|
167
|
+
}, te = () => {
|
|
168
|
+
if (!n || !f || !u || M) return;
|
|
169
|
+
const e = N(v.url, v.fileName, v.file);
|
|
170
|
+
let t;
|
|
171
|
+
const i = new o.LoadingManager();
|
|
172
|
+
if (e === "dxf")
|
|
173
|
+
t = new ve();
|
|
174
|
+
else if (e === "stl")
|
|
175
|
+
t = new ge(i);
|
|
176
|
+
else if (e === "obj")
|
|
177
|
+
t = new he(i);
|
|
178
|
+
else if (e === "gltf" || e === "glb")
|
|
179
|
+
t = new we(i);
|
|
180
|
+
else {
|
|
181
|
+
E.value = P.value("cad.parse_failed"), A.value = !1;
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const a = (r, s) => {
|
|
185
|
+
if (M) return;
|
|
186
|
+
if (!r) {
|
|
187
|
+
E.value = P.value("cad.parse_failed"), A.value = !1;
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
let l;
|
|
191
|
+
if (s === "stl") {
|
|
192
|
+
const _ = r, ie = new o.MeshPhongMaterial({
|
|
193
|
+
color: 8947848,
|
|
194
|
+
flatShading: !0,
|
|
195
|
+
side: o.DoubleSide
|
|
196
|
+
});
|
|
197
|
+
l = new o.Mesh(_, ie);
|
|
198
|
+
} else if (s === "gltf" || s === "glb") {
|
|
199
|
+
if (l = r.scene, !l) {
|
|
200
|
+
E.value = P.value("cad.parse_failed"), A.value = !1;
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
} else
|
|
204
|
+
l = r, l.traverse((_) => {
|
|
205
|
+
_ instanceof o.Mesh && !_.material && (_.material = new o.MeshPhongMaterial({
|
|
206
|
+
color: 8947848,
|
|
207
|
+
side: o.DoubleSide
|
|
208
|
+
}));
|
|
209
|
+
});
|
|
210
|
+
const h = new o.Box3().setFromObject(l);
|
|
211
|
+
if (h.isEmpty()) {
|
|
212
|
+
E.value = P.value("cad.parse_failed"), A.value = !1;
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
n.add(l), C = l;
|
|
216
|
+
const y = h.getCenter(new o.Vector3()), B = h.getSize(new o.Vector3());
|
|
217
|
+
Q(h), V(f, u, y, B), L = !0, A.value = !1, O.notify();
|
|
218
|
+
}, c = (r) => {
|
|
219
|
+
M || r.name !== "AbortError" && (E.value = P.value("cad.load_failed"), A.value = !1);
|
|
220
|
+
};
|
|
221
|
+
(v.file ? v.file.arrayBuffer() : X.value(v.url, { signal: S == null ? void 0 : S.signal }).then((r) => {
|
|
222
|
+
if (!M) {
|
|
223
|
+
if (!r.ok) throw new pe("file.load_failed");
|
|
224
|
+
return r.arrayBuffer();
|
|
225
|
+
}
|
|
226
|
+
})).then((r) => {
|
|
227
|
+
if (!(M || !r)) {
|
|
228
|
+
if (e === "stl") {
|
|
229
|
+
const s = t.parse(r);
|
|
230
|
+
a(s, e);
|
|
231
|
+
} else if (e === "obj") {
|
|
232
|
+
const l = new TextDecoder("utf-8").decode(r), h = t.parse(l);
|
|
233
|
+
a(h, e);
|
|
234
|
+
} else if (e === "gltf" || e === "glb")
|
|
235
|
+
t.parse(
|
|
236
|
+
r,
|
|
237
|
+
J(v.baseUrl || v.url),
|
|
238
|
+
(s) => {
|
|
239
|
+
M || a(s, e);
|
|
240
|
+
},
|
|
241
|
+
(s) => c(s)
|
|
242
|
+
);
|
|
243
|
+
else if (e === "dxf") {
|
|
244
|
+
const l = new TextDecoder("utf-8").decode(r), h = o.BufferGeometry.prototype.setFromPoints;
|
|
245
|
+
o.BufferGeometry.prototype.setFromPoints = function(y) {
|
|
246
|
+
const B = (y || []).filter(
|
|
247
|
+
(_) => _ && _.x !== void 0 && _.y !== void 0
|
|
248
|
+
);
|
|
249
|
+
return h.call(this, B);
|
|
250
|
+
};
|
|
251
|
+
try {
|
|
252
|
+
t.loadString(
|
|
253
|
+
l,
|
|
254
|
+
(y) => {
|
|
255
|
+
if (!M) {
|
|
256
|
+
const B = (y == null ? void 0 : y.entity) || y;
|
|
257
|
+
a(B, e);
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
(y) => {
|
|
261
|
+
c(y);
|
|
262
|
+
}
|
|
263
|
+
);
|
|
264
|
+
} catch (y) {
|
|
265
|
+
c(y);
|
|
266
|
+
} finally {
|
|
267
|
+
o.BufferGeometry.prototype.setFromPoints = h;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}).catch((r) => {
|
|
272
|
+
M || c(r);
|
|
273
|
+
});
|
|
274
|
+
}, oe = () => {
|
|
275
|
+
if (!x.value || !f || !d || M) return;
|
|
276
|
+
const e = x.value.clientWidth, t = x.value.clientHeight;
|
|
277
|
+
e <= 0 || t <= 0 || (f instanceof o.OrthographicCamera ? (f.right = f.top * e / t, f.left = -f.right) : f.aspect = e / t, f.updateProjectionMatrix(), d.setSize(e, t), L = !0);
|
|
278
|
+
}, I = () => {
|
|
279
|
+
M = !0, S && S.abort(), D !== null && (cancelAnimationFrame(D), D = null), R == null || R.disconnect(), R = null, C && (ee(C), n == null || n.remove(C), C = null), p && (p.geometry.dispose(), p.material.dispose(), n == null || n.remove(p), p = null), w && (w.geometry.dispose(), w.material.dispose(), n == null || n.remove(w), w = null), u == null || u.dispose(), d == null || d.dispose(), x.value && (d != null && d.domElement) && x.value.contains(d.domElement) && x.value.removeChild(d.domElement), n = null, f = null, d = null, u = null;
|
|
280
|
+
};
|
|
281
|
+
return re(() => {
|
|
282
|
+
j();
|
|
283
|
+
}), ae(() => {
|
|
284
|
+
I();
|
|
285
|
+
}), se(() => v.url, () => {
|
|
286
|
+
I(), A.value = !0, E.value = null, x.value && j();
|
|
287
|
+
}), (e, t) => (k(), H("div", {
|
|
288
|
+
ref_key: "containerRef",
|
|
289
|
+
ref: x,
|
|
290
|
+
class: "vfp-relative vfp-w-full vfp-h-full vfp-bg-media-bg"
|
|
291
|
+
}, [
|
|
292
|
+
E.value ? (k(), H("div", Ae, [
|
|
293
|
+
le(be, { message: E.value }, null, 8, ["message"])
|
|
294
|
+
])) : q("", !0),
|
|
295
|
+
A.value ? (k(), H("div", Ee, [
|
|
296
|
+
U("div", Pe, [
|
|
297
|
+
t[0] || (t[0] = U("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
298
|
+
U("p", Re, fe(ue(P)("cad.loading")), 1)
|
|
299
|
+
])
|
|
300
|
+
])) : q("", !0)
|
|
301
|
+
], 512));
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
export {
|
|
305
|
+
He as default
|
|
306
|
+
};
|
|
@@ -14,8 +14,8 @@ var jt = (u, e, t, s) => ({
|
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
import { defineComponent as _b, ref as si, watch as aa, nextTick as wu, onMounted as Gb, onBeforeUnmount as zb, openBlock as zh, createElementBlock as Eu, normalizeStyle as Ep, createElementVNode as ii, toDisplayString as Pm, unref as Sp, createVNode as Vb, createCommentVNode as Su, createBlock as Wb } from "vue";
|
|
17
|
-
import {
|
|
18
|
-
import { _ as Jb } from "./RendererError.vue_vue_type_script_setup_true_lang-
|
|
17
|
+
import { b as Xb, u as Yb, E as Mm, Q as Kb } from "./index-DZZN3kYi.mjs";
|
|
18
|
+
import { _ as Jb } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
|
|
19
19
|
import { X as Qb, Menu as Zb, ChevronLeft as qb, ChevronRight as tA, ZoomOut as eA, ZoomIn as sA, RefreshCw as iA } from "lucide-vue-next";
|
|
20
20
|
import { T as nA } from "./base.types-DaftHyg7.mjs";
|
|
21
21
|
var rA = {
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { defineComponent as k, ref as p, onMounted as D, watch as
|
|
1
|
+
import { defineComponent as k, ref as p, onMounted as D, watch as z, onBeforeUnmount as M, openBlock as v, createElementBlock as m, createElementVNode as w, toDisplayString as N, unref as S, createCommentVNode as g, createBlock as B, normalizeStyle as C } from "vue";
|
|
2
2
|
import { S as H } from "./index-CyBXARuf.mjs";
|
|
3
|
-
import { u as R,
|
|
4
|
-
import { _ as
|
|
5
|
-
const
|
|
3
|
+
import { u as R, c as W, X as G, m as E, T as F, p as L } from "./index-DZZN3kYi.mjs";
|
|
4
|
+
import { _ as O } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
|
|
5
|
+
const V = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full" }, X = {
|
|
6
6
|
key: 0,
|
|
7
7
|
class: "vfp-absolute vfp-inset-0 vfp-renderer-loading vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10"
|
|
8
|
-
},
|
|
8
|
+
}, j = { class: "vfp-renderer-loading-content" }, q = { class: "vfp-renderer-loading-text" }, K = /* @__PURE__ */ k({
|
|
9
9
|
__name: "index",
|
|
10
10
|
props: {
|
|
11
11
|
url: {},
|
|
12
12
|
fileName: {}
|
|
13
13
|
},
|
|
14
|
-
setup(
|
|
15
|
-
const i =
|
|
16
|
-
let r = null, u = null, o = null,
|
|
14
|
+
setup(T, { expose: x }) {
|
|
15
|
+
const i = T, { t: d } = R(), y = W(), a = p(!0), n = p(null), l = p(null);
|
|
16
|
+
let r = null, u = null, o = null, c = { width: 0, height: 0 };
|
|
17
17
|
const h = () => {
|
|
18
18
|
if (!l.value) return { width: 800, height: 600 };
|
|
19
|
-
const t = l.value.clientWidth, e = l.value.clientHeight, s = t > 100 ? t : 800,
|
|
20
|
-
return { width: s, height:
|
|
19
|
+
const t = l.value.clientWidth, e = l.value.clientHeight, s = t > 100 ? t : 800, f = e > 100 ? e : 600;
|
|
20
|
+
return { width: s, height: f };
|
|
21
21
|
}, b = () => {
|
|
22
22
|
if (!l.value || !r) return;
|
|
23
23
|
l.value.innerHTML = "";
|
|
@@ -44,12 +44,12 @@ const O = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-fu
|
|
|
44
44
|
}).loadData(r);
|
|
45
45
|
}, _ = async () => {
|
|
46
46
|
if (l.value) {
|
|
47
|
-
|
|
47
|
+
a.value = !0, n.value = null;
|
|
48
48
|
try {
|
|
49
|
-
const t = await G(i.url, { fetcher:
|
|
50
|
-
r =
|
|
49
|
+
const t = await G(i.url, { fetcher: y.value }), e = E(t, { delimiter: F(i.fileName) });
|
|
50
|
+
r = L(e.header, e.rows, i.fileName), b(), a.value = !1;
|
|
51
51
|
} catch (t) {
|
|
52
|
-
console.error(d.value("csv.parse_failed") + ":", t),
|
|
52
|
+
console.error(d.value("csv.parse_failed") + ":", t), n.value = d.value("csv.load_failed"), a.value = !1;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
};
|
|
@@ -58,47 +58,47 @@ const O = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-fu
|
|
|
58
58
|
let t = !0;
|
|
59
59
|
u = new ResizeObserver(() => {
|
|
60
60
|
if (t) {
|
|
61
|
-
t = !1,
|
|
61
|
+
t = !1, c = h();
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
|
-
const e = h(), s = Math.abs(
|
|
65
|
-
s < 10 &&
|
|
64
|
+
const e = h(), s = Math.abs(c.width - e.width), f = Math.abs(c.height - e.height);
|
|
65
|
+
s < 10 && f < 10 || (c = e, o !== null && clearTimeout(o), o = window.setTimeout(() => {
|
|
66
66
|
r && b();
|
|
67
67
|
}, 500));
|
|
68
68
|
}), u.observe(l.value), setTimeout(() => {
|
|
69
69
|
requestAnimationFrame(() => _());
|
|
70
70
|
}, 100);
|
|
71
|
-
}),
|
|
71
|
+
}), z(
|
|
72
72
|
() => i.url,
|
|
73
73
|
() => {
|
|
74
74
|
_();
|
|
75
75
|
}
|
|
76
|
-
),
|
|
76
|
+
), M(() => {
|
|
77
77
|
u && u.disconnect(), o !== null && clearTimeout(o), r = null, l.value && (l.value.innerHTML = "");
|
|
78
|
-
}),
|
|
78
|
+
}), x({
|
|
79
79
|
getToolbarGroups: () => []
|
|
80
|
-
}), (t, e) => (v(), m("div",
|
|
81
|
-
|
|
82
|
-
w("div",
|
|
80
|
+
}), (t, e) => (v(), m("div", V, [
|
|
81
|
+
a.value ? (v(), m("div", X, [
|
|
82
|
+
w("div", j, [
|
|
83
83
|
e[0] || (e[0] = w("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
84
|
-
w("p",
|
|
84
|
+
w("p", q, N(S(d)("csv.loading")), 1)
|
|
85
85
|
])
|
|
86
86
|
])) : g("", !0),
|
|
87
|
-
|
|
87
|
+
n.value && !a.value ? (v(), B(O, {
|
|
88
88
|
key: 1,
|
|
89
|
-
message:
|
|
89
|
+
message: n.value,
|
|
90
90
|
class: "vfp-absolute vfp-inset-0 vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10"
|
|
91
91
|
}, null, 8, ["message"])) : g("", !0),
|
|
92
|
-
|
|
92
|
+
n.value ? g("", !0) : (v(), m("div", {
|
|
93
93
|
key: 2,
|
|
94
94
|
ref_key: "containerRef",
|
|
95
95
|
ref: l,
|
|
96
96
|
class: "xlsx-spreadsheet-container vfp-w-full vfp-h-full",
|
|
97
|
-
style: C({ opacity:
|
|
97
|
+
style: C({ opacity: a.value ? 0 : 1 })
|
|
98
98
|
}, null, 4))
|
|
99
99
|
]));
|
|
100
100
|
}
|
|
101
101
|
});
|
|
102
102
|
export {
|
|
103
|
-
|
|
103
|
+
K as default
|
|
104
104
|
};
|