28 lines
828 B
TypeScript
28 lines
828 B
TypeScript
import { useSmoothedProgress } from "../../hooks/useSmoothedProgress";
|
|
|
|
type MessageStatus = "thinking" | "completed" | "failed" | string;
|
|
|
|
interface SmoothedProgressBarProps {
|
|
progress: number;
|
|
status: MessageStatus;
|
|
label?: string;
|
|
}
|
|
|
|
function mapMessageStatus(status: MessageStatus) {
|
|
if (status === "thinking") return "running" as const;
|
|
if (status === "completed") return "completed" as const;
|
|
if (status === "failed") return "failed" as const;
|
|
return "running" as const;
|
|
}
|
|
|
|
export function SmoothedProgressBar({ progress, status, label }: SmoothedProgressBarProps) {
|
|
const smoothed = useSmoothedProgress(progress, mapMessageStatus(status));
|
|
return (
|
|
<>
|
|
<span>{label || "超分处理中..."}</span>
|
|
<strong>{smoothed}%</strong>
|
|
<i style={{ width: `${smoothed}%` }} />
|
|
</>
|
|
);
|
|
}
|