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,33 @@
|
||||
import useLauncherStore from "@/stores/launcherStore";
|
||||
import useSettingStore from "@/stores/settingStore";
|
||||
import { FSService } from "@bindings/g-launcher/internal/fs-service";
|
||||
import { GitService } from "@bindings/g-launcher/internal/git-service";
|
||||
import { toast } from "react-toastify";
|
||||
|
||||
export async function CheckUpdateProxy(proxyPath: string, proxyVersion: string) : Promise<{isUpdate: boolean, isExists: boolean, version: string}> {
|
||||
const [ok, latestVersion, error] = await GitService.GetLatestProxyVersion()
|
||||
const isExists = await FSService.FileExists(proxyPath)
|
||||
|
||||
if (!ok) {
|
||||
toast.error("Proxy error: " + error)
|
||||
return { isUpdate: false, isExists, version: "" }
|
||||
}
|
||||
|
||||
const isUpdate = latestVersion !== proxyVersion
|
||||
return { isUpdate, isExists, version: latestVersion }
|
||||
}
|
||||
|
||||
export async function UpdateProxy(proxyVersion: string) : Promise<void> {
|
||||
const {setDownloadType } = useLauncherStore.getState()
|
||||
const {setProxyPath, setProxyVersion} = useSettingStore.getState()
|
||||
setDownloadType("Downloading proxy...")
|
||||
const [ok, error] = await GitService.DownloadProxyProgress(proxyVersion)
|
||||
if (ok) {
|
||||
setDownloadType("Download proxy successfully")
|
||||
setProxyVersion(proxyVersion)
|
||||
setProxyPath("./proxy/firefly-go-proxy.exe")
|
||||
} else {
|
||||
toast.error(error)
|
||||
setDownloadType("Download proxy failed")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user