FIX: Fail to start game

This commit is contained in:
2025-11-05 23:33:34 +07:00
parent 52134c2200
commit e08b265ae8
4 changed files with 26 additions and 23 deletions

View File

@@ -2,12 +2,12 @@ package fsService
import (
"firefly-launcher/pkg/sevenzip"
"fmt"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"github.com/wailsapp/wails/v3/pkg/application"
"golang.org/x/sys/windows"
)
@@ -75,13 +75,13 @@ func (f *FSService) RemoveFile(path string) error {
return os.Remove(path)
}
func (f *FSService) StartApp(path string) (bool, error) {
func (f *FSService) StartApp(path string) (bool, string) {
cmd := exec.Command(path)
err := cmd.Start()
if err != nil {
return false, err
return false, err.Error()
}
if strings.HasSuffix(path, "StarRail.exe") {
go func() {
_ = 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)
if err != nil {
return false, err
return false, err.Error()
}
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.Dir = filepath.Dir(absPath)
@@ -116,7 +116,7 @@ func (f *FSService) StartWithConsole(path string) (bool, error) {
err = cmd.Start()
if err != nil {
return false, err
return false, err.Error()
}
go func() {
@@ -129,7 +129,7 @@ func (f *FSService) StartWithConsole(path string) (bool, error) {
application.Get().Event.Emit("proxy:exit")
}
}()
return true, nil
return true, ""
}
func (f *FSService) OpenFolder(path string) (bool, string) {
@@ -155,4 +155,3 @@ func (f *FSService) FileExistsInZip(archivePath, fileInside string) (bool, strin
}
return exists, ""
}