@glodon-aiot/react-components 3.11.1-shapshot.1765331459 → 3.13.0-alpha.27

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.
Files changed (38) hide show
  1. package/dist/es/ImageMap/index.mjs +2 -3
  2. package/dist/es/index.mjs +38 -41
  3. package/dist/lib/index.js +2 -10
  4. package/dist/src/index.d.ts +0 -1
  5. package/package.json +12 -24
  6. package/dist/aiot-react-components.js +0 -20191
  7. package/dist/aiot-react-components.umd.cjs +0 -183
  8. package/dist/es/components/DocumentViewer/components/DownloadButton.mjs +0 -18
  9. package/dist/es/components/DocumentViewer/components/ErrorAlert.mjs +0 -28
  10. package/dist/es/components/DocumentViewer/components/FileRenderers.mjs +0 -486
  11. package/dist/es/components/DocumentViewer/components/MediaRenderers.mjs +0 -46
  12. package/dist/es/components/DocumentViewer/components/PDFViewer/index.mjs +0 -62
  13. package/dist/es/components/DocumentViewer/components/PDFViewer/style.less.mjs +0 -4
  14. package/dist/es/components/DocumentViewer/components/ZipRenderer.mjs +0 -154
  15. package/dist/es/components/DocumentViewer/constants.mjs +0 -21
  16. package/dist/es/components/DocumentViewer/hooks/useZipViewer.mjs +0 -153
  17. package/dist/es/components/DocumentViewer/index.mjs +0 -367
  18. package/dist/es/components/DocumentViewer/style.less.mjs +0 -4
  19. package/dist/es/components/DocumentViewer/utils.mjs +0 -96
  20. package/dist/es/node_modules/@react-pdf-viewer/open/lib/styles/index.css.mjs +0 -4
  21. package/dist/es/node_modules/@react-pdf-viewer/toolbar/lib/styles/index.css.mjs +0 -4
  22. package/dist/es/utils/file.mjs +0 -17
  23. package/dist/src/components/DocumentViewer/components/DownloadButton.d.ts +0 -7
  24. package/dist/src/components/DocumentViewer/components/ErrorAlert.d.ts +0 -10
  25. package/dist/src/components/DocumentViewer/components/FileRenderers.d.ts +0 -23
  26. package/dist/src/components/DocumentViewer/components/MediaRenderers.d.ts +0 -9
  27. package/dist/src/components/DocumentViewer/components/PDFViewer/index.d.ts +0 -7
  28. package/dist/src/components/DocumentViewer/components/PdfRenderer.d.ts +0 -11
  29. package/dist/src/components/DocumentViewer/components/ZipRenderer.d.ts +0 -22
  30. package/dist/src/components/DocumentViewer/components/index.d.ts +0 -9
  31. package/dist/src/components/DocumentViewer/constants.d.ts +0 -21
  32. package/dist/src/components/DocumentViewer/hooks/index.d.ts +0 -5
  33. package/dist/src/components/DocumentViewer/hooks/usePdfViewer.d.ts +0 -7
  34. package/dist/src/components/DocumentViewer/hooks/useZipViewer.d.ts +0 -21
  35. package/dist/src/components/DocumentViewer/index.d.ts +0 -11
  36. package/dist/src/components/DocumentViewer/utils.d.ts +0 -23
  37. package/dist/src/utils/file.d.ts +0 -16
  38. package/dist/style.css +0 -1
