mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-17 09:34:31 +08:00
修改压缩解压文件命令
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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 },
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user