mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-01 05:23:47 +08:00
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;
|
||
|
|
}
|