@knockout-js/layout 0.1.4 → 0.1.5-beta.0

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 (27) hide show
  1. package/es2017/components/upload-file/index.d.ts +9 -21
  2. package/es2017/components/upload-file/index.js.map +1 -1
  3. package/es2017/components/upload-file/locale/en_US.js +3 -1
  4. package/es2017/components/upload-file/locale/en_US.js.map +1 -1
  5. package/es2017/components/upload-file/locale/zh_CN.js +3 -1
  6. package/es2017/components/upload-file/locale/zh_CN.js.map +1 -1
  7. package/es2017/components/upload-file/uploadAvatar.d.ts +1 -1
  8. package/es2017/components/upload-file/uploadAvatar.js +19 -47
  9. package/es2017/components/upload-file/uploadAvatar.js.map +1 -1
  10. package/es2017/components/upload-file/uploadMultiple.js +96 -142
  11. package/es2017/components/upload-file/uploadMultiple.js.map +1 -1
  12. package/es2017/components/upload-file/uploadTemp.js +48 -74
  13. package/es2017/components/upload-file/uploadTemp.js.map +1 -1
  14. package/esm/components/upload-file/index.d.ts +9 -21
  15. package/esm/components/upload-file/index.js.map +1 -1
  16. package/esm/components/upload-file/locale/en_US.js +3 -1
  17. package/esm/components/upload-file/locale/en_US.js.map +1 -1
  18. package/esm/components/upload-file/locale/zh_CN.js +3 -1
  19. package/esm/components/upload-file/locale/zh_CN.js.map +1 -1
  20. package/esm/components/upload-file/uploadAvatar.d.ts +1 -1
  21. package/esm/components/upload-file/uploadAvatar.js +41 -94
  22. package/esm/components/upload-file/uploadAvatar.js.map +1 -1
  23. package/esm/components/upload-file/uploadMultiple.js +162 -233
  24. package/esm/components/upload-file/uploadMultiple.js.map +1 -1
  25. package/esm/components/upload-file/uploadTemp.js +104 -150
  26. package/esm/components/upload-file/uploadTemp.js.map +1 -1
  27. package/package.json +2 -2
@@ -2,89 +2,44 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@ice/jsx-runt
2
2
  import { UploadOutlined } from "@ant-design/icons";
3
3
  import { Button, Modal, Popconfirm, Space, Typography, Upload, message } from "antd";
4
4
  import { useEffect, useRef, useState } from "react";
5
- import { useAppCode, useTenantId } from "../provider/index";
6
5
  import { useLocale } from "../locale/index";
7
6
  import styles from "./index.module.css";
