optim fpstest ui and try to fix steam path related crash
This commit is contained in:
@@ -19,12 +19,31 @@ export default function RootLayout({ children }: { children: React.ReactNode })
|
||||
void init()
|
||||
|
||||
void listen<string>("tray://launch_game", async (event) => {
|
||||
await invoke("launch_game", {
|
||||
steamPath: `${steamStore.state.steamDir}\\steam.exe`,
|
||||
launchOption: toolStore.state.launchOptions[toolStore.state.launchIndex].option || "",
|
||||
server: event.payload || "worldwide",
|
||||
})
|
||||
addToast({ title: `启动${event.payload === "worldwide" ? "国际服" : "国服"}成功` })
|
||||
// 验证路径
|
||||
if (!steamStore.state.steamDir || !steamStore.state.steamDirValid) {
|
||||
addToast({
|
||||
title: "Steam 路径无效,请先配置路径",
|
||||
color: "warning"
|
||||
})
|
||||
return
|
||||
}
|
||||
try {
|
||||
await invoke("launch_game", {
|
||||
steamPath: `${steamStore.state.steamDir}\\steam.exe`,
|
||||
launchOption: toolStore.state.launchOptions[toolStore.state.launchIndex].option || "",
|
||||
server: event.payload || "worldwide",
|
||||
})
|
||||
addToast({
|
||||
title: `启动${event.payload === "worldwide" ? "国际服" : "国服"}成功`,
|
||||
color: "success"
|
||||
})
|
||||
} catch (error) {
|
||||
console.error("启动游戏失败:", error)
|
||||
addToast({
|
||||
title: `启动失败: ${error instanceof Error ? error.message : String(error)}`,
|
||||
color: "danger"
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
void listen("tray://kill_steam", async () => {
|
||||
@@ -82,10 +101,13 @@ export default function RootLayout({ children }: { children: React.ReactNode })
|
||||
void steam.checkCs2DirValid()
|
||||
}, [debounceCs2Dir])
|
||||
useEffect(() => {
|
||||
if (debounceSteamDirValid) {
|
||||
if (debounceSteamDirValid && steam.state.steamDir) {
|
||||
// 安全地获取用户列表(内部已有错误处理)
|
||||
void steam.getUsers()
|
||||
// 启动文件监听
|
||||
void invoke("start_watch_loginusers", { steamDir: steam.state.steamDir })
|
||||
// 启动文件监听,添加错误处理
|
||||
void invoke("start_watch_loginusers", { steamDir: steam.state.steamDir }).catch((error) => {
|
||||
console.error("启动文件监听失败:", error)
|
||||
})
|
||||
}
|
||||
}, [debounceSteamDirValid, steam.state.steamDir])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user