diff --git a/src/ui/App.tsx b/src/ui/App.tsx
index cd3cf56..b1b0ab1 100644
--- a/src/ui/App.tsx
+++ b/src/ui/App.tsx
@@ -30,15 +30,6 @@ async function download() {
const path = 'S:/Cultivation/grassclipper.zip'
const url = 'https://github.com/Grasscutters/GrassClipper/releases/download/v0.9.7/GrassClipper.zip'
downloadHandler.addDownload(url, path)
-
- const intv = setInterval(() => {
- const prog = downloadHandler.getDownloadProgress(path)
- console.log(prog)
-
- if (prog.status === 'finished') {
- clearInterval(intv)
- }
- }, 500)
}
async function toggleGrasscutter() {
@@ -61,16 +52,16 @@ function App() {
+
-
)
diff --git a/src/ui/components/common/ProgressBar.css b/src/ui/components/common/ProgressBar.css
index e69de29..d4efbad 100644
--- a/src/ui/components/common/ProgressBar.css
+++ b/src/ui/components/common/ProgressBar.css
@@ -0,0 +1,21 @@
+.ProgressBar, .InnerProgress {
+ border-radius: 20px;
+}
+
+.ProgressBarWrapper {
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+}
+
+.ProgressBar {
+ height: 20px;
+ width: 80%;
+ background-color: #fff;
+ color: #fff;
+}
+
+.InnerProgress {
+ height: 100%;
+ background-color: #00a8ff;
+}
\ No newline at end of file
diff --git a/src/ui/components/common/ProgressBar.tsx b/src/ui/components/common/ProgressBar.tsx
index 45b4bff..e468627 100644
--- a/src/ui/components/common/ProgressBar.tsx
+++ b/src/ui/components/common/ProgressBar.tsx
@@ -1,4 +1,5 @@
import React from 'react'
+import './ProgressBar.css'
interface IProps {
path: string,
@@ -18,7 +19,7 @@ export default class ProgressBar extends React.Component {
this.state = {
progress: 0,
status: '',
- total: this.props.downloadManager.getDownloadProgress(this.props.path).total,
+ total: this.props.downloadManager.getDownloadProgress(this.props.path)?.total || 0,
}
}
@@ -27,22 +28,41 @@ export default class ProgressBar extends React.Component {
const intv = setInterval(() => {
const prog = this.props.downloadManager.getDownloadProgress(this.props.path)
this.setState({
- progress: prog.progress,
- status: prog.status,
+ progress: parseInt(prog?.progress || 0, 10),
+ status: prog?.status || 'error',
+ total: prog?.total || 0,
})
- if (prog.status === 'finished') {
+ console.log(prog)
+
+ if (this.state.status === 'finished' /* || this.state.status === 'error' */) {
+ // Ensure progress is 100%
+
clearInterval(intv)
}
- }, 100)
+ }, 500)
}
render() {
return (
-
-
+
+
+
{
+ // Handles files with content-lengths of 0
+ if (this.state.status === 'finished') {
+ return '100'
+ }
+
+ if (this.state.total <= 0) {
+ return '0'
+ }
+
+ return this.state.progress / this.state.total * 100
+ })()}%`,
+ }}>
+
+
{this.state.status}