From 508bf79cc8bee9b1991bded150ffa343ce89f9ce Mon Sep 17 00:00:00 2001
From: HFO4 <912394456@qq.com>
Date: Sun, 9 Feb 2020 13:54:39 +0800
Subject: [PATCH] =?UTF-8?q?=E7=A6=BB=E7=BA=BF=E4=B8=8B=E8=BD=BD=E5=88=97?=
=?UTF-8?q?=E8=A1=A8=E9=A1=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/component/Download/Download.js | 161 +-----
src/component/Download/DownloadingCard.js | 515 +++++++++++-------
src/component/Download/FinishedCard.js | 400 ++++++++++++++
src/component/FileManager/FileManager.js | 1 -
.../FileManager/Navigator/Navigator.js | 5 +-
src/component/Modals/SelectFile.js | 124 +++++
src/component/Navbar/Navbar.js | 2 +-
src/untils/page.js | 2 +-
8 files changed, 861 insertions(+), 349 deletions(-)
create mode 100644 src/component/Download/FinishedCard.js
create mode 100644 src/component/Modals/SelectFile.js
diff --git a/src/component/Download/Download.js b/src/component/Download/Download.js
index 9e482a0..e4c937d 100644
--- a/src/component/Download/Download.js
+++ b/src/component/Download/Download.js
@@ -32,6 +32,7 @@ import {
IconButton
} from "@material-ui/core";
import DownloadingCard from "./DownloadingCard";
+import FinishedCard from "./FinishedCard";
const styles = theme => ({
actions: {
@@ -63,58 +64,6 @@ const styles = theme => ({
gird: {
marginTop: "30px"
},
- iconImgBig: {
- color: "#d32f2f",
- fontSize: "30px"
- },
- iconVideoBig: {
- color: "#d50000",
- fontSize: "30px"
- },
- iconAudioBig: {
- color: "#651fff",
- fontSize: "30px"
- },
- iconPdfBig: {
- color: "#f44336",
- fontSize: "30px"
- },
- iconWordBig: {
- color: "#538ce5",
- fontSize: "30px"
- },
- iconPptBig: {
- color: "rgb(239, 99, 63)",
- fontSize: "30px"
- },
- iconExcelBig: {
- color: "#4caf50",
- fontSize: "30px"
- },
- iconTextBig: {
- color: "#607d8b",
- fontSize: "30px"
- },
- iconFileBig: {
- color: "#424242",
- fontSize: "30px"
- },
- iconTorrentBig: {
- color: "#5c6bc0",
- fontSize: "30px"
- },
- iconZipBig: {
- color: "#f9a825",
- fontSize: "30px"
- },
- iconAndroidBig: {
- color: "#8bc34a",
- fontSize: "30px"
- },
- iconExeBig: {
- color: "#1a237e",
- fontSize: "30px"
- },
hide: {
display: "none"
},
@@ -128,6 +77,9 @@ const styles = theme => ({
textAlign: "center",
marginTop: "20px",
marginBottom: "20px"
+ },
+ margin:{
+ marginTop:theme.spacing(2),
}
});
const mapStateToProps = state => {
@@ -180,6 +132,7 @@ const getIcon = (classes, name) => {
class DownloadComponent extends Component {
page = 0;
+ interval = 0;
state = {
downloading: [],
@@ -190,8 +143,13 @@ class DownloadComponent extends Component {
componentDidMount = () => {
this.loadDownloading();
+ this.loadMore();
};
+ componentWillUnmount() {
+ clearTimeout(this.interval);
+ }
+
loadDownloading = () => {
this.setState({
loading: true
@@ -202,6 +160,11 @@ class DownloadComponent extends Component {
downloading: response.data,
loading: false
});
+ // 设定自动更新
+ clearTimeout(this.interval);
+ if(response.data.length > 0){
+ this.interval = setTimeout(this.loadDownloading,1000 * response.data[0].interval);
+ }
})
.catch(error => {
this.props.toggleSnackbar(
@@ -217,13 +180,13 @@ class DownloadComponent extends Component {
this.setState({
loading: true
});
- axios
- .get("/RemoteDownload/ListFinished?page=" + ++this.page)
+ API
+ .get("/aria2/finished?page=" + ++this.page)
.then(response => {
this.setState({
- finishedList: response.data,
+ finishedList: [...this.state.finishedList,...response.data],
loading: false,
- continue: response.data.length < 10 ? false : true
+ continue: response.data.length >= 10
});
})
.catch(error => {
@@ -234,43 +197,6 @@ class DownloadComponent extends Component {
});
};
- cancelDownload = id => {
- axios
- .post("/RemoteDownload/Cancel", {
- id: id
- })
- .then(response => {
- if (response.data.error !== 0) {
- this.props.toggleSnackbar(
- "top",
- "right",
- response.message,
- "error"
- );
- } else {
- this.setState({
- downloading: this.state.downloading.filter(value => {
- return value.id !== id;
- })
- });
- this.props.toggleSnackbar(
- "top",
- "right",
- "取消成功",
- "success"
- );
- }
- })
- .catch(error => {
- this.props.toggleSnackbar(
- "top",
- "right",
- error.message,
- "error"
- );
- });
- };
-
render() {
const { classes } = this.props;
@@ -300,50 +226,13 @@ class DownloadComponent extends Component {
已完成
- {this.state.finishedList.map(value => {
- return (
-
- {JSON.stringify(value.fileName) !== "[]" && (
-
- {getIcon(classes, value.fileName)}
-
- )}
+ {this.state.finishedList.map((value, k) => {
+ if (value.files) {
+ return (
+
+ )
+ }
-
-
- {value.fileName}
-
-
- {(() => {
- switch (value.status) {
- case "canceled":
- return 已取消
;
- case "error":
- return (
-
- 错误:{value.msg}
-
- );
- case "success":
- return 成功
;
- default:
- break;
- }
- })()}
-
-
-
- );
})}