修改压缩解压文件命令

This commit is contained in:
whyour
2024-03-22 22:23:49 +08:00
parent 47c2c61f33
commit 3f54048127
5 changed files with 40 additions and 49 deletions
+12 -6
View File
@@ -273,12 +273,18 @@ const Other = ({
showUploadList={false}
maxCount={1}
action={`${config.apiPrefix}system/data/import`}
onChange={(e) => {
if (e.event?.percent) {
showUploadProgress(parseFloat(e.event?.percent.toFixed(1)));
if (e.event?.percent === 100) {
showReloadModal();
}
onChange={({ file, event }) => {
if (event?.percent) {
showUploadProgress(
Math.min(parseFloat(event?.percent.toFixed(1)), 99),
);
}
if (file.status === 'done') {
showUploadProgress(100);
showReloadModal();
}
if (file.status === 'error') {
message.error('上传失败');
}
}}
name="data"
+23 -11
View File
@@ -2,30 +2,42 @@ import intl from 'react-intl-universal';
import { Modal, Progress } from 'antd';
import { useRef } from 'react';
export default function useProgress(title: string) {
const modalRef = useRef<ReturnType<typeof Modal.info>>();
const ProgressElement = ({ percent }: { percent: number }) => (
<Progress
style={{ display: 'flex', justifyContent: 'center' }}
type="circle"
percent={percent}
/>
);
const ProgressElement = ({ percent }: { percent: number }) => (
<Progress
style={{ display: 'flex', justifyContent: 'center' }}
type="circle"
percent={percent}
/>
);
export default function useProgress(title: string) {
const modalRef = useRef<ReturnType<typeof Modal.info> | null>();
const showProgress = (percent: number) => {
if (modalRef.current) {
modalRef.current.update({
title: `${title}${percent >= 100 ? intl.get('成功') : intl.get('中...')}`,
title: `${title}${
percent >= 100 ? intl.get('成功') : intl.get('中...')
}`,
content: <ProgressElement percent={percent} />,
okButtonProps: { disabled: percent !== 100 },
});
if (percent === 100) {
setTimeout(() => {
modalRef.current?.destroy();
modalRef.current = null;
});
}
} else {
modalRef.current = Modal.info({
width: 600,
maskClosable: false,
title: `${title}${percent >= 100 ? intl.get('成功') : intl.get('中...')}`,
title: `${title}${
percent >= 100 ? intl.get('成功') : intl.get('中...')
}`,
centered: true,
content: <ProgressElement percent={percent} />,
okButtonProps: { disabled: true },
});
}
};