mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-16 20:57:21 +08:00
Feat: If the interval between two outputs exceeds 600ms, a loading state is displayed at the end. (#16861)
### Summary Feat: If the interval between two outputs exceeds 600ms, a loading state is displayed at the end.
This commit is contained in:
24
web/src/hooks/use-loading-pause.ts
Normal file
24
web/src/hooks/use-loading-pause.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
export function useLoadingPause(
|
||||
loading: boolean,
|
||||
content: string,
|
||||
delay = 600,
|
||||
) {
|
||||
const [show, setShow] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!loading || !content) {
|
||||
setShow(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const timer = setTimeout(() => {
|
||||
setShow(true);
|
||||
}, delay);
|
||||
|
||||
return () => clearTimeout(timer);
|
||||
}, [loading, content, delay]);
|
||||
|
||||
return show;
|
||||
}
|
||||
Reference in New Issue
Block a user