Files
MyGoNavi/frontend/src/components/ExportProgressModal.tsx
Syngnat 6b67bb24b4 feat(tool-center): 优化工具中心分组交互与通用弹窗
- 重构工具中心为侧边分组导航,固定弹窗高度并支持内部滚动
- 新增通用可拖拽可缩放 Modal,统一主要弹窗打开体验
- 为工具中心内嵌入口补充返回上一步交互与底部操作区
- 补充多语言文案和工具中心/Modal/i18n 回归测试
2026-06-18 20:28:47 +08:00

77 lines
2.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import Modal from './common/ResizableDraggableModal';
import React from 'react';
import { Button, Typography } from 'antd';
import {
formatExportProgressRows,
} from '../utils/exportProgress';
import ExportProgressBar from './ExportProgressBar';
import { useExportProgressRunner } from './useExportProgressRunner';
const { Text, Paragraph } = Typography;
export function useExportProgressDialog() {
const { state, reset, runExportWithProgress } = useExportProgressRunner();
const canClose = state.status === 'done' || state.status === 'error';
const modalNode = (
<Modal
title={state.status === 'error' ? '导出失败' : (state.status === 'done' ? '导出完成' : '正在导出')}
open={state.open}
width={560}
mask={false}
keyboard={canClose}
closable={canClose}
onCancel={reset}
footer={canClose ? [
<Button key="close" onClick={reset}></Button>,
] : null}
>
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
<div style={{ display: 'grid', gridTemplateColumns: '72px 1fr', rowGap: 8, columnGap: 8 }}>
<Text type="secondary"></Text>
<Text>{state.title || state.targetName || '导出任务'}</Text>
<Text type="secondary"></Text>
<Text>{state.targetName || '未命名对象'}</Text>
<Text type="secondary"></Text>
<Text>{state.format || '-'}</Text>
<Text type="secondary"></Text>
<Text>{state.stage || '准备中'}</Text>
{state.filePath ? (
<>
<Text type="secondary"></Text>
<Paragraph style={{ marginBottom: 0, wordBreak: 'break-all' }}>{state.filePath}</Paragraph>
</>
) : null}
</div>
<ExportProgressBar
status={state.status}
current={state.current}
total={state.total}
totalRowsKnown={state.totalRowsKnown}
/>
<div style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
<Text type="secondary">{formatExportProgressRows(state.current, state.total, state.totalRowsKnown)}</Text>
{!state.totalRowsKnown && state.status !== 'done' && state.status !== 'error' ? (
<Text type="secondary"></Text>
) : null}
{state.message ? (
<Text type="danger">{state.message}</Text>
) : null}
</div>
</div>
</Modal>
);
return {
exportProgressModal: modalNode,
runExportWithProgress,
};
}