@glodon-aiot/react-components 3.25.1-alpha.7 → 3.26.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aiot-react-components.js +20191 -0
- package/dist/aiot-react-components.umd.cjs +183 -0
- package/dist/es/components/DocumentViewer/index.mjs +167 -165
- package/dist/es/index.mjs +1 -1
- package/dist/lib/index.js +9 -9
- package/dist/src/components/DocumentViewer/components/PdfRenderer.d.ts +11 -0
- package/dist/src/components/DocumentViewer/index.d.ts +3 -1
- package/dist/style.css +1 -0
- package/package.json +1 -1
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var x = (o, n, r) => new Promise((h, u) => {
|
|
2
|
+
var y = (l) => {
|
|
3
3
|
try {
|
|
4
|
-
|
|
5
|
-
} catch (
|
|
6
|
-
u(
|
|
4
|
+
s(r.next(l));
|
|
5
|
+
} catch (e) {
|
|
6
|
+
u(e);
|
|
7
7
|
}
|
|
8
|
-
},
|
|
8
|
+
}, v = (l) => {
|
|
9
9
|
try {
|
|
10
|
-
|
|
11
|
-
} catch (
|
|
12
|
-
u(
|
|
10
|
+
s(r.throw(l));
|
|
11
|
+
} catch (e) {
|
|
12
|
+
u(e);
|
|
13
13
|
}
|
|
14
|
-
},
|
|
15
|
-
|
|
14
|
+
}, s = (l) => l.done ? h(l.value) : Promise.resolve(l.value).then(y, v);
|
|
15
|
+
s((r = r.apply(o, n)).next());
|
|
16
16
|
});
|
|
17
|
-
import { jsxs as
|
|
18
|
-
import { useMemo as
|
|
19
|
-
import { message as
|
|
20
|
-
import { DownloadOutlined as
|
|
21
|
-
import { renderAsync as
|
|
22
|
-
import { getFileExtension as
|
|
23
|
-
import { MAX_FILE_SIZE as
|
|
24
|
-
import { normalizeUrl as
|
|
25
|
-
import { useZipViewer as
|
|
26
|
-
import { TextRenderer as
|
|
27
|
-
import { AudioRenderer as
|
|
28
|
-
import { ZipRenderer as
|
|
29
|
-
import { ErrorAlert as
|
|
17
|
+
import { jsxs as T, jsx as t } from "react/jsx-runtime";
|
|
18
|
+
import { useMemo as b, useState as w, useEffect as J, useCallback as L, useRef as me } from "react";
|
|
19
|
+
import { message as k, Space as fe, Button as $, Dropdown as pe, Spin as G, Alert as K } from "antd";
|
|
20
|
+
import { DownloadOutlined as O, CopyOutlined as we } from "@ant-design/icons";
|
|
21
|
+
import { renderAsync as he } from "docx-preview";
|
|
22
|
+
import { getFileExtension as _, getFileType as ye } from "../../utils/file.mjs";
|
|
23
|
+
import { MAX_FILE_SIZE as j } from "./constants.mjs";
|
|
24
|
+
import { normalizeUrl as ve } from "./utils.mjs";
|
|
25
|
+
import { useZipViewer as ge } from "./hooks/useZipViewer.mjs";
|
|
26
|
+
import { TextRenderer as Z, CodeRenderer as xe, XmlRenderer as be, HtmlRenderer as ke, MarkdownRenderer as Ce, JsonlRenderer as Te, TsvRenderer as ze, CsvRenderer as Fe, JsonRenderer as Re } from "./components/FileRenderers.mjs";
|
|
27
|
+
import { AudioRenderer as Ne, VideoRenderer as Ee, ImageRenderer as Se } from "./components/MediaRenderers.mjs";
|
|
28
|
+
import { ZipRenderer as Me } from "./components/ZipRenderer.mjs";
|
|
29
|
+
import { ErrorAlert as Be } from "./components/ErrorAlert.mjs";
|
|
30
30
|
import "./style.less.mjs";
|
|
31
|
-
import
|
|
32
|
-
const
|
|
31
|
+
import De from "./components/PDFViewer/index.mjs";
|
|
32
|
+
const Le = (o) => {
|
|
33
33
|
if (!o)
|
|
34
34
|
return "unknown";
|
|
35
35
|
const n = o.split(";")[0].trim().toLowerCase();
|
|
36
36
|
return n.startsWith("image/") ? "image" : n.startsWith("video/") ? "video" : n.startsWith("audio/") ? "audio" : n === "application/pdf" ? "pdf" : n === "text/markdown" || n === "text/x-markdown" ? "markdown" : n === "application/json" ? "json" : n === "application/jsonl" ? "jsonl" : n === "text/csv" || n === "application/csv" ? "csv" : n === "text/tab-separated-values" ? "tsv" : n === "application/javascript" || n === "text/javascript" ? "code" : n === "application/xml" || n === "text/xml" ? "xml" : n === "text/html" || n === "application/xhtml+xml" ? "html" : n === "text/plain" ? "text" : "unknown";
|
|
37
|
-
},
|
|
37
|
+
}, je = (o) => !o || Number.isNaN(o) ? "大小未知" : o < 1024 ? `${o} B` : o < 1024 * 1024 ? `${(o / 1024).toFixed(1)} KB` : o < 1024 * 1024 * 1024 ? `${(o / 1024 / 1024).toFixed(1)} MB` : `${(o / 1024 / 1024 / 1024).toFixed(1)} GB`, $e = (o, n) => {
|
|
38
38
|
if (n)
|
|
39
39
|
return n;
|
|
40
40
|
try {
|
|
@@ -43,112 +43,114 @@ const De = (o) => {
|
|
|
43
43
|
} catch (r) {
|
|
44
44
|
return o;
|
|
45
45
|
}
|
|
46
|
-
},
|
|
46
|
+
}, Oe = (o) => {
|
|
47
47
|
const {
|
|
48
48
|
url: n,
|
|
49
49
|
fileName: r,
|
|
50
|
-
className:
|
|
50
|
+
className: h,
|
|
51
51
|
style: u,
|
|
52
|
-
showToolbar:
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
showToolbar: y = !1,
|
|
53
|
+
toolbarExtra: v,
|
|
54
|
+
fileSize: s,
|
|
55
|
+
page: l = 1
|
|
56
|
+
} = o, e = b(() => ve(n), [n]);
|
|
55
57
|
console.log("normalizedUrl", e);
|
|
56
|
-
const
|
|
57
|
-
zipFiles:
|
|
58
|
-
zipLoading:
|
|
59
|
-
zipError:
|
|
60
|
-
selectedZipFile:
|
|
61
|
-
zipFileContent:
|
|
62
|
-
handleFileClick:
|
|
63
|
-
} =
|
|
58
|
+
const C = b(() => _(e) || _(r || ""), [e, r]), f = b(() => ye(C), [C]), [E, z] = w(f), {
|
|
59
|
+
zipFiles: q,
|
|
60
|
+
zipLoading: Q,
|
|
61
|
+
zipError: Y,
|
|
62
|
+
selectedZipFile: ee,
|
|
63
|
+
zipFileContent: te,
|
|
64
|
+
handleFileClick: re
|
|
65
|
+
} = ge(f === "zip" ? e : ""), [ne, m] = w(!0), [U, g] = w(null), [a, H] = w(null), [c, F] = w(s || 0), [oe, I] = w(!1), A = b(() => $e(e, r), [r, e]), ie = b(() => je(c || s || 0), [c, s]), S = !!(a != null && a.content), ae = !S && !e, se = b(() => [{
|
|
64
66
|
key: "copy-content",
|
|
65
67
|
label: "复制内容",
|
|
66
|
-
disabled: !
|
|
68
|
+
disabled: !S
|
|
67
69
|
}, {
|
|
68
70
|
key: "copy-url",
|
|
69
71
|
label: "复制地址",
|
|
70
72
|
disabled: !e
|
|
71
|
-
}], [
|
|
72
|
-
|
|
73
|
-
if (
|
|
73
|
+
}], [S, e]);
|
|
74
|
+
J(() => {
|
|
75
|
+
if (s && s > 0 && F(s), z(f), f === "pdf" || f === "zip") {
|
|
74
76
|
m(!1);
|
|
75
77
|
return;
|
|
76
78
|
}
|
|
77
79
|
if (!e) {
|
|
78
|
-
|
|
80
|
+
g("文件URL不能为空"), m(!1);
|
|
79
81
|
return;
|
|
80
82
|
}
|
|
81
|
-
if (["image", "video", "audio", "office"].includes(
|
|
83
|
+
if (["image", "video", "audio", "office"].includes(f)) {
|
|
82
84
|
m(!1);
|
|
83
85
|
return;
|
|
84
86
|
}
|
|
85
|
-
m(!0),
|
|
87
|
+
m(!0), g(null), x(void 0, null, function* () {
|
|
86
88
|
try {
|
|
87
89
|
if (e.startsWith("blob:") || e.startsWith("data:")) {
|
|
88
|
-
const
|
|
89
|
-
if (!
|
|
90
|
-
throw new Error(`HTTP error! status: ${
|
|
91
|
-
const
|
|
92
|
-
if (
|
|
93
|
-
|
|
90
|
+
const p = yield fetch(e);
|
|
91
|
+
if (!p.ok)
|
|
92
|
+
throw new Error(`HTTP error! status: ${p.status}`);
|
|
93
|
+
const X = yield p.blob(), D = X.size;
|
|
94
|
+
if (F(D), D > j) {
|
|
95
|
+
g(`文件过大(${Math.round(D / 1024 / 1024)}MB),无法预览。请下载后查看。`), m(!1);
|
|
94
96
|
return;
|
|
95
97
|
}
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
content:
|
|
98
|
+
const ue = yield X.text();
|
|
99
|
+
f === "unknown" && z("text"), H({
|
|
100
|
+
content: ue
|
|
99
101
|
}), m(!1);
|
|
100
102
|
return;
|
|
101
103
|
}
|
|
102
104
|
const i = yield fetch(e, {
|
|
103
105
|
method: "HEAD"
|
|
104
|
-
}),
|
|
105
|
-
if (
|
|
106
|
-
const
|
|
107
|
-
|
|
106
|
+
}), P = i.headers.get("Content-Length"), de = i.headers.get("Content-Type"), R = P ? parseInt(P, 10) : 0;
|
|
107
|
+
if (R > 0 && F(R), f === "unknown") {
|
|
108
|
+
const p = Le(de);
|
|
109
|
+
p !== "unknown" && z(p);
|
|
108
110
|
}
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
+
if (R > j) {
|
|
112
|
+
g(`文件过大(${Math.round(R / 1024 / 1024)}MB),无法预览。请下载后查看。`), m(!1);
|
|
111
113
|
return;
|
|
112
114
|
}
|
|
113
|
-
const
|
|
114
|
-
if (!
|
|
115
|
-
throw new Error(`HTTP error! status: ${
|
|
116
|
-
const
|
|
117
|
-
if (
|
|
118
|
-
|
|
115
|
+
const B = yield fetch(e);
|
|
116
|
+
if (!B.ok)
|
|
117
|
+
throw new Error(`HTTP error! status: ${B.status}`);
|
|
118
|
+
const V = yield B.text(), N = new Blob([V]).size;
|
|
119
|
+
if (N > 0 && F((p) => p || N), N > j) {
|
|
120
|
+
g(`文件过大(${Math.round(N / 1024 / 1024)}MB),无法预览。请下载后查看。`), m(!1);
|
|
119
121
|
return;
|
|
120
122
|
}
|
|
121
|
-
|
|
122
|
-
content:
|
|
123
|
+
E === "unknown" && z("text"), H({
|
|
124
|
+
content: V
|
|
123
125
|
}), m(!1);
|
|
124
126
|
} catch (d) {
|
|
125
|
-
|
|
127
|
+
g(d.message || "加载文件失败"), m(!1);
|
|
126
128
|
}
|
|
127
129
|
});
|
|
128
|
-
}, [e, s]);
|
|
129
|
-
const
|
|
130
|
+
}, [e, f, s]);
|
|
131
|
+
const M = L(() => x(void 0, null, function* () {
|
|
130
132
|
var d;
|
|
131
133
|
if (!(a != null && a.content)) {
|
|
132
|
-
|
|
134
|
+
k.warning("暂无可复制的内容");
|
|
133
135
|
return;
|
|
134
136
|
}
|
|
135
137
|
try {
|
|
136
|
-
if (
|
|
138
|
+
if (I(!0), (d = navigator == null ? void 0 : navigator.clipboard) != null && d.writeText)
|
|
137
139
|
yield navigator.clipboard.writeText(a.content);
|
|
138
140
|
else {
|
|
139
141
|
const i = document.createElement("textarea");
|
|
140
142
|
i.value = a.content, i.style.position = "fixed", i.style.opacity = "0", document.body.appendChild(i), i.select(), document.execCommand("copy"), document.body.removeChild(i);
|
|
141
143
|
}
|
|
142
|
-
|
|
144
|
+
k.success("内容已复制到剪贴板");
|
|
143
145
|
} catch (i) {
|
|
144
|
-
|
|
146
|
+
k.error((i == null ? void 0 : i.message) || "复制失败,请手动复制");
|
|
145
147
|
} finally {
|
|
146
|
-
|
|
148
|
+
I(!1);
|
|
147
149
|
}
|
|
148
|
-
}), [a]),
|
|
150
|
+
}), [a]), W = L(() => x(void 0, null, function* () {
|
|
149
151
|
var d;
|
|
150
152
|
if (!e) {
|
|
151
|
-
|
|
153
|
+
k.warning("暂无可复制的地址");
|
|
152
154
|
return;
|
|
153
155
|
}
|
|
154
156
|
try {
|
|
@@ -158,40 +160,40 @@ const De = (o) => {
|
|
|
158
160
|
const i = document.createElement("textarea");
|
|
159
161
|
i.value = e, i.style.position = "fixed", i.style.opacity = "0", document.body.appendChild(i), i.select(), document.execCommand("copy"), document.body.removeChild(i);
|
|
160
162
|
}
|
|
161
|
-
|
|
163
|
+
k.success("链接已复制到剪贴板");
|
|
162
164
|
} catch (i) {
|
|
163
|
-
|
|
165
|
+
k.error((i == null ? void 0 : i.message) || "复制失败,请手动复制");
|
|
164
166
|
}
|
|
165
|
-
}), [e]),
|
|
167
|
+
}), [e]), le = L((i) => x(void 0, [i], function* ({
|
|
166
168
|
key: d
|
|
167
169
|
}) {
|
|
168
|
-
d === "copy-content" && (yield
|
|
169
|
-
}), [
|
|
170
|
-
if (
|
|
170
|
+
d === "copy-content" && (yield M()), d === "copy-url" && (yield W());
|
|
171
|
+
}), [M, W]), ce = () => {
|
|
172
|
+
if (ne)
|
|
171
173
|
return /* @__PURE__ */ t("div", {
|
|
172
174
|
className: "document-viewer-loading",
|
|
173
|
-
children: /* @__PURE__ */ t(
|
|
175
|
+
children: /* @__PURE__ */ t(G, {
|
|
174
176
|
size: "large",
|
|
175
177
|
tip: "加载中..."
|
|
176
178
|
})
|
|
177
179
|
});
|
|
178
|
-
if (
|
|
179
|
-
return /* @__PURE__ */ t(
|
|
180
|
+
if (U)
|
|
181
|
+
return /* @__PURE__ */ t(Be, {
|
|
180
182
|
message: "加载失败",
|
|
181
|
-
description:
|
|
183
|
+
description: U,
|
|
182
184
|
url: e,
|
|
183
185
|
fileName: r
|
|
184
186
|
});
|
|
185
|
-
if (
|
|
186
|
-
return /* @__PURE__ */ t(
|
|
187
|
+
if (E === "unknown" && (a != null && a.content))
|
|
188
|
+
return /* @__PURE__ */ t(Z, {
|
|
187
189
|
fileContent: a,
|
|
188
190
|
fileSize: c,
|
|
189
191
|
url: e,
|
|
190
192
|
fileName: r
|
|
191
193
|
});
|
|
192
|
-
switch (
|
|
194
|
+
switch (E) {
|
|
193
195
|
case "text":
|
|
194
|
-
return /* @__PURE__ */ t(
|
|
196
|
+
return /* @__PURE__ */ t(Z, {
|
|
195
197
|
fileContent: a,
|
|
196
198
|
fileSize: c,
|
|
197
199
|
url: e,
|
|
@@ -205,159 +207,159 @@ const De = (o) => {
|
|
|
205
207
|
fileName: r
|
|
206
208
|
});
|
|
207
209
|
case "csv":
|
|
208
|
-
return /* @__PURE__ */ t(
|
|
210
|
+
return /* @__PURE__ */ t(Fe, {
|
|
209
211
|
fileContent: a,
|
|
210
212
|
fileSize: c,
|
|
211
213
|
url: e,
|
|
212
214
|
fileName: r
|
|
213
215
|
});
|
|
214
216
|
case "tsv":
|
|
215
|
-
return /* @__PURE__ */ t(
|
|
217
|
+
return /* @__PURE__ */ t(ze, {
|
|
216
218
|
fileContent: a,
|
|
217
219
|
fileSize: c,
|
|
218
220
|
url: e,
|
|
219
221
|
fileName: r
|
|
220
222
|
});
|
|
221
223
|
case "jsonl":
|
|
222
|
-
return /* @__PURE__ */ t(
|
|
224
|
+
return /* @__PURE__ */ t(Te, {
|
|
223
225
|
fileContent: a,
|
|
224
226
|
fileSize: c,
|
|
225
227
|
url: e,
|
|
226
228
|
fileName: r
|
|
227
229
|
});
|
|
228
230
|
case "markdown":
|
|
229
|
-
return /* @__PURE__ */ t(
|
|
231
|
+
return /* @__PURE__ */ t(Ce, {
|
|
230
232
|
fileContent: a,
|
|
231
233
|
fileSize: c,
|
|
232
234
|
url: e,
|
|
233
235
|
fileName: r
|
|
234
236
|
});
|
|
235
237
|
case "html":
|
|
236
|
-
return /* @__PURE__ */ t(
|
|
238
|
+
return /* @__PURE__ */ t(ke, {
|
|
237
239
|
fileContent: a,
|
|
238
240
|
fileSize: c,
|
|
239
241
|
url: e,
|
|
240
242
|
fileName: r
|
|
241
243
|
});
|
|
242
244
|
case "xml":
|
|
243
|
-
return /* @__PURE__ */ t(
|
|
245
|
+
return /* @__PURE__ */ t(be, {
|
|
244
246
|
fileContent: a,
|
|
245
247
|
fileSize: c,
|
|
246
248
|
url: e,
|
|
247
249
|
fileName: r
|
|
248
250
|
});
|
|
249
251
|
case "code":
|
|
250
|
-
return /* @__PURE__ */ t(
|
|
252
|
+
return /* @__PURE__ */ t(xe, {
|
|
251
253
|
fileContent: a,
|
|
252
254
|
fileSize: c,
|
|
253
255
|
url: e,
|
|
254
256
|
fileName: r
|
|
255
257
|
});
|
|
256
258
|
case "image":
|
|
257
|
-
return /* @__PURE__ */ t(
|
|
259
|
+
return /* @__PURE__ */ t(Se, {
|
|
258
260
|
url: e,
|
|
259
261
|
fileName: r
|
|
260
262
|
});
|
|
261
263
|
case "video":
|
|
262
|
-
return /* @__PURE__ */ t(
|
|
264
|
+
return /* @__PURE__ */ t(Ee, {
|
|
263
265
|
url: e,
|
|
264
266
|
fileName: r
|
|
265
267
|
});
|
|
266
268
|
case "audio":
|
|
267
|
-
return /* @__PURE__ */ t(
|
|
269
|
+
return /* @__PURE__ */ t(Ne, {
|
|
268
270
|
url: e,
|
|
269
271
|
fileName: r
|
|
270
272
|
});
|
|
271
273
|
case "pdf":
|
|
272
|
-
return /* @__PURE__ */ t(
|
|
274
|
+
return /* @__PURE__ */ t(De, {
|
|
273
275
|
fileUrl: e,
|
|
274
|
-
pageNumber:
|
|
276
|
+
pageNumber: l
|
|
275
277
|
});
|
|
276
278
|
case "office":
|
|
277
|
-
return /* @__PURE__ */ t(
|
|
279
|
+
return /* @__PURE__ */ t(Ue, {
|
|
278
280
|
url: e,
|
|
279
281
|
fileName: r,
|
|
280
|
-
extension:
|
|
282
|
+
extension: C
|
|
281
283
|
});
|
|
282
284
|
case "zip":
|
|
283
|
-
return /* @__PURE__ */ t(
|
|
284
|
-
zipFiles:
|
|
285
|
-
zipLoading:
|
|
286
|
-
zipError:
|
|
287
|
-
selectedZipFile:
|
|
288
|
-
zipFileContent:
|
|
289
|
-
onFileClick:
|
|
285
|
+
return /* @__PURE__ */ t(Me, {
|
|
286
|
+
zipFiles: q,
|
|
287
|
+
zipLoading: Q,
|
|
288
|
+
zipError: Y,
|
|
289
|
+
selectedZipFile: ee,
|
|
290
|
+
zipFileContent: te,
|
|
291
|
+
onFileClick: re,
|
|
290
292
|
url: e
|
|
291
293
|
});
|
|
292
294
|
case "unknown":
|
|
293
295
|
default:
|
|
294
|
-
return /* @__PURE__ */ t(
|
|
296
|
+
return /* @__PURE__ */ t(Ie, {
|
|
295
297
|
url: e
|
|
296
298
|
});
|
|
297
299
|
}
|
|
298
300
|
};
|
|
299
|
-
return /* @__PURE__ */
|
|
300
|
-
className: `document-viewer ${
|
|
301
|
+
return /* @__PURE__ */ T("div", {
|
|
302
|
+
className: `document-viewer ${h || ""}`,
|
|
301
303
|
style: u,
|
|
302
|
-
children: [
|
|
304
|
+
children: [y && /* @__PURE__ */ T("div", {
|
|
303
305
|
className: "document-viewer-toolbar",
|
|
304
|
-
children: [/* @__PURE__ */
|
|
306
|
+
children: [/* @__PURE__ */ T("div", {
|
|
305
307
|
className: "document-viewer-toolbar-meta",
|
|
306
308
|
children: [/* @__PURE__ */ t("span", {
|
|
307
309
|
className: "document-viewer-toolbar-name",
|
|
308
|
-
title:
|
|
309
|
-
children:
|
|
310
|
+
title: A,
|
|
311
|
+
children: A
|
|
310
312
|
}), /* @__PURE__ */ t("span", {
|
|
311
313
|
className: "document-viewer-toolbar-size",
|
|
312
|
-
children:
|
|
314
|
+
children: ie
|
|
313
315
|
})]
|
|
314
|
-
}), /* @__PURE__ */
|
|
316
|
+
}), /* @__PURE__ */ T(fe, {
|
|
315
317
|
size: 8,
|
|
316
318
|
wrap: !0,
|
|
317
|
-
children: [/* @__PURE__ */ t(
|
|
318
|
-
icon: /* @__PURE__ */ t(
|
|
319
|
+
children: [/* @__PURE__ */ t($, {
|
|
320
|
+
icon: /* @__PURE__ */ t(O, {}),
|
|
319
321
|
size: "small",
|
|
320
322
|
href: e,
|
|
321
323
|
target: "_blank",
|
|
322
324
|
rel: "noopener noreferrer",
|
|
323
325
|
download: r || void 0,
|
|
324
326
|
children: "下载"
|
|
325
|
-
}), /* @__PURE__ */ t(
|
|
327
|
+
}), /* @__PURE__ */ t(pe.Button, {
|
|
326
328
|
size: "small",
|
|
327
|
-
icon: /* @__PURE__ */ t(
|
|
329
|
+
icon: /* @__PURE__ */ t(we, {}),
|
|
328
330
|
menu: {
|
|
329
|
-
items:
|
|
330
|
-
onClick:
|
|
331
|
+
items: se,
|
|
332
|
+
onClick: le
|
|
331
333
|
},
|
|
332
|
-
disabled:
|
|
333
|
-
loading:
|
|
334
|
-
onClick:
|
|
334
|
+
disabled: ae,
|
|
335
|
+
loading: oe,
|
|
336
|
+
onClick: M,
|
|
335
337
|
children: "复制"
|
|
336
|
-
})]
|
|
338
|
+
}), v]
|
|
337
339
|
})]
|
|
338
340
|
}), /* @__PURE__ */ t("div", {
|
|
339
341
|
className: "document-viewer-body",
|
|
340
|
-
children:
|
|
342
|
+
children: ce()
|
|
341
343
|
})]
|
|
342
344
|
});
|
|
343
|
-
},
|
|
345
|
+
}, Ue = ({
|
|
344
346
|
url: o,
|
|
345
347
|
fileName: n,
|
|
346
348
|
extension: r
|
|
347
|
-
}) => r === "docx" ? /* @__PURE__ */ t(
|
|
349
|
+
}) => r === "docx" ? /* @__PURE__ */ t(He, {
|
|
348
350
|
url: o,
|
|
349
351
|
fileName: n
|
|
350
352
|
}) : /* @__PURE__ */ t("div", {
|
|
351
353
|
className: "document-viewer-office",
|
|
352
|
-
children: /* @__PURE__ */ t(
|
|
354
|
+
children: /* @__PURE__ */ t(K, {
|
|
353
355
|
className: "document-viewer-alert-full",
|
|
354
356
|
message: "暂不支持在线预览",
|
|
355
357
|
description: "当前仅支持 docx 文件在线预览,其他 Office 文档请下载后查看。",
|
|
356
358
|
type: "info",
|
|
357
359
|
showIcon: !0,
|
|
358
|
-
action: /* @__PURE__ */ t(
|
|
360
|
+
action: /* @__PURE__ */ t($, {
|
|
359
361
|
type: "link",
|
|
360
|
-
icon: /* @__PURE__ */ t(
|
|
362
|
+
icon: /* @__PURE__ */ t(O, {}),
|
|
361
363
|
href: o,
|
|
362
364
|
download: n,
|
|
363
365
|
target: "_blank",
|
|
@@ -365,51 +367,51 @@ const De = (o) => {
|
|
|
365
367
|
children: "下载文件"
|
|
366
368
|
})
|
|
367
369
|
})
|
|
368
|
-
}),
|
|
370
|
+
}), He = ({
|
|
369
371
|
url: o,
|
|
370
372
|
fileName: n
|
|
371
373
|
}) => {
|
|
372
|
-
const r =
|
|
373
|
-
return
|
|
374
|
-
let
|
|
374
|
+
const r = me(null), [h, u] = w(!0), [y, v] = w(null);
|
|
375
|
+
return J(() => {
|
|
376
|
+
let s = !1;
|
|
375
377
|
const l = r.current;
|
|
376
|
-
return l && (l.innerHTML = ""), u(!0),
|
|
378
|
+
return l && (l.innerHTML = ""), u(!0), v(null), x(void 0, null, function* () {
|
|
377
379
|
try {
|
|
378
|
-
const
|
|
379
|
-
if (!
|
|
380
|
-
throw new Error(`HTTP error! status: ${
|
|
381
|
-
const
|
|
382
|
-
if (
|
|
380
|
+
const e = yield fetch(o);
|
|
381
|
+
if (!e.ok)
|
|
382
|
+
throw new Error(`HTTP error! status: ${e.status}`);
|
|
383
|
+
const C = yield e.blob();
|
|
384
|
+
if (s || !r.current)
|
|
383
385
|
return;
|
|
384
|
-
yield
|
|
386
|
+
yield he(C, r.current, void 0, {
|
|
385
387
|
inWrapper: !1,
|
|
386
388
|
ignoreWidth: !1,
|
|
387
389
|
ignoreHeight: !1,
|
|
388
390
|
breakPages: !0
|
|
389
|
-
}),
|
|
390
|
-
} catch (
|
|
391
|
-
|
|
391
|
+
}), s || u(!1);
|
|
392
|
+
} catch (e) {
|
|
393
|
+
s || (v((e == null ? void 0 : e.message) || "DOCX文件预览失败"), u(!1));
|
|
392
394
|
}
|
|
393
395
|
}), () => {
|
|
394
|
-
|
|
396
|
+
s = !0, l && (l.innerHTML = "");
|
|
395
397
|
};
|
|
396
|
-
}, [o]), /* @__PURE__ */
|
|
398
|
+
}, [o]), /* @__PURE__ */ T("div", {
|
|
397
399
|
className: "document-viewer-office document-viewer-docx",
|
|
398
|
-
children: [
|
|
400
|
+
children: [h && /* @__PURE__ */ t("div", {
|
|
399
401
|
className: "document-viewer-loading",
|
|
400
|
-
children: /* @__PURE__ */ t(
|
|
402
|
+
children: /* @__PURE__ */ t(G, {
|
|
401
403
|
size: "large",
|
|
402
404
|
tip: "加载DOCX中..."
|
|
403
405
|
})
|
|
404
|
-
}),
|
|
406
|
+
}), y && /* @__PURE__ */ t(K, {
|
|
405
407
|
className: "document-viewer-alert-full",
|
|
406
408
|
message: "DOCX预览失败",
|
|
407
409
|
description: "文件无法在线预览,请下载后查看。",
|
|
408
410
|
type: "warning",
|
|
409
411
|
showIcon: !0,
|
|
410
|
-
action: /* @__PURE__ */ t(
|
|
412
|
+
action: /* @__PURE__ */ t($, {
|
|
411
413
|
type: "link",
|
|
412
|
-
icon: /* @__PURE__ */ t(
|
|
414
|
+
icon: /* @__PURE__ */ t(O, {}),
|
|
413
415
|
href: o,
|
|
414
416
|
download: n,
|
|
415
417
|
target: "_blank",
|
|
@@ -420,11 +422,11 @@ const De = (o) => {
|
|
|
420
422
|
ref: r,
|
|
421
423
|
className: "document-viewer-docx-content",
|
|
422
424
|
style: {
|
|
423
|
-
display:
|
|
425
|
+
display: h || y ? "none" : void 0
|
|
424
426
|
}
|
|
425
427
|
})]
|
|
426
428
|
});
|
|
427
|
-
},
|
|
429
|
+
}, Ie = ({
|
|
428
430
|
url: o
|
|
429
431
|
}) => /* @__PURE__ */ t("div", {
|
|
430
432
|
className: "document-viewer-unknown",
|
|
@@ -433,7 +435,7 @@ const De = (o) => {
|
|
|
433
435
|
className: "document-viewer-iframe",
|
|
434
436
|
title: "File Preview"
|
|
435
437
|
})
|
|
436
|
-
}),
|
|
438
|
+
}), nt = Oe;
|
|
437
439
|
export {
|
|
438
|
-
|
|
440
|
+
nt as default
|
|
439
441
|
};
|