mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 21:13:50 +00:00

* move components to web package (#37) * move components * fix * fix: cq connection * fix pagination (#41) * doc * openapi config * fix team share app lose (#42) * fix: ts * doc * doc --------- Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com> Co-authored-by: yst <77910600+yu-and-liu@users.noreply.github.com>
32 lines
713 B
TypeScript
32 lines
713 B
TypeScript
import { useState, useCallback } from 'react';
|
|
import LoadingComponent from '../components/common/MyLoading';
|
|
|
|
export const useLoading = (props?: { defaultLoading: boolean }) => {
|
|
const [isLoading, setIsLoading] = useState(props?.defaultLoading || false);
|
|
|
|
const Loading = useCallback(
|
|
({
|
|
loading,
|
|
fixed = true,
|
|
text = '',
|
|
zIndex
|
|
}: {
|
|
loading?: boolean;
|
|
fixed?: boolean;
|
|
text?: string;
|
|
zIndex?: number;
|
|
}): JSX.Element | null => {
|
|
return isLoading || loading ? (
|
|
<LoadingComponent fixed={fixed} text={text} zIndex={zIndex} />
|
|
) : null;
|
|
},
|
|
[isLoading]
|
|
);
|
|
|
|
return {
|
|
isLoading,
|
|
setIsLoading,
|
|
Loading
|
|
};
|
|
};
|