import { CheckCircleTwoTone, CloseCircleTwoTone, LinkOutlined } from "@ant-design/icons" import { Progress, Spin, Tag, Tooltip, Typography } from "antd" import type { SyncDetailProgress } from "~sync/extension/engine" import type { SyncResult } from "~sync/types" const { Text } = Typography export interface SyncProgressProps { /** 正在同步的平台数(用于计算整体进度) */ total: number progress: Record results: SyncResult[] platformNames: Record } /** * 同步进度与结果 */ export default function SyncProgress({ total, progress, results, platformNames }: SyncProgressProps) { const finished = results.length const percent = total > 0 ? Math.round((finished / total) * 100) : 0 const platformIds = Object.keys(progress) return (
{platformIds.map((platformId) => { const item = progress[platformId] const name = platformNames[platformId] || item.platformName || platformId return (
{name} {item.result?.message && ( {item.result.message.slice(0, 40)} )} {item.stage === "completed" && item.result?.postUrl && ( 打开 )}
) })}
) } function StageIcon({ stage }: { stage: SyncDetailProgress["stage"] }) { if (stage === "completed") { return } if (stage === "failed") { return } return } function StageText({ stage, imageProgress }: { stage: SyncDetailProgress["stage"] imageProgress?: { current: number; total: number } }) { switch (stage) { case "starting": return 准备中 case "uploading_images": return ( 上传图片 {imageProgress ? `${imageProgress.current}/${imageProgress.total}` : ""} ) case "saving": return 保存中 case "completed": return 已完成 case "failed": return 失败 default: return null } }