@@ -1,154 +0,0 @@
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
- import h from "../index.mjs";
4
- import { formatFileSize as p } from "../utils.mjs";
5
- const v = ({
6
- zipFiles: t,
7
- zipLoading: a,
8
- zipError: i,
9
- selectedZipFile: n,
10
- zipFileContent: o,
11
- onFileClick: s,
12
- url: c
13
- }) => a ? /* @__PURE__ */ e("div", {
14
- className: "document-viewer-loading",
15
- children: /* @__PURE__ */ e(m, {
16
- size: "large",
17
- tip: "加载 ZIP 文件..."
18
- })
19
- }) : i && t.length === 0 ? /* @__PURE__ */ e(d, {
20
- className: "document-viewer-alert-full",
21
- message: "ZIP 加载失败",
22
- description: i,
23
- type: "error",
24
- showIcon: !0,
25
- action: /* @__PURE__ */ e("a", {
26
- href: c,
27
- target: "_blank",
28
- rel: "noopener noreferrer",
29
- children: "下载文件"
30
- })
31
- }) : /* @__PURE__ */ r("div", {
32
- className: "document-viewer-zip",
33
- children: [i && t.length > 0 && /* @__PURE__ */ e(d, {
34
- className: "document-viewer-alert-full",
35
- message: "提示",
36
- description: i,
37
- type: "warning",
38
- showIcon: !0,
39
- style: {
40
- marginBottom: 16
41
- }
42
- }), /* @__PURE__ */ r("div", {
43
- style: {
44
- display: "flex",
45
- height: "100%",
46
- gap: "16px"
47
- },
48
- children: [/* @__PURE__ */ r("div", {
49
- style: {
50
- width: "300px",
51
- borderRight: "1px solid #e8e8e8",
52
- overflow: "auto",
53
- display: "flex",
54
- flexDirection: "column"
55
- },
56
- children: [/* @__PURE__ */ r("div", {
57
- style: {
58
- padding: "12px",
59
- fontWeight: "bold",
60
- borderBottom: "1px solid #e8e8e8",
61
- flexShrink: 0
62
- },
63
- children: ["文件列表 (", t.length, ")"]
64
- }), /* @__PURE__ */ e("div", {
65
- style: {
66
- flex: 1,
67
- overflow: "auto",
68
- minHeight: 0
69
- },
70
- children: /* @__PURE__ */ e(f, {
71
- dataSource: t,
72
- size: "small",
73
- pagination: !1,
74
- scroll: {
75
- y: "100%"
76
- },
77
- onRow: (l) => ({
78
- onClick: () => s(l.name),
79
- style: {
80
- cursor: "pointer",
81
- backgroundColor: n === l.name ? "#e6f7ff" : "transparent"
82
- }
83
- }),
84
- columns: [{
85
- title: "文件名",
86
- dataIndex: "name",
87
- key: "name",
88
- ellipsis: !0,
89
- render: (l) => /* @__PURE__ */ e("span", {
90
- title: l,
91
- children: l.split("/").pop()
92
- })
93
- }, {
94
- title: "大小",
95
- dataIndex: "size",
96
- key: "size",
97
- width: 80,
98
- render: (l) => p(l)
99
- }]
100
- })
101
- })]
102
- }), /* @__PURE__ */ e("div", {
103
- style: {
104
- flex: 1,
105
- overflow: "auto",
106
- display: "flex",
107
- flexDirection: "column"
108
- },
109
- children: n && o ? /* @__PURE__ */ r("div", {
110
- style: {
111
- display: "flex",
112
- flexDirection: "column",
113
- height: "100%"
114
- },
115
- children: [/* @__PURE__ */ e("div", {
116
- style: {
117
- padding: "12px",
118
- borderBottom: "1px solid #e8e8e8",
119
- fontWeight: "bold",
120
- flexShrink: 0
121
- },
122
- children: o.name
123
- }), /* @__PURE__ */ e("div", {
124
- style: {
125
- flex: 1,
126
- overflow: "auto",
127
- padding: "16px"
128
- },
129
- children: /* @__PURE__ */ e(h, {
130
- url: o.blobUrl,
131
- fileName: o.name,
132
- showToolbar: !1,
133
- style: {
134
- height: "100%",
135
- width: "100%"
136
- }
137
- })
138
- })]
139
- }) : /* @__PURE__ */ e("div", {
140
- style: {
141
- display: "flex",
142
- alignItems: "center",
143
- justifyContent: "center",
144
- height: "100%",
145
- color: "#999"
146
- },
147
- children: "请从左侧列表中选择文件进行预览"
148
- })
149
- })]
150
- })]
151
- });
152
- export {
153
- v as ZipRenderer
154
- };
@@ -1,21 +0,0 @@
1
- const _ = 5242880, I = 2097152, S = 2097152, o = 5242880, t = 5242880, E = 2097152, s = 2097152, n = 2097152, A = 2097152, c = 104857600, M = 104857600, X = 1e4, Z = 1e4, L = 5e3, e = 1e3, N = 5242880, P = 3e4, F = ["text", "json", "csv", "tsv", "markdown", "html", "xml", "jsonl", "image", "pdf", "code"];
2
- export {
3
- Z as MAX_CSV_ROWS,
4
- o as MAX_CSV_SIZE,
5
- X as MAX_DISPLAY_LINES,
6
- I as MAX_DISPLAY_SIZE,
7
- c as MAX_FALLBACK_SIZE,
8
- _ as MAX_FILE_SIZE,
9
- A as MAX_HIGHLIGHT_SIZE,
10
- L as MAX_JSONL_LINES,
11
- E as MAX_JSONL_SIZE,
12
- S as MAX_JSON_SIZE,
13
- s as MAX_MARKDOWN_SIZE,
14
- t as MAX_TSV_SIZE,
15
- n as MAX_XML_SIZE,
16
- e as MAX_ZIP_FILES,
17
- M as MAX_ZIP_FILE_SIZE,
18
- F as SAFE_FILE_TYPES,
19
- N as ZIP_CHUNK_SIZE,
20
- P as ZIP_ENTRIES_TIMEOUT
21
- };
@@ -1,153 +0,0 @@
1
- var U = (c, Z, f) => new Promise((I, u) => {
2
- var P = (w) => {
3
- try {
4
- E(f.next(w));
5
- } catch (t) {
6
- u(t);
7
- }
8
- }, p = (w) => {
9
- try {
10
- E(f.throw(w));
11
- } catch (t) {
12
- u(t);
13
- }
14
- }, E = (w) => w.done ? I(w.value) : Promise.resolve(w.value).then(P, p);
15
- E((f = f.apply(c, Z)).next());
16
- });
17
- import { useState as h, useEffect as _, useCallback as M } from "react";
18
- import { configure as A, BlobReader as L, ZipReader as R, HttpRangeReader as k, BlobWriter as H } from "@zip.js/zip.js";
19
- import { ZIP_CHUNK_SIZE as O, MAX_FALLBACK_SIZE as y, MAX_ZIP_FILES as m, ZIP_ENTRIES_TIMEOUT as B, MAX_ZIP_FILE_SIZE as C, SAFE_FILE_TYPES as D } from "../constants.mjs";
20
- import { checkRangeSupport as j, getFileSize as v } from "../utils.mjs";
21
- import { getFileExtension as x, getFileType as W } from "../../../utils/file.mjs";
22
- const S = {
23
- filenameEncoding: "utf-8"
24
- }, Q = (c) => {
25
- const [Z, f] = h([]), [I, u] = h(!0), [P, p] = h(null), [E, w] = h(null), [t, T] = h(null);
26
- _(() => {
27
- if (!c) {
28
- p("文件URL不能为空"), u(!1);
29
- return;
30
- }
31
- u(!0), p(null), f([]), w(null), t != null && t.blobUrl && (URL.revokeObjectURL(t.blobUrl), T(null));
32
- let e = null;
33
- U(void 0, null, function* () {
34
- try {
35
- A({
36
- chunkSize: O,
37
- useWebWorkers: !1
38
- });
39
- const {
40
- supportsRange: n,
41
- fileSize: r
42
- } = yield j(c);
43
- if (n) {
44
- const o = new k(c);
45
- e = new R(o, S);
46
- const b = (yield Promise.race([e.getEntries(), new Promise((i, a) => setTimeout(() => a(new Error("读取 ZIP 目录结构超时")), B))])).filter((i) => !i.directory).map((i) => ({
47
- name: i.filename,
48
- size: i.uncompressedSize || 0,
49
- isDirectory: !1
50
- }));
51
- b.sort((i, a) => i.name.localeCompare(a.name)), b.length > m ? (p(`ZIP 文件包含 ${b.length} 个文件,仅显示前 ${m} 个`), f(b.slice(0, m))) : f(b);
52
- } else {
53
- if (r > y)
54
- throw new Error(`服务器不支持 HTTP Range 请求,且文件过大(${Math.round(r / 1024 / 1024)}MB),无法预览。请下载后查看。`);
55
- const o = yield fetch(c);
56
- if (!o.ok)
57
- throw new Error(`HTTP error! status: ${o.status}`);
58
- const g = yield o.blob(), b = new L(g);
59
- e = new R(b, S);
60
- const a = (yield e.getEntries()).filter((s) => !s.directory).map((s) => ({
61
- name: s.filename,
62
- size: s.uncompressedSize || 0,
63
- isDirectory: !1
64
- }));
65
- a.sort((s, l) => s.name.localeCompare(l.name)), a.length > m ? (p(`ZIP 文件包含 ${a.length} 个文件,仅显示前 ${m} 个`), f(a.slice(0, m))) : f(a);
66
- }
67
- e && (yield e.close()), u(!1);
68
- } catch (n) {
69
- if (e)
70
- try {
71
- yield e.close();
72
- } catch (o) {
73
- }
74
- const r = n.message || n.toString() || "加载 ZIP 文件失败";
75
- if (r.includes("Range") || r.includes("range") || r.includes("HTTP Range not supported") || r.includes("超时"))
76
- try {
77
- const o = yield v(c);
78
- if (o > y)
79
- throw new Error(`文件过大(${Math.round(o / 1024 / 1024)}MB),无法通过 Range 请求加载,且文件过大无法下载整个文件预览。请下载后查看。`);
80
- const g = yield fetch(c);
81
- if (!g.ok)
82
- throw new Error(`HTTP error! status: ${g.status}`);
83
- const b = yield g.blob(), i = new L(b);
84
- e = new R(i, S);
85
- const s = (yield e.getEntries()).filter((l) => !l.directory).map((l) => ({
86
- name: l.filename,
87
- size: l.uncompressedSize || 0,
88
- isDirectory: !1
89
- }));
90
- s.sort((l, d) => l.name.localeCompare(d.name)), s.length > m ? (p(`ZIP 文件包含 ${s.length} 个文件,仅显示前 ${m} 个`), f(s.slice(0, m))) : f(s), e && (yield e.close()), u(!1);
91
- return;
92
- } catch (o) {
93
- const g = o.message || o.toString();
94
- p(`ZIP 文件加载失败: ${r}。Fallback 方案也失败: ${g}`);
95
- }
96
- else
97
- p(r);
98
- u(!1);
99
- }
100
- });
101
- }, [c]);
102
- const z = M((e) => U(void 0, null, function* () {
103
- if (E === e && t) {
104
- w(null), t.blobUrl && URL.revokeObjectURL(t.blobUrl), T(null);
105
- return;
106
- }
107
- w(e);
108
- try {
109
- let n = null, r;
110
- try {
111
- const s = new k(c);
112
- n = new R(s, S), r = (yield n.getEntries()).find((d) => d.filename === e);
113
- } catch (s) {
114
- const l = yield fetch(c);
115
- if (!l.ok)
116
- throw new Error(`HTTP error! status: ${l.status}`);
117
- const d = yield l.blob(), $ = new L(d);
118
- n = new R($, S), r = (yield n.getEntries()).find((F) => F.filename === e);
119
- }
120
- if (!r)
121
- throw new Error("文件不存在");
122
- if (r.directory)
123
- throw new Error("无法预览目录");
124
- if ((r.uncompressedSize || 0) > C)
125
- throw new Error("文件过大(超过 100MB),无法预览");
126
- const g = yield r.getData(new H()), b = URL.createObjectURL(g), i = x(e), a = W(i);
127
- if (!D.includes(a))
128
- throw new Error(`不支持预览 ${i || "未知"} 格式的文件`);
129
- T({
130
- name: e,
131
- blobUrl: b,
132
- type: a
133
- }), n && (yield n.close());
134
- } catch (n) {
135
- const r = n.message || n.toString() || "预览文件失败";
136
- p(r);
137
- }
138
- }), [c, E, t]);
139
- return _(() => () => {
140
- t != null && t.blobUrl && URL.revokeObjectURL(t.blobUrl);
141
- }, [t]), {
142
- zipFiles: Z,
143
- zipLoading: I,
144
- zipError: P,
145
- selectedZipFile: E,
146
- zipFileContent: t,
147
- handleFileClick: z,
148
- setSelectedZipFile: w
149
- };
150
- };
151
- export {
152
- Q as useZipViewer
153
- };
@@ -1,367 +0,0 @@
1
- var v = (i, r, n) => new Promise((y, m) => {
2
- var C = (s) => {
3
- try {
4
- e(n.next(s));
5
- } catch (u) {
6
- m(u);
7
- }
8
- }, k = (s) => {
9
- try {
10
- e(n.throw(s));
11
- } catch (u) {
12
- m(u);
13
- }
14
- }, e = (s) => s.done ? y(s.value) : Promise.resolve(s.value).then(C, k);
15
- e((n = n.apply(i, r)).next());
16
- });
17
- import { jsxs as g, jsx as t } from "react/jsx-runtime";
18
- import { useMemo as x, useState as w, useEffect as oe, useCallback as B } from "react";
19
- import { message as h, Space as ie, Button as ae, Dropdown as se, Spin as ce } from "antd";
20
- import { DownloadOutlined as le, CopyOutlined as de } from "@ant-design/icons";
21
- import { getFileExtension as A, getFileType as ue } from "../../utils/file.mjs";
22
- import { MAX_FILE_SIZE as S } from "./constants.mjs";
23
- import { normalizeUrl as me } from "./utils.mjs";
24
- import { useZipViewer as pe } from "./hooks/useZipViewer.mjs";
25
- import { TextRenderer as P, CodeRenderer as fe, XmlRenderer as we, HtmlRenderer as he, MarkdownRenderer as ve, JsonlRenderer as xe, TsvRenderer as ye, CsvRenderer as be, JsonRenderer as ge } from "./components/FileRenderers.mjs";
26
- import { AudioRenderer as Ce, VideoRenderer as ke, ImageRenderer as Fe } from "./components/MediaRenderers.mjs";
27
- import { ZipRenderer as Re } from "./components/ZipRenderer.mjs";
28
- import { ErrorAlert as ze } from "./components/ErrorAlert.mjs";
29
- import "./style.less.mjs";
30
- import Te from "./components/PDFViewer/index.mjs";
31
- const Ne = (i) => {
32
- if (!i)
33
- return "unknown";
34
- const r = i.split(";")[0].trim().toLowerCase();
35
- return r.startsWith("image/") ? "image" : r.startsWith("video/") ? "video" : r.startsWith("audio/") ? "audio" : r === "application/pdf" ? "pdf" : r === "text/markdown" || r === "text/x-markdown" ? "markdown" : r === "application/json" ? "json" : r === "application/jsonl" ? "jsonl" : r === "text/csv" || r === "application/csv" ? "csv" : r === "text/tab-separated-values" ? "tsv" : r === "application/javascript" || r === "text/javascript" ? "code" : r === "application/xml" || r === "text/xml" ? "xml" : r === "text/html" || r === "application/xhtml+xml" ? "html" : r === "text/plain" ? "text" : "unknown";
36
- }, Ee = (i) => !i || Number.isNaN(i) ? "大小未知" : i < 1024 ? `${i}B` : i < 1024 * 1024 ? `${(i / 1024).toFixed(1)}KB` : i < 1024 * 1024 * 1024 ? `${(i / 1024 / 1024).toFixed(1)}MB` : `${(i / 1024 / 1024 / 1024).toFixed(1)}GB`, Be = (i, r) => {
37
- if (r)
38
- return r;
39
- try {
40
- const m = new URL(i).pathname.split("/").filter(Boolean).pop();
41
- return decodeURIComponent(m || i);
42
- } catch (n) {
43
- return i;
44
- }
45
- }, Se = (i) => {
46
- const {
47
- url: r,
48
- fileName: n,
49
- className: y,
50
- style: m,
51
- showToolbar: C = !1,
52
- page: k = 1
53
- } = i, e = x(() => me(r), [r]);
54
- console.log("normalizedUrl", e);
55
- const s = x(() => {
56
- const c = A(e), o = n ? A(n) : void 0;
57
- return ue(c || o);
58
- }, [e, n]), [u, b] = w(s), {
59
- zipFiles: W,
60
- zipLoading: H,
61
- zipError: Z,
62
- selectedZipFile: _,
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(() => [{
66
- key: "copy-content",
67
- label: "复制内容",
68
- disabled: !F
69
- }, {
70
- key: "copy-url",
71
- label: "复制地址",
72
- disabled: !e
73
- }], [F, e]);
74
- oe(() => {
75
- if (b(s), s === "pdf" || s === "zip") {
76
- d(!1);
77
- return;
78
- }
79
- if (!e) {
80
- p("文件URL不能为空"), d(!1);
81
- return;
82
- }
83
- if (["image", "video", "audio", "office"].includes(s)) {
84
- d(!1);
85
- return;
86
- }
87
- d(!0), p(null), v(void 0, null, function* () {
88
- try {
89
- if (e.startsWith("blob:") || e.startsWith("data:")) {
90
- const f = yield fetch(e);
91
- if (!f.ok)
92
- throw new Error(`HTTP error! status: ${f.status}`);
93
- const V = yield f.blob(), E = V.size;
94
- if (M(E), E > S) {
95
- p(`文件过大(${Math.round(E / 1024 / 1024)}MB),无法预览。请下载后查看。`), d(!1);
96
- return;
97
- }
98
- const ne = yield V.text();
99
- s === "unknown" && b("text"), j({
100
- content: ne
101
- }), d(!1);
102
- return;
103
- }
104
- const o = yield fetch(e, {
105
- method: "HEAD"
106
- }), z = o.headers.get("Content-Length"), re = o.headers.get("Content-Type"), T = z ? parseInt(z, 10) : 0;
107
- if (M(T), s === "unknown") {
108
- const f = Ne(re);
109
- f !== "unknown" && b(f);
110
- }
111
- if (T > S) {
112
- p(`文件过大(${Math.round(T / 1024 / 1024)}MB),无法预览。请下载后查看。`), d(!1);
113
- return;
114
- }
115
- const N = yield fetch(e);
116
- if (!N.ok)
117
- throw new Error(`HTTP error! status: ${N.status}`);
118
- const O = yield N.text(), I = new Blob([O]).size;
119
- if (I > S) {
120
- p(`文件过大(${Math.round(I / 1024 / 1024)}MB),无法预览。请下载后查看。`), d(!1);
121
- return;
122
- }
123
- u === "unknown" && b("text"), j({
124
- content: O
125
- }), d(!1);
126
- } catch (c) {
127
- p(c.message || "加载文件失败"), d(!1);
128
- }
129
- });
130
- }, [e, s]);
131
- const R = B(() => v(void 0, null, function* () {
132
- var c;
133
- if (!(a != null && a.content)) {
134
- h.warning("暂无可复制的内容");
135
- return;
136
- }
137
- try {
138
- if ($(!0), (c = navigator == null ? void 0 : navigator.clipboard) != null && c.writeText)
139
- yield navigator.clipboard.writeText(a.content);
140
- else {
141
- const o = document.createElement("textarea");
142
- o.value = a.content, o.style.position = "fixed", o.style.opacity = "0", document.body.appendChild(o), o.select(), document.execCommand("copy"), document.body.removeChild(o);
143
- }
144
- h.success("内容已复制到剪贴板");
145
- } catch (o) {
146
- h.error((o == null ? void 0 : o.message) || "复制失败,请手动复制");
147
- } finally {
148
- $(!1);
149
- }
150
- }), [a]), L = B(() => v(void 0, null, function* () {
151
- var c;
152
- if (!e) {
153
- h.warning("暂无可复制的地址");
154
- return;
155
- }
156
- try {
157
- if ((c = navigator == null ? void 0 : navigator.clipboard) != null && c.writeText)
158
- yield navigator.clipboard.writeText(e);
159
- else {
160
- const o = document.createElement("textarea");
161
- o.value = e, o.style.position = "fixed", o.style.opacity = "0", document.body.appendChild(o), o.select(), document.execCommand("copy"), document.body.removeChild(o);
162
- }
163
- h.success("链接已复制到剪贴板");
164
- } catch (o) {
165
- h.error((o == null ? void 0 : o.message) || "复制失败,请手动复制");
166
- }
167
- }), [e]), ee = B((o) => v(void 0, [o], function* ({
168
- key: c
169
- }) {
170
- c === "copy-content" && (yield R()), c === "copy-url" && (yield L());
171
- }), [R, L]), te = () => {
172
- if (G)
173
- return /* @__PURE__ */ t("div", {
174
- className: "document-viewer-loading",
175
- children: /* @__PURE__ */ t(ce, {
176
- size: "large",
177
- tip: "加载中..."
178
- })
179
- });
180
- if (U)
181
- return /* @__PURE__ */ t(ze, {
182
- message: "加载失败",
183
- description: U,
184
- url: e,
185
- fileName: n
186
- });
187
- if (u === "unknown" && (a != null && a.content))
188
- return /* @__PURE__ */ t(P, {
189
- fileContent: a,
190
- fileSize: l,
191
- url: e,
192
- fileName: n
193
- });
194
- switch (u) {
195
- case "text":
196
- return /* @__PURE__ */ t(P, {
197
- fileContent: a,
198
- fileSize: l,
199
- url: e,
200
- fileName: n
201
- });
202
- case "json":
203
- return /* @__PURE__ */ t(ge, {
204
- fileContent: a,
205
- fileSize: l,
206
- url: e,
207
- fileName: n
208
- });
209
- case "csv":
210
- return /* @__PURE__ */ t(be, {
211
- fileContent: a,
212
- fileSize: l,
213
- url: e,
214
- fileName: n
215
- });
216
- case "tsv":
217
- return /* @__PURE__ */ t(ye, {
218
- fileContent: a,
219
- fileSize: l,
220
- url: e,
221
- fileName: n
222
- });
223
- case "jsonl":
224
- return /* @__PURE__ */ t(xe, {
225
- fileContent: a,
226
- fileSize: l,
227
- url: e,
228
- fileName: n
229
- });
230
- case "markdown":
231
- return /* @__PURE__ */ t(ve, {
232
- fileContent: a,
233
- fileSize: l,
234
- url: e,
235
- fileName: n
236
- });
237
- case "html":
238
- return /* @__PURE__ */ t(he, {
239
- fileContent: a,
240
- fileSize: l,
241
- url: e,
242
- fileName: n
243
- });
244
- case "xml":
245
- return /* @__PURE__ */ t(we, {
246
- fileContent: a,
247
- fileSize: l,
248
- url: e,
249
- fileName: n
250
- });
251
- case "code":
252
- return /* @__PURE__ */ t(fe, {
253
- fileContent: a,
254
- fileSize: l,
255
- url: e,
256
- fileName: n
257
- });
258
- case "image":
259
- return /* @__PURE__ */ t(Fe, {
260
- url: e,
261
- fileName: n
262
- });
263
- case "video":
264
- return /* @__PURE__ */ t(ke, {
265
- url: e,
266
- fileName: n
267
- });
268
- case "audio":
269
- return /* @__PURE__ */ t(Ce, {
270
- url: e,
271
- fileName: n
272
- });
273
- case "pdf":
274
- return /* @__PURE__ */ t(Te, {
275
- fileUrl: e,
276
- pageNumber: k
277
- });
278
- case "office":
279
- return /* @__PURE__ */ t(Ue, {
280
- url: e
281
- });
282
- case "zip":
283
- return /* @__PURE__ */ t(Re, {
284
- zipFiles: W,
285
- zipLoading: H,
286
- zipError: Z,
287
- selectedZipFile: _,
288
- zipFileContent: J,
289
- onFileClick: X,
290
- url: e
291
- });
292
- case "unknown":
293
- default:
294
- return /* @__PURE__ */ t(je, {
295
- url: e
296
- });
297
- }
298
- };
299
- return /* @__PURE__ */ g("div", {
300
- className: `document-viewer ${y || ""}`,
301
- style: m,
302
- children: [C && /* @__PURE__ */ g("div", {
303
- className: "document-viewer-toolbar",
304
- children: [/* @__PURE__ */ g("div", {
305
- className: "document-viewer-toolbar-meta",
306
- children: [/* @__PURE__ */ t("span", {
307
- className: "document-viewer-toolbar-name",
308
- title: D,
309
- children: D
310
- }), /* @__PURE__ */ t("span", {
311
- className: "document-viewer-toolbar-size",
312
- children: q
313
- })]
314
- }), /* @__PURE__ */ g(ie, {
315
- size: 8,
316
- wrap: !0,
317
- children: [/* @__PURE__ */ t(ae, {
318
- icon: /* @__PURE__ */ t(le, {}),
319
- size: "small",
320
- href: e,
321
- target: "_blank",
322
- rel: "noopener noreferrer",
323
- download: n || void 0,
324
- children: "下载"
325
- }), /* @__PURE__ */ t(se.Button, {
326
- size: "small",
327
- icon: /* @__PURE__ */ t(de, {}),
328
- menu: {
329
- items: Y,
330
- onClick: ee
331
- },
332
- disabled: Q,
333
- loading: K,
334
- onClick: R,
335
- children: "复制"
336
- })]
337
- })]
338
- }), /* @__PURE__ */ t("div", {
339
- className: "document-viewer-body",
340
- children: te()
341
- })]
342
- });
343
- }, Ue = ({
344
- url: i
345
- }) => {
346
- const r = `https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(i)}`;
347
- return /* @__PURE__ */ t("div", {
348
- className: "document-viewer-office",
349
- children: /* @__PURE__ */ t("iframe", {
350
- src: r,
351
- className: "document-viewer-iframe",
352
- title: "Office Document Preview"
353
- })
354
- });
355
- }, je = ({
356
- url: i
357
- }) => /* @__PURE__ */ t("div", {
358
- className: "document-viewer-unknown",
359
- children: /* @__PURE__ */ t("iframe", {
360
- src: i,
361
- className: "document-viewer-iframe",
362
- title: "File Preview"
363
- })
364
- }), Ge = Se;
365
- export {
366
- Ge as default
367
- };
@@ -1,4 +0,0 @@
1
- const t = "";
2
- export {
3
- t as default
4
- };