LoadingCircular.jsx 894 B

123456789101112131415161718192021222324252627282930313233
  1. import React, {useEffect, useState} from "react";
  2. import {CircularProgress} from "@mui/material";
  3. const LoadingCircular=()=>{
  4. const [isShow, setIsShow] = useState(false);
  5. const [showMask,setShowMask]=useState(false);
  6. const show=(showMask=false)=>{
  7. setIsShow(true);
  8. setShowMask(showMask);
  9. }
  10. const hide=()=>{
  11. setIsShow(false);
  12. }
  13. useEffect(()=>{
  14. const loadingCircular={
  15. show,
  16. hide
  17. };
  18. global.loadingCircular=loadingCircular;
  19. },[])
  20. return (
  21. <>
  22. {
  23. isShow? (
  24. <div className={`loading-circular ${showMask?'loading-circular_mask':''}`}>
  25. <CircularProgress color="success" size={40} thickness={4}/>
  26. </div>
  27. ):(<></>)
  28. }
  29. </>
  30. )
  31. }
  32. export default LoadingCircular;