index.tsx 1015 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import store, { RootState } from "@/store";
  2. import { Button } from "antd";
  3. import React, { useCallback } from "react";
  4. import { useSelector } from "react-redux";
  5. import styles from "./index.module.scss";
  6. function UpAsyncLoding() {
  7. // 从仓库中获取取消上传的函数
  8. const closeUpFile = useSelector(
  9. (state: RootState) => state.A0Layout.closeUpFile
  10. );
  11. const btnClose = useCallback(() => {
  12. closeUpFile.fu();
  13. setTimeout(() => {
  14. store.dispatch({
  15. type: "layout/closeUpFile",
  16. payload: { fu: () => {}, state: false },
  17. });
  18. }, 200);
  19. }, [closeUpFile]);
  20. return (
  21. <div id="UpAsyncLoding" className={styles.UpAsyncLoding}>
  22. <div className="progressBox">
  23. <div id="progress"></div>
  24. </div>
  25. {/* 手动取消上传按钮 */}
  26. <div className="closeUpBtn">
  27. <Button onClick={btnClose}>取消上传</Button>
  28. </div>
  29. </div>
  30. );
  31. }
  32. const MemoUpAsyncLoding = React.memo(UpAsyncLoding);
  33. export default MemoUpAsyncLoding;