3 Commits

Author SHA1 Message Date
2349d6d360 FIX: Fix some bug 2025-12-12 18:55:46 +07:00
acdd761652 UPDATE: Change proxy 2025-12-12 18:49:30 +07:00
e08b265ae8 FIX: Fail to start game 2025-11-05 23:33:34 +07:00
11 changed files with 43 additions and 46 deletions

View File

@@ -80,7 +80,7 @@ export function RemoveFile(path) {
/** /**
* @param {string} path * @param {string} path
* @returns {$CancellablePromise<boolean>} * @returns {$CancellablePromise<[boolean, string]>}
*/ */
export function StartApp(path) { export function StartApp(path) {
return $Call.ByID(1267568402, path); return $Call.ByID(1267568402, path);
@@ -88,7 +88,7 @@ export function StartApp(path) {
/** /**
* @param {string} path * @param {string} path
* @returns {$CancellablePromise<boolean>} * @returns {$CancellablePromise<[boolean, string]>}
*/ */
export function StartWithConsole(path) { export function StartWithConsole(path) {
return $Call.ByID(3249271428, path); return $Call.ByID(3249271428, path);

View File

@@ -43,13 +43,6 @@ export function GetLatestServerVersion() {
return $Call.ByID(2918980975); return $Call.ByID(2918980975);
} }
/**
* @returns {$CancellablePromise<void>}
*/
export function UnzipProxy() {
return $Call.ByID(2563246729);
}
/** /**
* @returns {$CancellablePromise<void>} * @returns {$CancellablePromise<void>}
*/ */

View File

@@ -0,0 +1,9 @@
//@ts-check
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import { Create as $Create } from "@wailsio/runtime";
Object.freeze($Create.Events);

View File

@@ -0,0 +1,2 @@
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT

View File

@@ -23,11 +23,9 @@ export async function UpdateProxy(proxyVersion: string) : Promise<void> {
setDownloadType("Downloading proxy...") setDownloadType("Downloading proxy...")
const [ok, error] = await GitService.DownloadProxyProgress(proxyVersion) const [ok, error] = await GitService.DownloadProxyProgress(proxyVersion)
if (ok) { if (ok) {
setDownloadType("Unzipping proxy...")
GitService.UnzipProxy()
setDownloadType("Download proxy successfully") setDownloadType("Download proxy successfully")
setProxyVersion(proxyVersion) setProxyVersion(proxyVersion)
setProxyPath("./proxy/FireflyProxy.exe") setProxyPath("./proxy/firefly-go-proxy.exe")
} else { } else {
toast.error(error) toast.error(error)
setDownloadType("Download proxy failed") setDownloadType("Download proxy failed")

View File

@@ -178,8 +178,6 @@ export default function LauncherPage() {
} }
} }
const handleStartGame = async () => { const handleStartGame = async () => {
if (!gamePath) { if (!gamePath) {
return return
@@ -190,18 +188,18 @@ export default function LauncherPage() {
try { try {
setIsLoading(true) setIsLoading(true)
if (!proxyRunning && !gamePath.endsWith("launcher.exe")) { if (!proxyRunning && !gamePath.endsWith("launcher.exe")) {
const resultProxy = await FSService.StartWithConsole(proxyPath) const [resultProxy, error] = await FSService.StartWithConsole(proxyPath)
if (!resultProxy) { if (!resultProxy) {
toast.error('Failed to start proxy') toast.error('Failed to start proxy: ' + error)
return return
} }
setProxyRunning(true) setProxyRunning(true)
} }
await sleep(500) await sleep(500)
if (!serverRunning) { if (!serverRunning) {
const resultServer = await FSService.StartWithConsole(serverPath) const [resultServer, error] = await FSService.StartWithConsole(serverPath)
if (!resultServer) { if (!resultServer) {
toast.error('Failed to start server') toast.error('Failed to start server: ' + error)
return return
} }
setServerRunning(true) setServerRunning(true)
@@ -209,23 +207,27 @@ export default function LauncherPage() {
await sleep(1000) await sleep(1000)
const gameFolder = await FSService.GetDir(gamePath) const gameFolder = await FSService.GetDir(gamePath)
const fileNeedRemove = await FSService.Join(gameFolder, "StarRail_Data", "Plugins", "x86_64", "AccountPlatNative.dll") const fileNeedRemove = await FSService.Join(gameFolder, "StarRail_Data", "Plugins", "x86_64", "AccountPlatNative.dll")
await FSService.RemoveFile(fileNeedRemove) const fileExists = await FSService.FileExists(fileNeedRemove)
if (fileExists) {
await FSService.RemoveFile(fileNeedRemove)
}
if (gamePath.endsWith("launcher.exe")) { if (gamePath.endsWith("launcher.exe")) {
const resultGame = await FSService.StartWithConsole(gamePath) const [resultGame, error] = await FSService.StartWithConsole(gamePath)
if (!resultGame) { if (!resultGame) {
toast.error('Failed to start game') toast.error('Failed to start game: ' + error)
return return
} }
} else { } else {
const resultGame = await FSService.StartApp(gamePath) const [resultGame, error] = await FSService.StartApp(gamePath)
if (!resultGame) { if (!resultGame) {
toast.error('Failed to start game') toast.error('Failed to start game: ' + error)
return return
} }
} }
setGameRunning(true) setGameRunning(true)
} catch (err: any) { } catch (err: any) {
console.log(err)
toast.error('StartGame error:', err) toast.error('StartGame error:', err)
} finally { } finally {
setIsLoading(false) setIsLoading(false)

2
go.mod
View File

@@ -1,6 +1,6 @@
module firefly-launcher module firefly-launcher
go 1.25 go 1.25.5
require ( require (
github.com/klauspost/compress v1.18.0 github.com/klauspost/compress v1.18.0

View File

@@ -2,12 +2,12 @@ package fsService
import ( import (
"firefly-launcher/pkg/sevenzip" "firefly-launcher/pkg/sevenzip"
"fmt"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"runtime" "runtime"
"strings" "strings"
"github.com/wailsapp/wails/v3/pkg/application" "github.com/wailsapp/wails/v3/pkg/application"
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
) )
@@ -75,13 +75,13 @@ func (f *FSService) RemoveFile(path string) error {
return os.Remove(path) return os.Remove(path)
} }
func (f *FSService) StartApp(path string) (bool, string) {
func (f *FSService) StartApp(path string) (bool, error) {
cmd := exec.Command(path) cmd := exec.Command(path)
err := cmd.Start() err := cmd.Start()
if err != nil { if err != nil {
return false, err return false, err.Error()
} }
if strings.HasSuffix(path, "StarRail.exe") { if strings.HasSuffix(path, "StarRail.exe") {
go func() { go func() {
_ = cmd.Wait() _ = cmd.Wait()
@@ -89,17 +89,17 @@ func (f *FSService) StartApp(path string) (bool, error) {
}() }()
} }
return true, nil return true, ""
} }
func (f *FSService) StartWithConsole(path string) (bool, error) { func (f *FSService) StartWithConsole(path string) (bool, string) {
absPath, err := filepath.Abs(path) absPath, err := filepath.Abs(path)
if err != nil { if err != nil {
return false, err return false, err.Error()
} }
if _, err := os.Stat(absPath); os.IsNotExist(err) { if _, err := os.Stat(absPath); os.IsNotExist(err) {
return false, fmt.Errorf("file not found: %s", absPath) return false, "file not found: " + absPath
} }
cmd := exec.Command(absPath) cmd := exec.Command(absPath)
cmd.Dir = filepath.Dir(absPath) cmd.Dir = filepath.Dir(absPath)
@@ -116,7 +116,7 @@ func (f *FSService) StartWithConsole(path string) (bool, error) {
err = cmd.Start() err = cmd.Start()
if err != nil { if err != nil {
return false, err return false, err.Error()
} }
go func() { go func() {
@@ -125,11 +125,11 @@ func (f *FSService) StartWithConsole(path string) (bool, error) {
application.Get().Event.Emit("game:exit") application.Get().Event.Emit("game:exit")
} else if strings.HasSuffix(path, "firefly-go_win.exe") { } else if strings.HasSuffix(path, "firefly-go_win.exe") {
application.Get().Event.Emit("server:exit") application.Get().Event.Emit("server:exit")
} else if strings.HasSuffix(path, "FireflyProxy.exe") { } else if strings.HasSuffix(path, "firefly-go-proxy.exe") {
application.Get().Event.Emit("proxy:exit") application.Get().Event.Emit("proxy:exit")
} }
}() }()
return true, nil return true, ""
} }
func (f *FSService) OpenFolder(path string) (bool, string) { func (f *FSService) OpenFolder(path string) (bool, string) {
@@ -155,4 +155,3 @@ func (f *FSService) FileExistsInZip(archivePath, fileInside string) (bool, strin
} }
return exists, "" return exists, ""
} }

View File

@@ -37,7 +37,7 @@ func (g *GitService) GetLatestProxyVersion() (bool, string, string) {
} }
func (g *GitService) DownloadProxyProgress(version string) (bool, string) { func (g *GitService) DownloadProxyProgress(version string) (bool, string) {
asset, ok := g.getReleaseAsset(version, constant.ProxyGitUrl, constant.ProxyZipFile) asset, ok := g.getReleaseAsset(version, constant.ProxyGitUrl, constant.ProxyFile)
if !ok { if !ok {
return false, "no release found" return false, "no release found"
} }
@@ -65,7 +65,3 @@ func (g *GitService) DownloadProxyProgress(version string) (bool, string) {
return false, "failed to rename tmp file after retries" return false, "failed to rename tmp file after retries"
} }
func (g *GitService) UnzipProxy() {
g.unzipParallel(filepath.Join(constant.ProxyStorageUrl, constant.ProxyZipFile), constant.ProxyStorageUrl)
os.Remove(filepath.Join(constant.ProxyStorageUrl, constant.ProxyZipFile))
}

View File

@@ -117,8 +117,6 @@ func main() {
systemTray.SetMenu(menu) systemTray.SetMenu(menu)
window.RegisterHook(events.Common.WindowClosing, func(e *application.WindowEvent) { window.RegisterHook(events.Common.WindowClosing, func(e *application.WindowEvent) {
app.Event.Emit("window:close") app.Event.Emit("window:close")
e.Cancel() e.Cancel()

View File

@@ -1,16 +1,16 @@
package constant package constant
const ProxyGitUrl = "https://git.kain.io.vn/api/v1/repos/Firefly-Shelter/Firefly_Proxy/releases" const ProxyGitUrl = "https://git.kain.io.vn/api/v1/repos/Firefly-Shelter/FireflyGo_Proxy/releases"
const ServerGitUrl = "https://git.kain.io.vn/api/v1/repos/Firefly-Shelter/FireflyGo_Local_Archive/releases" const ServerGitUrl = "https://git.kain.io.vn/api/v1/repos/Firefly-Shelter/FireflyGo_Local_Archive/releases"
const LauncherGitUrl = "https://git.kain.io.vn/api/v1/repos/Firefly-Shelter/Firefly_Launcher/releases" const LauncherGitUrl = "https://git.kain.io.vn/api/v1/repos/Firefly-Shelter/Firefly_Launcher/releases"
const ServerStorageUrl = "./server" const ServerStorageUrl = "./server"
const ProxyStorageUrl = "./proxy" const ProxyStorageUrl = "./proxy"
const ServerZipFile = "prebuild_win_x86.zip" const ServerZipFile = "prebuild_win_x86.zip"
const ProxyZipFile = "64bit.zip" const ProxyFile = "firefly-go-proxy.exe"
const LauncherFile = "firefly-launcher.exe" const LauncherFile = "firefly-launcher.exe"
const TempUrl = "./temp" const TempUrl = "./temp"
const CurrentLauncherVersion = "2.3.0" const CurrentLauncherVersion = "2.3.3"
type ToolFile string type ToolFile string