fix(download manager): use of completed signal, and pause/resuming

This commit is contained in:
DecDuck
2024-11-28 12:39:21 +11:00
parent 2dedfbbd5c
commit 64d7f649c6
9 changed files with 162 additions and 90 deletions

View File

@ -7,14 +7,30 @@
@click="startGameDownload"
>
Download game
<span v-if="progress != 0"> ({{ Math.floor(progress * 1000) / 10 }}%) </span>
<span v-if="progress != 0">
({{ Math.floor(progress * 1000) / 10 }}%)
</span>
</button>
<button
class="w-full rounded-md p-4 bg-blue-600 text-white"
@click="stopGameDownload"
>
Cancel game download
</button></template>
</button>
<button
class="w-full rounded-md p-4 bg-blue-600 text-white"
@click="pause"
>
Pause game download
</button>
<button
class="w-full rounded-md p-4 bg-blue-600 text-white"
@click="resume"
>
Resume game download
</button>
</template>
<script setup lang="ts">
import { invoke } from "@tauri-apps/api/core";
@ -42,6 +58,12 @@ async function startGameDownload() {
}, 100);
}
async function stopGameDownload() {
await invoke("stop_game_download", { "gameId": gameId.value })
await invoke("cancel_game_download", { gameId: gameId.value });
}
async function pause() {
await invoke("pause_game_downloads");
}
async function resume() {
await invoke("resume_game_downloads");
}
</script>