@glodon-aiot/react-components 3.11.0-snapshot.1765331441 → 3.11.0-snapshot.1765331448
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/es/components/DocumentViewer/components/ErrorAlert.mjs +11 -10
- package/dist/es/components/DocumentViewer/components/FileRenderers.mjs +113 -103
- package/dist/es/components/DocumentViewer/components/MediaRenderers.mjs +7 -2
- package/dist/es/components/DocumentViewer/components/ZipRenderer.mjs +30 -23
- package/dist/es/components/DocumentViewer/hooks/useZipViewer.mjs +62 -60
- package/dist/es/components/DocumentViewer/index.mjs +274 -160
- package/dist/es/index.mjs +1 -1
- package/dist/es/utils/file.mjs +6 -6
- package/dist/lib/index.js +10 -10
- package/dist/src/components/DocumentViewer/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { Alert as i, Button as
|
|
3
|
-
import { DownloadOutlined as
|
|
4
|
-
const
|
|
5
|
-
message:
|
|
6
|
-
description:
|
|
2
|
+
import { Alert as i, Button as a } from "antd";
|
|
3
|
+
import { DownloadOutlined as c } from "@ant-design/icons";
|
|
4
|
+
const p = ({
|
|
5
|
+
message: e,
|
|
6
|
+
description: t,
|
|
7
7
|
action: n,
|
|
8
8
|
url: o,
|
|
9
9
|
fileName: l
|
|
10
10
|
}) => /* @__PURE__ */ r(i, {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
className: "document-viewer-alert-full",
|
|
12
|
+
message: e,
|
|
13
|
+
description: t,
|
|
13
14
|
type: "error",
|
|
14
15
|
showIcon: !0,
|
|
15
|
-
action: n || (o ? /* @__PURE__ */ r(
|
|
16
|
+
action: n || (o ? /* @__PURE__ */ r(a, {
|
|
16
17
|
type: "link",
|
|
17
|
-
icon: /* @__PURE__ */ r(
|
|
18
|
+
icon: /* @__PURE__ */ r(c, {}),
|
|
18
19
|
href: o,
|
|
19
20
|
download: l,
|
|
20
21
|
target: "_blank",
|
|
@@ -23,5 +24,5 @@ const u = ({
|
|
|
23
24
|
}) : null)
|
|
24
25
|
});
|
|
25
26
|
export {
|
|
26
|
-
|
|
27
|
+
p as ErrorAlert
|
|
27
28
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as x, jsx as n } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo as B } from "react";
|
|
3
|
-
import { Alert as
|
|
4
|
-
import { Prism as
|
|
5
|
-
import { Markdown as
|
|
6
|
-
import { getFileExtension as
|
|
7
|
-
import { MAX_DISPLAY_SIZE as
|
|
8
|
-
import { DownloadButton as
|
|
3
|
+
import { Alert as d, Table as _ } from "antd";
|
|
4
|
+
import { Prism as b } from "react-syntax-highlighter";
|
|
5
|
+
import { Markdown as N } from "../../Markdown/index.mjs";
|
|
6
|
+
import { getFileExtension as z } from "../../../utils/file.mjs";
|
|
7
|
+
import { MAX_DISPLAY_SIZE as T, MAX_DISPLAY_LINES as w, MAX_JSON_SIZE as $, MAX_CSV_SIZE as A, MAX_CSV_ROWS as S, MAX_TSV_SIZE as J, MAX_JSONL_SIZE as O, MAX_JSONL_LINES as L, MAX_MARKDOWN_SIZE as X, MAX_XML_SIZE as E, MAX_HIGHLIGHT_SIZE as k } from "../constants.mjs";
|
|
8
|
+
import { DownloadButton as l } from "./DownloadButton.mjs";
|
|
9
9
|
const R = ({
|
|
10
10
|
fileContent: e,
|
|
11
11
|
fileSize: i,
|
|
@@ -14,18 +14,18 @@ const R = ({
|
|
|
14
14
|
}) => {
|
|
15
15
|
if (!(e != null && e.content))
|
|
16
16
|
return null;
|
|
17
|
-
if ((i || new Blob([e.content]).size) >
|
|
17
|
+
if ((i || new Blob([e.content]).size) > T) {
|
|
18
18
|
const r = e.content.split(`
|
|
19
19
|
`), m = r.length > w, a = (m ? r.slice(0, w) : r).join(`
|
|
20
20
|
`);
|
|
21
|
-
return /* @__PURE__ */
|
|
21
|
+
return /* @__PURE__ */ x("div", {
|
|
22
22
|
style: {
|
|
23
23
|
display: "flex",
|
|
24
24
|
flexDirection: "column",
|
|
25
25
|
height: "100%",
|
|
26
26
|
overflow: "hidden"
|
|
27
27
|
},
|
|
28
|
-
children: [m && /* @__PURE__ */ n(
|
|
28
|
+
children: [m && /* @__PURE__ */ n(d, {
|
|
29
29
|
message: "文件过大",
|
|
30
30
|
description: `文件包含 ${r.length} 行,仅显示前 ${w} 行。请下载完整文件查看。`,
|
|
31
31
|
type: "warning",
|
|
@@ -34,7 +34,7 @@ const R = ({
|
|
|
34
34
|
marginBottom: 16,
|
|
35
35
|
flexShrink: 0
|
|
36
36
|
},
|
|
37
|
-
action: /* @__PURE__ */ n(
|
|
37
|
+
action: /* @__PURE__ */ n(l, {
|
|
38
38
|
url: s,
|
|
39
39
|
fileName: t
|
|
40
40
|
})
|
|
@@ -56,14 +56,14 @@ const R = ({
|
|
|
56
56
|
}) => {
|
|
57
57
|
if (!(e != null && e.content))
|
|
58
58
|
return null;
|
|
59
|
-
const
|
|
60
|
-
if (
|
|
61
|
-
return /* @__PURE__ */ n(
|
|
59
|
+
const o = i || new Blob([e.content]).size;
|
|
60
|
+
if (o > $)
|
|
61
|
+
return /* @__PURE__ */ n(d, {
|
|
62
62
|
message: "JSON文件过大",
|
|
63
|
-
description: `文件大小 ${Math.round(
|
|
63
|
+
description: `文件大小 ${Math.round(o / 1024 / 1024)}MB,无法预览。请下载后查看。`,
|
|
64
64
|
type: "warning",
|
|
65
65
|
showIcon: !0,
|
|
66
|
-
action: /* @__PURE__ */ n(
|
|
66
|
+
action: /* @__PURE__ */ n(l, {
|
|
67
67
|
url: s,
|
|
68
68
|
fileName: t
|
|
69
69
|
})
|
|
@@ -75,11 +75,11 @@ const R = ({
|
|
|
75
75
|
children: JSON.stringify(r, null, 2)
|
|
76
76
|
});
|
|
77
77
|
} catch (r) {
|
|
78
|
-
return /* @__PURE__ */ n(
|
|
78
|
+
return /* @__PURE__ */ n(d, {
|
|
79
79
|
message: "JSON解析失败",
|
|
80
80
|
description: "文件内容不是有效的JSON格式",
|
|
81
81
|
type: "error",
|
|
82
|
-
action: /* @__PURE__ */ n(
|
|
82
|
+
action: /* @__PURE__ */ n(l, {
|
|
83
83
|
url: s,
|
|
84
84
|
fileName: t
|
|
85
85
|
})
|
|
@@ -93,52 +93,52 @@ const R = ({
|
|
|
93
93
|
}) => {
|
|
94
94
|
if (!(e != null && e.content))
|
|
95
95
|
return null;
|
|
96
|
-
const
|
|
97
|
-
if (
|
|
98
|
-
return /* @__PURE__ */ n(
|
|
96
|
+
const o = i || new Blob([e.content]).size;
|
|
97
|
+
if (o > A)
|
|
98
|
+
return /* @__PURE__ */ n(d, {
|
|
99
99
|
message: "CSV文件过大",
|
|
100
|
-
description: `文件大小 ${Math.round(
|
|
100
|
+
description: `文件大小 ${Math.round(o / 1024 / 1024)}MB,无法预览。请下载后查看。`,
|
|
101
101
|
type: "warning",
|
|
102
102
|
showIcon: !0,
|
|
103
|
-
action: /* @__PURE__ */ n(
|
|
103
|
+
action: /* @__PURE__ */ n(l, {
|
|
104
104
|
url: s,
|
|
105
105
|
fileName: t
|
|
106
106
|
})
|
|
107
107
|
});
|
|
108
108
|
try {
|
|
109
109
|
const r = e.content.split(`
|
|
110
|
-
`).filter((
|
|
110
|
+
`).filter((c) => c.trim());
|
|
111
111
|
if (r.length === 0)
|
|
112
112
|
return null;
|
|
113
|
-
const m = r.length >
|
|
114
|
-
const M =
|
|
115
|
-
key: String(
|
|
113
|
+
const m = r.length > S, u = m ? r.slice(0, S) : r, a = u[0].split(",").map((c) => c.trim()), p = u.slice(1).map((c, v) => {
|
|
114
|
+
const M = c.split(",").map((g) => g.trim()), y = {
|
|
115
|
+
key: String(v)
|
|
116
116
|
};
|
|
117
117
|
return a.forEach((g, I) => {
|
|
118
|
-
|
|
119
|
-
}),
|
|
120
|
-
}),
|
|
121
|
-
title:
|
|
122
|
-
dataIndex:
|
|
123
|
-
key:
|
|
118
|
+
y[g] = M[I] || "";
|
|
119
|
+
}), y;
|
|
120
|
+
}), h = a.map((c) => ({
|
|
121
|
+
title: c,
|
|
122
|
+
dataIndex: c,
|
|
123
|
+
key: c
|
|
124
124
|
}));
|
|
125
|
-
return /* @__PURE__ */
|
|
125
|
+
return /* @__PURE__ */ x("div", {
|
|
126
126
|
style: {
|
|
127
127
|
display: "flex",
|
|
128
128
|
flexDirection: "column",
|
|
129
129
|
height: "100%",
|
|
130
130
|
overflow: "hidden"
|
|
131
131
|
},
|
|
132
|
-
children: [m && /* @__PURE__ */ n(
|
|
132
|
+
children: [m && /* @__PURE__ */ n(d, {
|
|
133
133
|
message: "文件过大",
|
|
134
|
-
description: `CSV文件包含 ${r.length} 行,仅显示前 ${
|
|
134
|
+
description: `CSV文件包含 ${r.length} 行,仅显示前 ${S} 行。请下载完整文件查看。`,
|
|
135
135
|
type: "warning",
|
|
136
136
|
showIcon: !0,
|
|
137
137
|
style: {
|
|
138
138
|
marginBottom: 16,
|
|
139
139
|
flexShrink: 0
|
|
140
140
|
},
|
|
141
|
-
action: /* @__PURE__ */ n(
|
|
141
|
+
action: /* @__PURE__ */ n(l, {
|
|
142
142
|
url: s,
|
|
143
143
|
fileName: t
|
|
144
144
|
})
|
|
@@ -148,9 +148,9 @@ const R = ({
|
|
|
148
148
|
overflow: "auto",
|
|
149
149
|
minHeight: 0
|
|
150
150
|
},
|
|
151
|
-
children: /* @__PURE__ */ n(
|
|
152
|
-
dataSource:
|
|
153
|
-
columns:
|
|
151
|
+
children: /* @__PURE__ */ n(_, {
|
|
152
|
+
dataSource: p,
|
|
153
|
+
columns: h,
|
|
154
154
|
pagination: !1,
|
|
155
155
|
scroll: {
|
|
156
156
|
x: "max-content",
|
|
@@ -161,11 +161,11 @@ const R = ({
|
|
|
161
161
|
})]
|
|
162
162
|
});
|
|
163
163
|
} catch (r) {
|
|
164
|
-
return /* @__PURE__ */ n(
|
|
164
|
+
return /* @__PURE__ */ n(d, {
|
|
165
165
|
message: "CSV解析失败",
|
|
166
166
|
description: "文件内容不是有效的CSV格式",
|
|
167
167
|
type: "error",
|
|
168
|
-
action: /* @__PURE__ */ n(
|
|
168
|
+
action: /* @__PURE__ */ n(l, {
|
|
169
169
|
url: s,
|
|
170
170
|
fileName: t
|
|
171
171
|
})
|
|
@@ -179,52 +179,52 @@ const R = ({
|
|
|
179
179
|
}) => {
|
|
180
180
|
if (!(e != null && e.content))
|
|
181
181
|
return null;
|
|
182
|
-
const
|
|
183
|
-
if (
|
|
184
|
-
return /* @__PURE__ */ n(
|
|
182
|
+
const o = i || new Blob([e.content]).size;
|
|
183
|
+
if (o > J)
|
|
184
|
+
return /* @__PURE__ */ n(d, {
|
|
185
185
|
message: "TSV文件过大",
|
|
186
|
-
description: `文件大小 ${Math.round(
|
|
186
|
+
description: `文件大小 ${Math.round(o / 1024 / 1024)}MB,无法预览。请下载后查看。`,
|
|
187
187
|
type: "warning",
|
|
188
188
|
showIcon: !0,
|
|
189
|
-
action: /* @__PURE__ */ n(
|
|
189
|
+
action: /* @__PURE__ */ n(l, {
|
|
190
190
|
url: s,
|
|
191
191
|
fileName: t
|
|
192
192
|
})
|
|
193
193
|
});
|
|
194
194
|
try {
|
|
195
195
|
const r = e.content.split(`
|
|
196
|
-
`).filter((
|
|
196
|
+
`).filter((c) => c.trim());
|
|
197
197
|
if (r.length === 0)
|
|
198
198
|
return null;
|
|
199
|
-
const m = r.length >
|
|
200
|
-
const M =
|
|
201
|
-
key: String(
|
|
199
|
+
const m = r.length > S, u = m ? r.slice(0, S) : r, a = u[0].split(" ").map((c) => c.trim()), p = u.slice(1).map((c, v) => {
|
|
200
|
+
const M = c.split(" ").map((g) => g.trim()), y = {
|
|
201
|
+
key: String(v)
|
|
202
202
|
};
|
|
203
203
|
return a.forEach((g, I) => {
|
|
204
|
-
|
|
205
|
-
}),
|
|
206
|
-
}),
|
|
207
|
-
title:
|
|
208
|
-
dataIndex:
|
|
209
|
-
key:
|
|
204
|
+
y[g] = M[I] || "";
|
|
205
|
+
}), y;
|
|
206
|
+
}), h = a.map((c) => ({
|
|
207
|
+
title: c,
|
|
208
|
+
dataIndex: c,
|
|
209
|
+
key: c
|
|
210
210
|
}));
|
|
211
|
-
return /* @__PURE__ */
|
|
211
|
+
return /* @__PURE__ */ x("div", {
|
|
212
212
|
style: {
|
|
213
213
|
display: "flex",
|
|
214
214
|
flexDirection: "column",
|
|
215
215
|
height: "100%",
|
|
216
216
|
overflow: "hidden"
|
|
217
217
|
},
|
|
218
|
-
children: [m && /* @__PURE__ */ n(
|
|
218
|
+
children: [m && /* @__PURE__ */ n(d, {
|
|
219
219
|
message: "文件过大",
|
|
220
|
-
description: `TSV文件包含 ${r.length} 行,仅显示前 ${
|
|
220
|
+
description: `TSV文件包含 ${r.length} 行,仅显示前 ${S} 行。请下载完整文件查看。`,
|
|
221
221
|
type: "warning",
|
|
222
222
|
showIcon: !0,
|
|
223
223
|
style: {
|
|
224
224
|
marginBottom: 16,
|
|
225
225
|
flexShrink: 0
|
|
226
226
|
},
|
|
227
|
-
action: /* @__PURE__ */ n(
|
|
227
|
+
action: /* @__PURE__ */ n(l, {
|
|
228
228
|
url: s,
|
|
229
229
|
fileName: t
|
|
230
230
|
})
|
|
@@ -234,9 +234,9 @@ const R = ({
|
|
|
234
234
|
overflow: "auto",
|
|
235
235
|
minHeight: 0
|
|
236
236
|
},
|
|
237
|
-
children: /* @__PURE__ */ n(
|
|
238
|
-
dataSource:
|
|
239
|
-
columns:
|
|
237
|
+
children: /* @__PURE__ */ n(_, {
|
|
238
|
+
dataSource: p,
|
|
239
|
+
columns: h,
|
|
240
240
|
pagination: !1,
|
|
241
241
|
scroll: {
|
|
242
242
|
x: "max-content",
|
|
@@ -247,11 +247,11 @@ const R = ({
|
|
|
247
247
|
})]
|
|
248
248
|
});
|
|
249
249
|
} catch (r) {
|
|
250
|
-
return /* @__PURE__ */ n(
|
|
250
|
+
return /* @__PURE__ */ n(d, {
|
|
251
251
|
message: "TSV解析失败",
|
|
252
252
|
description: "文件内容不是有效的TSV格式",
|
|
253
253
|
type: "error",
|
|
254
|
-
action: /* @__PURE__ */ n(
|
|
254
|
+
action: /* @__PURE__ */ n(l, {
|
|
255
255
|
url: s,
|
|
256
256
|
fileName: t
|
|
257
257
|
})
|
|
@@ -265,14 +265,14 @@ const R = ({
|
|
|
265
265
|
}) => {
|
|
266
266
|
if (!(e != null && e.content))
|
|
267
267
|
return null;
|
|
268
|
-
const
|
|
269
|
-
if (
|
|
270
|
-
return /* @__PURE__ */ n(
|
|
268
|
+
const o = i || new Blob([e.content]).size;
|
|
269
|
+
if (o > O)
|
|
270
|
+
return /* @__PURE__ */ n(d, {
|
|
271
271
|
message: "JSONL文件过大",
|
|
272
|
-
description: `文件大小 ${Math.round(
|
|
272
|
+
description: `文件大小 ${Math.round(o / 1024 / 1024)}MB,无法预览。请下载后查看。`,
|
|
273
273
|
type: "warning",
|
|
274
274
|
showIcon: !0,
|
|
275
|
-
action: /* @__PURE__ */ n(
|
|
275
|
+
action: /* @__PURE__ */ n(l, {
|
|
276
276
|
url: s,
|
|
277
277
|
fileName: t
|
|
278
278
|
})
|
|
@@ -280,14 +280,15 @@ const R = ({
|
|
|
280
280
|
try {
|
|
281
281
|
const r = e.content.split(`
|
|
282
282
|
`).filter((a) => a.trim()), m = r.length > L, u = m ? r.slice(0, L) : r;
|
|
283
|
-
return /* @__PURE__ */
|
|
283
|
+
return /* @__PURE__ */ x("div", {
|
|
284
284
|
style: {
|
|
285
285
|
display: "flex",
|
|
286
286
|
flexDirection: "column",
|
|
287
287
|
height: "100%",
|
|
288
|
+
width: "100%",
|
|
288
289
|
overflow: "hidden"
|
|
289
290
|
},
|
|
290
|
-
children: [m && /* @__PURE__ */ n(
|
|
291
|
+
children: [m && /* @__PURE__ */ n(d, {
|
|
291
292
|
message: "文件过大",
|
|
292
293
|
description: `JSONL文件包含 ${r.length} 行,仅显示前 ${L} 行。请下载完整文件查看。`,
|
|
293
294
|
type: "warning",
|
|
@@ -296,38 +297,38 @@ const R = ({
|
|
|
296
297
|
marginBottom: 16,
|
|
297
298
|
flexShrink: 0
|
|
298
299
|
},
|
|
299
|
-
action: /* @__PURE__ */ n(
|
|
300
|
+
action: /* @__PURE__ */ n(l, {
|
|
300
301
|
url: s,
|
|
301
302
|
fileName: t
|
|
302
303
|
})
|
|
303
304
|
}), /* @__PURE__ */ n("div", {
|
|
304
305
|
className: "document-viewer-jsonl",
|
|
305
|
-
children: u.map((a,
|
|
306
|
+
children: u.map((a, p) => {
|
|
306
307
|
try {
|
|
307
|
-
const
|
|
308
|
+
const h = JSON.parse(a);
|
|
308
309
|
return /* @__PURE__ */ n("div", {
|
|
309
310
|
className: "document-viewer-jsonl-item",
|
|
310
311
|
children: /* @__PURE__ */ n("pre", {
|
|
311
|
-
children: JSON.stringify(
|
|
312
|
+
children: JSON.stringify(h, null, 2)
|
|
312
313
|
})
|
|
313
|
-
},
|
|
314
|
-
} catch (
|
|
314
|
+
}, p);
|
|
315
|
+
} catch (h) {
|
|
315
316
|
return /* @__PURE__ */ n("div", {
|
|
316
317
|
className: "document-viewer-jsonl-item",
|
|
317
318
|
children: /* @__PURE__ */ n("pre", {
|
|
318
319
|
children: a
|
|
319
320
|
})
|
|
320
|
-
},
|
|
321
|
+
}, p);
|
|
321
322
|
}
|
|
322
323
|
})
|
|
323
324
|
})]
|
|
324
325
|
});
|
|
325
326
|
} catch (r) {
|
|
326
|
-
return /* @__PURE__ */ n(
|
|
327
|
+
return /* @__PURE__ */ n(d, {
|
|
327
328
|
message: "JSONL解析失败",
|
|
328
329
|
description: "文件内容解析出错",
|
|
329
330
|
type: "error",
|
|
330
|
-
action: /* @__PURE__ */ n(
|
|
331
|
+
action: /* @__PURE__ */ n(l, {
|
|
331
332
|
url: s,
|
|
332
333
|
fileName: t
|
|
333
334
|
})
|
|
@@ -341,13 +342,13 @@ const R = ({
|
|
|
341
342
|
}) => {
|
|
342
343
|
if (!(e != null && e.content))
|
|
343
344
|
return null;
|
|
344
|
-
const
|
|
345
|
-
return
|
|
345
|
+
const o = i || new Blob([e.content]).size;
|
|
346
|
+
return o > X ? /* @__PURE__ */ n(d, {
|
|
346
347
|
message: "Markdown文件过大",
|
|
347
|
-
description: `文件大小 ${Math.round(
|
|
348
|
+
description: `文件大小 ${Math.round(o / 1024 / 1024)}MB,无法预览。请下载后查看。`,
|
|
348
349
|
type: "warning",
|
|
349
350
|
showIcon: !0,
|
|
350
|
-
action: /* @__PURE__ */ n(
|
|
351
|
+
action: /* @__PURE__ */ n(l, {
|
|
351
352
|
url: s,
|
|
352
353
|
fileName: t
|
|
353
354
|
})
|
|
@@ -357,7 +358,7 @@ const R = ({
|
|
|
357
358
|
overflow: "auto",
|
|
358
359
|
padding: "16px"
|
|
359
360
|
},
|
|
360
|
-
children: /* @__PURE__ */ n(
|
|
361
|
+
children: /* @__PURE__ */ n(N, {
|
|
361
362
|
children: e.content
|
|
362
363
|
})
|
|
363
364
|
});
|
|
@@ -376,14 +377,14 @@ const R = ({
|
|
|
376
377
|
}) => {
|
|
377
378
|
if (!(e != null && e.content))
|
|
378
379
|
return null;
|
|
379
|
-
const
|
|
380
|
-
if (
|
|
381
|
-
return /* @__PURE__ */ n(
|
|
380
|
+
const o = i || new Blob([e.content]).size;
|
|
381
|
+
if (o > E)
|
|
382
|
+
return /* @__PURE__ */ n(d, {
|
|
382
383
|
message: "XML文件过大",
|
|
383
|
-
description: `文件大小 ${Math.round(
|
|
384
|
+
description: `文件大小 ${Math.round(o / 1024 / 1024)}MB,无法预览。请下载后查看。`,
|
|
384
385
|
type: "warning",
|
|
385
386
|
showIcon: !0,
|
|
386
|
-
action: /* @__PURE__ */ n(
|
|
387
|
+
action: /* @__PURE__ */ n(l, {
|
|
387
388
|
url: s,
|
|
388
389
|
fileName: t
|
|
389
390
|
})
|
|
@@ -411,14 +412,14 @@ const R = ({
|
|
|
411
412
|
}) => {
|
|
412
413
|
if (!(e != null && e.content))
|
|
413
414
|
return null;
|
|
414
|
-
const r = B(() => t ?
|
|
415
|
-
if ((i || new Blob([e.content]).size) >
|
|
415
|
+
const r = B(() => t ? z(t) : z(s), [t, s]) || "text";
|
|
416
|
+
if ((i || new Blob([e.content]).size) > k) {
|
|
416
417
|
const u = e.content.split(`
|
|
417
|
-
`), a = u.length > w,
|
|
418
|
+
`), a = u.length > w, h = (a ? u.slice(0, w) : u).join(`
|
|
418
419
|
`);
|
|
419
|
-
return /* @__PURE__ */
|
|
420
|
+
return /* @__PURE__ */ x("div", {
|
|
420
421
|
className: "document-viewer-code",
|
|
421
|
-
children: [a && /* @__PURE__ */ n(
|
|
422
|
+
children: [a && /* @__PURE__ */ n(d, {
|
|
422
423
|
message: "文件过大",
|
|
423
424
|
description: `文件包含 ${u.length} 行,仅显示前 ${w} 行。请下载完整文件查看。`,
|
|
424
425
|
type: "warning",
|
|
@@ -427,21 +428,24 @@ const R = ({
|
|
|
427
428
|
marginBottom: 16,
|
|
428
429
|
flexShrink: 0
|
|
429
430
|
},
|
|
430
|
-
action: /* @__PURE__ */ n(
|
|
431
|
+
action: /* @__PURE__ */ n(l, {
|
|
431
432
|
url: s,
|
|
432
433
|
fileName: t
|
|
433
434
|
})
|
|
434
435
|
}), /* @__PURE__ */ n("div", {
|
|
435
436
|
style: {
|
|
436
437
|
overflow: "auto",
|
|
437
|
-
flex: 1
|
|
438
|
+
flex: 1,
|
|
439
|
+
width: "100%"
|
|
438
440
|
},
|
|
439
441
|
children: /* @__PURE__ */ n("pre", {
|
|
440
442
|
className: "document-viewer-text",
|
|
441
443
|
style: {
|
|
442
|
-
fontSize: "12px"
|
|
444
|
+
fontSize: "12px",
|
|
445
|
+
width: "100%",
|
|
446
|
+
boxSizing: "border-box"
|
|
443
447
|
},
|
|
444
|
-
children:
|
|
448
|
+
children: h
|
|
445
449
|
})
|
|
446
450
|
})]
|
|
447
451
|
});
|
|
@@ -451,13 +455,19 @@ const R = ({
|
|
|
451
455
|
children: /* @__PURE__ */ n("div", {
|
|
452
456
|
style: {
|
|
453
457
|
overflow: "auto",
|
|
454
|
-
flex: 1
|
|
458
|
+
flex: 1,
|
|
459
|
+
width: "100%"
|
|
455
460
|
},
|
|
456
|
-
children: /* @__PURE__ */ n(
|
|
461
|
+
children: /* @__PURE__ */ n(b, {
|
|
457
462
|
language: r,
|
|
458
463
|
wrapLongLines: !0,
|
|
459
464
|
showLineNumbers: !0,
|
|
460
465
|
PreTag: "div",
|
|
466
|
+
customStyle: {
|
|
467
|
+
width: "100%",
|
|
468
|
+
margin: 0,
|
|
469
|
+
boxSizing: "border-box"
|
|
470
|
+
},
|
|
461
471
|
children: e.content
|
|
462
472
|
})
|
|
463
473
|
})
|
|
@@ -2,12 +2,17 @@ import { jsx as e } from "react/jsx-runtime";
|
|
|
2
2
|
import { Image as i } from "antd";
|
|
3
3
|
const c = ({
|
|
4
4
|
url: r,
|
|
5
|
-
fileName:
|
|
5
|
+
fileName: t
|
|
6
6
|
}) => /* @__PURE__ */ e("div", {
|
|
7
7
|
className: "document-viewer-image",
|
|
8
8
|
children: /* @__PURE__ */ e(i, {
|
|
9
9
|
src: r,
|
|
10
|
-
alt:
|
|
10
|
+
alt: t || "Image",
|
|
11
|
+
style: {
|
|
12
|
+
maxWidth: "100%",
|
|
13
|
+
maxHeight: "100%",
|
|
14
|
+
objectFit: "contain"
|
|
15
|
+
}
|
|
11
16
|
})
|
|
12
17
|
}), n = ({
|
|
13
18
|
url: r
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { Spin as
|
|
1
|
+
import { jsx as e, jsxs as r } from "react/jsx-runtime";
|
|
2
|
+
import { Spin as m, Alert as d, Table as f } from "antd";
|
|
3
3
|
import h from "../index.mjs";
|
|
4
4
|
import { formatFileSize as p } from "../utils.mjs";
|
|
5
5
|
const v = ({
|
|
6
|
-
zipFiles:
|
|
6
|
+
zipFiles: t,
|
|
7
7
|
zipLoading: a,
|
|
8
|
-
zipError:
|
|
9
|
-
selectedZipFile:
|
|
10
|
-
zipFileContent:
|
|
8
|
+
zipError: i,
|
|
9
|
+
selectedZipFile: n,
|
|
10
|
+
zipFileContent: o,
|
|
11
11
|
onFileClick: s,
|
|
12
12
|
url: c
|
|
13
13
|
}) => a ? /* @__PURE__ */ e("div", {
|
|
14
14
|
className: "document-viewer-loading",
|
|
15
|
-
children: /* @__PURE__ */ e(
|
|
15
|
+
children: /* @__PURE__ */ e(m, {
|
|
16
16
|
size: "large",
|
|
17
17
|
tip: "加载 ZIP 文件..."
|
|
18
18
|
})
|
|
19
|
-
}) :
|
|
19
|
+
}) : i && t.length === 0 ? /* @__PURE__ */ e(d, {
|
|
20
|
+
className: "document-viewer-alert-full",
|
|
20
21
|
message: "ZIP 加载失败",
|
|
21
|
-
description:
|
|
22
|
+
description: i,
|
|
22
23
|
type: "error",
|
|
23
24
|
showIcon: !0,
|
|
24
25
|
action: /* @__PURE__ */ e("a", {
|
|
@@ -27,23 +28,24 @@ const v = ({
|
|
|
27
28
|
rel: "noopener noreferrer",
|
|
28
29
|
children: "下载文件"
|
|
29
30
|
})
|
|
30
|
-
}) : /* @__PURE__ */
|
|
31
|
+
}) : /* @__PURE__ */ r("div", {
|
|
31
32
|
className: "document-viewer-zip",
|
|
32
|
-
children: [
|
|
33
|
+
children: [i && t.length > 0 && /* @__PURE__ */ e(d, {
|
|
34
|
+
className: "document-viewer-alert-full",
|
|
33
35
|
message: "提示",
|
|
34
|
-
description:
|
|
36
|
+
description: i,
|
|
35
37
|
type: "warning",
|
|
36
38
|
showIcon: !0,
|
|
37
39
|
style: {
|
|
38
40
|
marginBottom: 16
|
|
39
41
|
}
|
|
40
|
-
}), /* @__PURE__ */
|
|
42
|
+
}), /* @__PURE__ */ r("div", {
|
|
41
43
|
style: {
|
|
42
44
|
display: "flex",
|
|
43
45
|
height: "100%",
|
|
44
46
|
gap: "16px"
|
|
45
47
|
},
|
|
46
|
-
children: [/* @__PURE__ */
|
|
48
|
+
children: [/* @__PURE__ */ r("div", {
|
|
47
49
|
style: {
|
|
48
50
|
width: "300px",
|
|
49
51
|
borderRight: "1px solid #e8e8e8",
|
|
@@ -51,22 +53,22 @@ const v = ({
|
|
|
51
53
|
display: "flex",
|
|
52
54
|
flexDirection: "column"
|
|
53
55
|
},
|
|
54
|
-
children: [/* @__PURE__ */
|
|
56
|
+
children: [/* @__PURE__ */ r("div", {
|
|
55
57
|
style: {
|
|
56
58
|
padding: "12px",
|
|
57
59
|
fontWeight: "bold",
|
|
58
60
|
borderBottom: "1px solid #e8e8e8",
|
|
59
61
|
flexShrink: 0
|
|
60
62
|
},
|
|
61
|
-
children: ["文件列表 (",
|
|
63
|
+
children: ["文件列表 (", t.length, ")"]
|
|
62
64
|
}), /* @__PURE__ */ e("div", {
|
|
63
65
|
style: {
|
|
64
66
|
flex: 1,
|
|
65
67
|
overflow: "auto",
|
|
66
68
|
minHeight: 0
|
|
67
69
|
},
|
|
68
|
-
children: /* @__PURE__ */ e(
|
|
69
|
-
dataSource:
|
|
70
|
+
children: /* @__PURE__ */ e(f, {
|
|
71
|
+
dataSource: t,
|
|
70
72
|
size: "small",
|
|
71
73
|
pagination: !1,
|
|
72
74
|
scroll: {
|
|
@@ -76,7 +78,7 @@ const v = ({
|
|
|
76
78
|
onClick: () => s(l.name),
|
|
77
79
|
style: {
|
|
78
80
|
cursor: "pointer",
|
|
79
|
-
backgroundColor:
|
|
81
|
+
backgroundColor: n === l.name ? "#e6f7ff" : "transparent"
|
|
80
82
|
}
|
|
81
83
|
}),
|
|
82
84
|
columns: [{
|
|
@@ -104,7 +106,7 @@ const v = ({
|
|
|
104
106
|
display: "flex",
|
|
105
107
|
flexDirection: "column"
|
|
106
108
|
},
|
|
107
|
-
children:
|
|
109
|
+
children: n && o ? /* @__PURE__ */ r("div", {
|
|
108
110
|
style: {
|
|
109
111
|
display: "flex",
|
|
110
112
|
flexDirection: "column",
|
|
@@ -117,7 +119,7 @@ const v = ({
|
|
|
117
119
|
fontWeight: "bold",
|
|
118
120
|
flexShrink: 0
|
|
119
121
|
},
|
|
120
|
-
children:
|
|
122
|
+
children: o.name
|
|
121
123
|
}), /* @__PURE__ */ e("div", {
|
|
122
124
|
style: {
|
|
123
125
|
flex: 1,
|
|
@@ -125,8 +127,13 @@ const v = ({
|
|
|
125
127
|
padding: "16px"
|
|
126
128
|
},
|
|
127
129
|
children: /* @__PURE__ */ e(h, {
|
|
128
|
-
url:
|
|
129
|
-
fileName:
|
|
130
|
+
url: o.blobUrl,
|
|
131
|
+
fileName: o.name,
|
|
132
|
+
showToolbar: !1,
|
|
133
|
+
style: {
|
|
134
|
+
height: "100%",
|
|
135
|
+
width: "100%"
|
|
136
|
+
}
|
|
130
137
|
})
|
|
131
138
|
})]
|
|
132
139
|
}) : /* @__PURE__ */ e("div", {
|