进度条
This commit is contained in:
parent
78214be4be
commit
20132c3086
|
|
@ -24,4 +24,12 @@
|
|||
> div:nth-child(2) {
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.updateDiv {
|
||||
color: #ffffff;
|
||||
|
||||
.ant-progress .ant-progress-text {
|
||||
color: #ffffff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,18 @@
|
|||
import styles from '@/components/SharedFilesModel/index.module.scss'
|
||||
import { DeleteOutlined, ProfileOutlined, ReloadOutlined, SearchOutlined, VerticalAlignBottomOutlined } from '@ant-design/icons';
|
||||
import { Button, Input, Modal, Pagination, Table, message } from 'antd';
|
||||
import { useState, useImperativeHandle, forwardRef, useEffect } from "react";
|
||||
import { PostRoomFile, DeleteRoomFile, GetRoomUpFileurl, GetRoomFileDwUrl, GetRoomFile } from '@/api/Meeting';
|
||||
import {
|
||||
DeleteOutlined,
|
||||
ProfileOutlined,
|
||||
ReloadOutlined,
|
||||
SearchOutlined,
|
||||
VerticalAlignBottomOutlined
|
||||
} from '@ant-design/icons';
|
||||
import {Button, Input, message, Modal, Pagination, Progress, Table} from 'antd';
|
||||
import {forwardRef, useEffect, useImperativeHandle, useState} from "react";
|
||||
import {DeleteRoomFile, GetRoomFile, GetRoomFileDwUrl, GetRoomUpFileurl, PostRoomFile} from '@/api/Meeting';
|
||||
import axios from 'axios';
|
||||
import {useLocation} from 'react-router-dom';
|
||||
import {storage} from '@/utils';
|
||||
|
||||
const {Column} = Table
|
||||
|
||||
const SharedFilesModel = forwardRef((props: any, ref: any) => {
|
||||
|
|
@ -26,6 +33,7 @@ const SharedFilesModel = forwardRef((props: any, ref: any) => {
|
|||
pageIndex: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
const [uploadProgress, setUploadProgress] = useState(0);
|
||||
useEffect(() => {
|
||||
let userInfo = JSON.parse(storage.getItem('user') as string)
|
||||
setUser(userInfo)
|
||||
|
|
@ -66,8 +74,13 @@ const SharedFilesModel = forwardRef((props: any, ref: any) => {
|
|||
>
|
||||
<div>
|
||||
<div className={styles.sharedFilesModel}>
|
||||
<div>
|
||||
<div className={styles.updateDiv}>
|
||||
<span>共{fileList.total}个文件</span>
|
||||
<div>
|
||||
<Progress percent={uploadProgress} strokeColor={'green'} trailColor={'#e8e8e8'}
|
||||
percentPosition={{align: 'center', type: 'inner'}}
|
||||
size={{width: 100, height: 20}}/>
|
||||
</div>
|
||||
<div style={{color: 'white'}}>
|
||||
<Input
|
||||
placeholder="搜索"
|
||||
|
|
@ -155,7 +168,14 @@ const SharedFilesModel = forwardRef((props: any, ref: any) => {
|
|||
"Content-Type": "multipart/form-data",
|
||||
"Authorization": `Bearer ${user.token}`
|
||||
},
|
||||
withCredentials: false
|
||||
withCredentials: false,
|
||||
onUploadProgress: (progressEvent: any) => {
|
||||
// 获取上传进度
|
||||
const {loaded, total} = progressEvent;
|
||||
const progress = Math.round((loaded * 100) / total);
|
||||
console.log(`上传进度: ${progress}%`);
|
||||
setUploadProgress(progress)
|
||||
}
|
||||
})
|
||||
await PostRoomFile({
|
||||
fileUrl: res.data.key,
|
||||
|
|
@ -202,16 +222,94 @@ const SharedFilesModel = forwardRef((props: any, ref: any) => {
|
|||
/>
|
||||
<Column title="操作" render={(item) => (
|
||||
<>
|
||||
<VerticalAlignBottomOutlined title='下载' style={{ color: '#5575F2', cursor: 'pointer' }} onClick={() => {
|
||||
<VerticalAlignBottomOutlined title='下载'
|
||||
style={{color: '#5575F2', cursor: 'pointer'}}
|
||||
onClick={async () => {
|
||||
GetRoomFileDwUrl(item.fileUrl, item.id).then(res => {
|
||||
console.log(res)
|
||||
if (res.code === 200) {
|
||||
// const downloadLink = document.createElement("a");
|
||||
// downloadLink.href = res.data;
|
||||
// downloadLink.download = item.fileName;
|
||||
axios({
|
||||
url: res.data,
|
||||
method: 'GET',
|
||||
// headers: {
|
||||
// "Authorization": `Bearer ${user.token}`,
|
||||
// "responseType": 'stream'
|
||||
// },
|
||||
onDownloadProgress: (progressEvent: any) => {
|
||||
const totalLength = item.size;
|
||||
console.log(2222222)
|
||||
if (totalLength !== null) {
|
||||
const percentComplete = (progressEvent.loaded / totalLength * 100).toFixed(2);
|
||||
console.log(`下载进度: ${percentComplete}%`);
|
||||
item.percentComplete = percentComplete
|
||||
}
|
||||
}
|
||||
}).then(() => {
|
||||
const downloadLink = document.createElement("a");
|
||||
downloadLink.href = res.data;
|
||||
downloadLink.download = item.fileName;
|
||||
downloadLink.click();
|
||||
getRoomFile()
|
||||
})
|
||||
// downloadLink.click();
|
||||
// getRoomFile()
|
||||
}
|
||||
})
|
||||
|
||||
// const url = "https://wgshare.oss-cn-chengdu.aliyuncs.com/share_file/559167236182085/20421555/b24e2c41f47140308c47cdd77e6305c7.jpg?Expires=1722923931&OSSAccessKeyId=LTAI5tQYVQHkkXxXTmjwiSDv&Signature=eJTWD93ifV2v1R6XCHSOa6j1R%2FE%3D"
|
||||
// axios({
|
||||
// url,
|
||||
// method: 'GET',
|
||||
// // headers: {
|
||||
// // "Authorization": `Bearer ${user.token}`,
|
||||
// // "responseType": 'stream'
|
||||
// // },
|
||||
// onDownloadProgress: (progressEvent: any) => {
|
||||
// const totalLength = item.size;
|
||||
// console.log(2222222)
|
||||
// if (totalLength !== null) {
|
||||
// const percentComplete = (progressEvent.loaded / totalLength * 100).toFixed(2);
|
||||
// console.log(`下载进度: ${percentComplete}%`);
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// .then((response: any) => {
|
||||
// const downloadLink = document.createElement("a");
|
||||
// downloadLink.href = response.data;
|
||||
// downloadLink.download = item.fileName;
|
||||
// downloadLink.click();
|
||||
// getRoomFile()
|
||||
// })
|
||||
|
||||
// await axios.get(`${import.meta.env.VITE_BASE_URL_API}/room/file-dw-url?fileUrl=${item.fileUrl}&fileId=${item.id}`, {
|
||||
// headers: {
|
||||
// "Authorization": `Bearer ${user.token}`,
|
||||
// "responseType": 'stream'
|
||||
// },
|
||||
// onDownloadProgress: (progressEvent: any) => {
|
||||
// const totalLength = item.size;
|
||||
// const percentComplete = (progressEvent.loaded / totalLength * 100).toFixed(2);
|
||||
// console.log(`下载进度: ${percentComplete}%`);
|
||||
// }
|
||||
// })
|
||||
// await axios.get(`${import.meta.env.VITE_BASE_URL_API}/room/file-dw-url?fileUrl=${item.fileUrl}&fileId=${item.id}`, {
|
||||
// headers: {
|
||||
// "ResponseType": "blob",
|
||||
// "Authorization": `Bearer ${user.token}`
|
||||
// },
|
||||
// withCredentials: false,
|
||||
// onDownloadProgress: (progressEvent: any) => {
|
||||
// console.log(progressEvent, 33333)
|
||||
// // 获取上传进度
|
||||
// const {loaded, total} = progressEvent;
|
||||
// const progress = Math.round((loaded * 100) / total);
|
||||
// console.log(`下载进度: ${progress}%`);
|
||||
// setUploadProgress(progress)
|
||||
// }
|
||||
// })
|
||||
}}/>
|
||||
{/* <FolderOutlined title='文件' style={{ color: '#FFA000', cursor: 'pointer' }} /> */}
|
||||
</>
|
||||
|
|
|
|||
Loading…
Reference in New Issue