8
- import { formatFileSize, randomId } from "../_util/index";
9
- import { getFiles, getFilesRaw, updateFiles } from "@knockout-js/api";
7
+ import { formatFileSize } from "../_util/index";
8
+ import { getFileRaw, getFileUrl, getStorageUrl, parseStorageData, uploadFile } from "@knockout-js/api";
10
9
  export default ((props)=>{
11
10
  var _props_accept;
12
- var _props_bucket, _props_appCode, _props_tenantId;
13
- const bucket = (_props_bucket = props.bucket) !== null && _props_bucket !== void 0 ? _props_bucket : 'local', appCode = (_props_appCode = props.appCode) !== null && _props_appCode !== void 0 ? _props_appCode : useAppCode(), tenantId = (_props_tenantId = props.tenantId) !== null && _props_tenantId !== void 0 ? _props_tenantId : useTenantId(), locale = useLocale("UploadFile"), [messageApi] = message.useMessage(), [loading, setLoading] = useState(false), iframeRef = useRef(null), [name, setName] = useState(), [urlSrc, setUrlSrc] = useState(), [modal, setModal] = useState({
11
+ const locale = useLocale("UploadFile"), [messageApi] = message.useMessage(), [loading, setLoading] = useState(false), iframeRef = useRef(null), [name, setName] = useState(), [urlSrc, setUrlSrc] = useState(), [modal, setModal] = useState({
14
12
  show: false
15
13
  });
16
- const getUploadKey = (file)=>{
17
- const suffix = file.name.split('.').pop(), keys = [];
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
- }
30
- }
31
- keys.push(`${randomId(16)}.${suffix}`);
32
- return `/${keys.join('/')}`.replace('//', '/');
33
- }, beforeUpload = async (file)=>{
34
- const maxSize = props.maxSize || 1024 * 1024 * 5;
35
- if (file.size > maxSize) {
36
- messageApi.error(`${locale.fileSizeTip}: ${formatFileSize(maxSize)}`);
37
- return false;
38
- }
39
- await updateFile(file);
40
- return false;
41
- }, updateFile = async (file)=>{
42
- const key = getUploadKey(file);
43
- setLoading(true);
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
- }
58
- setLoading(false);
59
- }, getValueFile = async ()=>{
14
+ const getValueFile = async ()=>{
60
15
  if (props.value) {
61
- const result = await getFiles(props.value);
62
- if (result === null || result === void 0 ? void 0 : result.id) {
16
+ const result = await parseStorageData(props.value, undefined, false, props.endpoint, props.bucket);
17
+ if (result) {
63
18
  setName(result.name);
19
+ setUrlSrc(result.url);
64
20
  }
65
- if (bucket === 'local') {
66
- const result = await getFilesRaw(props.value, 'url');
67
- if (typeof result === 'string') {
68
- setUrlSrc(result);
69
- }
70
- }
71
- } else {
72
- setUrlSrc(undefined);
73
21
  }
74
22
  }, updateContent = async ()=>{
75
23
  if (props.value) {
76
- const result = await getFilesRaw(props.value);
77
- if (result && typeof result != 'string') {
78
- const r = new FileReader();
79
- r.readAsText(result, 'utf-8');
80
- r.onload = ()=>{
81
- var _iframeRef_current, _iframeRef_current1;
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
- }
87
- };
24
+ const dataRes = await parseStorageData(props.value);
25
+ if (dataRes) {
26
+ const result = await getFileRaw(dataRes.path, props.endpoint, props.bucket);
27
+ if (result) {
28
+ var _result_Body;
29
+ const content = await ((_result_Body = result.Body) === null || _result_Body === void 0 ? void 0 : _result_Body.transformToString('utf-8'));
30
+ const r = new FileReader();
31
+ r.readAsText(new Blob([
32
+ content !== null && content !== void 0 ? content : ''
33
+ ]), 'utf-8');
34
+ r.onload = ()=>{
35
+ var _iframeRef_current, _iframeRef_current1;
36
+ if ((_iframeRef_current = iframeRef.current) === null || _iframeRef_current === void 0 ? void 0 : _iframeRef_current.contentWindow) {
37
+ iframeRef.current.contentWindow.document.write(`<pre>${r.result}</pre>`);
38
+ } else if ((_iframeRef_current1 = iframeRef.current) === null || _iframeRef_current1 === void 0 ? void 0 : _iframeRef_current1.contentDocument) {
39
+ iframeRef.current.contentDocument.write(`<pre>${r.result}</pre>`);
40
+ }
41
+ };
42
+ }
88
43
  }
89
44
  }
90
45
  };
@@ -107,7 +62,26 @@ export default ((props)=>{
107
62
  /*#__PURE__*/ _jsx(Upload, {
108
63
  accept: props.accept,
109
64
  showUploadList: false,
110
- beforeUpload: beforeUpload,
65
+ beforeUpload: async (file)=>{
66
+ const maxSize = props.maxSize || 1024 * 1024 * 5;
67
+ if (file.size > maxSize) {
68
+ messageApi.error(`${locale.fileSizeTip}: ${formatFileSize(maxSize)}`);
69
+ return false;
70
+ }
71
+ setLoading(true);
72
+ const result = await uploadFile(file, props.directory, props.endpoint, props.bucket);
73
+ if (result === null || result === void 0 ? void 0 : result.path) {
74
+ var _props_onChange;
75
+ const storageUlr = await getStorageUrl(result.path, props.endpoint, props.bucket), url = await getFileUrl(result.path, 3600, undefined, props.endpoint, props.bucket);
76
+ setName(file.name);
77
+ setUrlSrc(url);
78
+ (_props_onChange = props.onChange) === null || _props_onChange === void 0 ? void 0 : _props_onChange.call(props, storageUlr);
79
+ } else {
80
+ messageApi.error(locale.errorUpload);
81
+ }
82
+ setLoading(false);
83
+ return false;
84
+ },
111
85
  children: /*#__PURE__*/ _jsx(Button, {
112
86
  loading: loading,
113
87
  icon: /*#__PURE__*/ _jsx(UploadOutlined, {
@@ -143,15 +117,15 @@ export default ((props)=>{
143
117
  target: "_blank",
144
118
  href: urlSrc,
145
119
  download: name,
120
+ rel: "noopener noreferrer",
146
121
  children: locale.tempDown
147
122
  }),
148
123
  props.showDelBtn ? /*#__PURE__*/ _jsx(Popconfirm, {
149
124
  title: locale.del,
150
125
  description: locale.confirmDel,
151
126
  onConfirm: ()=>{
152
- var _props_onChange, _props_onChangePath;
127
+ var _props_onChange;
153
128
  (_props_onChange = props.onChange) === null || _props_onChange === void 0 ? void 0 : _props_onChange.call(props);
154
- (_props_onChangePath = props.onChangePath) === null || _props_onChangePath === void 0 ? void 0 : _props_onChangePath.call(props);
155
129
  },
156
130
  okText: "Yes",
157
131
  cancelText: "No",
@@ -1 +1 @@
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,aAAa,EAC1CY,SAASX,UAAU,eACnB,CAACY,WAAW,GAAGlB,QAAQmB,UAAU,IACjC,CAACC,SAASC,WAAW,GAAGlB,SAAS,KAAK,GACtCmB,YAAYpB,OAA0B,IAAI,GAC1C,CAACqB,MAAMC,QAAQ,GAAGrB,YAClB,CAACsB,QAAQC,UAAU,GAAGvB,YACtB,CAACwB,OAAOC,SAAS,GAAGzB,SAEjB;QACD0B,MAAM,KAAK;IACb;I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A,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 { UploadFileProps } from \".\";\r\nimport { useLocale } from \"../locale\";\r\nimport styles from \"./index.module.css\";\r\nimport { formatFileSize } from \"../_util\";\r\nimport { getFileRaw, getFileUrl, getStorageUrl, parseStorageData, uploadFile } 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 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 getValueFile = async () => {\r\n if (props.value) {\r\n const result = await parseStorageData(props.value, undefined, false, props.endpoint, props.bucket);\r\n if (result) {\r\n setName(result.name)\r\n setUrlSrc(result.url)\r\n }\r\n }\r\n },\r\n updateContent = async () => {\r\n if (props.value) {\r\n const dataRes = await parseStorageData(props.value)\r\n if (dataRes) {\r\n const result = await getFileRaw(dataRes.path, props.endpoint, props.bucket)\r\n if (result) {\r\n const content = await result.Body?.transformToString('utf-8')\r\n const r = new FileReader()\r\n r.readAsText(new Blob([content ?? '']), 'utf-8')\r\n r.onload = () => {\r\n if (iframeRef.current?.contentWindow) {\r\n iframeRef.current.contentWindow.document.write(`<pre>${r.result}</pre>`)\r\n } else if (iframeRef.current?.contentDocument) {\r\n iframeRef.current.contentDocument.write(`<pre>${r.result}</pre>`)\r\n }\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={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 setLoading(true);\r\n const result = await uploadFile(file, props.directory, props.endpoint, props.bucket);\r\n if (result?.path) {\r\n const storageUlr = await getStorageUrl(result.path, props.endpoint, props.bucket),\r\n url = await getFileUrl(result.path, 3600, undefined, props.endpoint, props.bucket)\r\n setName(file.name)\r\n setUrlSrc(url)\r\n props.onChange?.(storageUlr)\r\n } else {\r\n messageApi.error(locale.errorUpload);\r\n }\r\n setLoading(false);\r\n return false;\r\n }}\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} rel=\"noopener noreferrer\">{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 }}\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","useLocale","styles","formatFileSize","getFileRaw","getFileUrl","getStorageUrl","parseStorageData","uploadFile","props","locale","messageApi","useMessage","loading","setLoading","iframeRef","name","setName","urlSrc","setUrlSrc","modal","setModal","show","getValueFile","value","result","undefined","endpoint","bucket","url","updateContent","dataRes","path","content","Body","transformToString","r","FileReader","readAsText","Blob","onload","current","contentWindow","document","write","contentDocument","accept","showUploadList","beforeUpload","file","maxSize","size","error","fileSizeTip","directory","storageUlr","onChange","errorUpload","icon","rev","fileUpload","Text","type","supportExtension","split","join","replace","div","style","height","a","onClick","tempViewer","target","href","download","rel","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;AAEp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,MAAMqE,UAAU,iBAAG,KAACrF;gCACnBsF,OAAOrE,OAAOsE,GAAG;gCACjBC,aAAavE,OAAOwE,UAAU;gCAC9BC,WAAW,IAAM;wCACf1E;oCAAAA,CAAAA,kBAAAA,MAAM+C,QAAQ,cAAd/C,6BAAAA,KAAAA,IAAAA,gBAAAA,KAAAA;gCACF;gCACA2E,QAAO;gCACPC,YAAW;0CAEX,cAAA,KAACf;oCAAEgB,WAAWpF,OAAOqF,OAAO;8CAAG7E,OAAOsE,GAAG;;+CAC3B,mBAAK;;;kCAEvB,KAACxF;wBACCuF,OAAOrE,OAAO8D,UAAU;wBACxBgB,MAAMpE,MAAME,IAAI;wBAChBmE,cAAc;wBACdC,QAAQ,IAAI;wBACZC,OAAO;wBACPC,UAAU,IAAM;4BACdvE,SAAS;gCAAEC,MAAM,KAAK;4BAAC;wBACzB;kCAEA,cAAA,KAACuE;4BAAOP,WAAWpF,OAAO4F,WAAW;4BAAEC,KAAKhF;;;;+BAE1C,mBAAK;;;AAEf,CAAA,EAAC"}
@@ -5,6 +5,8 @@ export type UploadFileLocale = {
5
5
  clickOrDragUpload: string;
6
6
  supportExtension: string;
7
7
  errSupportExtension: string;
8
+ errorUpload: string;
9
+ errorDel: string;
8
10
  fileUpload: string;
9
11
  tempViewer: string;
10
12
  tempDown: string;
@@ -15,23 +17,15 @@ export interface UploadFileProps<T> {
15
17
  */
16
18
  bucket?: string;
17
19
  /**
18
- * 应用code
20
+ * endpoint
19
21
  */
20
- appCode?: string;
22
+ endpoint?: string;
21
23
  /**
22
- * tenantId
24
+ * 目录格式 xxx/xx
23
25
  */
24
- tenantId?: string;
26
+ directory: string;
25
27
  /**
26
- * 目录格式 xxx/ss
27
- */
28
- directory?: string;
29
- /**
30
- * 强制使用目录当前缀
31
- */
32
- forceDirectory?: boolean;
33
- /**
34
- * 限制文件大小
28
+ * 限制文件大小 默认5M
35
29
  */
36
30
  maxSize?: number;
37
31
  /**
@@ -39,19 +33,13 @@ export interface UploadFileProps<T> {
39
33
  */
40
34
  accept?: string;
41
35
  /**
42
- * 文件 id
36
+ * 使用url
43
37
  */
44
38
  value?: T;
45
39
  /**
46
- * 返回文件id
40
+ * 返回存储数据库的url
47
41
  * @param value
48
42
  * @returns
49
43
  */
50
44
  onChange?: (value?: T) => void;
51
- /**
52
- * 返回文件path
53
- * @param path
54
- * @returns
55
- */
56
- onChangePath?: (path?: T) => void;
57
45
  }
@@ -1 +1 @@
1
- {"version":3,"sources":[".\\src\\components\\upload-file\\index.ts"],"sourcesContent":["export type UploadFileLocale = {\r\n // 文件大小必须小于:\r\n fileSizeTip: string;\r\n del: string;\r\n confirmDel: string;\r\n // 点击或拖拽文件上传\r\n clickOrDragUpload: string;\r\n // 支持扩展名\r\n supportExtension: string;\r\n errSupportExtension: string;\r\n fileUpload: string;\r\n tempViewer: string;\r\n tempDown: string;\r\n}\r\n\r\nexport interface UploadFileProps<T> {\r\n /**\r\n * bucket\r\n */\r\n bucket?: string;\r\n /**\r\n * 应用code\r\n */\r\n appCode?: string;\r\n /**\r\n * tenantId\r\n */\r\n tenantId?: string;\r\n /**\r\n * 目录格式 xxx/ss\r\n */\r\n directory?: string;\r\n /**\r\n * 强制使用目录当前缀\r\n */\r\n forceDirectory?: boolean;\r\n /**\r\n * 限制文件大小\r\n */\r\n maxSize?: number;\r\n /**\r\n * 限制弹框选择\r\n */\r\n accept?: string;\r\n /**\r\n * 文件 id\r\n */\r\n value?: T;\r\n /**\r\n * 返回文件id\r\n * @param value\r\n * @returns\r\n */\r\n onChange?: (value?: T) => void;\r\n /**\r\n * 返回文件path\r\n * @param path\r\n * @returns\r\n */\r\n onChangePath?: (path?: T) => void;\r\n}\r\n"],"names":[],"mappings":"AAAA,WA4DC"}
1
+ {"version":3,"sources":[".\\src\\components\\upload-file\\index.ts"],"sourcesContent":["export type UploadFileLocale = {\r\n // 文件大小必须小于:\r\n fileSizeTip: string;\r\n del: string;\r\n confirmDel: string;\r\n // 点击或拖拽文件上传\r\n clickOrDragUpload: string;\r\n // 支持扩展名\r\n supportExtension: string;\r\n errSupportExtension: string;\r\n errorUpload: string;\r\n errorDel: string;\r\n fileUpload: string;\r\n tempViewer: string;\r\n tempDown: string;\r\n}\r\n\r\nexport interface UploadFileProps<T> {\r\n /**\r\n * bucket\r\n */\r\n bucket?: string;\r\n /**\r\n * endpoint\r\n */\r\n endpoint?: string;\r\n /**\r\n * 目录格式 xxx/xx\r\n */\r\n directory: string;\r\n /**\r\n * 限制文件大小 默认5M\r\n */\r\n maxSize?: number;\r\n /**\r\n * 限制弹框选择\r\n */\r\n accept?: string;\r\n /**\r\n * 使用url\r\n */\r\n value?: T;\r\n /**\r\n * 返回存储数据库的url\r\n * @param value\r\n * @returns\r\n */\r\n onChange?: (value?: T) => void;\r\n\r\n}\r\n"],"names":[],"mappings":"AAAA,WAiDC"}
@@ -7,7 +7,9 @@ var locale = {
7
7
  errSupportExtension: "Only the extension name is supported",
8
8
  fileUpload: "File upload",
9
9
  tempViewer: "Template preview",
10
- tempDown: "Template download"
10
+ tempDown: "Template download",
11
+ errorUpload: "If the upload is abnormal, contact the administrator",
12
+ errorDel: "If the deletion is abnormal, contact the administrator"
11
13
  };
12
14
  export default locale;
13
15
 
@@ -1 +1 @@
1
- {"version":3,"sources":[".\\src\\components\\upload-file\\locale\\en_US.ts"],"sourcesContent":["import { UploadFileLocale } from \"../index\";\r\n\r\nconst locale: UploadFileLocale = {\r\n fileSizeTip: \"The file size cannot be less than\",\r\n del: \"delete\",\r\n confirmDel: \"Confirm deletion\",\r\n clickOrDragUpload: \"Click or drag the file to upload\",\r\n supportExtension: \"Support extension\",\r\n errSupportExtension: \"Only the extension name is supported\",\r\n fileUpload: \"File upload\",\r\n tempViewer: \"Template preview\",\r\n tempDown: \"Template download\",\r\n};\r\n\r\nexport default locale\r\n"],"names":["locale","fileSizeTip","del","confirmDel","clickOrDragUpload","supportExtension","errSupportExtension","fileUpload","tempViewer","tempDown"],"mappings":"AAEA,IAAMA,SAA2B;IAC/BC,aAAa;IACbC,KAAK;IACLC,YAAY;IACZC,mBAAmB;IACnBC,kBAAkB;IAClBC,qBAAqB;IACrBC,YAAY;IACZC,YAAY;IACZC,UAAU;AACZ;AAEA,eAAeT,OAAM"}
1
+ {"version":3,"sources":[".\\src\\components\\upload-file\\locale\\en_US.ts"],"sourcesContent":["import { UploadFileLocale } from \"../index\";\r\n\r\nconst locale: UploadFileLocale = {\r\n fileSizeTip: \"The file size cannot be less than\",\r\n del: \"delete\",\r\n confirmDel: \"Confirm deletion\",\r\n clickOrDragUpload: \"Click or drag the file to upload\",\r\n supportExtension: \"Support extension\",\r\n errSupportExtension: \"Only the extension name is supported\",\r\n fileUpload: \"File upload\",\r\n tempViewer: \"Template preview\",\r\n tempDown: \"Template download\",\r\n errorUpload: 'If the upload is abnormal, contact the administrator',\r\n errorDel: 'If the deletion is abnormal, contact the administrator',\r\n};\r\n\r\nexport default locale\r\n"],"names":["locale","fileSizeTip","del","confirmDel","clickOrDragUpload","supportExtension","errSupportExtension","fileUpload","tempViewer","tempDown","errorUpload","errorDel"],"mappings":"AAEA,IAAMA,SAA2B;IAC/BC,aAAa;IACbC,KAAK;IACLC,YAAY;IACZC,mBAAmB;IACnBC,kBAAkB;IAClBC,qBAAqB;IACrBC,YAAY;IACZC,YAAY;IACZC,UAAU;IACVC,aAAa;IACbC,UAAU;AACZ;AAEA,eAAeX,OAAM"}
@@ -7,7 +7,9 @@ var locale = {
7
7
  errSupportExtension: "只支持扩展名",
8
8
  fileUpload: "文件上传",
9
9
  tempViewer: "模板预览",
10
- tempDown: "模板下载"
10
+ tempDown: "模板下载",
11
+ errorUpload: "上传异常,请联系管理员",
12
+ errorDel: "删除异常,请联系管理员"
11
13
  };
12
14
  export default locale;
13
15
 
@@ -1 +1 @@
1
- {"version":3,"sources":[".\\src\\components\\upload-file\\locale\\zh_CN.ts"],"sourcesContent":["import { UploadFileLocale } from \"../index\";\r\n\r\nconst locale: UploadFileLocale = {\r\n fileSizeTip: \"文件大小不能小于\",\r\n del: \"删除\",\r\n confirmDel: \"确认删除\",\r\n clickOrDragUpload: \"点击或拖拽文件上传\",\r\n supportExtension: \"支持扩展名\",\r\n errSupportExtension: \"只支持扩展名\",\r\n fileUpload: \"文件上传\",\r\n tempViewer: \"模板预览\",\r\n tempDown: \"模板下载\",\r\n};\r\n\r\nexport default locale\r\n"],"names":["locale","fileSizeTip","del","confirmDel","clickOrDragUpload","supportExtension","errSupportExtension","fileUpload","tempViewer","tempDown"],"mappings":"AAEA,IAAMA,SAA2B;IAC/BC,aAAa;IACbC,KAAK;IACLC,YAAY;IACZC,mBAAmB;IACnBC,kBAAkB;IAClBC,qBAAqB;IACrBC,YAAY;IACZC,YAAY;IACZC,UAAU;AACZ;AAEA,eAAeT,OAAM"}
1
+ {"version":3,"sources":[".\\src\\components\\upload-file\\locale\\zh_CN.ts"],"sourcesContent":["import { UploadFileLocale } from \"../index\";\r\n\r\nconst locale: UploadFileLocale = {\r\n fileSizeTip: \"文件大小不能小于\",\r\n del: \"删除\",\r\n confirmDel: \"确认删除\",\r\n clickOrDragUpload: \"点击或拖拽文件上传\",\r\n supportExtension: \"支持扩展名\",\r\n errSupportExtension: \"只支持扩展名\",\r\n fileUpload: \"文件上传\",\r\n tempViewer: \"模板预览\",\r\n tempDown: \"模板下载\",\r\n errorUpload: '上传异常,请联系管理员',\r\n errorDel: '删除异常,请联系管理员',\r\n};\r\n\r\nexport default locale\r\n"],"names":["locale","fileSizeTip","del","confirmDel","clickOrDragUpload","supportExtension","errSupportExtension","fileUpload","tempViewer","tempDown","errorUpload","errorDel"],"mappings":"AAEA,IAAMA,SAA2B;IAC/BC,aAAa;IACbC,KAAK;IACLC,YAAY;IACZC,mBAAmB;IACnBC,kBAAkB;IAClBC,qBAAqB;IACrBC,YAAY;IACZC,YAAY;IACZC,UAAU;IACVC,aAAa;IACbC,UAAU;AACZ;AAEA,eAAeX,OAAM"}
@@ -1,3 +1,3 @@
1
- import { UploadFileProps } from ".";
1
+ import { UploadFileProps } from "./index";
2
2
  declare const _default: (props: UploadFileProps<string>) => import("react/jsx-runtime").JSX.Element;
3
3
  export default _default;
@@ -5,119 +5,38 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@ice/jsx-runt
5
5
  import { PlusOutlined } from "@ant-design/icons";
6
6
  import { Spin, Upload, message } from "antd";
7
7
  import { useEffect, useState } from "react";
8
- import { useAppCode, useTenantId } from "../provider/index";
9
8
  import { useLocale } from "../locale/index";
10
- import { formatFileSize, randomId } from "../_util/index";
11
- import { getFilesRaw, updateFiles } from "@knockout-js/api";
9
+ import { formatFileSize } from "../_util/index";
10
+ import { parseStorageUrl, getStorageUrl, uploadFile, getFileUrl } from "@knockout-js/api";
12
11
  export default function(props) {
13
- var _props_bucket, _props_appCode, _props_tenantId;
14
- var bucket = (_props_bucket = props.bucket) !== null && _props_bucket !== void 0 ? _props_bucket : "local", appCode = (_props_appCode = props.appCode) !== null && _props_appCode !== void 0 ? _props_appCode : useAppCode(), tenantId = (_props_tenantId = props.tenantId) !== null && _props_tenantId !== void 0 ? _props_tenantId : useTenantId(), locale = useLocale("UploadFile"), _message_useMessage = _sliced_to_array(message.useMessage(), 1), messageApi = _message_useMessage[0], _useState = _sliced_to_array(useState(false), 2), loading = _useState[0], setLoading = _useState[1], _useState1 = _sliced_to_array(useState(), 2), imgsrc = _useState1[0], setImgsrc = _useState1[1];
15
- var getUploadKey = function(file) {
16
- var suffix = file.name.split(".").pop(), keys = [];
17
- if (props.forceDirectory && props.directory) {
18
- keys.push(props.directory);
19
- } else {
20
- if (appCode) {
21
- keys.push(appCode);
22
- }
23
- if (tenantId) {
24
- keys.push(tenantId);
25
- }
26
- if (props.directory) {
27
- keys.push(props.directory);
28
- }
29
- }
30
- keys.push("".concat(randomId(16), ".").concat(suffix));
31
- return "/".concat(keys.join("/")).replace("//", "/");
32
- }, updateFile = function() {
33
- var _ref = _async_to_generator(function(file) {
34
- var key, result, _props_onChange, _props_onChangePath, error;
35
- return _ts_generator(this, function(_state) {
36
- switch(_state.label){
37
- case 0:
38
- key = getUploadKey(file);
39
- setLoading(true);
40
- if (!(bucket === "local")) return [
41
- 3,
42
- 4
43
- ];
44
- _state.label = 1;
45
- case 1:
46
- _state.trys.push([
47
- 1,
48
- 3,
49
- ,
50
- 4
51
- ]);
52
- return [
53
- 4,
54
- updateFiles({
55
- key: key,
56
- bucket: bucket,
57
- file: file
58
- })
59
- ];
60
- case 2:
61
- result = _state.sent();
62
- if (result) {
63
- ;
64
- (_props_onChange = props.onChange) === null || _props_onChange === void 0 ? void 0 : _props_onChange.call(props, result);
65
- (_props_onChangePath = props.onChangePath) === null || _props_onChangePath === void 0 ? void 0 : _props_onChangePath.call(props, key);
66
- }
67
- return [
68
- 3,
69
- 4
70
- ];
71
- case 3:
72
- error = _state.sent();
73
- return [
74
- 3,
75
- 4
76
- ];
77
- case 4:
78
- setLoading(false);
79
- return [
80
- 2
81
- ];
82
- }
83
- });
84
- });
85
- return function updateFile(file) {
86
- return _ref.apply(this, arguments);
87
- };
88
- }(), getValueFile = function() {
12
+ var locale = useLocale("UploadFile"), _message_useMessage = _sliced_to_array(message.useMessage(), 1), messageApi = _message_useMessage[0], _useState = _sliced_to_array(useState(false), 2), loading = _useState[0], setLoading = _useState[1], _useState1 = _sliced_to_array(useState(), 2), imgsrc = _useState1[0], setImgsrc = _useState1[1];
13
+ var getValueFile = function() {
89
14
  var _ref = _async_to_generator(function() {
90
15
  var result;
91
16
  return _ts_generator(this, function(_state) {
92
17
  switch(_state.label){
93
18
  case 0:
94
19
  if (!props.value) return [
95
- 3,
96
- 3
97
- ];
98
- if (!(bucket === "local")) return [
99
20
  3,
100
21
  2
101
22
  ];
102
23
  return [
103
24
  4,
104
- getFilesRaw(props.value, "url")
25
+ parseStorageUrl(props.value, undefined, undefined, props.endpoint, props.bucket)
105
26
  ];
106
27
  case 1:
107
28
  result = _state.sent();
108
- if (typeof result === "string") {
29
+ if (result) {
109
30
  setImgsrc(result);
110
31
  }
111
- _state.label = 2;
112
- case 2:
113
32
  return [
114
33
  3,
115
- 4
34
+ 3
116
35
  ];
117
- case 3:
36
+ case 2:
118
37
  setImgsrc(undefined);
119
- _state.label = 4;
120
- case 4:
38
+ _state.label = 3;
39
+ case 3:
121
40
  return [
122
41
  2
123
42
  ];
@@ -145,7 +64,7 @@ export default function(props) {
145
64
  showUploadList: false,
146
65
  beforeUpload: function() {
147
66
  var _ref = _async_to_generator(function(file) {
148
- var maxSize;
67
+ var maxSize, result, _props_onChange, storageUrl, url;
149
68
  return _ts_generator(this, function(_state) {
150
69
  switch(_state.label){
151
70
  case 0:
@@ -157,12 +76,40 @@ export default function(props) {
157
76
  false
158
77
  ];
159
78
  }
79
+ setLoading(true);
160
80
  return [
161
81
  4,
162
- updateFile(file)
82
+ uploadFile(file, props.directory, props.endpoint, props.bucket)
163
83
  ];
164
84
  case 1:
165
- _state.sent();
85
+ result = _state.sent();
86
+ if (!(result === null || result === void 0 ? void 0 : result.path)) return [
87
+ 3,
88
+ 4
89
+ ];
90
+ return [
91
+ 4,
92
+ getStorageUrl(result.path, props.endpoint, props.bucket)
93
+ ];
94
+ case 2:
95
+ storageUrl = _state.sent();
96
+ return [
97
+ 4,
98
+ getFileUrl(result.path, undefined, undefined, props.endpoint, props.bucket)
99
+ ];
100
+ case 3:
101
+ url = _state.sent();
102
+ (_props_onChange = props.onChange) === null || _props_onChange === void 0 ? void 0 : _props_onChange.call(props, storageUrl);
103
+ setImgsrc(url);
104
+ return [
105
+ 3,
106
+ 5
107
+ ];
108
+ case 4:
109
+ messageApi.error(locale.errorUpload);
110
+ _state.label = 5;
111
+ case 5:
112
+ setLoading(false);
166
113
  return [
167
114
  2,
168
115
  false
@@ -1 +1 @@
1
- {"version":3,"sources":[".\\src\\components\\upload-file\\uploadAvatar.tsx"],"sourcesContent":["import { PlusOutlined } from \"@ant-design/icons\";\r\nimport { Spin, Upload, message } from \"antd\"\r\nimport { RcFile } from \"antd/es/upload\";\r\nimport { useEffect, useState } from \"react\";\r\nimport { useAppCode, useTenantId } from \"../provider\";\r\nimport { UploadFileProps } from \".\";\r\nimport { useLocale } from \"../locale\";\r\nimport { formatFileSize, randomId } from \"../_util\";\r\nimport { getFilesRaw, updateFiles } from \"@knockout-js/api\";\r\n\r\nexport default (props: UploadFileProps<string>) => {\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 [imgsrc, setImgsrc] = useState<string>();\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 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 if (bucket === 'local') {\r\n const result = await getFilesRaw(props.value, 'url');\r\n if (typeof result === 'string') {\r\n setImgsrc(result)\r\n }\r\n }\r\n } else {\r\n setImgsrc(undefined)\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n getValueFile()\r\n }, [props.value])\r\n\r\n return <div style={{ display: \"inline-block\" }}>\r\n <Spin spinning={loading} >\r\n <Upload\r\n accept={props.accept}\r\n listType=\"picture-card\"\r\n showUploadList={false}\r\n beforeUpload={async (file) => {\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 >\r\n {\r\n imgsrc ? <img\r\n src={imgsrc} alt=\"avatar\" style={{ width: '100%' }}\r\n /> : <>\r\n <PlusOutlined rev={undefined} />\r\n <div style={{ marginTop: 8 }}></div>\r\n </>\r\n }\r\n </Upload>\r\n </Spin>\r\n </div>\r\n}\r\n"],"names":["PlusOutlined","Spin","Upload","message","useEffect","useState","useAppCode","useTenantId","useLocale","formatFileSize","randomId","getFilesRaw","updateFiles","props","bucket","appCode","tenantId","locale","useMessage","messageApi","loading","setLoading","imgsrc","setImgsrc","getUploadKey","file","suffix","name","split","pop","keys","forceDirectory","directory","push","join","replace","updateFile","key","result","error","onChange","onChangePath","getValueFile","value","undefined","div","style","display","spinning","accept","listType","showUploadList","beforeUpload","maxSize","size","fileSizeTip","img","src","alt","width","rev","marginTop"],"mappings":";;;;AAAA,SAASA,YAAY,QAAQ,oBAAoB;AACjD,SAASC,IAAI,EAAEC,MAAM,EAAEC,OAAO,QAAQ,OAAM;AAE5C,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAC5C,SAASC,UAAU,EAAEC,WAAW,QAAQ,oBAAc;AAEtD,SAASC,SAAS,QAAQ,kBAAY;AACtC,SAASC,cAAc,EAAEC,QAAQ,QAAQ,iBAAW;AACpD,SAASC,WAAW,EAAEC,WAAW,QAAQ,mBAAmB;AAE5D,eAAe,SAACC,OAAmC;QAEtCA,eACCA,gBACCA;IAHb,IACEC,SAASD,CAAAA,gBAAAA,MAAMC,MAAM,cAAZD,2BAAAA,gBAAgB,OAAO,EAChCE,UAAUF,CAAAA,iBAAAA,MAAME,OAAO,cAAbF,4BAAAA,iBAAiBP,YAAY,EACvCU,WAAWH,CAAAA,kB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OAAO;gCAAEe,WAAW;4BAAE;;;kBAC1B;;;;AAKb,EAAC"}
1
+ {"version":3,"sources":[".\\src\\components\\upload-file\\uploadAvatar.tsx"],"sourcesContent":["import { PlusOutlined } from \"@ant-design/icons\";\r\nimport { Spin, Upload, message } from \"antd\"\r\nimport { useEffect, useState } from \"react\";\r\nimport { UploadFileProps } from \"./index\";\r\nimport { useLocale } from \"../locale\";\r\nimport { formatFileSize } from \"../_util\";\r\nimport { parseStorageUrl, getStorageUrl, uploadFile, getFileUrl } from \"@knockout-js/api\";\r\n\r\nexport default (props: UploadFileProps<string>) => {\r\n const locale = useLocale(\"UploadFile\"),\r\n [messageApi] = message.useMessage(),\r\n [loading, setLoading] = useState(false),\r\n [imgsrc, setImgsrc] = useState<string>();\r\n\r\n const getValueFile = async () => {\r\n if (props.value) {\r\n const result = await parseStorageUrl(props.value, undefined, undefined, props.endpoint, props.bucket);\r\n if (result) {\r\n setImgsrc(result)\r\n }\r\n } else {\r\n setImgsrc(undefined)\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n getValueFile()\r\n }, [props.value])\r\n\r\n return <div style={{ display: \"inline-block\" }}>\r\n <Spin spinning={loading} >\r\n <Upload\r\n accept={props.accept}\r\n listType=\"picture-card\"\r\n showUploadList={false}\r\n beforeUpload={async (file) => {\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 setLoading(true);\r\n const result = await uploadFile(file, props.directory, props.endpoint, props.bucket);\r\n\r\n if (result?.path) {\r\n const storageUrl = await getStorageUrl(result.path, props.endpoint, props.bucket);\r\n const url = await getFileUrl(result.path, undefined, undefined, props.endpoint, props.bucket)\r\n props.onChange?.(storageUrl);\r\n setImgsrc(url)\r\n } else {\r\n messageApi.error(locale.errorUpload);\r\n }\r\n setLoading(false)\r\n return false;\r\n }}\r\n >\r\n {\r\n imgsrc ? <img\r\n src={imgsrc} alt=\"avatar\" style={{ width: '100%' }}\r\n /> : <>\r\n <PlusOutlined rev={undefined} />\r\n <div style={{ marginTop: 8 }}></div>\r\n </>\r\n }\r\n </Upload>\r\n </Spin>\r\n </div>\r\n}\r\n"],"names":["PlusOutlined","Spin","Upload","message","useEffect","useState","useLocale","formatFileSize","parseStorageUrl","getStorageUrl","uploadFile","getFileUrl","props","locale","useMessage","messageApi","loading","setLoading","imgsrc","setImgsrc","getValueFile","result","value","undefined","endpoint","bucket","div","style","display","spinning","accept","listType","showUploadList","beforeUpload","file","maxSize","storageUrl","url","size","error","fileSizeTip","directory","path","onChange","errorUpload","img","src","alt","width","rev","marginTop"],"mappings":";;;;AAAA,SAASA,YAAY,QAAQ,oBAAoB;AACjD,SAASC,IAAI,EAAEC,MAAM,EAAEC,OAAO,QAAQ,OAAM;AAC5C,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAE5C,SAASC,SAAS,QAAQ,kBAAY;AACtC,SAASC,cAAc,QAAQ,iBAAW;AAC1C,SAASC,eAAe,EAAEC,aAAa,EAAEC,UAAU,EAAEC,UAAU,QAAQ,mBAAmB;AAE1F,eAAe,SAACC,OAAmC;IACjD,IAAMC,SAASP,UAAU,eACRH,uCAAAA,QAAQW,UAAU,QAAhCC,aAAcZ,wBACSE,6BAAAA,SAAS,KAAK,OAArCW,UAAuBX,cAAdY,aAAcZ,cACFA,8BAAAA,gBAArBa,SAAqBb,eAAbc,YAAad;IAExB,IAAMe;mBAAe,oBAAA,WAAY;gBAEvBC;;;;6BADJT,MAAMU,KAAK,EAAXV;;;;wBACa;;4BAAMJ,gBAAgBI,MAAMU,KAAK,EAAEC,WAAWA,WAAWX,MAAMY,QAAQ,EAAEZ,MAAMa,MAAM;;;wBAA9FJ,SAAS;wBACf,IAAIA,QAAQ;4BACVF,UAAUE;wBACZ,CAAC;;;;;;wBAEDF,UAAUI;;;;;;;;QAEd;wBATMH;;;;IAWNhB,UAAU,WAAM;QACdgB;I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