添加下载全部文件功能
This commit is contained in:
parent
29064fc5e5
commit
9e7f0a2b7e
@ -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([])
|
||||
// // 获取标签
|
||||
@ -84,9 +85,9 @@ export default function CardProj(props: any) {
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
const downAll = async (projId: string,name:string) => {
|
||||
const downAll = async (projId: string, name: string) => {
|
||||
setHasDown(true)
|
||||
if(!hasDown){
|
||||
if (!hasDown) {
|
||||
|
||||
try {
|
||||
setDownModal(true)
|
||||
@ -94,12 +95,7 @@ export default function CardProj(props: any) {
|
||||
// 发送请求
|
||||
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
|
||||
);
|
||||
|
||||
// 检查状态码
|
||||
@ -117,20 +113,20 @@ export default function CardProj(props: any) {
|
||||
link.click(); // 触发下载
|
||||
document.body.removeChild(link); // 下载完成后移除 <a> 元素
|
||||
// 释放 URL 对象
|
||||
window.URL.revokeObjectURL(url);
|
||||
// window.URL.revokeObjectURL(url);
|
||||
} else {
|
||||
console.error('下载失败');
|
||||
// 你可以在这里处理错误情况,例如显示错误消息
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('请求失败', error);
|
||||
// 你可以在这里处理错误情况,例如显示错误消息
|
||||
}finally {
|
||||
|
||||
} finally {
|
||||
// 无论请求成功与否,下载完成后都重置 hasDown 状态
|
||||
setHasDown(false);
|
||||
setDownModal(false); // 关闭模态框
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
setDownModal(true);
|
||||
}
|
||||
|
||||
@ -539,7 +535,7 @@ export default function CardProj(props: any) {
|
||||
</div>
|
||||
<Button size="small" type="text" onClick={() => {
|
||||
// window.open(`${Axios.defaults?.baseURL}/route/proj/download/all/${data.projId}`)
|
||||
downAll(data.projId,data.projName)
|
||||
downAll(data.projId, data.projName)
|
||||
}}><DownloadOutlined /> 全部</Button>
|
||||
</div>
|
||||
) : <></>
|
||||
@ -903,8 +899,8 @@ export default function CardProj(props: any) {
|
||||
</Button>
|
||||
}
|
||||
onCancel={() => { setDownModal(false) }} width={500} >
|
||||
<div style={{width:500}}>
|
||||
正在打包中请稍后<span style={{marginLeft:10}}><LoadingOutlined /></span>
|
||||
<div style={{ width: 500 }}>
|
||||
正在打包中请稍后<span style={{ marginLeft: 10 }}><LoadingOutlined /></span>
|
||||
</div>
|
||||
</Modal>
|
||||
</>
|
||||
|
Loading…
Reference in New Issue
Block a user