@glodon-aiot/react-components 3.9.0-beta.9 → 3.11.0-snapshot.1765331440
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/components/DownloadButton.mjs +18 -0
- package/dist/es/components/DocumentViewer/components/ErrorAlert.mjs +27 -0
- package/dist/es/components/DocumentViewer/components/FileRenderers.mjs +476 -0
- package/dist/es/components/DocumentViewer/components/MediaRenderers.mjs +41 -0
- package/dist/es/components/DocumentViewer/components/PdfRenderer.mjs +44 -0
- package/dist/es/components/DocumentViewer/components/ZipRenderer.mjs +147 -0
- package/dist/es/components/DocumentViewer/constants.mjs +21 -0
- package/dist/es/components/DocumentViewer/hooks/usePdfViewer.mjs +31 -0
- package/dist/es/components/DocumentViewer/hooks/useZipViewer.mjs +151 -0
- package/dist/es/components/DocumentViewer/index.mjs +255 -0
- package/dist/es/components/DocumentViewer/style.less.mjs +4 -0
- package/dist/es/components/DocumentViewer/utils.mjs +60 -0
- package/dist/es/index.mjs +36 -34
- package/dist/es/utils/file.mjs +17 -0
- package/dist/lib/index.js +10 -2
- package/dist/src/components/DocumentViewer/components/DownloadButton.d.ts +7 -0
- package/dist/src/components/DocumentViewer/components/ErrorAlert.d.ts +10 -0
- package/dist/src/components/DocumentViewer/components/FileRenderers.d.ts +23 -0
- package/dist/src/components/DocumentViewer/components/MediaRenderers.d.ts +9 -0
- package/dist/src/components/DocumentViewer/components/PdfRenderer.d.ts +10 -0
- package/dist/src/components/DocumentViewer/components/ZipRenderer.d.ts +22 -0
- package/dist/src/components/DocumentViewer/components/index.d.ts +9 -0
- package/dist/src/components/DocumentViewer/constants.d.ts +21 -0
- package/dist/src/components/DocumentViewer/hooks/index.d.ts +5 -0
- package/dist/src/components/DocumentViewer/hooks/usePdfViewer.d.ts +7 -0
- package/dist/src/components/DocumentViewer/hooks/useZipViewer.d.ts +21 -0
- package/dist/src/components/DocumentViewer/index.d.ts +9 -0
- package/dist/src/components/DocumentViewer/utils.d.ts +18 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/utils/file.d.ts +16 -0
- package/dist/style.css +1 -0
- package/package.json +15 -11
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { Button as t } from "antd";
|
|
3
|
+
import { DownloadOutlined as e } from "@ant-design/icons";
|
|
4
|
+
const m = ({
|
|
5
|
+
url: r,
|
|
6
|
+
fileName: n
|
|
7
|
+
}) => /* @__PURE__ */ o(t, {
|
|
8
|
+
type: "link",
|
|
9
|
+
icon: /* @__PURE__ */ o(e, {}),
|
|
10
|
+
href: r,
|
|
11
|
+
download: n,
|
|
12
|
+
target: "_blank",
|
|
13
|
+
rel: "noopener noreferrer",
|
|
14
|
+
children: "下载文件"
|
|
15
|
+
});
|
|
16
|
+
export {
|
|
17
|
+
m as DownloadButton
|
|
18
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { Alert as i, Button as c } from "antd";
|
|
3
|
+
import { DownloadOutlined as a } from "@ant-design/icons";
|
|
4
|
+
const u = ({
|
|
5
|
+
message: t,
|
|
6
|
+
description: e,
|
|
7
|
+
action: n,
|
|
8
|
+
url: o,
|
|
9
|
+
fileName: l
|
|
10
|
+
}) => /* @__PURE__ */ r(i, {
|
|
11
|
+
message: t,
|
|
12
|
+
description: e,
|
|
13
|
+
type: "error",
|
|
14
|
+
showIcon: !0,
|
|
15
|
+
action: n || (o ? /* @__PURE__ */ r(c, {
|
|
16
|
+
type: "link",
|
|
17
|
+
icon: /* @__PURE__ */ r(a, {}),
|
|
18
|
+
href: o,
|
|
19
|
+
download: l,
|
|
20
|
+
target: "_blank",
|
|
21
|
+
rel: "noopener noreferrer",
|
|
22
|
+
children: "下载文件"
|
|
23
|
+
}) : null)
|
|
24
|
+
});
|
|
25
|
+
export {
|
|
26
|
+
u as ErrorAlert
|
|
27
|
+
};
|
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
import { jsxs as v, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as B } from "react";
|
|
3
|
+
import { Alert as l, Table as z } from "antd";
|
|
4
|
+
import { Prism as N } from "react-syntax-highlighter";
|
|
5
|
+
import { Markdown as T } from "../../Markdown/index.mjs";
|
|
6
|
+
import { getFileExtension as _ } from "../../../utils/file.mjs";
|
|
7
|
+
import { MAX_DISPLAY_SIZE as $, MAX_DISPLAY_LINES as w, MAX_JSON_SIZE as A, MAX_CSV_SIZE as J, MAX_CSV_ROWS as y, MAX_TSV_SIZE as O, MAX_JSONL_SIZE as X, MAX_JSONL_LINES as L, MAX_MARKDOWN_SIZE as E, MAX_XML_SIZE as k, MAX_HIGHLIGHT_SIZE as b } from "../constants.mjs";
|
|
8
|
+
import { DownloadButton as d } from "./DownloadButton.mjs";
|
|
9
|
+
const R = ({
|
|
10
|
+
fileContent: e,
|
|
11
|
+
fileSize: i,
|
|
12
|
+
url: s,
|
|
13
|
+
fileName: t
|
|
14
|
+
}) => {
|
|
15
|
+
if (!(e != null && e.content))
|
|
16
|
+
return null;
|
|
17
|
+
if ((i || new Blob([e.content]).size) > $) {
|
|
18
|
+
const r = e.content.split(`
|
|
19
|
+
`), m = r.length > w, a = (m ? r.slice(0, w) : r).join(`
|
|
20
|
+
`);
|
|
21
|
+
return /* @__PURE__ */ v("div", {
|
|
22
|
+
style: {
|
|
23
|
+
display: "flex",
|
|
24
|
+
flexDirection: "column",
|
|
25
|
+
height: "100%",
|
|
26
|
+
overflow: "hidden"
|
|
27
|
+
},
|
|
28
|
+
children: [m && /* @__PURE__ */ n(l, {
|
|
29
|
+
message: "文件过大",
|
|
30
|
+
description: `文件包含 ${r.length} 行,仅显示前 ${w} 行。请下载完整文件查看。`,
|
|
31
|
+
type: "warning",
|
|
32
|
+
showIcon: !0,
|
|
33
|
+
style: {
|
|
34
|
+
marginBottom: 16,
|
|
35
|
+
flexShrink: 0
|
|
36
|
+
},
|
|
37
|
+
action: /* @__PURE__ */ n(d, {
|
|
38
|
+
url: s,
|
|
39
|
+
fileName: t
|
|
40
|
+
})
|
|
41
|
+
}), /* @__PURE__ */ n("pre", {
|
|
42
|
+
className: "document-viewer-text",
|
|
43
|
+
children: a
|
|
44
|
+
})]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return /* @__PURE__ */ n("pre", {
|
|
48
|
+
className: "document-viewer-text",
|
|
49
|
+
children: e.content
|
|
50
|
+
});
|
|
51
|
+
}, Y = ({
|
|
52
|
+
fileContent: e,
|
|
53
|
+
fileSize: i,
|
|
54
|
+
url: s,
|
|
55
|
+
fileName: t
|
|
56
|
+
}) => {
|
|
57
|
+
if (!(e != null && e.content))
|
|
58
|
+
return null;
|
|
59
|
+
const c = i || new Blob([e.content]).size;
|
|
60
|
+
if (c > A)
|
|
61
|
+
return /* @__PURE__ */ n(l, {
|
|
62
|
+
message: "JSON文件过大",
|
|
63
|
+
description: `文件大小 ${Math.round(c / 1024 / 1024)}MB,无法预览。请下载后查看。`,
|
|
64
|
+
type: "warning",
|
|
65
|
+
showIcon: !0,
|
|
66
|
+
action: /* @__PURE__ */ n(d, {
|
|
67
|
+
url: s,
|
|
68
|
+
fileName: t
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
try {
|
|
72
|
+
const r = JSON.parse(e.content);
|
|
73
|
+
return /* @__PURE__ */ n("pre", {
|
|
74
|
+
className: "document-viewer-json",
|
|
75
|
+
children: JSON.stringify(r, null, 2)
|
|
76
|
+
});
|
|
77
|
+
} catch (r) {
|
|
78
|
+
return /* @__PURE__ */ n(l, {
|
|
79
|
+
message: "JSON解析失败",
|
|
80
|
+
description: "文件内容不是有效的JSON格式",
|
|
81
|
+
type: "error",
|
|
82
|
+
action: /* @__PURE__ */ n(d, {
|
|
83
|
+
url: s,
|
|
84
|
+
fileName: t
|
|
85
|
+
})
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}, F = ({
|
|
89
|
+
fileContent: e,
|
|
90
|
+
fileSize: i,
|
|
91
|
+
url: s,
|
|
92
|
+
fileName: t
|
|
93
|
+
}) => {
|
|
94
|
+
if (!(e != null && e.content))
|
|
95
|
+
return null;
|
|
96
|
+
const c = i || new Blob([e.content]).size;
|
|
97
|
+
if (c > J)
|
|
98
|
+
return /* @__PURE__ */ n(l, {
|
|
99
|
+
message: "CSV文件过大",
|
|
100
|
+
description: `文件大小 ${Math.round(c / 1024 / 1024)}MB,无法预览。请下载后查看。`,
|
|
101
|
+
type: "warning",
|
|
102
|
+
showIcon: !0,
|
|
103
|
+
action: /* @__PURE__ */ n(d, {
|
|
104
|
+
url: s,
|
|
105
|
+
fileName: t
|
|
106
|
+
})
|
|
107
|
+
});
|
|
108
|
+
try {
|
|
109
|
+
const r = e.content.split(`
|
|
110
|
+
`).filter((o) => o.trim());
|
|
111
|
+
if (r.length === 0)
|
|
112
|
+
return null;
|
|
113
|
+
const m = r.length > y, u = m ? r.slice(0, y) : r, a = u[0].split(",").map((o) => o.trim()), h = u.slice(1).map((o, x) => {
|
|
114
|
+
const M = o.split(",").map((g) => g.trim()), S = {
|
|
115
|
+
key: String(x)
|
|
116
|
+
};
|
|
117
|
+
return a.forEach((g, I) => {
|
|
118
|
+
S[g] = M[I] || "";
|
|
119
|
+
}), S;
|
|
120
|
+
}), p = a.map((o) => ({
|
|
121
|
+
title: o,
|
|
122
|
+
dataIndex: o,
|
|
123
|
+
key: o
|
|
124
|
+
}));
|
|
125
|
+
return /* @__PURE__ */ v("div", {
|
|
126
|
+
style: {
|
|
127
|
+
display: "flex",
|
|
128
|
+
flexDirection: "column",
|
|
129
|
+
height: "100%",
|
|
130
|
+
overflow: "hidden"
|
|
131
|
+
},
|
|
132
|
+
children: [m && /* @__PURE__ */ n(l, {
|
|
133
|
+
message: "文件过大",
|
|
134
|
+
description: `CSV文件包含 ${r.length} 行,仅显示前 ${y} 行。请下载完整文件查看。`,
|
|
135
|
+
type: "warning",
|
|
136
|
+
showIcon: !0,
|
|
137
|
+
style: {
|
|
138
|
+
marginBottom: 16,
|
|
139
|
+
flexShrink: 0
|
|
140
|
+
},
|
|
141
|
+
action: /* @__PURE__ */ n(d, {
|
|
142
|
+
url: s,
|
|
143
|
+
fileName: t
|
|
144
|
+
})
|
|
145
|
+
}), /* @__PURE__ */ n("div", {
|
|
146
|
+
style: {
|
|
147
|
+
flex: 1,
|
|
148
|
+
overflow: "auto",
|
|
149
|
+
minHeight: 0
|
|
150
|
+
},
|
|
151
|
+
children: /* @__PURE__ */ n(z, {
|
|
152
|
+
dataSource: h,
|
|
153
|
+
columns: p,
|
|
154
|
+
pagination: !1,
|
|
155
|
+
scroll: {
|
|
156
|
+
x: "max-content",
|
|
157
|
+
y: "100%"
|
|
158
|
+
},
|
|
159
|
+
size: "small"
|
|
160
|
+
})
|
|
161
|
+
})]
|
|
162
|
+
});
|
|
163
|
+
} catch (r) {
|
|
164
|
+
return /* @__PURE__ */ n(l, {
|
|
165
|
+
message: "CSV解析失败",
|
|
166
|
+
description: "文件内容不是有效的CSV格式",
|
|
167
|
+
type: "error",
|
|
168
|
+
action: /* @__PURE__ */ n(d, {
|
|
169
|
+
url: s,
|
|
170
|
+
fileName: t
|
|
171
|
+
})
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}, K = ({
|
|
175
|
+
fileContent: e,
|
|
176
|
+
fileSize: i,
|
|
177
|
+
url: s,
|
|
178
|
+
fileName: t
|
|
179
|
+
}) => {
|
|
180
|
+
if (!(e != null && e.content))
|
|
181
|
+
return null;
|
|
182
|
+
const c = i || new Blob([e.content]).size;
|
|
183
|
+
if (c > O)
|
|
184
|
+
return /* @__PURE__ */ n(l, {
|
|
185
|
+
message: "TSV文件过大",
|
|
186
|
+
description: `文件大小 ${Math.round(c / 1024 / 1024)}MB,无法预览。请下载后查看。`,
|
|
187
|
+
type: "warning",
|
|
188
|
+
showIcon: !0,
|
|
189
|
+
action: /* @__PURE__ */ n(d, {
|
|
190
|
+
url: s,
|
|
191
|
+
fileName: t
|
|
192
|
+
})
|
|
193
|
+
});
|
|
194
|
+
try {
|
|
195
|
+
const r = e.content.split(`
|
|
196
|
+
`).filter((o) => o.trim());
|
|
197
|
+
if (r.length === 0)
|
|
198
|
+
return null;
|
|
199
|
+
const m = r.length > y, u = m ? r.slice(0, y) : r, a = u[0].split(" ").map((o) => o.trim()), h = u.slice(1).map((o, x) => {
|
|
200
|
+
const M = o.split(" ").map((g) => g.trim()), S = {
|
|
201
|
+
key: String(x)
|
|
202
|
+
};
|
|
203
|
+
return a.forEach((g, I) => {
|
|
204
|
+
S[g] = M[I] || "";
|
|
205
|
+
}), S;
|
|
206
|
+
}), p = a.map((o) => ({
|
|
207
|
+
title: o,
|
|
208
|
+
dataIndex: o,
|
|
209
|
+
key: o
|
|
210
|
+
}));
|
|
211
|
+
return /* @__PURE__ */ v("div", {
|
|
212
|
+
style: {
|
|
213
|
+
display: "flex",
|
|
214
|
+
flexDirection: "column",
|
|
215
|
+
height: "100%",
|
|
216
|
+
overflow: "hidden"
|
|
217
|
+
},
|
|
218
|
+
children: [m && /* @__PURE__ */ n(l, {
|
|
219
|
+
message: "文件过大",
|
|
220
|
+
description: `TSV文件包含 ${r.length} 行,仅显示前 ${y} 行。请下载完整文件查看。`,
|
|
221
|
+
type: "warning",
|
|
222
|
+
showIcon: !0,
|
|
223
|
+
style: {
|
|
224
|
+
marginBottom: 16,
|
|
225
|
+
flexShrink: 0
|
|
226
|
+
},
|
|
227
|
+
action: /* @__PURE__ */ n(d, {
|
|
228
|
+
url: s,
|
|
229
|
+
fileName: t
|
|
230
|
+
})
|
|
231
|
+
}), /* @__PURE__ */ n("div", {
|
|
232
|
+
style: {
|
|
233
|
+
flex: 1,
|
|
234
|
+
overflow: "auto",
|
|
235
|
+
minHeight: 0
|
|
236
|
+
},
|
|
237
|
+
children: /* @__PURE__ */ n(z, {
|
|
238
|
+
dataSource: h,
|
|
239
|
+
columns: p,
|
|
240
|
+
pagination: !1,
|
|
241
|
+
scroll: {
|
|
242
|
+
x: "max-content",
|
|
243
|
+
y: "100%"
|
|
244
|
+
},
|
|
245
|
+
size: "small"
|
|
246
|
+
})
|
|
247
|
+
})]
|
|
248
|
+
});
|
|
249
|
+
} catch (r) {
|
|
250
|
+
return /* @__PURE__ */ n(l, {
|
|
251
|
+
message: "TSV解析失败",
|
|
252
|
+
description: "文件内容不是有效的TSV格式",
|
|
253
|
+
type: "error",
|
|
254
|
+
action: /* @__PURE__ */ n(d, {
|
|
255
|
+
url: s,
|
|
256
|
+
fileName: t
|
|
257
|
+
})
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}, q = ({
|
|
261
|
+
fileContent: e,
|
|
262
|
+
fileSize: i,
|
|
263
|
+
url: s,
|
|
264
|
+
fileName: t
|
|
265
|
+
}) => {
|
|
266
|
+
if (!(e != null && e.content))
|
|
267
|
+
return null;
|
|
268
|
+
const c = i || new Blob([e.content]).size;
|
|
269
|
+
if (c > X)
|
|
270
|
+
return /* @__PURE__ */ n(l, {
|
|
271
|
+
message: "JSONL文件过大",
|
|
272
|
+
description: `文件大小 ${Math.round(c / 1024 / 1024)}MB,无法预览。请下载后查看。`,
|
|
273
|
+
type: "warning",
|
|
274
|
+
showIcon: !0,
|
|
275
|
+
action: /* @__PURE__ */ n(d, {
|
|
276
|
+
url: s,
|
|
277
|
+
fileName: t
|
|
278
|
+
})
|
|
279
|
+
});
|
|
280
|
+
try {
|
|
281
|
+
const r = e.content.split(`
|
|
282
|
+
`).filter((a) => a.trim()), m = r.length > L, u = m ? r.slice(0, L) : r;
|
|
283
|
+
return /* @__PURE__ */ v("div", {
|
|
284
|
+
style: {
|
|
285
|
+
display: "flex",
|
|
286
|
+
flexDirection: "column",
|
|
287
|
+
height: "100%",
|
|
288
|
+
overflow: "hidden"
|
|
289
|
+
},
|
|
290
|
+
children: [m && /* @__PURE__ */ n(l, {
|
|
291
|
+
message: "文件过大",
|
|
292
|
+
description: `JSONL文件包含 ${r.length} 行,仅显示前 ${L} 行。请下载完整文件查看。`,
|
|
293
|
+
type: "warning",
|
|
294
|
+
showIcon: !0,
|
|
295
|
+
style: {
|
|
296
|
+
marginBottom: 16,
|
|
297
|
+
flexShrink: 0
|
|
298
|
+
},
|
|
299
|
+
action: /* @__PURE__ */ n(d, {
|
|
300
|
+
url: s,
|
|
301
|
+
fileName: t
|
|
302
|
+
})
|
|
303
|
+
}), /* @__PURE__ */ n("div", {
|
|
304
|
+
className: "document-viewer-jsonl",
|
|
305
|
+
children: u.map((a, h) => {
|
|
306
|
+
try {
|
|
307
|
+
const p = JSON.parse(a);
|
|
308
|
+
return /* @__PURE__ */ n("div", {
|
|
309
|
+
className: "document-viewer-jsonl-item",
|
|
310
|
+
children: /* @__PURE__ */ n("pre", {
|
|
311
|
+
children: JSON.stringify(p, null, 2)
|
|
312
|
+
})
|
|
313
|
+
}, h);
|
|
314
|
+
} catch (p) {
|
|
315
|
+
return /* @__PURE__ */ n("div", {
|
|
316
|
+
className: "document-viewer-jsonl-item",
|
|
317
|
+
children: /* @__PURE__ */ n("pre", {
|
|
318
|
+
children: a
|
|
319
|
+
})
|
|
320
|
+
}, h);
|
|
321
|
+
}
|
|
322
|
+
})
|
|
323
|
+
})]
|
|
324
|
+
});
|
|
325
|
+
} catch (r) {
|
|
326
|
+
return /* @__PURE__ */ n(l, {
|
|
327
|
+
message: "JSONL解析失败",
|
|
328
|
+
description: "文件内容解析出错",
|
|
329
|
+
type: "error",
|
|
330
|
+
action: /* @__PURE__ */ n(d, {
|
|
331
|
+
url: s,
|
|
332
|
+
fileName: t
|
|
333
|
+
})
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
}, Q = ({
|
|
337
|
+
fileContent: e,
|
|
338
|
+
fileSize: i,
|
|
339
|
+
url: s,
|
|
340
|
+
fileName: t
|
|
341
|
+
}) => {
|
|
342
|
+
if (!(e != null && e.content))
|
|
343
|
+
return null;
|
|
344
|
+
const c = i || new Blob([e.content]).size;
|
|
345
|
+
return c > E ? /* @__PURE__ */ n(l, {
|
|
346
|
+
message: "Markdown文件过大",
|
|
347
|
+
description: `文件大小 ${Math.round(c / 1024 / 1024)}MB,无法预览。请下载后查看。`,
|
|
348
|
+
type: "warning",
|
|
349
|
+
showIcon: !0,
|
|
350
|
+
action: /* @__PURE__ */ n(d, {
|
|
351
|
+
url: s,
|
|
352
|
+
fileName: t
|
|
353
|
+
})
|
|
354
|
+
}) : /* @__PURE__ */ n("div", {
|
|
355
|
+
style: {
|
|
356
|
+
height: "100%",
|
|
357
|
+
overflow: "auto",
|
|
358
|
+
padding: "16px"
|
|
359
|
+
},
|
|
360
|
+
children: /* @__PURE__ */ n(T, {
|
|
361
|
+
children: e.content
|
|
362
|
+
})
|
|
363
|
+
});
|
|
364
|
+
}, U = ({
|
|
365
|
+
fileContent: e
|
|
366
|
+
}) => e != null && e.content ? /* @__PURE__ */ n("iframe", {
|
|
367
|
+
srcDoc: e.content,
|
|
368
|
+
className: "document-viewer-iframe",
|
|
369
|
+
title: "HTML Preview",
|
|
370
|
+
sandbox: "allow-same-origin allow-scripts"
|
|
371
|
+
}) : null, f = ({
|
|
372
|
+
fileContent: e,
|
|
373
|
+
fileSize: i,
|
|
374
|
+
url: s,
|
|
375
|
+
fileName: t
|
|
376
|
+
}) => {
|
|
377
|
+
if (!(e != null && e.content))
|
|
378
|
+
return null;
|
|
379
|
+
const c = i || new Blob([e.content]).size;
|
|
380
|
+
if (c > k)
|
|
381
|
+
return /* @__PURE__ */ n(l, {
|
|
382
|
+
message: "XML文件过大",
|
|
383
|
+
description: `文件大小 ${Math.round(c / 1024 / 1024)}MB,无法预览。请下载后查看。`,
|
|
384
|
+
type: "warning",
|
|
385
|
+
showIcon: !0,
|
|
386
|
+
action: /* @__PURE__ */ n(d, {
|
|
387
|
+
url: s,
|
|
388
|
+
fileName: t
|
|
389
|
+
})
|
|
390
|
+
});
|
|
391
|
+
try {
|
|
392
|
+
const r = e.content.replace(/></g, `>
|
|
393
|
+
<`).replace(/^\s+/gm, "");
|
|
394
|
+
return /* @__PURE__ */ n("pre", {
|
|
395
|
+
className: "document-viewer-xml",
|
|
396
|
+
children: r
|
|
397
|
+
});
|
|
398
|
+
} catch (r) {
|
|
399
|
+
return /* @__PURE__ */ n(R, {
|
|
400
|
+
fileContent: e,
|
|
401
|
+
fileSize: i,
|
|
402
|
+
url: s,
|
|
403
|
+
fileName: t
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
}, C = ({
|
|
407
|
+
fileContent: e,
|
|
408
|
+
fileSize: i,
|
|
409
|
+
url: s,
|
|
410
|
+
fileName: t
|
|
411
|
+
}) => {
|
|
412
|
+
if (!(e != null && e.content))
|
|
413
|
+
return null;
|
|
414
|
+
const r = B(() => t ? _(t) : _(s), [t, s]) || "text";
|
|
415
|
+
if ((i || new Blob([e.content]).size) > b) {
|
|
416
|
+
const u = e.content.split(`
|
|
417
|
+
`), a = u.length > w, p = (a ? u.slice(0, w) : u).join(`
|
|
418
|
+
`);
|
|
419
|
+
return /* @__PURE__ */ v("div", {
|
|
420
|
+
className: "document-viewer-code",
|
|
421
|
+
children: [a && /* @__PURE__ */ n(l, {
|
|
422
|
+
message: "文件过大",
|
|
423
|
+
description: `文件包含 ${u.length} 行,仅显示前 ${w} 行。请下载完整文件查看。`,
|
|
424
|
+
type: "warning",
|
|
425
|
+
showIcon: !0,
|
|
426
|
+
style: {
|
|
427
|
+
marginBottom: 16,
|
|
428
|
+
flexShrink: 0
|
|
429
|
+
},
|
|
430
|
+
action: /* @__PURE__ */ n(d, {
|
|
431
|
+
url: s,
|
|
432
|
+
fileName: t
|
|
433
|
+
})
|
|
434
|
+
}), /* @__PURE__ */ n("div", {
|
|
435
|
+
style: {
|
|
436
|
+
overflow: "auto",
|
|
437
|
+
flex: 1
|
|
438
|
+
},
|
|
439
|
+
children: /* @__PURE__ */ n("pre", {
|
|
440
|
+
className: "document-viewer-text",
|
|
441
|
+
style: {
|
|
442
|
+
fontSize: "12px"
|
|
443
|
+
},
|
|
444
|
+
children: p
|
|
445
|
+
})
|
|
446
|
+
})]
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
return /* @__PURE__ */ n("div", {
|
|
450
|
+
className: "document-viewer-code",
|
|
451
|
+
children: /* @__PURE__ */ n("div", {
|
|
452
|
+
style: {
|
|
453
|
+
overflow: "auto",
|
|
454
|
+
flex: 1
|
|
455
|
+
},
|
|
456
|
+
children: /* @__PURE__ */ n(N, {
|
|
457
|
+
language: r,
|
|
458
|
+
wrapLongLines: !0,
|
|
459
|
+
showLineNumbers: !0,
|
|
460
|
+
PreTag: "div",
|
|
461
|
+
children: e.content
|
|
462
|
+
})
|
|
463
|
+
})
|
|
464
|
+
});
|
|
465
|
+
};
|
|
466
|
+
export {
|
|
467
|
+
C as CodeRenderer,
|
|
468
|
+
F as CsvRenderer,
|
|
469
|
+
U as HtmlRenderer,
|
|
470
|
+
Y as JsonRenderer,
|
|
471
|
+
q as JsonlRenderer,
|
|
472
|
+
Q as MarkdownRenderer,
|
|
473
|
+
R as TextRenderer,
|
|
474
|
+
K as TsvRenderer,
|
|
475
|
+
f as XmlRenderer
|
|
476
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { Image as i } from "antd";
|
|
3
|
+
const c = ({
|
|
4
|
+
url: r,
|
|
5
|
+
fileName: d
|
|
6
|
+
}) => /* @__PURE__ */ e("div", {
|
|
7
|
+
className: "document-viewer-image",
|
|
8
|
+
children: /* @__PURE__ */ e(i, {
|
|
9
|
+
src: r,
|
|
10
|
+
alt: d || "Image"
|
|
11
|
+
})
|
|
12
|
+
}), n = ({
|
|
13
|
+
url: r
|
|
14
|
+
}) => /* @__PURE__ */ e("div", {
|
|
15
|
+
className: "document-viewer-video",
|
|
16
|
+
children: /* @__PURE__ */ e("video", {
|
|
17
|
+
src: r,
|
|
18
|
+
controls: !0,
|
|
19
|
+
style: {
|
|
20
|
+
maxWidth: "100%"
|
|
21
|
+
},
|
|
22
|
+
children: "您的浏览器不支持视频播放"
|
|
23
|
+
})
|
|
24
|
+
}), s = ({
|
|
25
|
+
url: r
|
|
26
|
+
}) => /* @__PURE__ */ e("div", {
|
|
27
|
+
className: "document-viewer-audio",
|
|
28
|
+
children: /* @__PURE__ */ e("audio", {
|
|
29
|
+
src: r,
|
|
30
|
+
controls: !0,
|
|
31
|
+
style: {
|
|
32
|
+
width: "100%"
|
|
33
|
+
},
|
|
34
|
+
children: "您的浏览器不支持音频播放"
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
export {
|
|
38
|
+
s as AudioRenderer,
|
|
39
|
+
c as ImageRenderer,
|
|
40
|
+
n as VideoRenderer
|
|
41
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { Spin as m, Alert as n } from "antd";
|
|
3
|
+
import { DownloadButton as s } from "./DownloadButton.mjs";
|
|
4
|
+
const u = ({
|
|
5
|
+
pdfBlobUrl: r,
|
|
6
|
+
pdfLoading: c,
|
|
7
|
+
pdfError: i,
|
|
8
|
+
url: t,
|
|
9
|
+
fileName: o
|
|
10
|
+
}) => c ? /* @__PURE__ */ e("div", {
|
|
11
|
+
className: "document-viewer-loading",
|
|
12
|
+
children: /* @__PURE__ */ e(m, {
|
|
13
|
+
size: "large",
|
|
14
|
+
tip: "加载 PDF 中..."
|
|
15
|
+
})
|
|
16
|
+
}) : i ? /* @__PURE__ */ e(n, {
|
|
17
|
+
message: "PDF 加载失败",
|
|
18
|
+
description: i,
|
|
19
|
+
type: "error",
|
|
20
|
+
showIcon: !0,
|
|
21
|
+
action: /* @__PURE__ */ e(s, {
|
|
22
|
+
url: t,
|
|
23
|
+
fileName: o
|
|
24
|
+
})
|
|
25
|
+
}) : r ? /* @__PURE__ */ e("div", {
|
|
26
|
+
className: "document-viewer-pdf",
|
|
27
|
+
children: /* @__PURE__ */ e("iframe", {
|
|
28
|
+
src: r,
|
|
29
|
+
className: "document-viewer-iframe",
|
|
30
|
+
title: "PDF Preview"
|
|
31
|
+
})
|
|
32
|
+
}) : /* @__PURE__ */ e(n, {
|
|
33
|
+
message: "PDF 加载失败",
|
|
34
|
+
description: "无法创建 PDF 预览",
|
|
35
|
+
type: "error",
|
|
36
|
+
showIcon: !0,
|
|
37
|
+
action: /* @__PURE__ */ e(s, {
|
|
38
|
+
url: t,
|
|
39
|
+
fileName: o
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
export {
|
|
43
|
+
u as PdfRenderer
|
|
44
|
+
};
|