2025-10-30 11:14:43 +08:00
|
|
|
import React from 'react';
|
2026-03-06 14:14:57 +08:00
|
|
|
import { theme } from 'antd';
|
2025-10-30 11:14:43 +08:00
|
|
|
|
|
|
|
|
interface SSEProgressBarProps {
|
|
|
|
|
loading: boolean;
|
|
|
|
|
progress: number;
|
|
|
|
|
message: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const SSEProgressBar: React.FC<SSEProgressBarProps> = ({
|
|
|
|
|
loading,
|
|
|
|
|
progress,
|
|
|
|
|
message
|
|
|
|
|
}) => {
|
2026-03-06 14:14:57 +08:00
|
|
|
const { token } = theme.useToken();
|
|
|
|
|
|
2025-10-30 11:14:43 +08:00
|
|
|
if (!loading) return null;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div style={{ marginTop: 16 }}>
|
|
|
|
|
{/* 进度条 */}
|
|
|
|
|
<div style={{
|
|
|
|
|
height: 8,
|
2026-03-06 14:14:57 +08:00
|
|
|
background: token.colorFillTertiary,
|
2025-10-30 11:14:43 +08:00
|
|
|
borderRadius: 4,
|
|
|
|
|
overflow: 'hidden',
|
|
|
|
|
marginBottom: 8
|
|
|
|
|
}}>
|
|
|
|
|
<div style={{
|
|
|
|
|
height: '100%',
|
2026-03-06 14:14:57 +08:00
|
|
|
background: progress === 100 ? token.colorSuccess : token.colorPrimary,
|
2025-10-30 11:14:43 +08:00
|
|
|
width: `${progress}%`,
|
|
|
|
|
transition: 'all 0.3s ease',
|
|
|
|
|
borderRadius: 4
|
|
|
|
|
}} />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* 进度信息 */}
|
|
|
|
|
<div style={{
|
|
|
|
|
display: 'flex',
|
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
fontSize: 14
|
|
|
|
|
}}>
|
2026-03-06 14:14:57 +08:00
|
|
|
<span style={{ color: token.colorTextSecondary }}>
|
2025-10-30 11:14:43 +08:00
|
|
|
{message || '准备生成...'}
|
|
|
|
|
</span>
|
|
|
|
|
<span style={{
|
|
|
|
|
fontWeight: 'bold',
|
2026-03-06 14:14:57 +08:00
|
|
|
color: progress === 100 ? token.colorSuccess : token.colorPrimary
|
2025-10-30 11:14:43 +08:00
|
|
|
}}>
|
|
|
|
|
{progress}%
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|