Initial ecommerce standalone package
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
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}%` }} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user