Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e08b265ae8 |
@@ -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);
|
||||||
|
|||||||
@@ -190,18 +190,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 +209,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")
|
||||||
|
const fileExists = await FSService.FileExists(fileNeedRemove)
|
||||||
|
if (fileExists) {
|
||||||
await FSService.RemoveFile(fileNeedRemove)
|
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,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() {
|
||||||
@@ -129,7 +129,7 @@ func (f *FSService) StartWithConsole(path string) (bool, error) {
|
|||||||
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, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const ProxyZipFile = "64bit.zip"
|
|||||||
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.1"
|
||||||
|
|
||||||
type ToolFile string
|
type ToolFile string
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user