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,4 @@
|
||||
export * from "./server"
|
||||
export * from "./proxy"
|
||||
export * from "./launcher"
|
||||
export * from "./sleep"
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
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 CheckUpdateServer(
|
||||
serverPath: string,
|
||||
serverVersion: string
|
||||
): Promise<{ isUpdate: boolean; isExists: boolean; version: string }> {
|
||||
const [ok, latestVersion, error] = await GitService.GetLatestServerVersion()
|
||||
const isExists = await FSService.FileExists(serverPath)
|
||||
|
||||
if (!ok) {
|
||||
toast.error("Server error: " + error)
|
||||
return { isUpdate: false, isExists, version: "" }
|
||||
}
|
||||
|
||||
const isUpdate = latestVersion !== serverVersion
|
||||
return { isUpdate, isExists, version: latestVersion }
|
||||
}
|
||||
|
||||
|
||||
export async function UpdateServer(serverVersion: string) : Promise<void> {
|
||||
const {setDownloadType } = useLauncherStore.getState()
|
||||
const {setServerPath, setServerVersion} = useSettingStore.getState()
|
||||
setDownloadType("Downloading server...")
|
||||
const [ok, error] = await GitService.DownloadServerProgress(serverVersion)
|
||||
if (ok) {
|
||||
setDownloadType("Unzipping server...")
|
||||
GitService.UnzipServer()
|
||||
setDownloadType("Download server successfully")
|
||||
setServerVersion(serverVersion)
|
||||
setServerPath("./server/firefly-go_win.exe")
|
||||
} else {
|
||||
toast.error(error)
|
||||
setDownloadType("Download server failed")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export function sleep(ms: number) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
Reference in new issue
Block a user