fix(frontend): RefineView 取消在途 refine——AbortController 防段切换竞态(CR-H12)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user