diff --git a/src/components/card/CardProj.tsx b/src/components/card/CardProj.tsx index 7b355b3..d2376af 100644 --- a/src/components/card/CardProj.tsx +++ b/src/components/card/CardProj.tsx @@ -33,9 +33,10 @@ import DisplayOrderShow from '../../route/proj/edit/ProjConfigMenuListShow.tsx' export default function CardProj(props: any) { const height = window.innerHeight - 250; // 下载等待弹窗 - const [downModal,setDownModal] = useState(false) + const [downModal, setDownModal] = useState(false) // 是否已经点击下载按钮 - const [hasDown,setHasDown] = useState(false) + const [hasDown, setHasDown] = useState(false) + // 是否可以关闭等待下载弹窗 // // 选项数组 // const [tagArray, setTagArray] = useState([]) // // 获取标签 @@ -77,31 +78,26 @@ export default function CardProj(props: any) { // }, // onSuccess(data: any) { // console.log(data) - + // }, // onFinally() { // } // }) // } - const downAll = async (projId: string,name:string) => { + const downAll = async (projId: string, name: string) => { setHasDown(true) - if(!hasDown){ - + if (!hasDown) { + try { setDownModal(true) setHasDown(true) // 发送请求 const response = await Axios.get( `${Axios.defaults?.baseURL}/route/proj/download/all/${projId}`, - { - responseType: 'blob', // 设置响应类型为 blob - headers: { - 'Content-Type': 'application/octet-stream', - }, - } + { responseType: 'blob' } // 指定响应类型为 blob ); - + // 检查状态码 if (response.status === 200) { setDownModal(false) @@ -117,24 +113,24 @@ export default function CardProj(props: any) { link.click(); // 触发下载 document.body.removeChild(link); // 下载完成后移除 元素 // 释放 URL 对象 - window.URL.revokeObjectURL(url); + // window.URL.revokeObjectURL(url); } else { console.error('下载失败'); - // 你可以在这里处理错误情况,例如显示错误消息 + } } catch (error) { console.error('请求失败', error); - // 你可以在这里处理错误情况,例如显示错误消息 - }finally { + + } finally { // 无论请求成功与否,下载完成后都重置 hasDown 状态 setHasDown(false); - setDownModal(false); // 关闭模态框 + setDownModal(false); // 关闭模态框 } - }else{ + } else { setDownModal(true); } - - + + }; // 更新标签状态 const upTag = (dataId: string, projId: string) => { @@ -539,7 +535,7 @@ export default function CardProj(props: any) { ) : <> @@ -888,23 +884,23 @@ export default function CardProj(props: any) { height: `${height}px`, }} destroyOnClose={true} - open={downModal} + open={downModal} footer={ - } - onCancel={() => { setDownModal(false) }} width={500} > -
- 正在打包中请稍后 + onCancel={() => { setDownModal(false) }} width={500} > +
+ 正在打包中请稍后