feat: initial commit for G-Launcher based on Firefly with Horoyoi enhancements
This commit is contained in:
commit
a99470a69f
155 files changed
+19061
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import useLauncherStore from "@/stores/launcherStore";
|
||||
import { AppService, } from "@bindings/g-launcher/internal/app-service";
|
||||
import { toast } from "react-toastify";
|
||||
import { sleep } from "./sleep";
|
||||
import { GitService } from "@bindings/g-launcher/internal/git-service";
|
||||
|
||||
export async function CheckUpdateLauncher(): Promise<{ isUpdate: boolean; isExists: boolean; version: string }> {
|
||||
const [currentOk, currentVersion] = await AppService.GetCurrentLauncherVersion()
|
||||
if (!currentOk) {
|
||||
toast.error("Launcher error: cannot get current version")
|
||||
return { isUpdate: false, isExists: true, version: "" }
|
||||
}
|
||||
|
||||
const [latestOk, latestVersion, latestError] = await GitService.GetLatestLauncherVersion()
|
||||
if (!latestOk) {
|
||||
toast.error("Launcher error: " + latestError)
|
||||
return { isUpdate: false, isExists: true, version: currentVersion }
|
||||
}
|
||||
|
||||
const isUpdate = latestVersion !== currentVersion
|
||||
return { isUpdate, isExists: true, version: latestVersion }
|
||||
}
|
||||
|
||||
|
||||
export async function UpdateLauncher(launcherVersion: string) : Promise<void> {
|
||||
const {setDownloadType } = useLauncherStore.getState()
|
||||
setDownloadType("update:launcher:downloading")
|
||||
const [ok, error] = await GitService.UpdateLauncherProgress(launcherVersion)
|
||||
if (ok) {
|
||||
setDownloadType("update:launcher:success")
|
||||
|
||||
} else {
|
||||
toast.error(error)
|
||||
setDownloadType("update:launcher:failed")
|
||||
}
|
||||
AppService.CloseAppAfterTimeout(5)
|
||||
await sleep(5000)
|
||||
}
|
||||
Reference in new issue
Block a user