fix(frontend): RefineView 取消在途 refine——AbortController 防段切换竞态(CR-H12)

This commit is contained in:
Yaojia Wang
2026-07-08 11:08:21 +02:00
parent 5665cc9a16
commit 5c02792e5f
3 changed files with 65 additions and 7 deletions

View File

@@ -28,15 +28,17 @@ export function RefineView({
onClose,
}: RefineViewProps) {
const refiner = useRefine();
const { refine, abort } = refiner;
// 进入即触发回炉(段非空)。
// 进入即触发回炉(段非空)清理时取消在途请求避免旧段迟到响应覆盖新段CR-H12
useEffect(() => {
if (segment.trim().length > 0) {
void refiner.refine(projectId, chapterNo, segment);
void refine(projectId, chapterNo, segment);
}
// 仅在段变化时触发。
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [segment, projectId, chapterNo]);
return () => {
abort();
};
}, [segment, projectId, chapterNo, refine, abort]);
return (
<div