fix: Stop button uses cancelling poll flow, shows status text during stop
This commit is contained in:
+18
-2
@@ -1112,12 +1112,28 @@ function App() {
|
||||
{thread.isLoading ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => thread.stop()}
|
||||
onClick={() => {
|
||||
setConcurrentStatus("stopping");
|
||||
wasStoppedRef.current = true;
|
||||
thread.stop();
|
||||
setTimeout(() => {
|
||||
setConcurrentStatus("cancelling");
|
||||
const waitForStop = () => {
|
||||
if (!thread.isLoading) {
|
||||
wasStoppedRef.current = false;
|
||||
setConcurrentStatus("idle");
|
||||
} else {
|
||||
setTimeout(waitForStop, 200);
|
||||
}
|
||||
};
|
||||
waitForStop();
|
||||
}, 150);
|
||||
}}
|
||||
className="rounded-xl bg-destructive text-destructive-foreground px-4 py-2.5 text-sm font-medium hover:opacity-90 transition-opacity flex items-center gap-1.5"
|
||||
title="点击停止生成"
|
||||
>
|
||||
<Square className="size-4 fill-current" />
|
||||
停止
|
||||
{concurrentStatus === "stopping" ? "停止中..." : concurrentStatus === "cancelling" ? "等待停止..." : "停止"}
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user