mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-30 20:49:21 +08:00
### Summary Feat: If the interval between two outputs exceeds 600ms, a loading state is displayed at the end.
25 lines
439 B
TypeScript
25 lines
439 B
TypeScript
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;
|
|
}
|