chore(polish & cleanup)
This commit is contained in:
@@ -393,6 +393,15 @@ async function play() {
|
||||
try {
|
||||
await invoke("launch_game", { gameId: game.value.id });
|
||||
} catch (e) {
|
||||
createModal(
|
||||
ModalType.Notification,
|
||||
{
|
||||
title: `Couldn't run "${game.value.mName}"`,
|
||||
description: `Drop failed to launch "${game.value.mName}": ${e}`,
|
||||
buttonText: "Close",
|
||||
},
|
||||
(e, c) => c()
|
||||
);
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<template>
|
||||
<h1>Home</h1>
|
||||
|
||||
</template>
|
||||
@@ -1,64 +1,2 @@
|
||||
<template>
|
||||
<input placeholder="GAME ID" v-model="gameId" />
|
||||
<input placeholder="VERSION NAME" v-model="versionName" />
|
||||
|
||||
<button
|
||||
class="w-full rounded-md p-4 bg-blue-600 text-white"
|
||||
@click="startGameDownload"
|
||||
>
|
||||
Download game
|
||||
<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>
|
||||
<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";
|
||||
|
||||
const gameId = ref("");
|
||||
const versionName = ref("");
|
||||
const progress = ref(0);
|
||||
|
||||
async function startGameDownload() {
|
||||
setInterval(() => {
|
||||
(async () => {
|
||||
const currentProgress = await invoke<number>(
|
||||
"get_current_game_download_progress",
|
||||
{
|
||||
gameId: gameId.value,
|
||||
}
|
||||
);
|
||||
console.log(currentProgress);
|
||||
progress.value = currentProgress;
|
||||
})();
|
||||
}, 100);
|
||||
}
|
||||
async function stopGameDownload() {
|
||||
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>
|
||||
<template></template>
|
||||
<script setup lang="ts"></script>
|
||||
|
||||
Reference in New Issue
Block a user