@glodon-aiot/react-components 3.11.0-snapshot.1765331441 → 3.11.0-snapshot.1765331443
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 +112 -103
- package/dist/es/components/DocumentViewer/components/MediaRenderers.mjs +7 -2
- package/dist/es/components/DocumentViewer/components/ZipRenderer.mjs +16 -14
- 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,14 @@ 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
288
|
overflow: "hidden"
|
|
289
289
|
},
|
|
290
|
-
children: [m && /* @__PURE__ */ n(
|
|
290
|
+
children: [m && /* @__PURE__ */ n(d, {
|
|
291
291
|
message: "文件过大",
|
|
292
292
|
description: `JSONL文件包含 ${r.length} 行,仅显示前 ${L} 行。请下载完整文件查看。`,
|
|
293
293
|
type: "warning",
|
|
@@ -296,38 +296,38 @@ const R = ({
|
|
|
296
296
|
marginBottom: 16,
|
|
297
297
|
flexShrink: 0
|
|
298
298
|
},
|
|
299
|
-
action: /* @__PURE__ */ n(
|
|
299
|
+
action: /* @__PURE__ */ n(l, {
|
|
300
300
|
url: s,
|
|
301
301
|
fileName: t
|
|
302
302
|
})
|
|
303
303
|
}), /* @__PURE__ */ n("div", {
|
|
304
304
|
className: "document-viewer-jsonl",
|
|
305
|
-
children: u.map((a,
|
|
305
|
+
children: u.map((a, p) => {
|
|
306
306
|
try {
|
|
307
|
-
const
|
|
307
|
+
const h = JSON.parse(a);
|
|
308
308
|
return /* @__PURE__ */ n("div", {
|
|
309
309
|
className: "document-viewer-jsonl-item",
|
|
310
310
|
children: /* @__PURE__ */ n("pre", {
|
|
311
|
-
children: JSON.stringify(
|
|
311
|
+
children: JSON.stringify(h, null, 2)
|
|
312
312
|
})
|
|
313
|
-
},
|
|
314
|
-
} catch (
|
|
313
|
+
}, p);
|
|
314
|
+
} catch (h) {
|
|
315
315
|
return /* @__PURE__ */ n("div", {
|
|
316
316
|
className: "document-viewer-jsonl-item",
|
|
317
317
|
children: /* @__PURE__ */ n("pre", {
|
|
318
318
|
children: a
|
|
319
319
|
})
|
|
320
|
-
},
|
|
320
|
+
}, p);
|
|
321
321
|
}
|
|
322
322
|
})
|
|
323
323
|
})]
|
|
324
324
|
});
|
|
325
325
|
} catch (r) {
|
|
326
|
-
return /* @__PURE__ */ n(
|
|
326
|
+
return /* @__PURE__ */ n(d, {
|
|
327
327
|
message: "JSONL解析失败",
|
|
328
328
|
description: "文件内容解析出错",
|
|
329
329
|
type: "error",
|
|
330
|
-
action: /* @__PURE__ */ n(
|
|
330
|
+
action: /* @__PURE__ */ n(l, {
|
|
331
331
|
url: s,
|
|
332
332
|
fileName: t
|
|
333
333
|
})
|
|
@@ -341,13 +341,13 @@ const R = ({
|
|
|
341
341
|
}) => {
|
|
342
342
|
if (!(e != null && e.content))
|
|
343
343
|
return null;
|
|
344
|
-
const
|
|
345
|
-
return
|
|
344
|
+
const o = i || new Blob([e.content]).size;
|
|
345
|
+
return o > X ? /* @__PURE__ */ n(d, {
|
|
346
346
|
message: "Markdown文件过大",
|
|
347
|
-
description: `文件大小 ${Math.round(
|
|
347
|
+
description: `文件大小 ${Math.round(o / 1024 / 1024)}MB,无法预览。请下载后查看。`,
|
|
348
348
|
type: "warning",
|
|
349
349
|
showIcon: !0,
|
|
350
|
-
action: /* @__PURE__ */ n(
|
|
350
|
+
action: /* @__PURE__ */ n(l, {
|
|
351
351
|
url: s,
|
|
352
352
|
fileName: t
|
|
353
353
|
})
|
|
@@ -357,7 +357,7 @@ const R = ({
|
|
|
357
357
|
overflow: "auto",
|
|
358
358
|
padding: "16px"
|
|
359
359
|
},
|
|
360
|
-
children: /* @__PURE__ */ n(
|
|
360
|
+
children: /* @__PURE__ */ n(N, {
|
|
361
361
|
children: e.content
|
|
362
362
|
})
|
|
363
363
|
});
|
|
@@ -376,14 +376,14 @@ const R = ({
|
|
|
376
376
|
}) => {
|
|
377
377
|
if (!(e != null && e.content))
|
|
378
378
|
return null;
|
|
379
|
-
const
|
|
380
|
-
if (
|
|
381
|
-
return /* @__PURE__ */ n(
|
|
379
|
+
const o = i || new Blob([e.content]).size;
|
|
380
|
+
if (o > E)
|
|
381
|
+
return /* @__PURE__ */ n(d, {
|
|
382
382
|
message: "XML文件过大",
|
|
383
|
-
description: `文件大小 ${Math.round(
|
|
383
|
+
description: `文件大小 ${Math.round(o / 1024 / 1024)}MB,无法预览。请下载后查看。`,
|
|
384
384
|
type: "warning",
|
|
385
385
|
showIcon: !0,
|
|
386
|
-
action: /* @__PURE__ */ n(
|
|
386
|
+
action: /* @__PURE__ */ n(l, {
|
|
387
387
|
url: s,
|
|
388
388
|
fileName: t
|
|
389
389
|
})
|
|
@@ -411,14 +411,14 @@ const R = ({
|
|
|
411
411
|
}) => {
|
|
412
412
|
if (!(e != null && e.content))
|
|
413
413
|
return null;
|
|
414
|
-
const r = B(() => t ?
|
|
415
|
-
if ((i || new Blob([e.content]).size) >
|
|
414
|
+
const r = B(() => t ? z(t) : z(s), [t, s]) || "text";
|
|
415
|
+
if ((i || new Blob([e.content]).size) > k) {
|
|
416
416
|
const u = e.content.split(`
|
|
417
|
-
`), a = u.length > w,
|
|
417
|
+
`), a = u.length > w, h = (a ? u.slice(0, w) : u).join(`
|
|
418
418
|
`);
|
|
419
|
-
return /* @__PURE__ */
|
|
419
|
+
return /* @__PURE__ */ x("div", {
|
|
420
420
|
className: "document-viewer-code",
|
|
421
|
-
children: [a && /* @__PURE__ */ n(
|
|
421
|
+
children: [a && /* @__PURE__ */ n(d, {
|
|
422
422
|
message: "文件过大",
|
|
423
423
|
description: `文件包含 ${u.length} 行,仅显示前 ${w} 行。请下载完整文件查看。`,
|
|
424
424
|
type: "warning",
|
|
@@ -427,21 +427,24 @@ const R = ({
|
|
|
427
427
|
marginBottom: 16,
|
|
428
428
|
flexShrink: 0
|
|
429
429
|
},
|
|
430
|
-
action: /* @__PURE__ */ n(
|
|
430
|
+
action: /* @__PURE__ */ n(l, {
|
|
431
431
|
url: s,
|
|
432
432
|
fileName: t
|
|
433
433
|
})
|
|
434
434
|
}), /* @__PURE__ */ n("div", {
|
|
435
435
|
style: {
|
|
436
436
|
overflow: "auto",
|
|
437
|
-
flex: 1
|
|
437
|
+
flex: 1,
|
|
438
|
+
width: "100%"
|
|
438
439
|
},
|
|
439
440
|
children: /* @__PURE__ */ n("pre", {
|
|
440
441
|
className: "document-viewer-text",
|
|
441
442
|
style: {
|
|
442
|
-
fontSize: "12px"
|
|
443
|
+
fontSize: "12px",
|
|
444
|
+
width: "100%",
|
|
445
|
+
boxSizing: "border-box"
|
|
443
446
|
},
|
|
444
|
-
children:
|
|
447
|
+
children: h
|
|
445
448
|
})
|
|
446
449
|
})]
|
|
447
450
|
});
|
|
@@ -451,13 +454,19 @@ const R = ({
|
|
|
451
454
|
children: /* @__PURE__ */ n("div", {
|
|
452
455
|
style: {
|
|
453
456
|
overflow: "auto",
|
|
454
|
-
flex: 1
|
|
457
|
+
flex: 1,
|
|
458
|
+
width: "100%"
|
|
455
459
|
},
|
|
456
|
-
children: /* @__PURE__ */ n(
|
|
460
|
+
children: /* @__PURE__ */ n(b, {
|
|
457
461
|
language: r,
|
|
458
462
|
wrapLongLines: !0,
|
|
459
463
|
showLineNumbers: !0,
|
|
460
464
|
PreTag: "div",
|
|
465
|
+
customStyle: {
|
|
466
|
+
width: "100%",
|
|
467
|
+
margin: 0,
|
|
468
|
+
boxSizing: "border-box"
|
|
469
|
+
},
|
|
461
470
|
children: e.content
|
|
462
471
|
})
|
|
463
472
|
})
|
|
@@ -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,9 +1,9 @@
|
|
|
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: i,
|
|
7
7
|
zipLoading: a,
|
|
8
8
|
zipError: t,
|
|
9
9
|
selectedZipFile: o,
|
|
@@ -12,11 +12,12 @@ const v = ({
|
|
|
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
|
-
}) : t &&
|
|
19
|
+
}) : t && i.length === 0 ? /* @__PURE__ */ e(d, {
|
|
20
|
+
className: "document-viewer-alert-full",
|
|
20
21
|
message: "ZIP 加载失败",
|
|
21
22
|
description: t,
|
|
22
23
|
type: "error",
|
|
@@ -27,9 +28,10 @@ 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: [t &&
|
|
33
|
+
children: [t && i.length > 0 && /* @__PURE__ */ e(d, {
|
|
34
|
+
className: "document-viewer-alert-full",
|
|
33
35
|
message: "提示",
|
|
34
36
|
description: t,
|
|
35
37
|
type: "warning",
|
|
@@ -37,13 +39,13 @@ const v = ({
|
|
|
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: ["文件列表 (", i.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: i,
|
|
70
72
|
size: "small",
|
|
71
73
|
pagination: !1,
|
|
72
74
|
scroll: {
|
|
@@ -104,7 +106,7 @@ const v = ({
|
|
|
104
106
|
display: "flex",
|
|
105
107
|
flexDirection: "column"
|
|
106
108
|
},
|
|
107
|
-
children: o && n ? /* @__PURE__ */
|
|
109
|
+
children: o && n ? /* @__PURE__ */ r("div", {
|
|
108
110
|
style: {
|
|
109
111
|
display: "flex",
|
|
110
112
|
flexDirection: "column",
|