UPDATE: update to go 1.25

This commit is contained in:
2025-08-24 17:22:30 +07:00
parent b2adcd7981
commit 99b9df1ce5
11 changed files with 1232 additions and 1730 deletions

View File

@@ -39,6 +39,7 @@ func (f *FSService) PickFile() (string, error) {
} else {
dialog.SetTitle("Select a file/directory")
}
dialog.AddFilter("Executable Files (*.exe)", "*.exe")
if path, err := dialog.PromptForSingleSelection(); err == nil {
return path, nil
}
@@ -69,7 +70,7 @@ func (f *FSService) StartApp(path string) (bool, error) {
if strings.HasSuffix(path, "StarRail.exe") {
go func() {
_ = cmd.Wait()
application.Get().EmitEvent("game:exit")
application.Get().Event.Emit("game:exit")
}()
}
@@ -106,11 +107,11 @@ func (f *FSService) StartWithConsole(path string) (bool, error) {
go func() {
_ = cmd.Wait()
if strings.HasSuffix(path, "launcher.exe") {
application.Get().EmitEvent("game:exit")
application.Get().Event.Emit("game:exit")
} else if strings.HasSuffix(path, "firefly-go_win.exe") {
application.Get().EmitEvent("server:exit")
application.Get().Event.Emit("server:exit")
} else if strings.HasSuffix(path, "FireflyProxy.exe") {
application.Get().EmitEvent("proxy:exit")
application.Get().Event.Emit("proxy:exit")
}
}()
return true, nil
@@ -127,7 +128,7 @@ func (f *FSService) OpenFolder(path string) (bool, string) {
}
url := "file:///" + filepath.ToSlash(absPath)
application.Get().BrowserOpenURL(url)
application.Get().Browser.OpenURL(url)
return true, ""
}

View File

@@ -96,7 +96,7 @@ func (g *GitService) DownloadServerProgress(version string) (bool, string) {
defer resp.Body.Close()
DownloadFile(saveFile, assetWin.BrowserDownloadURL, func(percent float64, speed float64) {
application.Get().EmitEvent("download:server", map[string]interface{}{
application.Get().Event.Emit("download:server", map[string]interface{}{
"percent": fmt.Sprintf("%.2f", percent),
"speed": fmt.Sprintf("%.2f", speed),
})
@@ -188,7 +188,7 @@ func (g *GitService) DownloadProxyProgress(version string) (bool, string) {
defer resp.Body.Close()
DownloadFile(saveFile, assetWin.BrowserDownloadURL, func(percent float64, speed float64) {
application.Get().EmitEvent("download:proxy", map[string]interface{}{
application.Get().Event.Emit("download:proxy", map[string]interface{}{
"percent": fmt.Sprintf("%.2f", percent),
"speed": fmt.Sprintf("%.2f", speed),
})

View File

@@ -116,7 +116,7 @@ func (h *HdiffzService) CutData(gamePath string) (bool, string) {
return err
}
destPath := filepath.Join(gamePath, relPath)
application.Get().EmitEvent("hdiffz:message", map[string]string{"message": destPath})
application.Get().Event.Emit("hdiffz:message", map[string]string{"message": destPath})
if info.IsDir() {
return os.MkdirAll(destPath, os.ModePerm)
}
@@ -189,7 +189,7 @@ func (h *HdiffzService) PatchData(gamePath string) (bool, string) {
}
for i, entry := range jsonData.DiffMap {
application.Get().EmitEvent(
application.Get().Event.Emit(
"hdiffz:progress", map[string]int{
"progress": i,
"maxProgress": len(jsonData.DiffMap),
@@ -262,7 +262,7 @@ func (h *HdiffzService) DeleteFiles(gamePath string) (bool, string) {
for i, file := range deleteFiles {
os.Remove(filepath.Join(gamePath, file))
application.Get().EmitEvent("hdiffz:progress", map[string]int{"progress": i, "maxProgress": len(deleteFiles)})
application.Get().Event.Emit("hdiffz:progress", map[string]int{"progress": i, "maxProgress": len(deleteFiles)})
}
_ = os.Remove(filepath.Join(gamePath, "deletefiles.txt"))
return true, ""

View File

@@ -109,8 +109,6 @@ func DownloadFile(filepath string, url string, onEmit func(percent float64, spee
return nil
}
func unzipParallel(src string, dest string) error {
numCPU := runtime.NumCPU()
@@ -141,16 +139,14 @@ func unzipParallel(src string, dest string) error {
// Worker pool
for i := 0; i < maxWorkers; i++ {
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
for j := range jobs {
err := extractFile(j.f, dest)
if err != nil {
fmt.Printf("Error extracting %s: %v\n", j.f.Name, err)
}
}
}()
})
}
// Feed jobs
@@ -189,4 +185,4 @@ func extractFile(f *zip.File, dest string) error {
_, err = io.Copy(out, rc)
return err
}
}