@knockout-js/layout 0.1.2 → 0.1.3
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/es2017/components/_util/index.d.ts +8 -7
- package/es2017/components/_util/index.js +31 -13
- package/es2017/components/_util/index.js.map +1 -1
- package/es2017/components/aggregate-menu/index.d.ts +1 -2
- package/es2017/components/aggregate-menu/index.js +56 -39
- package/es2017/components/aggregate-menu/index.js.map +1 -1
- package/es2017/components/aggregate-menu/locale/en_US.js +1 -1
- package/es2017/components/aggregate-menu/locale/en_US.js.map +1 -1
- package/es2017/components/aggregate-menu/locale/zh_CN.js +1 -1
- package/es2017/components/aggregate-menu/locale/zh_CN.js.map +1 -1
- package/es2017/components/avatar-dropdown/index.d.ts +1 -2
- package/es2017/components/avatar-dropdown/index.js +1 -1
- package/es2017/components/avatar-dropdown/index.js.map +1 -1
- package/es2017/components/avatar-dropdown/locale/en_US.js +1 -1
- package/es2017/components/avatar-dropdown/locale/en_US.js.map +1 -1
- package/es2017/components/avatar-dropdown/locale/zh_CN.js +1 -1
- package/es2017/components/avatar-dropdown/locale/zh_CN.js.map +1 -1
- package/es2017/components/collect-providers/index.d.ts +1 -1
- package/es2017/components/collect-providers/index.js +7 -4
- package/es2017/components/collect-providers/index.js.map +1 -1
- package/es2017/components/i18n-dropdown/index.d.ts +1 -2
- package/es2017/components/i18n-dropdown/index.js +1 -1
- package/es2017/components/i18n-dropdown/index.js.map +1 -1
- package/es2017/components/icons/index.d.ts +3 -3
- package/es2017/components/icons/index.js +3 -3
- package/es2017/components/icons/index.js.map +1 -1
- package/es2017/components/index.d.ts +0 -2
- package/es2017/components/index.js +1 -3
- package/es2017/components/index.js.map +1 -1
- package/es2017/components/keep-alive/index.js +8 -4
- package/es2017/components/keep-alive/index.js.map +1 -1
- package/es2017/components/layout/index.d.ts +2 -2
- package/es2017/components/layout/index.js +15 -9
- package/es2017/components/layout/index.js.map +1 -1
- package/es2017/components/layout/logo.js +1 -1
- package/es2017/components/layout/logo.js.map +1 -1
- package/es2017/components/leave-prompt/index.d.ts +1 -1
- package/es2017/components/leave-prompt/index.js +10 -5
- package/es2017/components/leave-prompt/index.js.map +1 -1
- package/es2017/components/leave-prompt/locale/en_US.js +1 -1
- package/es2017/components/leave-prompt/locale/en_US.js.map +1 -1
- package/es2017/components/leave-prompt/locale/zh_CN.js +1 -1
- package/es2017/components/leave-prompt/locale/zh_CN.js.map +1 -1
- package/es2017/components/locale/en_US.js +1 -1
- package/es2017/components/locale/en_US.js.map +1 -1
- package/es2017/components/locale/index.js +5 -3
- package/es2017/components/locale/index.js.map +1 -1
- package/es2017/components/locale/zh_CN.js +1 -1
- package/es2017/components/locale/zh_CN.js.map +1 -1
- package/es2017/components/modal/index.d.ts +1 -1
- package/es2017/components/modal/index.js +10 -6
- package/es2017/components/modal/index.js.map +1 -1
- package/es2017/components/msg-dropdown/index.js +13 -6
- package/es2017/components/msg-dropdown/index.js.map +1 -1
- package/es2017/components/msg-dropdown/locale/en_US.js +1 -1
- package/es2017/components/msg-dropdown/locale/en_US.js.map +1 -1
- package/es2017/components/msg-dropdown/locale/zh_CN.js +1 -1
- package/es2017/components/msg-dropdown/locale/zh_CN.js.map +1 -1
- package/es2017/components/provider/index.d.ts +3 -3
- package/es2017/components/provider/index.js +3 -3
- package/es2017/components/provider/index.js.map +1 -1
- package/es2017/components/tenant-dropdown/index.d.ts +1 -2
- package/es2017/components/tenant-dropdown/index.js +9 -4
- package/es2017/components/tenant-dropdown/index.js.map +1 -1
- package/es2017/components/tenant-dropdown/locale/en_US.js +1 -1
- package/es2017/components/tenant-dropdown/locale/en_US.js.map +1 -1
- package/es2017/components/tenant-dropdown/locale/zh_CN.js +1 -1
- package/es2017/components/tenant-dropdown/locale/zh_CN.js.map +1 -1
- package/es2017/components/theme-switch/index.js +1 -1
- package/es2017/components/theme-switch/index.js.map +1 -1
- package/es2017/components/theme-switch/locale/en_US.js +1 -1
- package/es2017/components/theme-switch/locale/en_US.js.map +1 -1
- package/es2017/components/theme-switch/locale/zh_CN.js +1 -1
- package/es2017/components/theme-switch/locale/zh_CN.js.map +1 -1
- package/es2017/components/upload-file/index.js +1 -1
- package/es2017/components/upload-file/index.js.map +1 -1
- package/es2017/components/upload-file/locale/en_US.js +1 -1
- package/es2017/components/upload-file/locale/en_US.js.map +1 -1
- package/es2017/components/upload-file/locale/zh_CN.js +1 -1
- package/es2017/components/upload-file/locale/zh_CN.js.map +1 -1
- package/es2017/components/upload-file/uploadAvatar.d.ts +1 -2
- package/es2017/components/upload-file/uploadAvatar.js +34 -21
- package/es2017/components/upload-file/uploadAvatar.js.map +1 -1
- package/es2017/components/upload-file/uploadMultiple.d.ts +1 -2
- package/es2017/components/upload-file/uploadMultiple.js +35 -18
- package/es2017/components/upload-file/uploadMultiple.js.map +1 -1
- package/es2017/components/upload-file/uploadTemp.d.ts +1 -2
- package/es2017/components/upload-file/uploadTemp.js +45 -25
- package/es2017/components/upload-file/uploadTemp.js.map +1 -1
- package/es2017/index.js +1 -1
- package/es2017/index.js.map +1 -1
- package/esm/components/_util/index.d.ts +8 -7
- package/esm/components/_util/index.js +35 -17
- package/esm/components/_util/index.js.map +1 -1
- package/esm/components/aggregate-menu/index.d.ts +1 -2
- package/esm/components/aggregate-menu/index.js +66 -49
- package/esm/components/aggregate-menu/index.js.map +1 -1
- package/esm/components/aggregate-menu/locale/en_US.js +1 -1
- package/esm/components/aggregate-menu/locale/en_US.js.map +1 -1
- package/esm/components/aggregate-menu/locale/zh_CN.js +1 -1
- package/esm/components/aggregate-menu/locale/zh_CN.js.map +1 -1
- package/esm/components/avatar-dropdown/index.d.ts +1 -2
- package/esm/components/avatar-dropdown/index.js +1 -1
- package/esm/components/avatar-dropdown/index.js.map +1 -1
- package/esm/components/avatar-dropdown/locale/en_US.js +1 -1
- package/esm/components/avatar-dropdown/locale/en_US.js.map +1 -1
- package/esm/components/avatar-dropdown/locale/zh_CN.js +1 -1
- package/esm/components/avatar-dropdown/locale/zh_CN.js.map +1 -1
- package/esm/components/collect-providers/index.d.ts +1 -1
- package/esm/components/collect-providers/index.js +8 -5
- package/esm/components/collect-providers/index.js.map +1 -1
- package/esm/components/i18n-dropdown/index.d.ts +1 -2
- package/esm/components/i18n-dropdown/index.js +2 -2
- package/esm/components/i18n-dropdown/index.js.map +1 -1
- package/esm/components/icons/index.d.ts +3 -3
- package/esm/components/icons/index.js +3 -3
- package/esm/components/icons/index.js.map +1 -1
- package/esm/components/index.d.ts +0 -2
- package/esm/components/index.js +1 -3
- package/esm/components/index.js.map +1 -1
- package/esm/components/keep-alive/index.js +8 -4
- package/esm/components/keep-alive/index.js.map +1 -1
- package/esm/components/layout/index.d.ts +2 -2
- package/esm/components/layout/index.js +17 -11
- package/esm/components/layout/index.js.map +1 -1
- package/esm/components/layout/logo.js +1 -1
- package/esm/components/layout/logo.js.map +1 -1
- package/esm/components/leave-prompt/index.d.ts +1 -1
- package/esm/components/leave-prompt/index.js +10 -5
- package/esm/components/leave-prompt/index.js.map +1 -1
- package/esm/components/leave-prompt/locale/en_US.js +1 -1
- package/esm/components/leave-prompt/locale/en_US.js.map +1 -1
- package/esm/components/leave-prompt/locale/zh_CN.js +1 -1
- package/esm/components/leave-prompt/locale/zh_CN.js.map +1 -1
- package/esm/components/locale/en_US.js +1 -1
- package/esm/components/locale/en_US.js.map +1 -1
- package/esm/components/locale/index.js +5 -3
- package/esm/components/locale/index.js.map +1 -1
- package/esm/components/locale/zh_CN.js +1 -1
- package/esm/components/locale/zh_CN.js.map +1 -1
- package/esm/components/modal/index.d.ts +1 -1
- package/esm/components/modal/index.js +11 -7
- package/esm/components/modal/index.js.map +1 -1
- package/esm/components/msg-dropdown/index.js +16 -9
- package/esm/components/msg-dropdown/index.js.map +1 -1
- package/esm/components/msg-dropdown/locale/en_US.js +1 -1
- package/esm/components/msg-dropdown/locale/en_US.js.map +1 -1
- package/esm/components/msg-dropdown/locale/zh_CN.js +1 -1
- package/esm/components/msg-dropdown/locale/zh_CN.js.map +1 -1
- package/esm/components/provider/index.d.ts +3 -3
- package/esm/components/provider/index.js +3 -3
- package/esm/components/provider/index.js.map +1 -1
- package/esm/components/tenant-dropdown/index.d.ts +1 -2
- package/esm/components/tenant-dropdown/index.js +12 -7
- package/esm/components/tenant-dropdown/index.js.map +1 -1
- package/esm/components/tenant-dropdown/locale/en_US.js +1 -1
- package/esm/components/tenant-dropdown/locale/en_US.js.map +1 -1
- package/esm/components/tenant-dropdown/locale/zh_CN.js +1 -1
- package/esm/components/tenant-dropdown/locale/zh_CN.js.map +1 -1
- package/esm/components/theme-switch/index.js +1 -1
- package/esm/components/theme-switch/index.js.map +1 -1
- package/esm/components/theme-switch/locale/en_US.js +1 -1
- package/esm/components/theme-switch/locale/en_US.js.map +1 -1
- package/esm/components/theme-switch/locale/zh_CN.js +1 -1
- package/esm/components/theme-switch/locale/zh_CN.js.map +1 -1
- package/esm/components/upload-file/index.js +1 -1
- package/esm/components/upload-file/index.js.map +1 -1
- package/esm/components/upload-file/locale/en_US.js +1 -1
- package/esm/components/upload-file/locale/en_US.js.map +1 -1
- package/esm/components/upload-file/locale/zh_CN.js +1 -1
- package/esm/components/upload-file/locale/zh_CN.js.map +1 -1
- package/esm/components/upload-file/uploadAvatar.d.ts +1 -2
- package/esm/components/upload-file/uploadAvatar.js +20 -11
- package/esm/components/upload-file/uploadAvatar.js.map +1 -1
- package/esm/components/upload-file/uploadMultiple.d.ts +1 -2
- package/esm/components/upload-file/uploadMultiple.js +27 -14
- package/esm/components/upload-file/uploadMultiple.js.map +1 -1
- package/esm/components/upload-file/uploadTemp.d.ts +1 -2
- package/esm/components/upload-file/uploadTemp.js +31 -15
- package/esm/components/upload-file/uploadTemp.js.map +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/package.json +4 -6
- package/es2017/components/dictionary/index.d.ts +0 -6
- package/es2017/components/dictionary/index.js +0 -71
- package/es2017/components/dictionary/index.js.map +0 -1
- package/es2017/components/dictionary/index.module.css +0 -4
- package/es2017/components/dictionary/select.d.ts +0 -19
- package/es2017/components/dictionary/select.js +0 -51
- package/es2017/components/dictionary/select.js.map +0 -1
- package/es2017/components/dictionary/text.d.ts +0 -23
- package/es2017/components/dictionary/text.js +0 -28
- package/es2017/components/dictionary/text.js.map +0 -1
- package/esm/components/dictionary/index.d.ts +0 -6
- package/esm/components/dictionary/index.js +0 -92
- package/esm/components/dictionary/index.js.map +0 -1
- package/esm/components/dictionary/index.module.css +0 -4
- package/esm/components/dictionary/select.d.ts +0 -19
- package/esm/components/dictionary/select.js +0 -71
- package/esm/components/dictionary/select.js.map +0 -1
- package/esm/components/dictionary/text.d.ts +0 -23
- package/esm/components/dictionary/text.js +0 -31
- package/esm/components/dictionary/text.js.map +0 -1
|
@@ -15,16 +15,23 @@ export default ((props)=>{
|
|
|
15
15
|
});
|
|
16
16
|
const getUploadKey = (file)=>{
|
|
17
17
|
const suffix = file.name.split('.').pop(), keys = [];
|
|
18
|
-
if (props.forceDirectory && props.directory)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
|
|
18
|
+
if (props.forceDirectory && props.directory) {
|
|
19
|
+
keys.push(props.directory);
|
|
20
|
+
} else {
|
|
21
|
+
if (appCode) {
|
|
22
|
+
keys.push(appCode);
|
|
23
|
+
}
|
|
24
|
+
if (tenantId) {
|
|
25
|
+
keys.push(tenantId);
|
|
26
|
+
}
|
|
27
|
+
if (props.directory) {
|
|
28
|
+
keys.push(props.directory);
|
|
29
|
+
}
|
|
23
30
|
}
|
|
24
31
|
keys.push(`${randomId(16)}.${suffix}`);
|
|
25
32
|
return `/${keys.join('/')}`.replace('//', '/');
|
|
26
33
|
}, beforeUpload = async (file)=>{
|
|
27
|
-
const maxSize = props.maxSize ||
|
|
34
|
+
const maxSize = props.maxSize || 1024 * 1024 * 5;
|
|
28
35
|
if (file.size > maxSize) {
|
|
29
36
|
messageApi.error(`${locale.fileSizeTip}: ${formatFileSize(maxSize)}`);
|
|
30
37
|
return false;
|
|
@@ -34,28 +41,36 @@ export default ((props)=>{
|
|
|
34
41
|
}, updateFile = async (file)=>{
|
|
35
42
|
const key = getUploadKey(file);
|
|
36
43
|
setLoading(true);
|
|
37
|
-
if (bucket === 'local')
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
if (bucket === 'local') {
|
|
45
|
+
try {
|
|
46
|
+
const result = await updateFiles({
|
|
47
|
+
key,
|
|
48
|
+
bucket,
|
|
49
|
+
file
|
|
50
|
+
});
|
|
51
|
+
if (result) {
|
|
52
|
+
var _props_onChange, _props_onChangePath;
|
|
53
|
+
(_props_onChange = props.onChange) === null || _props_onChange === void 0 ? void 0 : _props_onChange.call(props, result);
|
|
54
|
+
(_props_onChangePath = props.onChangePath) === null || _props_onChangePath === void 0 ? void 0 : _props_onChangePath.call(props, key);
|
|
55
|
+
}
|
|
56
|
+
} catch (error) {}
|
|
57
|
+
}
|
|
49
58
|
setLoading(false);
|
|
50
59
|
}, getValueFile = async ()=>{
|
|
51
60
|
if (props.value) {
|
|
52
61
|
const result = await getFiles(props.value);
|
|
53
|
-
if (result === null || result === void 0 ? void 0 : result.id)
|
|
62
|
+
if (result === null || result === void 0 ? void 0 : result.id) {
|
|
63
|
+
setName(result.name);
|
|
64
|
+
}
|
|
54
65
|
if (bucket === 'local') {
|
|
55
66
|
const result = await getFilesRaw(props.value, 'url');
|
|
56
|
-
if (typeof result === 'string')
|
|
67
|
+
if (typeof result === 'string') {
|
|
68
|
+
setUrlSrc(result);
|
|
69
|
+
}
|
|
57
70
|
}
|
|
58
|
-
} else
|
|
71
|
+
} else {
|
|
72
|
+
setUrlSrc(undefined);
|
|
73
|
+
}
|
|
59
74
|
}, updateContent = async ()=>{
|
|
60
75
|
if (props.value) {
|
|
61
76
|
const result = await getFilesRaw(props.value);
|
|
@@ -64,8 +79,11 @@ export default ((props)=>{
|
|
|
64
79
|
r.readAsText(result, 'utf-8');
|
|
65
80
|
r.onload = ()=>{
|
|
66
81
|
var _iframeRef_current, _iframeRef_current1;
|
|
67
|
-
if ((_iframeRef_current = iframeRef.current) === null || _iframeRef_current === void 0 ? void 0 : _iframeRef_current.contentWindow)
|
|
68
|
-
|
|
82
|
+
if ((_iframeRef_current = iframeRef.current) === null || _iframeRef_current === void 0 ? void 0 : _iframeRef_current.contentWindow) {
|
|
83
|
+
iframeRef.current.contentWindow.document.write(r.result);
|
|
84
|
+
} else if ((_iframeRef_current1 = iframeRef.current) === null || _iframeRef_current1 === void 0 ? void 0 : _iframeRef_current1.contentDocument) {
|
|
85
|
+
iframeRef.current.contentDocument.write(r.result);
|
|
86
|
+
}
|
|
69
87
|
};
|
|
70
88
|
}
|
|
71
89
|
}
|
|
@@ -76,7 +94,9 @@ export default ((props)=>{
|
|
|
76
94
|
props.value
|
|
77
95
|
]);
|
|
78
96
|
useEffect(()=>{
|
|
79
|
-
if (modal.show)
|
|
97
|
+
if (modal.show) {
|
|
98
|
+
updateContent();
|
|
99
|
+
}
|
|
80
100
|
}, [
|
|
81
101
|
modal.show
|
|
82
102
|
]);
|
|
@@ -164,4 +184,4 @@ export default ((props)=>{
|
|
|
164
184
|
});
|
|
165
185
|
});
|
|
166
186
|
|
|
167
|
-
//# sourceMappingURL=
|
|
187
|
+
//# sourceMappingURL=uploadTemp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["D:\\codeing\\git\\github\\knockout-js\\packages\\layout\\src\\components\\upload-file\\uploadTemp.tsx"],"sourcesContent":["import { UploadOutlined } from \"@ant-design/icons\";\r\nimport { Button, Modal, Popconfirm, Space, Typography, Upload, message } from \"antd\"\r\nimport { RcFile } from \"antd/es/upload\";\r\nimport { useEffect, useRef, useState } from \"react\";\r\nimport { useAppCode, useTenantId } from \"../provider\";\r\nimport { UploadFileProps } from \".\";\r\nimport { useLocale } from \"../locale\";\r\nimport styles from \"./index.module.css\";\r\nimport { formatFileSize, randomId } from \"../_util\";\r\nimport { getFiles, getFilesRaw, updateFiles } from \"@knockout-js/api\";\r\n\r\nexport default (props: UploadFileProps<string> & {\r\n /**\r\n * 显示删除按钮\r\n */\r\n showDelBtn?: boolean;\r\n}) => {\r\n const\r\n bucket = props.bucket ?? 'local',\r\n appCode = props.appCode ?? useAppCode(),\r\n tenantId = props.tenantId ?? useTenantId(),\r\n locale = useLocale(\"UploadFile\"),\r\n [messageApi] = message.useMessage(),\r\n [loading, setLoading] = useState(false),\r\n iframeRef = useRef<HTMLIFrameElement>(null),\r\n [name, setName] = useState<string>(),\r\n [urlSrc, setUrlSrc] = useState<string>(),\r\n [modal, setModal] = useState<{\r\n show: boolean,\r\n }>({\r\n show: false,\r\n });\r\n\r\n const\r\n getUploadKey = (file: RcFile) => {\r\n const suffix = file.name.split('.').pop(),\r\n keys: string[] = [];\r\n if (props.forceDirectory && props.directory) {\r\n keys.push(props.directory)\r\n } else {\r\n if (appCode) {\r\n keys.push(appCode)\r\n }\r\n if (tenantId) {\r\n keys.push(tenantId)\r\n }\r\n if (props.directory) {\r\n keys.push(props.directory)\r\n }\r\n }\r\n keys.push(`${randomId(16)}.${suffix}`);\r\n return `/${keys.join('/')}`.replace('//', '/');\r\n },\r\n beforeUpload = async (file: RcFile) => {\r\n const maxSize = props.maxSize || (1024 * 1024 * 5);\r\n\r\n if (file.size > maxSize) {\r\n messageApi.error(`${locale.fileSizeTip}: ${formatFileSize(maxSize)}`);\r\n return false;\r\n }\r\n\r\n await updateFile(file);\r\n return false;\r\n },\r\n updateFile = async (file: RcFile) => {\r\n const key = getUploadKey(file);\r\n setLoading(true);\r\n if (bucket === 'local') {\r\n try {\r\n const result = await updateFiles({\r\n key,\r\n bucket,\r\n file,\r\n })\r\n if (result) {\r\n props.onChange?.(result)\r\n props.onChangePath?.(key);\r\n }\r\n } catch (error) {\r\n\r\n }\r\n }\r\n setLoading(false)\r\n },\r\n getValueFile = async () => {\r\n if (props.value) {\r\n const result = await getFiles(props.value);\r\n if (result?.id) {\r\n setName(result.name)\r\n }\r\n if (bucket === 'local') {\r\n const result = await getFilesRaw(props.value, 'url');\r\n if (typeof result === 'string') {\r\n setUrlSrc(result)\r\n }\r\n }\r\n } else {\r\n setUrlSrc(undefined)\r\n }\r\n },\r\n updateContent = async () => {\r\n if (props.value) {\r\n const result = await getFilesRaw(props.value)\r\n if (result && typeof result != 'string') {\r\n const r = new FileReader()\r\n r.readAsText(result, 'utf-8')\r\n r.onload = () => {\r\n if (iframeRef.current?.contentWindow) {\r\n iframeRef.current.contentWindow.document.write(r.result as string)\r\n } else if (iframeRef.current?.contentDocument) {\r\n iframeRef.current.contentDocument.write(r.result as string)\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n getValueFile();\r\n }, [props.value]);\r\n\r\n useEffect(() => {\r\n if (modal.show) {\r\n updateContent();\r\n }\r\n }, [modal.show]);\r\n\r\n return <>\r\n <Space>\r\n <Upload\r\n accept={props.accept}\r\n showUploadList={false}\r\n beforeUpload={beforeUpload}\r\n >\r\n <Button loading={loading} icon={<UploadOutlined rev={undefined} />}>{locale.fileUpload}</Button>\r\n </Upload>\r\n <Typography.Text type=\"secondary\">\r\n {`${locale.supportExtension}: ${props.accept?.split(',.').join('、').replace('.', '')}`}\r\n </Typography.Text>\r\n </Space>\r\n {props.value ? <>\r\n <div style={{ height: \"8px\" }}></div>\r\n <Space >\r\n <a onClick={() => {\r\n setModal({ show: true })\r\n }}\r\n >{locale.tempViewer}</a>\r\n <a target=\"_blank\" href={urlSrc} download={name}>{locale.tempDown}</a>\r\n {props.showDelBtn ? <Popconfirm\r\n title={locale.del}\r\n description={locale.confirmDel}\r\n onConfirm={() => {\r\n props.onChange?.()\r\n props.onChangePath?.();\r\n }}\r\n okText=\"Yes\"\r\n cancelText=\"No\"\r\n >\r\n <a className={styles.delText}>{locale.del}</a>\r\n </Popconfirm> : <></>}\r\n </Space>\r\n <Modal\r\n title={locale.tempViewer}\r\n open={modal.show}\r\n destroyOnClose\r\n footer={null}\r\n width={800}\r\n onCancel={() => {\r\n setModal({ show: false })\r\n }}\r\n >\r\n <iframe className={styles.modalIframe} ref={iframeRef}></iframe>\r\n </Modal>\r\n </> : <></>}\r\n </>\r\n}\r\n"],"names":["UploadOutlined","Button","Modal","Popconfirm","Space","Typography","Upload","message","useEffect","useRef","useState","useAppCode","useTenantId","useLocale","styles","formatFileSize","randomId","getFiles","getFilesRaw","updateFiles","props","bucket","appCode","tenantId","locale","messageApi","useMessage","loading","setLoading","iframeRef","name","setName","urlSrc","setUrlSrc","modal","setModal","show","getUploadKey","file","suffix","split","pop","keys","forceDirectory","directory","push","join","replace","beforeUpload","maxSize","size","error","fileSizeTip","updateFile","key","result","onChange","onChangePath","getValueFile","value","id","undefined","updateContent","r","FileReader","readAsText","onload","current","contentWindow","document","write","contentDocument","accept","showUploadList","icon","rev","fileUpload","Text","type","supportExtension","div","style","height","a","onClick","tempViewer","target","href","download","tempDown","showDelBtn","title","del","description","confirmDel","onConfirm","okText","cancelText","className","delText","open","destroyOnClose","footer","width","onCancel","iframe","modalIframe","ref"],"mappings":";AAAA,SAASA,cAAc,QAAQ,oBAAoB;AACnD,SAASC,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAEC,KAAK,EAAEC,UAAU,EAAEC,MAAM,EAAEC,OAAO,QAAQ,OAAM;AAEpF,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AACpD,SAASC,UAAU,EAAEC,WAAW,QAAQ,oBAAc;AAEtD,SAASC,SAAS,QAAQ,kBAAY;AACtC,OAAOC,YAAY,qBAAqB;AACxC,SAASC,cAAc,EAAEC,QAAQ,QAAQ,iBAAW;AACpD,SAASC,QAAQ,EAAEC,WAAW,EAAEC,WAAW,QAAQ,mBAAmB;AAEtE,eAAe,CAAA,CAACC,QAKV;QAyHkCA;QAvH3BA,eACCA,gBACCA;IAHb,MACEC,SAAS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ChErE,MAAMsE,UAAU,iBAAG,KAACvF;gCACnBwF,OAAOnE,OAAOoE,GAAG;gCACjBC,aAAarE,OAAOsE,UAAU;gCAC9BC,WAAW,IAAM;wCACf3E,iBACAA;oCADAA,CAAAA,kBAAAA,MAAMoC,QAAQ,cAAdpC,6BAAAA,KAAAA,IAAAA,gBAAAA,KAAAA;oCACAA,CAAAA,sBAAAA,MAAMqC,YAAY,cAAlBrC,iCAAAA,KAAAA,IAAAA,oBAAAA,KAAAA;gCACF;gCACA4E,QAAO;gCACPC,YAAW;0CAEX,cAAA,KAACd;oCAAEe,WAAWpF,OAAOqF,OAAO;8CAAG3E,OAAOoE,GAAG;;+CAC3B,mBAAK;;;kCAEvB,KAAC1F;wBACCyF,OAAOnE,OAAO6D,UAAU;wBACxBe,MAAMlE,MAAME,IAAI;wBAChBiE,cAAc;wBACdC,QAAQ,IAAI;wBACZC,OAAO;wBACPC,UAAU,IAAM;4BACdrE,SAAS;gCAAEC,MAAM,KAAK;4BAAC;wBACzB;kCAEA,cAAA,KAACqE;4BAAOP,WAAWpF,OAAO4F,WAAW;4BAAEC,KAAK9E;;;;+BAE1C,mBAAK;;;AAEf,CAAA,EAAC"}
|
|
1
|
+
{"version":3,"sources":[".\\src\\components\\upload-file\\uploadTemp.tsx"],"sourcesContent":["import { UploadOutlined } from \"@ant-design/icons\";\r\nimport { Button, Modal, Popconfirm, Space, Typography, Upload, message } from \"antd\"\r\nimport { RcFile } from \"antd/es/upload\";\r\nimport { useEffect, useRef, useState } from \"react\";\r\nimport { useAppCode, useTenantId } from \"../provider\";\r\nimport { UploadFileProps } from \".\";\r\nimport { useLocale } from \"../locale\";\r\nimport styles from \"./index.module.css\";\r\nimport { formatFileSize, randomId } from \"../_util\";\r\nimport { getFiles, getFilesRaw, updateFiles } from \"@knockout-js/api\";\r\n\r\nexport default (props: UploadFileProps<string> & {\r\n /**\r\n * 显示删除按钮\r\n */\r\n showDelBtn?: boolean;\r\n}) => {\r\n const\r\n bucket = props.bucket ?? 'local',\r\n appCode = props.appCode ?? useAppCode(),\r\n tenantId = props.tenantId ?? useTenantId(),\r\n locale = useLocale(\"UploadFile\"),\r\n [messageApi] = message.useMessage(),\r\n [loading, setLoading] = useState(false),\r\n iframeRef = useRef<HTMLIFrameElement>(null),\r\n [name, setName] = useState<string>(),\r\n [urlSrc, setUrlSrc] = useState<string>(),\r\n [modal, setModal] = useState<{\r\n show: boolean,\r\n }>({\r\n show: false,\r\n });\r\n\r\n const\r\n getUploadKey = (file: RcFile) => {\r\n const suffix = file.name.split('.').pop(),\r\n keys: string[] = [];\r\n if (props.forceDirectory && props.directory) {\r\n keys.push(props.directory)\r\n } else {\r\n if (appCode) {\r\n keys.push(appCode)\r\n }\r\n if (tenantId) {\r\n keys.push(tenantId)\r\n }\r\n if (props.directory) {\r\n keys.push(props.directory)\r\n }\r\n }\r\n keys.push(`${randomId(16)}.${suffix}`);\r\n return `/${keys.join('/')}`.replace('//', '/');\r\n },\r\n beforeUpload = async (file: RcFile) => {\r\n const maxSize = props.maxSize || (1024 * 1024 * 5);\r\n\r\n if (file.size > maxSize) {\r\n messageApi.error(`${locale.fileSizeTip}: ${formatFileSize(maxSize)}`);\r\n return false;\r\n }\r\n\r\n await updateFile(file);\r\n return false;\r\n },\r\n updateFile = async (file: RcFile) => {\r\n const key = getUploadKey(file);\r\n setLoading(true);\r\n if (bucket === 'local') {\r\n try {\r\n const result = await updateFiles({\r\n key,\r\n bucket,\r\n file,\r\n })\r\n if (result) {\r\n props.onChange?.(result)\r\n props.onChangePath?.(key);\r\n }\r\n } catch (error) {\r\n\r\n }\r\n }\r\n setLoading(false)\r\n },\r\n getValueFile = async () => {\r\n if (props.value) {\r\n const result = await getFiles(props.value);\r\n if (result?.id) {\r\n setName(result.name)\r\n }\r\n if (bucket === 'local') {\r\n const result = await getFilesRaw(props.value, 'url');\r\n if (typeof result === 'string') {\r\n setUrlSrc(result)\r\n }\r\n }\r\n } else {\r\n setUrlSrc(undefined)\r\n }\r\n },\r\n updateContent = async () => {\r\n if (props.value) {\r\n const result = await getFilesRaw(props.value)\r\n if (result && typeof result != 'string') {\r\n const r = new FileReader()\r\n r.readAsText(result, 'utf-8')\r\n r.onload = () => {\r\n if (iframeRef.current?.contentWindow) {\r\n iframeRef.current.contentWindow.document.write(r.result as string)\r\n } else if (iframeRef.current?.contentDocument) {\r\n iframeRef.current.contentDocument.write(r.result as string)\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n getValueFile();\r\n }, [props.value]);\r\n\r\n useEffect(() => {\r\n if (modal.show) {\r\n updateContent();\r\n }\r\n }, [modal.show]);\r\n\r\n return <>\r\n <Space>\r\n <Upload\r\n accept={props.accept}\r\n showUploadList={false}\r\n beforeUpload={beforeUpload}\r\n >\r\n <Button loading={loading} icon={<UploadOutlined rev={undefined} />}>{locale.fileUpload}</Button>\r\n </Upload>\r\n <Typography.Text type=\"secondary\">\r\n {`${locale.supportExtension}: ${props.accept?.split(',.').join('、').replace('.', '')}`}\r\n </Typography.Text>\r\n </Space>\r\n {props.value ? <>\r\n <div style={{ height: \"8px\" }}></div>\r\n <Space >\r\n <a onClick={() => {\r\n setModal({ show: true })\r\n }}\r\n >{locale.tempViewer}</a>\r\n <a target=\"_blank\" href={urlSrc} download={name}>{locale.tempDown}</a>\r\n {props.showDelBtn ? <Popconfirm\r\n title={locale.del}\r\n description={locale.confirmDel}\r\n onConfirm={() => {\r\n props.onChange?.()\r\n props.onChangePath?.();\r\n }}\r\n okText=\"Yes\"\r\n cancelText=\"No\"\r\n >\r\n <a className={styles.delText}>{locale.del}</a>\r\n </Popconfirm> : <></>}\r\n </Space>\r\n <Modal\r\n title={locale.tempViewer}\r\n open={modal.show}\r\n destroyOnClose\r\n footer={null}\r\n width={800}\r\n onCancel={() => {\r\n setModal({ show: false })\r\n }}\r\n >\r\n <iframe className={styles.modalIframe} ref={iframeRef}></iframe>\r\n </Modal>\r\n </> : <></>}\r\n </>\r\n}\r\n"],"names":["UploadOutlined","Button","Modal","Popconfirm","Space","Typography","Upload","message","useEffect","useRef","useState","useAppCode","useTenantId","useLocale","styles","formatFileSize","randomId","getFiles","getFilesRaw","updateFiles","props","bucket","appCode","tenantId","locale","messageApi","useMessage","loading","setLoading","iframeRef","name","setName","urlSrc","setUrlSrc","modal","setModal","show","getUploadKey","file","suffix","split","pop","keys","forceDirectory","directory","push","join","replace","beforeUpload","maxSize","size","error","fileSizeTip","updateFile","key","result","onChange","onChangePath","getValueFile","value","id","undefined","updateContent","r","FileReader","readAsText","onload","current","contentWindow","document","write","contentDocument","accept","showUploadList","icon","rev","fileUpload","Text","type","supportExtension","div","style","height","a","onClick","tempViewer","target","href","download","tempDown","showDelBtn","title","del","description","confirmDel","onConfirm","okText","cancelText","className","delText","open","destroyOnClose","footer","width","onCancel","iframe","modalIframe","ref"],"mappings":";AAAA,SAASA,cAAc,QAAQ,oBAAoB;AACnD,SAASC,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAEC,KAAK,EAAEC,UAAU,EAAEC,MAAM,EAAEC,OAAO,QAAQ,OAAM;AAEpF,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AACpD,SAASC,UAAU,EAAEC,WAAW,QAAQ,oBAAc;AAEtD,SAASC,SAAS,QAAQ,kBAAY;AACtC,OAAOC,YAAY,qBAAqB;AACxC,SAASC,cAAc,EAAEC,QAAQ,QAAQ,iBAAW;AACpD,SAASC,QAAQ,EAAEC,WAAW,EAAEC,WAAW,QAAQ,mBAAmB;AAEtE,eAAe,CAAA,CAACC,QAKV;QAyHkCA;QAvH3BA,eACCA,gBACCA;IAHb,MACEC,SAASD,CAAAA,gBAAAA,MAAMC,MAAM,cAAZD,2BAAAA,gBAAgB,OAAO,EAChCE,UAAUF,CAAAA,iBAAAA,MAAME,OAAO,cAAbF,4BAAAA,iBAAiBT,YAAY,EACvCY,WAAWH,CAAAA,kBAAAA,MAAMG,QAAQ,cAAdH,6BAAAA,kBAAkBR,aAA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MsE,UAAU,iBAAG,KAACvF;gCACnBwF,OAAOnE,OAAOoE,GAAG;gCACjBC,aAAarE,OAAOsE,UAAU;gCAC9BC,WAAW,IAAM;wCACf3E,iBACAA;oCADAA,CAAAA,kBAAAA,MAAMoC,QAAQ,cAAdpC,6BAAAA,KAAAA,IAAAA,gBAAAA,KAAAA;oCACAA,CAAAA,sBAAAA,MAAMqC,YAAY,cAAlBrC,iCAAAA,KAAAA,IAAAA,oBAAAA,KAAAA;gCACF;gCACA4E,QAAO;gCACPC,YAAW;0CAEX,cAAA,KAACd;oCAAEe,WAAWpF,OAAOqF,OAAO;8CAAG3E,OAAOoE,GAAG;;+CAC3B,mBAAK;;;kCAEvB,KAAC1F;wBACCyF,OAAOnE,OAAO6D,UAAU;wBACxBe,MAAMlE,MAAME,IAAI;wBAChBiE,cAAc;wBACdC,QAAQ,IAAI;wBACZC,OAAO;wBACPC,UAAU,IAAM;4BACdrE,SAAS;gCAAEC,MAAM,KAAK;4BAAC;wBACzB;kCAEA,cAAA,KAACqE;4BAAOP,WAAWpF,OAAO4F,WAAW;4BAAEC,KAAK9E;;;;+BAE1C,mBAAK;;;AAEf,CAAA,EAAC"}
|
package/es2017/index.js
CHANGED
package/es2017/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":[".\\src\\index.tsx"],"sourcesContent":["export * from './components';\r\n"],"names":[],"mappings":"AAAA,cAAc,qBAAe"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
1
2
|
/**
|
|
2
3
|
* 列表数据格式化成树结构
|
|
3
4
|
* @param allList
|
|
@@ -7,18 +8,18 @@
|
|
|
7
8
|
* @returns
|
|
8
9
|
*/
|
|
9
10
|
export declare const listFormatTreeData: <T extends Record<string, any> & {
|
|
10
|
-
children?: T[];
|
|
11
|
-
}>(allList: T[], parentList?: T[], defineKey?: {
|
|
12
|
-
key?: string;
|
|
13
|
-
parentId?: string;
|
|
14
|
-
}, parentId?: string | number) => T[];
|
|
11
|
+
children?: T[] | undefined;
|
|
12
|
+
}>(allList: T[], parentList?: T[] | undefined, defineKey?: {
|
|
13
|
+
key?: string | undefined;
|
|
14
|
+
parentId?: string | undefined;
|
|
15
|
+
} | undefined, parentId?: string | number) => T[];
|
|
15
16
|
/**
|
|
16
17
|
* 解析树结构按树顺序处理成列表
|
|
17
18
|
* @param treeList
|
|
18
19
|
* @returns
|
|
19
20
|
*/
|
|
20
21
|
export declare const treeFormatList: <T extends Record<string, any> & {
|
|
21
|
-
children?: T[];
|
|
22
|
+
children?: T[] | undefined;
|
|
22
23
|
}>(treeList: T[]) => T[];
|
|
23
24
|
/**
|
|
24
25
|
* 字节大小展示处理
|
|
@@ -52,4 +53,4 @@ export declare const parseEnvAppAddress: (evnStr: string) => Record<string, stri
|
|
|
52
53
|
* = "2022-07-07 16:30:00"
|
|
53
54
|
* @returns
|
|
54
55
|
*/
|
|
55
|
-
export declare const getDate: (date: dayjs.ConfigType, format?: string, tz?: string, isTzSet?: boolean) =>
|
|
56
|
+
export declare const getDate: (date: dayjs.ConfigType, format?: string, tz?: string, isTzSet?: boolean) => string | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _object_spread from "@swc/helpers/
|
|
2
|
-
import _to_consumable_array from "@swc/helpers/
|
|
1
|
+
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
2
|
+
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
3
3
|
import dayjs from "dayjs";
|
|
4
4
|
import timezone from "dayjs/plugin/timezone";
|
|
5
5
|
import utc from "dayjs/plugin/utc";
|
|
@@ -17,14 +17,18 @@ dayjs.extend(timezone);
|
|
|
17
17
|
key: "key",
|
|
18
18
|
parentId: "parentId"
|
|
19
19
|
}, defineKey), pid = parentId === undefined ? "0" : parentId;
|
|
20
|
-
if (!parentList)
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
if (!parentList) {
|
|
21
|
+
parentList = allList.filter(function(item) {
|
|
22
|
+
return item[dataKey.parentId] == pid;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
23
25
|
parentList.forEach(function(pItem) {
|
|
24
26
|
var children = allList.filter(function(allItem) {
|
|
25
27
|
return allItem[dataKey.parentId] == pItem[dataKey.key];
|
|
26
28
|
});
|
|
27
|
-
if (children && children.length)
|
|
29
|
+
if (children && children.length) {
|
|
30
|
+
pItem.children = listFormatTreeData(allList, children, dataKey);
|
|
31
|
+
}
|
|
28
32
|
});
|
|
29
33
|
return parentList;
|
|
30
34
|
};
|
|
@@ -35,11 +39,13 @@ dayjs.extend(timezone);
|
|
|
35
39
|
*/ export var treeFormatList = function(treeList) {
|
|
36
40
|
var allList = [];
|
|
37
41
|
treeList.forEach(function(item) {
|
|
38
|
-
var _allList;
|
|
39
42
|
var children = item.children;
|
|
40
43
|
delete item.children;
|
|
41
44
|
allList === null || allList === void 0 ? void 0 : allList.push(item);
|
|
42
|
-
if (children)
|
|
45
|
+
if (children) {
|
|
46
|
+
var _allList;
|
|
47
|
+
(_allList = allList).push.apply(_allList, _to_consumable_array(treeFormatList(children)));
|
|
48
|
+
}
|
|
43
49
|
});
|
|
44
50
|
return allList;
|
|
45
51
|
};
|
|
@@ -48,10 +54,15 @@ dayjs.extend(timezone);
|
|
|
48
54
|
* @param fileSize
|
|
49
55
|
* @returns
|
|
50
56
|
*/ export var formatFileSize = function(fileSize) {
|
|
51
|
-
if (fileSize < 1024)
|
|
52
|
-
|
|
53
|
-
else if (fileSize <
|
|
54
|
-
|
|
57
|
+
if (fileSize < 1024) {
|
|
58
|
+
return fileSize + "B";
|
|
59
|
+
} else if (fileSize < 1024 * 1024) {
|
|
60
|
+
return (fileSize / 1024).toFixed(2) + "KB";
|
|
61
|
+
} else if (fileSize < 1024 * 1024 * 1024) {
|
|
62
|
+
return (fileSize / (1024 * 1024)).toFixed(2) + "MB";
|
|
63
|
+
} else {
|
|
64
|
+
return (fileSize / (1024 * 1024 * 1024)).toFixed(2) + "GB";
|
|
65
|
+
}
|
|
55
66
|
};
|
|
56
67
|
/**
|
|
57
68
|
* 随机数
|
|
@@ -71,7 +82,9 @@ dayjs.extend(timezone);
|
|
|
71
82
|
evnStr.split(";").forEach(function(str) {
|
|
72
83
|
if (str) {
|
|
73
84
|
var adds = str.split("@");
|
|
74
|
-
if (adds.length === 2)
|
|
85
|
+
if (adds.length === 2) {
|
|
86
|
+
address[adds[0]] = adds[1];
|
|
87
|
+
}
|
|
75
88
|
}
|
|
76
89
|
});
|
|
77
90
|
return address;
|
|
@@ -93,11 +106,16 @@ dayjs.extend(timezone);
|
|
|
93
106
|
var format = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "YYYY-MM-DD", tz = arguments.length > 2 ? arguments[2] : void 0, isTzSet = arguments.length > 3 ? arguments[3] : void 0;
|
|
94
107
|
if (date) {
|
|
95
108
|
if (tz) {
|
|
96
|
-
if (isTzSet)
|
|
97
|
-
|
|
109
|
+
if (isTzSet) {
|
|
110
|
+
return dayjs.tz(date, tz).format(format);
|
|
111
|
+
} else {
|
|
112
|
+
return dayjs(date).tz(tz).format(format);
|
|
113
|
+
}
|
|
98
114
|
}
|
|
99
115
|
return dayjs(date).format(format);
|
|
100
|
-
} else
|
|
116
|
+
} else {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
101
119
|
};
|
|
102
120
|
|
|
103
|
-
//# sourceMappingURL=
|
|
121
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":[".\\src\\components\\_util\\index.ts"],"sourcesContent":["import dayjs from 'dayjs';\r\nimport timezone from 'dayjs/plugin/timezone';\r\nimport utc from 'dayjs/plugin/utc';\r\n\r\ndayjs.extend(utc);\r\ndayjs.extend(timezone);\r\n\r\n/**\r\n * 列表数据格式化成树结构\r\n * @param allList\r\n * @param parentList\r\n * @param defineKey\r\n * @param parentId\r\n * @returns\r\n */\r\nexport const listFormatTreeData = <T extends Record<string, any> & { children?: T[] }>(\r\n allList: T[],\r\n parentList?: T[],\r\n defineKey?: {\r\n key?: string;\r\n parentId?: string;\r\n },\r\n parentId?: string | number,\r\n) => {\r\n const dataKey = { key: 'key', parentId: 'parentId', ...defineKey },\r\n pid = parentId === undefined ? '0' : parentId;\r\n\r\n if (!parentList) {\r\n parentList = allList.filter(item => item[dataKey.parentId] == pid);\r\n }\r\n\r\n parentList.forEach((pItem) => {\r\n const children = allList.filter(\r\n (allItem) => allItem[dataKey.parentId] == pItem[dataKey.key],\r\n );\r\n if (children && children.length) {\r\n pItem.children = listFormatTreeData(allList, children, dataKey);\r\n }\r\n });\r\n return parentList;\r\n};\r\n\r\n/**\r\n * 解析树结构按树顺序处理成列表\r\n * @param treeList\r\n * @returns\r\n */\r\nexport const treeFormatList = <T extends Record<string, any> & { children?: T[] }>(treeList: T[]) => {\r\n const allList: T[] = [];\r\n\r\n treeList.forEach(item => {\r\n const children = item.children;\r\n delete item.children;\r\n allList?.push(item);\r\n if (children) {\r\n allList.push(...treeFormatList(children));\r\n }\r\n });\r\n\r\n return allList;\r\n}\r\n\r\n/**\r\n * 字节大小展示处理\r\n * @param fileSize\r\n * @returns\r\n */\r\nexport const formatFileSize = (fileSize: number) => {\r\n if (fileSize < 1024) {\r\n return fileSize + 'B';\r\n } else if (fileSize < (1024 * 1024)) {\r\n return (fileSize / 1024).toFixed(2) + 'KB';\r\n } else if (fileSize < (1024 * 1024 * 1024)) {\r\n return (fileSize / (1024 * 1024)).toFixed(2) + 'MB';\r\n } else {\r\n return (fileSize / (1024 * 1024 * 1024)).toFixed(2) + 'GB';\r\n }\r\n}\r\n\r\n/**\r\n * 随机数\r\n * @param len\r\n * @returns\r\n */\r\nexport const randomId = (len: number) => {\r\n let str = '';\r\n for (; str.length < len; str += Math.random().toString(36).substring(2));\r\n return str.substring(0, len);\r\n}\r\n\r\n\r\n/**\r\n * 解析env配置的app地址字符串\r\n * @param evnStr appCode@deploy_address;\r\n * @returns\r\n */\r\nexport const parseEnvAppAddress = (evnStr: string) => {\r\n const address: Record<string, string> = {};\r\n evnStr.split(';').forEach(str => {\r\n if (str) {\r\n const adds = str.split('@');\r\n if (adds.length === 2) {\r\n address[adds[0]] = adds[1];\r\n }\r\n }\r\n })\r\n return address;\r\n}\r\n\r\n\r\n\r\n/**\r\n * 格式化日期\r\n * @param date\r\n * @param format YYYY-MM-DD HH:mm:ss\r\n * @param tz 时区\r\n * @param isTzSet true将当前时间设置成这个时区,false 将当前时间根据时区转换\r\n * 例子 isTzSet=true\r\n * dayjs.tz(\"2022-07-07 16:30:00\", \"America/New_York\").format(\"YYYY-MM-DDTHH:mm:ssZ\")\r\n * = \"2022-07-07T16:30:00-04:00\"\r\n * 例子 isTzSet=false\r\n * dayjs(\"2022-07-07T20:30:00Z\").tz(\"America/New_York\").format(\"YYYY-MM-DD HH:mm:ss\")\r\n * = \"2022-07-07 16:30:00\"\r\n * @returns\r\n */\r\nexport const getDate = (\r\n date: dayjs.ConfigType,\r\n format = 'YYYY-MM-DD',\r\n tz?: string,\r\n isTzSet?: boolean,\r\n) => {\r\n if (date) {\r\n if (tz) {\r\n if (isTzSet) {\r\n return dayjs.tz(date, tz).format(format);\r\n } else {\r\n return dayjs(date).tz(tz).format(format);\r\n }\r\n }\r\n return dayjs(date).format(format);\r\n } else {\r\n return null\r\n }\r\n};\r\n"],"names":["dayjs","timezone","utc","extend","listFormatTreeData","allList","parentList","defineKey","parentId","dataKey","key","pid","undefined","filter","item","forEach","pItem","children","allItem","length","treeFormatList","treeList","push","formatFileSize","fileSize","toFixed","randomId","len","str","Math","random","toString","substring","parseEnvAppAddress","evnStr","address","split","adds","getDate","date","format","tz","isTzSet"],"mappings":";;AAAA,OAAOA,WAAW,QAAQ;AAC1B,OAAOC,cAAc,wBAAwB;AAC7C,OAAOC,SAAS,mBAAmB;AAEnCF,MAAMG,MAAM,CAACD;AACbF,MAAMG,MAAM,CAACF;AA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="react" />
|
|
2
1
|
import { DrawerProps } from "antd";
|
|
3
2
|
import { App, AppMenu } from "@knockout-js/api/ucenter";
|
|
4
3
|
export type AggregateMenuLocale = {
|
|
@@ -33,5 +32,5 @@ export interface AggregateMenuProps {
|
|
|
33
32
|
*/
|
|
34
33
|
onClick?: (menuItem: AppMenu, app: App, isOpen?: boolean) => void;
|
|
35
34
|
}
|
|
36
|
-
declare const _default: (props: AggregateMenuProps) => JSX.Element;
|
|
35
|
+
declare const _default: (props: AggregateMenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
37
36
|
export default _default;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import _async_to_generator from "@swc/helpers/
|
|
2
|
-
import _object_spread from "@swc/helpers/
|
|
3
|
-
import _object_spread_props from "@swc/helpers/
|
|
4
|
-
import _sliced_to_array from "@swc/helpers/
|
|
5
|
-
import _to_consumable_array from "@swc/helpers/
|
|
6
|
-
import _ts_generator from "@swc/helpers/
|
|
1
|
+
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
|
+
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
3
|
+
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
4
|
+
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
5
|
+
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
6
|
+
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
7
7
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@ice/jsx-runtime/jsx-runtime";
|
|
8
8
|
import { CloseOutlined, DragOutlined, SearchOutlined, StarOutlined } from "@ant-design/icons";
|
|
9
9
|
import { useCallback, useEffect, useState } from "react";
|
|
@@ -96,9 +96,11 @@ export default function(props) {
|
|
|
96
96
|
];
|
|
97
97
|
case 1:
|
|
98
98
|
appsResult = _state.sent(), apps = [];
|
|
99
|
-
if ((_appsResult_data = appsResult.data) === null || _appsResult_data === void 0 ? void 0 : _appsResult_data.userApps)
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
if ((_appsResult_data = appsResult.data) === null || _appsResult_data === void 0 ? void 0 : _appsResult_data.userApps) {
|
|
100
|
+
appsResult.data.userApps.forEach(function(app) {
|
|
101
|
+
apps.push(app);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
102
104
|
newAll = [];
|
|
103
105
|
_tmp = [];
|
|
104
106
|
for(_tmp1 in apps)_tmp.push(_tmp1);
|
|
@@ -153,28 +155,32 @@ export default function(props) {
|
|
|
153
155
|
preferenceResult = _state.sent();
|
|
154
156
|
if ((_preferenceResult_data = preferenceResult.data) === null || _preferenceResult_data === void 0 ? void 0 : (_preferenceResult_data_orgUserPreference = _preferenceResult_data.orgUserPreference) === null || _preferenceResult_data_orgUserPreference === void 0 ? void 0 : _preferenceResult_data_orgUserPreference.id) {
|
|
155
157
|
menuFavorite = preferenceResult.data.orgUserPreference.menuFavorite, menuRecent = preferenceResult.data.orgUserPreference.menuRecent, collectsList = [], latelyList = [];
|
|
156
|
-
if (menuFavorite)
|
|
157
|
-
|
|
158
|
-
var
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
158
|
+
if (menuFavorite) {
|
|
159
|
+
menuFavorite.forEach(function(id) {
|
|
160
|
+
for(var i in newAll){
|
|
161
|
+
var menuItem = newAll[i].menu.find(function(item) {
|
|
162
|
+
return item.id == id;
|
|
163
|
+
});
|
|
164
|
+
if (menuItem) {
|
|
165
|
+
collectsList.push(menuItem);
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
164
168
|
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
if (menuRecent)
|
|
168
|
-
|
|
169
|
-
var
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
if (menuRecent) {
|
|
172
|
+
menuRecent.forEach(function(id) {
|
|
173
|
+
for(var i in newAll){
|
|
174
|
+
var menuItem = newAll[i].menu.find(function(item) {
|
|
175
|
+
return item.id == id;
|
|
176
|
+
});
|
|
177
|
+
if (menuItem) {
|
|
178
|
+
latelyList.push(menuItem);
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
175
181
|
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
178
184
|
setCollects(collectsList);
|
|
179
185
|
setLately(latelyList);
|
|
180
186
|
}
|
|
@@ -262,7 +268,9 @@ export default function(props) {
|
|
|
262
268
|
oldIdx = latelyList.findIndex(function(lately) {
|
|
263
269
|
return lately.id == menuItem.id;
|
|
264
270
|
});
|
|
265
|
-
if (oldIdx > -1)
|
|
271
|
+
if (oldIdx > -1) {
|
|
272
|
+
latelyList.splice(oldIdx, 1);
|
|
273
|
+
}
|
|
266
274
|
latelyList.unshift(menuItem);
|
|
267
275
|
latelyList.splice(6);
|
|
268
276
|
return [
|
|
@@ -322,12 +330,15 @@ export default function(props) {
|
|
|
322
330
|
case 0:
|
|
323
331
|
event.stopPropagation();
|
|
324
332
|
collectList = [];
|
|
325
|
-
if (checkCollect(menuItem))
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
333
|
+
if (checkCollect(menuItem)) {
|
|
334
|
+
collectList = collects.filter(function(c) {
|
|
335
|
+
return !(c.id === menuItem.id && c.appID === menuItem.appID);
|
|
336
|
+
});
|
|
337
|
+
} else {
|
|
338
|
+
collectList = _to_consumable_array(collects).concat([
|
|
339
|
+
menuItem
|
|
340
|
+
]);
|
|
341
|
+
}
|
|
331
342
|
return [
|
|
332
343
|
4,
|
|
333
344
|
requestFavorite(collectList)
|
|
@@ -356,7 +367,9 @@ export default function(props) {
|
|
|
356
367
|
if (props.dataSource) {
|
|
357
368
|
setAll(props.dataSource);
|
|
358
369
|
setFilterList(props.dataSource);
|
|
359
|
-
} else
|
|
370
|
+
} else {
|
|
371
|
+
request();
|
|
372
|
+
}
|
|
360
373
|
}, [
|
|
361
374
|
props.dataSource
|
|
362
375
|
]);
|
|
@@ -386,17 +399,19 @@ export default function(props) {
|
|
|
386
399
|
collisionDetection: closestCenter,
|
|
387
400
|
onDragEnd: function(event) {
|
|
388
401
|
var active = event.active, over = event.over;
|
|
389
|
-
if (over && active.id !== over.id)
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
402
|
+
if (over && active.id !== over.id) {
|
|
403
|
+
setCollects(function(items) {
|
|
404
|
+
var oldIndex = items.findIndex(function(oItem) {
|
|
405
|
+
return "".concat(oItem.id, "-").concat(oItem.appID) == active.id;
|
|
406
|
+
});
|
|
407
|
+
var newIndex = items.findIndex(function(nItem) {
|
|
408
|
+
return "".concat(nItem.id, "-").concat(nItem.appID) == over.id;
|
|
409
|
+
});
|
|
410
|
+
var collectList = arrayMove(items, oldIndex, newIndex);
|
|
411
|
+
requestFavorite(collectList);
|
|
412
|
+
return collectList;
|
|
395
413
|
});
|
|
396
|
-
|
|
397
|
-
requestFavorite(collectList);
|
|
398
|
-
return collectList;
|
|
399
|
-
});
|
|
414
|
+
}
|
|
400
415
|
},
|
|
401
416
|
children: /*#__PURE__*/ _jsx(SortableContext, {
|
|
402
417
|
items: collects.map(function(item) {
|
|
@@ -465,7 +480,9 @@ export default function(props) {
|
|
|
465
480
|
return f.menu.length;
|
|
466
481
|
});
|
|
467
482
|
setFilterList(fList);
|
|
468
|
-
} else
|
|
483
|
+
} else {
|
|
484
|
+
setFilterList(_to_consumable_array(all));
|
|
485
|
+
}
|
|
469
486
|
}
|
|
470
487
|
})
|
|
471
488
|
}),
|
|
@@ -518,4 +535,4 @@ export default function(props) {
|
|
|
518
535
|
});
|
|
519
536
|
};
|
|
520
537
|
|
|
521
|
-
//# sourceMappingURL=
|
|
538
|
+
//# sourceMappingURL=index.js.map
|