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