@hkyhy/marsun-components-core 0.1.123 → 0.1.125
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/README.md +1 -0
- package/dist/_virtual/index.js +5 -5
- package/dist/_virtual/index2.js +5 -5
- package/dist/components/File/FileItem/index.js +65 -55
- package/dist/components/File/FileItem/index.js.map +1 -1
- package/dist/components/File/FilePreview/FilePreviewContent.js +114 -90
- package/dist/components/File/FilePreview/FilePreviewContent.js.map +1 -1
- package/dist/components/File/FilePreview/index.js +43 -33
- package/dist/components/File/FilePreview/index.js.map +1 -1
- package/dist/components/File/index.d.ts +1 -0
- package/dist/components/File/utils/authedFetch.d.ts +12 -0
- package/dist/components/File/utils/authedFetch.js +50 -0
- package/dist/components/File/utils/authedFetch.js.map +1 -0
- package/dist/components/Form/index.d.ts +1 -1
- package/dist/components/Form/kneFormInfo.d.ts +2 -0
- package/dist/components/Form/kneFormInfo.js +30 -27
- package/dist/components/Form/kneFormInfo.js.map +1 -1
- package/dist/components/FormInfo/fields.d.ts +2 -0
- package/dist/components/FormInfo/fields.js +22 -19
- package/dist/components/FormInfo/fields.js.map +1 -1
- package/dist/components/FormInfo/index.d.ts +1 -1
- package/dist/components/Tools/ActionTracking/CreateAction/CreateActionForm.d.ts +8 -1
- package/dist/components/Tools/ActionTracking/CreateAction/CreateActionForm.js +148 -142
- package/dist/components/Tools/ActionTracking/CreateAction/CreateActionForm.js.map +1 -1
- package/dist/components/Tools/ActionTracking/CreateAction/CreateActionForm.module.scss.js +5 -4
- package/dist/components/Tools/ActionTracking/CreateAction/CreateActionForm.module.scss.js.map +1 -1
- package/dist/components/Tools/ActionTracking/CreateAction/CreateActionModal.d.ts +10 -2
- package/dist/components/Tools/ActionTracking/CreateAction/CreateActionModal.js +122 -116
- package/dist/components/Tools/ActionTracking/CreateAction/CreateActionModal.js.map +1 -1
- package/dist/components/Tools/ActionTracking/CreateAction/PersonRoleCascaderField.js +20 -31
- package/dist/components/Tools/ActionTracking/CreateAction/PersonRoleCascaderField.js.map +1 -1
- package/dist/components/Tools/ActionTracking/CreateAction/PersonRoleCascaderField.module.scss.js +1 -2
- package/dist/components/Tools/ActionTracking/CreateAction/PersonRoleCascaderField.module.scss.js.map +1 -1
- package/dist/components/Tools/ActionTracking/CreateAction/index.d.ts +1 -1
- package/dist/components/Tools/ActionTracking/CreateAction/submitHelpers.d.ts +5 -0
- package/dist/components/Tools/ActionTracking/CreateAction/submitHelpers.js +37 -18
- package/dist/components/Tools/ActionTracking/CreateAction/submitHelpers.js.map +1 -1
- package/dist/components/Tools/ActionTracking/CreateAction/types.d.ts +9 -0
- package/dist/components/Tools/ActionTracking/index.d.ts +1 -1
- package/dist/components/Tools/Inbox/InboxBell/InboxBell.d.ts +43 -3
- package/dist/components/Tools/Inbox/InboxBell/InboxBell.js +345 -130
- package/dist/components/Tools/Inbox/InboxBell/InboxBell.js.map +1 -1
- package/dist/components/Tools/Inbox/InboxBell/emphasizeQuoted.d.ts +3 -0
- package/dist/components/Tools/Inbox/InboxBell/emphasizeQuoted.js +13 -0
- package/dist/components/Tools/Inbox/InboxBell/emphasizeQuoted.js.map +1 -0
- package/dist/components/Tools/Inbox/InboxBell/inboxItemActions.d.ts +37 -0
- package/dist/components/Tools/Inbox/InboxBell/inboxItemActions.js +97 -0
- package/dist/components/Tools/Inbox/InboxBell/inboxItemActions.js.map +1 -0
- package/dist/components/Tools/Inbox/InboxBell/index.d.ts +2 -0
- package/dist/components/Tools/Inbox/InboxBell/style.module.scss.js +58 -26
- package/dist/components/Tools/Inbox/InboxBell/style.module.scss.js.map +1 -1
- package/dist/components/Tools/Inbox/InboxBell/toastPrefs.d.ts +10 -0
- package/dist/components/Tools/Inbox/InboxBell/toastPrefs.js +46 -0
- package/dist/components/Tools/Inbox/InboxBell/toastPrefs.js.map +1 -0
- package/dist/components/Tools/Inbox/index.d.ts +2 -0
- package/dist/components/Tools/index.d.ts +3 -2
- package/dist/file.js +24 -19
- package/dist/file.js.map +1 -1
- package/dist/form-info.js +46 -45
- package/dist/index.js +517 -504
- package/dist/index.js.map +1 -1
- package/dist/marsun-components-core.css +1 -1
- package/dist/node_modules/@antv/g-lite/dist/index.esm.js +1 -1
- package/dist/node_modules/@antv/g2/esm/data/kde.js +1 -1
- package/dist/node_modules/eventemitter3/index.js +1 -1
- package/dist/styles/global.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -136,6 +136,7 @@ node scripts/version-check.mjs --apply # → 0.1.99
|
|
|
136
136
|
|
|
137
137
|
也可在 Actions 中手动运行 **Publish npm**,填写已有 tag 重新发布。
|
|
138
138
|
|
|
139
|
+
- 2026-10-09:`v0.1.124` — CreateAction FormInfo DatePicker 与 scopeMode=none(token 刷新后重发)
|
|
139
140
|
- 2026-09-23:`v0.1.122` — ActionListTable 默认 scrollX 对齐长状态列(0.1.121 已发后补发)
|
|
140
141
|
|
|
141
142
|
## 后续接入 maoyang
|
package/dist/_virtual/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { getDefaultExportFromCjs as
|
|
2
|
-
import { __require as
|
|
3
|
-
var
|
|
4
|
-
const
|
|
1
|
+
import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
|
|
2
|
+
import { __require as o } from "../node_modules/pdfast/src/index.js";
|
|
3
|
+
var t = o();
|
|
4
|
+
const s = /* @__PURE__ */ r(t);
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
s as default
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/dist/_virtual/index2.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { getDefaultExportFromCjs as
|
|
2
|
-
import { __require as
|
|
3
|
-
var
|
|
4
|
-
const
|
|
1
|
+
import { getDefaultExportFromCjs as t } from "./_commonjsHelpers.js";
|
|
2
|
+
import { __require as e } from "../node_modules/eventemitter3/index2.js";
|
|
3
|
+
var r = e();
|
|
4
|
+
const i = /* @__PURE__ */ t(r);
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
i as default
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=index2.js.map
|
|
@@ -1,106 +1,116 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { formatFileSize as
|
|
3
|
-
import { Tooltip as
|
|
4
|
-
import { useState as
|
|
5
|
-
import
|
|
6
|
-
import { normalizeFileDisplayItem as
|
|
7
|
-
import
|
|
8
|
-
import t from "
|
|
9
|
-
import
|
|
1
|
+
import { jsxs as r, Fragment as U, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { formatFileSize as z } from "../../../utils/format.js";
|
|
3
|
+
import { Tooltip as j, Button as x, message as A } from "antd";
|
|
4
|
+
import { useState as E } from "react";
|
|
5
|
+
import L from "../FilePreviewModal/index.js";
|
|
6
|
+
import { normalizeFileDisplayItem as O, getFileTypeName as R, getFileIcon as I } from "../fileDisplay.js";
|
|
7
|
+
import { useFileAuthHeaders as P, fetchWithMarsunAuth as H } from "../utils/authedFetch.js";
|
|
8
|
+
import t from "./style.module.scss.js";
|
|
9
|
+
import l from "classnames";
|
|
10
|
+
import M from "../../Tag/FileTags.js";
|
|
10
11
|
import { Eye as S } from "../../Icons/Eye.js";
|
|
11
12
|
import { Download as B } from "../../Icons/Download.js";
|
|
12
13
|
import { Trash2 as D } from "../../Icons/Trash2.js";
|
|
13
|
-
const
|
|
14
|
-
file:
|
|
15
|
-
status:
|
|
16
|
-
showDownload:
|
|
17
|
-
showDelete:
|
|
18
|
-
showPreview:
|
|
19
|
-
actions:
|
|
20
|
-
onDownload:
|
|
21
|
-
onDelete:
|
|
22
|
-
onPreview:
|
|
14
|
+
const ie = ({
|
|
15
|
+
file: u,
|
|
16
|
+
status: n,
|
|
17
|
+
showDownload: w = !0,
|
|
18
|
+
showDelete: y = !1,
|
|
19
|
+
showPreview: N = !0,
|
|
20
|
+
actions: g,
|
|
21
|
+
onDownload: c,
|
|
22
|
+
onDelete: f,
|
|
23
|
+
onPreview: p
|
|
23
24
|
}) => {
|
|
24
|
-
const [
|
|
25
|
-
if (
|
|
26
|
-
|
|
25
|
+
const [v, d] = E(!1), e = O(u), k = P(), b = () => {
|
|
26
|
+
if (c) {
|
|
27
|
+
c(e);
|
|
27
28
|
return;
|
|
28
29
|
}
|
|
29
|
-
e.url &&
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
e.url && (async () => {
|
|
31
|
+
try {
|
|
32
|
+
const o = await H(e.url, k);
|
|
33
|
+
if (!o.ok) throw new Error(`下载失败 (${o.status})`);
|
|
34
|
+
const m = await o.blob(), h = URL.createObjectURL(m), s = document.createElement("a");
|
|
35
|
+
s.href = h, s.download = e.name || "download", s.click(), URL.revokeObjectURL(h);
|
|
36
|
+
} catch (o) {
|
|
37
|
+
A.error(o instanceof Error ? o.message : "下载失败");
|
|
38
|
+
}
|
|
39
|
+
})();
|
|
40
|
+
}, F = () => {
|
|
41
|
+
p ? p(e) : d(!0);
|
|
42
|
+
}, a = [];
|
|
43
|
+
N && a.push({
|
|
34
44
|
key: "preview",
|
|
35
45
|
icon: /* @__PURE__ */ i(S, {}),
|
|
36
46
|
tooltip: "预览",
|
|
37
|
-
onClick: () =>
|
|
38
|
-
}),
|
|
47
|
+
onClick: () => F()
|
|
48
|
+
}), w && a.push({
|
|
39
49
|
key: "download",
|
|
40
50
|
icon: /* @__PURE__ */ i(B, {}),
|
|
41
51
|
tooltip: "下载",
|
|
42
|
-
onClick: () =>
|
|
43
|
-
}),
|
|
52
|
+
onClick: () => b()
|
|
53
|
+
}), y && f && a.push({
|
|
44
54
|
key: "delete",
|
|
45
55
|
icon: /* @__PURE__ */ i(D, {}),
|
|
46
56
|
tooltip: "删除",
|
|
47
|
-
onClick: () =>
|
|
57
|
+
onClick: () => f(e)
|
|
48
58
|
});
|
|
49
|
-
const
|
|
50
|
-
return /* @__PURE__ */
|
|
51
|
-
/* @__PURE__ */ i("div", { className:
|
|
52
|
-
/* @__PURE__ */
|
|
53
|
-
/* @__PURE__ */ i("span", { className:
|
|
54
|
-
/* @__PURE__ */
|
|
55
|
-
/* @__PURE__ */
|
|
59
|
+
const C = [...a, ...g ?? []], T = R(e.name, e.mimeType);
|
|
60
|
+
return /* @__PURE__ */ r(U, { children: [
|
|
61
|
+
/* @__PURE__ */ i("div", { className: l("file-item-root", t["file-item-root"]), children: /* @__PURE__ */ r("div", { className: l("file-item-container", t["file-item-container"]), children: [
|
|
62
|
+
/* @__PURE__ */ r("div", { className: l("file-item-wrapper", t["file-item-wrapper"]), children: [
|
|
63
|
+
/* @__PURE__ */ i("span", { className: l("file-item-inner", t["file-item-inner"]), children: I(e.name, e.mimeType) }),
|
|
64
|
+
/* @__PURE__ */ r("div", { className: l("file-item-header", t["file-item-header"]), children: [
|
|
65
|
+
/* @__PURE__ */ r("div", { className: l("file-item-body", t["file-item-body"]), children: [
|
|
56
66
|
/* @__PURE__ */ i(
|
|
57
67
|
"span",
|
|
58
68
|
{
|
|
59
|
-
className:
|
|
69
|
+
className: l("file-item-footer", t["file-item-footer"]),
|
|
60
70
|
title: e.name,
|
|
61
71
|
children: e.name
|
|
62
72
|
}
|
|
63
73
|
),
|
|
64
|
-
/* @__PURE__ */ i("span", { className:
|
|
65
|
-
e.size != null && /* @__PURE__ */ i("span", { className:
|
|
74
|
+
/* @__PURE__ */ i("span", { className: l("file-item-row", t["file-item-row"]), children: T }),
|
|
75
|
+
e.size != null && /* @__PURE__ */ i("span", { className: l("file-item-row", t["file-item-row"]), children: z(e.size) })
|
|
66
76
|
] }),
|
|
67
77
|
e.tags && e.tags.length > 0 && /* @__PURE__ */ i(
|
|
68
|
-
|
|
78
|
+
M,
|
|
69
79
|
{
|
|
70
80
|
tags: e.tags,
|
|
71
|
-
className:
|
|
81
|
+
className: l("file-item-col", t["file-item-col"])
|
|
72
82
|
}
|
|
73
83
|
)
|
|
74
84
|
] })
|
|
75
85
|
] }),
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
|
|
78
|
-
/* @__PURE__ */ i("div", { className:
|
|
86
|
+
/* @__PURE__ */ r("div", { className: l("file-item-wrap", t["file-item-wrap"]), children: [
|
|
87
|
+
n && /* @__PURE__ */ i("span", { className: l("file-item-panel", t["file-item-panel"]), children: n }),
|
|
88
|
+
/* @__PURE__ */ i("div", { className: l("file-item-action-group", t["file-item-action-group"]), children: C.map((o) => /* @__PURE__ */ i(j, { title: o.tooltip, children: /* @__PURE__ */ i(
|
|
79
89
|
x,
|
|
80
90
|
{
|
|
81
91
|
type: "text",
|
|
82
92
|
size: "small",
|
|
83
|
-
icon:
|
|
84
|
-
onClick: (
|
|
85
|
-
|
|
93
|
+
icon: o.icon,
|
|
94
|
+
onClick: (m) => {
|
|
95
|
+
m.stopPropagation(), o.onClick(e);
|
|
86
96
|
}
|
|
87
97
|
}
|
|
88
|
-
) },
|
|
98
|
+
) }, o.key)) })
|
|
89
99
|
] })
|
|
90
100
|
] }) }),
|
|
91
101
|
/* @__PURE__ */ i(
|
|
92
|
-
|
|
102
|
+
L,
|
|
93
103
|
{
|
|
94
|
-
open:
|
|
104
|
+
open: v,
|
|
95
105
|
file: e,
|
|
96
106
|
url: e.url,
|
|
97
107
|
downloadUrl: e.url,
|
|
98
|
-
onClose: () =>
|
|
108
|
+
onClose: () => d(!1)
|
|
99
109
|
}
|
|
100
110
|
)
|
|
101
111
|
] });
|
|
102
112
|
};
|
|
103
113
|
export {
|
|
104
|
-
|
|
114
|
+
ie as FileItem
|
|
105
115
|
};
|
|
106
116
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/File/FileItem/index.tsx"],"sourcesContent":["import { FileTags } from '@/components/Tag';\nimport { Trash2, Download, Eye } from '@/components/Icons';\nimport { formatFileSize } from '@/utils/format';\nimport { Button, Tooltip } from 'antd';\nimport React, { useState } from 'react';\nimport FilePreviewModal from '../FilePreviewModal';\nimport { getFileIcon, getFileTypeName, normalizeFileDisplayItem } from '../fileDisplay';\nimport type { FileDisplayItem } from '../types';\nimport styles from './style.module.scss';\nimport classNames from 'classnames';\n\nexport interface FileItemAction {\n key: string;\n icon: React.ReactNode;\n tooltip: string;\n onClick: (file: FileDisplayItem) => void;\n}\n\nexport interface FileItemProps {\n file: FileDisplayItem;\n status?: React.ReactNode;\n showDownload?: boolean;\n showDelete?: boolean;\n showPreview?: boolean;\n actions?: FileItemAction[];\n onDownload?: (file: FileDisplayItem) => void;\n onDelete?: (file: FileDisplayItem) => void;\n onPreview?: (file: FileDisplayItem) => void;\n}\n\nconst FileItem: React.FC<FileItemProps> = ({\n file,\n status,\n showDownload = true,\n showDelete = false,\n showPreview = true,\n actions,\n onDownload,\n onDelete,\n onPreview,\n}) => {\n const [previewOpen, setPreviewOpen] = useState(false);\n const resolvedFile = normalizeFileDisplayItem(file);\n\n const handleDownload = () => {\n if (onDownload) {\n onDownload(resolvedFile);\n return;\n }\n if (resolvedFile.url)
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/File/FileItem/index.tsx"],"sourcesContent":["import { FileTags } from '@/components/Tag';\nimport { Trash2, Download, Eye } from '@/components/Icons';\nimport { formatFileSize } from '@/utils/format';\nimport { Button, Tooltip, message } from 'antd';\nimport React, { useState } from 'react';\nimport FilePreviewModal from '../FilePreviewModal';\nimport { getFileIcon, getFileTypeName, normalizeFileDisplayItem } from '../fileDisplay';\nimport type { FileDisplayItem } from '../types';\nimport { fetchWithMarsunAuth, useFileAuthHeaders } from '../utils/authedFetch';\nimport styles from './style.module.scss';\nimport classNames from 'classnames';\n\nexport interface FileItemAction {\n key: string;\n icon: React.ReactNode;\n tooltip: string;\n onClick: (file: FileDisplayItem) => void;\n}\n\nexport interface FileItemProps {\n file: FileDisplayItem;\n status?: React.ReactNode;\n showDownload?: boolean;\n showDelete?: boolean;\n showPreview?: boolean;\n actions?: FileItemAction[];\n onDownload?: (file: FileDisplayItem) => void;\n onDelete?: (file: FileDisplayItem) => void;\n onPreview?: (file: FileDisplayItem) => void;\n}\n\nconst FileItem: React.FC<FileItemProps> = ({\n file,\n status,\n showDownload = true,\n showDelete = false,\n showPreview = true,\n actions,\n onDownload,\n onDelete,\n onPreview,\n}) => {\n const [previewOpen, setPreviewOpen] = useState(false);\n const resolvedFile = normalizeFileDisplayItem(file);\n const authHeaders = useFileAuthHeaders();\n\n const handleDownload = () => {\n if (onDownload) {\n onDownload(resolvedFile);\n return;\n }\n if (!resolvedFile.url) return;\n void (async () => {\n try {\n const res = await fetchWithMarsunAuth(resolvedFile.url!, authHeaders);\n if (!res.ok) throw new Error(`下载失败 (${res.status})`);\n const blob = await res.blob();\n const blobUrl = URL.createObjectURL(blob);\n const a = document.createElement('a');\n a.href = blobUrl;\n a.download = resolvedFile.name || 'download';\n a.click();\n URL.revokeObjectURL(blobUrl);\n } catch (err) {\n message.error(err instanceof Error ? err.message : '下载失败');\n }\n })();\n };\n\n const handlePreview = () => {\n if (onPreview) onPreview(resolvedFile);\n else setPreviewOpen(true);\n };\n\n const defaultActions: FileItemAction[] = [];\n if (showPreview) {\n defaultActions.push({\n key: 'preview',\n icon: <Eye />,\n tooltip: '预览',\n onClick: () => handlePreview(),\n });\n }\n if (showDownload) {\n defaultActions.push({\n key: 'download',\n icon: <Download />,\n tooltip: '下载',\n onClick: () => handleDownload(),\n });\n }\n if (showDelete && onDelete) {\n defaultActions.push({\n key: 'delete',\n icon: <Trash2 />,\n tooltip: '删除',\n onClick: () => onDelete(resolvedFile),\n });\n }\n\n const allActions = [...defaultActions, ...(actions ?? [])];\n const typeName = getFileTypeName(resolvedFile.name, resolvedFile.mimeType);\n\n return (\n <>\n <div className={classNames('file-item-root', styles['file-item-root'])}>\n <div className={classNames('file-item-container', styles['file-item-container'])}>\n <div className={classNames('file-item-wrapper', styles['file-item-wrapper'])}>\n <span className={classNames('file-item-inner', styles['file-item-inner'])}>\n {getFileIcon(resolvedFile.name, resolvedFile.mimeType)}\n </span>\n <div className={classNames('file-item-header', styles['file-item-header'])}>\n <div className={classNames('file-item-body', styles['file-item-body'])}>\n <span\n className={classNames('file-item-footer', styles['file-item-footer'])}\n title={resolvedFile.name}\n >\n {resolvedFile.name}\n </span>\n <span className={classNames('file-item-row', styles['file-item-row'])}>\n {typeName}\n </span>\n {resolvedFile.size != null && (\n <span className={classNames('file-item-row', styles['file-item-row'])}>\n {formatFileSize(resolvedFile.size)}\n </span>\n )}\n </div>\n {resolvedFile.tags && resolvedFile.tags.length > 0 && (\n <FileTags\n tags={resolvedFile.tags}\n className={classNames('file-item-col', styles['file-item-col'])}\n />\n )}\n </div>\n </div>\n\n <div className={classNames('file-item-wrap', styles['file-item-wrap'])}>\n {status && (\n <span className={classNames('file-item-panel', styles['file-item-panel'])}>\n {status}\n </span>\n )}\n <div className={classNames('file-item-action-group', styles['file-item-action-group'])}>\n {allActions.map((action) => (\n <Tooltip key={action.key} title={action.tooltip}>\n <Button\n type=\"text\"\n size=\"small\"\n icon={action.icon}\n onClick={(e) => {\n e.stopPropagation();\n action.onClick(resolvedFile);\n }}\n />\n </Tooltip>\n ))}\n </div>\n </div>\n </div>\n </div>\n <FilePreviewModal\n open={previewOpen}\n file={resolvedFile}\n url={resolvedFile.url}\n downloadUrl={resolvedFile.url}\n onClose={() => setPreviewOpen(false)}\n />\n </>\n );\n};\n\nexport { FileItem };\nexport default FileItem;\n"],"names":["FileItem","file","status","showDownload","showDelete","showPreview","actions","onDownload","onDelete","onPreview","previewOpen","setPreviewOpen","useState","resolvedFile","normalizeFileDisplayItem","authHeaders","useFileAuthHeaders","handleDownload","res","fetchWithMarsunAuth","blob","blobUrl","a","err","message","handlePreview","defaultActions","Eye","Download","Trash2","allActions","typeName","getFileTypeName","jsxs","Fragment","jsx","classNames","styles","getFileIcon","formatFileSize","FileTags","action","Tooltip","Button","e","FilePreviewModal"],"mappings":";;;;;;;;;;;;;AA+BA,MAAMA,KAAoC,CAAC;AAAA,EACzC,MAAAC;AAAA,EACA,QAAAC;AAAA,EACA,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
|
2
|
-
import { Empty as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { getPreviewKind as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { Empty as h, Spin as g } from "antd";
|
|
3
|
+
import { useRef as N, useState as y, useEffect as A } from "react";
|
|
4
|
+
import { getPreviewKind as S, needsBlobPreview as T } from "../previewKind.js";
|
|
5
|
+
import { useFileAuthHeaders as H, useFileAuthHeaderKey as L, fetchAuthedObjectUrl as j, fetchAuthedArrayBuffer as B } from "../utils/authedFetch.js";
|
|
6
|
+
import l from "./style.module.scss.js";
|
|
7
|
+
import M from "classnames";
|
|
8
|
+
function C(r) {
|
|
9
|
+
const e = H(), t = L(), [o, a] = y(void 0), [n, d] = y(!1), [u, f] = y(null);
|
|
10
|
+
return A(() => {
|
|
11
|
+
if (!r) {
|
|
12
|
+
a(void 0), f(null), d(!1);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
let i = !1, v;
|
|
16
|
+
return d(!0), f(null), (async () => {
|
|
17
|
+
try {
|
|
18
|
+
const p = await j(r, e);
|
|
19
|
+
if (i) {
|
|
20
|
+
p.revoke();
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
v = p.revoke, a(p.objectUrl);
|
|
24
|
+
} catch (p) {
|
|
25
|
+
i || (a(void 0), f(p instanceof Error ? p.message : "预览加载失败"));
|
|
26
|
+
} finally {
|
|
27
|
+
i || d(!1);
|
|
28
|
+
}
|
|
29
|
+
})(), () => {
|
|
30
|
+
i = !0, v == null || v();
|
|
31
|
+
};
|
|
32
|
+
}, [r, t]), { src: o, loading: n, error: u };
|
|
11
33
|
}
|
|
12
|
-
function
|
|
34
|
+
function E(r, e) {
|
|
13
35
|
const t = r instanceof Error ? r.message : String(r ?? "");
|
|
14
36
|
return e === "excel" && /anchors/i.test(t) ? "该 Excel 含图表/绘图等对象,当前预览引擎无法解析,请下载后用本地软件打开" : e === "word" && /ole|compound|docfile|not a valid/i.test(t) ? "旧版 Word(.doc)暂无法排版预览,请下载后用 Word 打开" : t && !/^Cannot read properties/i.test(t) && !/^undefined/i.test(t) ? t : e === "excel" ? "Excel 预览失败,请下载后查看" : e === "word" ? "Word 预览失败,请下载后查看" : "预览加载失败";
|
|
15
37
|
}
|
|
16
|
-
async function
|
|
38
|
+
async function D(r) {
|
|
17
39
|
try {
|
|
18
|
-
const { default: e } = await import("../../../_virtual/jszip.min.js").then((
|
|
19
|
-
(
|
|
40
|
+
const { default: e } = await import("../../../_virtual/jszip.min.js").then((n) => n.j), t = await e.loadAsync(r), o = Object.keys(t.files), a = o.filter(
|
|
41
|
+
(n) => n.startsWith("xl/drawings/") || n.startsWith("xl/charts/") || n.startsWith("xl/diagrams/") || /drawing[0-9]*\.xml$/i.test(n)
|
|
20
42
|
);
|
|
21
|
-
if (
|
|
22
|
-
for (const
|
|
23
|
-
t.remove(
|
|
43
|
+
if (a.length === 0) return null;
|
|
44
|
+
for (const n of a)
|
|
45
|
+
t.remove(n);
|
|
24
46
|
return await Promise.all(
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
if (!
|
|
28
|
-
const
|
|
29
|
-
f !==
|
|
47
|
+
o.filter((n) => /^xl\/worksheets\/[^/]+\.xml$/i.test(n) && t.file(n)).map(async (n) => {
|
|
48
|
+
const d = t.file(n);
|
|
49
|
+
if (!d) return;
|
|
50
|
+
const u = await d.async("string"), f = u.replace(/<drawing[^>]*\/>/gi, "").replace(/<drawing[^>]*>[\s\S]*?<\/drawing>/gi, "");
|
|
51
|
+
f !== u && t.file(n, f);
|
|
30
52
|
})
|
|
31
53
|
), t.generateAsync({ type: "arraybuffer" });
|
|
32
54
|
} catch {
|
|
33
55
|
return null;
|
|
34
56
|
}
|
|
35
57
|
}
|
|
36
|
-
async function
|
|
37
|
-
const
|
|
58
|
+
async function b(r, e, t) {
|
|
59
|
+
const o = r.init(e);
|
|
38
60
|
try {
|
|
39
|
-
return await
|
|
40
|
-
} catch (
|
|
61
|
+
return await o.preview(t), () => o.destroy();
|
|
62
|
+
} catch (a) {
|
|
41
63
|
try {
|
|
42
|
-
|
|
64
|
+
o.destroy();
|
|
43
65
|
} catch {
|
|
44
66
|
}
|
|
45
|
-
throw
|
|
67
|
+
throw a;
|
|
46
68
|
}
|
|
47
69
|
}
|
|
48
|
-
async function
|
|
49
|
-
var
|
|
70
|
+
async function K(r, e) {
|
|
71
|
+
var a;
|
|
50
72
|
const [{ default: t }] = await Promise.all([
|
|
51
73
|
import("@js-preview/excel"),
|
|
52
74
|
Promise.resolve({ })
|
|
53
|
-
]),
|
|
54
|
-
((
|
|
75
|
+
]), o = Math.max(
|
|
76
|
+
((a = r.parentElement) == null ? void 0 : a.clientHeight) ?? 0,
|
|
55
77
|
Math.round(window.innerHeight * 0.65),
|
|
56
78
|
480
|
|
57
79
|
);
|
|
58
|
-
r.style.height = `${
|
|
80
|
+
r.style.height = `${o}px`;
|
|
59
81
|
try {
|
|
60
|
-
return await
|
|
61
|
-
} catch (
|
|
62
|
-
const
|
|
63
|
-
if (!/anchors/i.test(
|
|
64
|
-
throw
|
|
65
|
-
const
|
|
66
|
-
if (!
|
|
67
|
-
throw
|
|
82
|
+
return await b(t, r, e);
|
|
83
|
+
} catch (n) {
|
|
84
|
+
const d = n instanceof Error ? n.message : String(n ?? "");
|
|
85
|
+
if (!/anchors/i.test(d))
|
|
86
|
+
throw n instanceof Error ? n : new Error(E(n, "excel"));
|
|
87
|
+
const u = await D(e);
|
|
88
|
+
if (!u)
|
|
89
|
+
throw n instanceof Error ? n : new Error(E(n, "excel"));
|
|
68
90
|
r.innerHTML = "";
|
|
69
91
|
try {
|
|
70
|
-
return await
|
|
92
|
+
return await b(t, r, u);
|
|
71
93
|
} catch (f) {
|
|
72
|
-
throw f instanceof Error ? f : new Error(
|
|
94
|
+
throw f instanceof Error ? f : new Error(E(f, "excel"));
|
|
73
95
|
}
|
|
74
96
|
}
|
|
75
97
|
}
|
|
76
|
-
function
|
|
98
|
+
function O(r) {
|
|
77
99
|
const e = new Uint8Array(r);
|
|
78
100
|
return e.length >= 2 && e[0] === 80 && e[1] === 75;
|
|
79
101
|
}
|
|
80
|
-
function
|
|
102
|
+
function k(r) {
|
|
81
103
|
const e = new Uint8Array(r);
|
|
82
104
|
return e.length >= 4 && e[0] === 208 && e[1] === 207 && e[2] === 17 && e[3] === 224;
|
|
83
105
|
}
|
|
84
|
-
function
|
|
106
|
+
function F(r) {
|
|
85
107
|
const e = new Uint8Array(r.byteLength > 64 ? r.slice(0, 64) : r);
|
|
86
108
|
let t = 0;
|
|
87
109
|
e.length >= 3 && e[0] === 239 && e[1] === 187 && e[2] === 191 && (t = 3);
|
|
88
|
-
const
|
|
89
|
-
return
|
|
110
|
+
const o = new TextDecoder("utf-8").decode(e.subarray(t)).trimStart().toLowerCase();
|
|
111
|
+
return o.startsWith("<!doctype") || o.startsWith("<html") || o.startsWith("<pre") || o.startsWith("<div") || o.startsWith("<article");
|
|
90
112
|
}
|
|
91
|
-
async function
|
|
92
|
-
if (
|
|
93
|
-
const { renderAsync: t } = await import("docx-preview"),
|
|
94
|
-
await t(
|
|
113
|
+
async function $(r, e) {
|
|
114
|
+
if (O(e)) {
|
|
115
|
+
const { renderAsync: t } = await import("docx-preview"), o = new Blob([e]);
|
|
116
|
+
await t(o, r, r, {
|
|
95
117
|
inWrapper: !0,
|
|
96
118
|
ignoreWidth: !1,
|
|
97
119
|
ignoreHeight: !1,
|
|
@@ -99,64 +121,66 @@ async function C(r, e) {
|
|
|
99
121
|
});
|
|
100
122
|
return;
|
|
101
123
|
}
|
|
102
|
-
if (
|
|
124
|
+
if (F(e)) {
|
|
103
125
|
r.innerHTML = new TextDecoder("utf-8").decode(e);
|
|
104
126
|
return;
|
|
105
127
|
}
|
|
106
|
-
throw
|
|
128
|
+
throw k(e) ? new Error("旧版 Word(.doc)暂无法排版预览,请下载后用 Word 打开") : new Error("无法识别的 Word 文件格式,请下载后查看");
|
|
107
129
|
}
|
|
108
|
-
async function
|
|
109
|
-
const { init:
|
|
110
|
-
return await
|
|
130
|
+
async function Z(r, e, t) {
|
|
131
|
+
const { init: o } = await import("pptx-preview"), a = o(r, { width: t, height: Math.round(t * 0.5625), mode: "list" });
|
|
132
|
+
return await a.preview(e), () => a.destroy();
|
|
111
133
|
}
|
|
112
|
-
function
|
|
113
|
-
const t = new TextDecoder("utf-8"),
|
|
114
|
-
|
|
134
|
+
function z(r, e) {
|
|
135
|
+
const t = new TextDecoder("utf-8"), o = document.createElement("pre");
|
|
136
|
+
o.className = l["file-preview-text"], o.textContent = t.decode(e), r.appendChild(o);
|
|
115
137
|
}
|
|
116
|
-
const
|
|
138
|
+
const Y = ({
|
|
117
139
|
file: r,
|
|
118
140
|
previewUrl: e,
|
|
119
141
|
unsupportedMessage: t = "暂不支持预览此文件类型"
|
|
120
142
|
}) => {
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
143
|
+
const o = N(null), a = N(void 0), [n, d] = y(!1), [u, f] = y(null), i = S(r), v = H(), p = L(), c = C(
|
|
144
|
+
i === "image" || i === "pdf" || i === "iframe" || i === "video" || i === "audio" ? e : void 0
|
|
145
|
+
);
|
|
146
|
+
return A(() => {
|
|
147
|
+
var W;
|
|
148
|
+
const w = o.current;
|
|
149
|
+
if (!w || !e) return;
|
|
150
|
+
let x = !1;
|
|
151
|
+
return (W = a.current) == null || W.call(a), a.current = void 0, w.innerHTML = "", f(null), (async () => {
|
|
152
|
+
if (i !== "image" && !(i === "pdf" || i === "iframe") && !(i === "video" || i === "audio") && i !== "unsupported") {
|
|
153
|
+
d(!0);
|
|
130
154
|
try {
|
|
131
|
-
const
|
|
132
|
-
if (
|
|
133
|
-
if (
|
|
134
|
-
|
|
135
|
-
else if (
|
|
136
|
-
await
|
|
137
|
-
else if (
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
} else
|
|
141
|
-
} catch (
|
|
142
|
-
|
|
155
|
+
const m = await B(e, v);
|
|
156
|
+
if (x) return;
|
|
157
|
+
if (i === "excel")
|
|
158
|
+
a.current = await K(w, m);
|
|
159
|
+
else if (i === "word")
|
|
160
|
+
await $(w, m);
|
|
161
|
+
else if (i === "ppt") {
|
|
162
|
+
const P = w.clientWidth || 852;
|
|
163
|
+
a.current = await Z(w, m, P);
|
|
164
|
+
} else i === "text" && z(w, m);
|
|
165
|
+
} catch (m) {
|
|
166
|
+
x || f(E(m, i));
|
|
143
167
|
} finally {
|
|
144
|
-
|
|
168
|
+
x || d(!1);
|
|
145
169
|
}
|
|
146
170
|
}
|
|
147
171
|
})(), () => {
|
|
148
|
-
var
|
|
149
|
-
|
|
172
|
+
var m;
|
|
173
|
+
x = !0, (m = a.current) == null || m.call(a), a.current = void 0, w.innerHTML = "";
|
|
150
174
|
};
|
|
151
|
-
}, [e,
|
|
175
|
+
}, [e, i, r.id, r.name, p]), e ? i === "image" ? c.loading ? /* @__PURE__ */ s("div", { className: l["file-preview-media-wrap"], children: /* @__PURE__ */ s(g, {}) }) : c.error || !c.src ? /* @__PURE__ */ s(h, { description: c.error || "预览加载失败" }) : /* @__PURE__ */ s("div", { className: l["file-preview-media-wrap"], children: /* @__PURE__ */ s("img", { src: c.src, alt: r.name, className: l["file-preview-image"] }) }) : i === "pdf" || i === "iframe" ? c.loading ? /* @__PURE__ */ s("div", { className: l["file-preview-media-wrap"], children: /* @__PURE__ */ s(g, {}) }) : c.error || !c.src ? /* @__PURE__ */ s(h, { description: c.error || "预览加载失败" }) : /* @__PURE__ */ s("iframe", { src: c.src, title: r.name, className: l["file-preview-iframe"] }) : i === "video" ? c.loading ? /* @__PURE__ */ s("div", { className: l["file-preview-media-wrap"], children: /* @__PURE__ */ s(g, {}) }) : c.error || !c.src ? /* @__PURE__ */ s(h, { description: c.error || "预览加载失败" }) : /* @__PURE__ */ s("div", { className: l["file-preview-media-wrap"], children: /* @__PURE__ */ s("video", { src: c.src, controls: !0, className: l["file-preview-video"] }) }) : i === "audio" ? c.loading ? /* @__PURE__ */ s("div", { className: l["file-preview-audio-wrap"], children: /* @__PURE__ */ s(g, {}) }) : c.error || !c.src ? /* @__PURE__ */ s(h, { description: c.error || "预览加载失败" }) : /* @__PURE__ */ s("div", { className: l["file-preview-audio-wrap"], children: /* @__PURE__ */ s("audio", { src: c.src, controls: !0, className: l["file-preview-audio"] }) }) : i === "unsupported" ? /* @__PURE__ */ s(h, { description: t }) : T(i) ? /* @__PURE__ */ s(
|
|
152
176
|
"div",
|
|
153
177
|
{
|
|
154
|
-
className:
|
|
155
|
-
children: /* @__PURE__ */
|
|
178
|
+
className: M(l["file-preview-office"], l["file-preview-office-wrap"]),
|
|
179
|
+
children: /* @__PURE__ */ s(g, { spinning: n, classNames: { root: l["file-preview-office-spin"] }, children: u ? /* @__PURE__ */ s(h, { description: u }) : /* @__PURE__ */ s("div", { ref: o, className: l["file-preview-office-inner"] }) })
|
|
156
180
|
}
|
|
157
|
-
) : /* @__PURE__ */
|
|
181
|
+
) : /* @__PURE__ */ s(h, { description: t }) : /* @__PURE__ */ s(h, { description: "无可预览地址" });
|
|
158
182
|
};
|
|
159
183
|
export {
|
|
160
|
-
|
|
184
|
+
Y as default
|
|
161
185
|
};
|
|
162
186
|
//# sourceMappingURL=FilePreviewContent.js.map
|