mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-12 23:24:35 +01:00
remove downloads frontend
This commit is contained in:
@@ -36,7 +36,7 @@ async function TESTDOWNLOAD() {
|
||||
download(
|
||||
'https://github.com/Grasscutters/Grasscutter/archive/refs/heads/stable.zip',
|
||||
'grasscutter.zip',
|
||||
'C:\\Users\\spike\\Documents\\dev\\Cultivation'
|
||||
'S:\\Cultivation'
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,11 @@ import { capitalize } from '../../../utils/string'
|
||||
|
||||
import Stop from '../../../resources/icons/close.svg'
|
||||
import './ProgressBar.css'
|
||||
import DownloadHandler from '../../../utils/download'
|
||||
|
||||
interface IProps {
|
||||
path: string,
|
||||
downloadManager: any,
|
||||
downloadManager: DownloadHandler,
|
||||
}
|
||||
|
||||
interface IState {
|
||||
@@ -31,7 +32,7 @@ export default class ProgressBar extends React.Component<IProps, IState> {
|
||||
const intv = setInterval(() => {
|
||||
const prog = this.props.downloadManager.getDownloadProgress(this.props.path)
|
||||
this.setState({
|
||||
progress: parseInt(prog?.progress || 0, 10),
|
||||
progress: prog?.progress || 0,
|
||||
status: prog?.status || 'error',
|
||||
total: prog?.total || 0,
|
||||
})
|
||||
@@ -43,6 +44,10 @@ export default class ProgressBar extends React.Component<IProps, IState> {
|
||||
}, 500)
|
||||
}
|
||||
|
||||
stopDownload() {
|
||||
this.props.downloadManager.stopDownload(this.props.path)
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="ProgressBarWrapper">
|
||||
@@ -66,7 +71,7 @@ export default class ProgressBar extends React.Component<IProps, IState> {
|
||||
}}></div>
|
||||
</div>
|
||||
<div className="DownloadControls">
|
||||
<div>
|
||||
<div onClick={this.stopDownload}>
|
||||
<img src={Stop}></img>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -69,6 +69,15 @@ export default class DownloadHandler {
|
||||
this.downloads.push(obj)
|
||||
}
|
||||
|
||||
stopDownload(path: string) {
|
||||
// Stop download and remove from list.
|
||||
invoke('stop_download', { path })
|
||||
|
||||
// Remove from list
|
||||
const index = this.downloads.findIndex(download => download.path === path)
|
||||
this.downloads.splice(index, 1)
|
||||
}
|
||||
|
||||
getDownloadProgress(path: string) {
|
||||
const index = this.downloads.findIndex(download => download.path === path)
|
||||
return this.downloads[index] || null
|
||||
|
||||
Reference in New Issue
Block a user