Optimize the project structure and introduce DDD design (#394)

This commit is contained in:
Archer
2023-10-12 17:46:37 +08:00
committed by GitHub
parent 76ac5238b6
commit ad7a17bf40
193 changed files with 1169 additions and 1084 deletions

View File

@@ -0,0 +1,31 @@
import { useState, useCallback } from 'react';
import LoadingComponent from '@/components/Loading';
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
};
};