[fix] fast launch from tray not working

This commit is contained in:
Purp1e
2025-03-28 13:22:26 +08:00
parent dbedf25f0c
commit 1d23c29ba8
3 changed files with 16 additions and 8 deletions

View File

@@ -16,7 +16,14 @@ pub fn greet(name: &str) -> Result<String, String> {
#[tauri::command]
pub fn launch_game(steam_path: &str, launch_option: &str, server: &str) -> Result<String, String> {
wrap_err!(steam::launch_game(steam_path, launch_option, server));
println!("{}: launching game on server: {}, with launch Option {}", steam_path, server, launch_option);
// wrap_err!(steam::launch_game(steam_path, launch_option, server));
// 如果有错误,打印出来
if let Err(e) = steam::launch_game(steam_path, launch_option, server) {
println!("Error: {}", e);
return Err(e.to_string());
}
// steam::launch_game(steam_path, launch_option, server);
Ok(format!(
"Launching game on server: {}, with launch Option {}",

View File

@@ -1,11 +1,11 @@
"use client"
import { init } from "@/store"
import { useSteamStore } from "@/store/steam"
import { useToolStore } from "@/store/tool"
import { steamStore, useSteamStore } from "@/store/steam"
import { toolStore, useToolStore } from "@/store/tool"
import { addToast } from "@heroui/react"
import { invoke } from "@tauri-apps/api/core"
import { listen } from "@tauri-apps/api/event"
import { useDebounce } from "ahooks"
import { useDebounce, useDebounceEffect, useDebounceFn } from "ahooks"
import { useEffect } from "react"
import "./globals.css"
import Providers from "./providers"
@@ -20,11 +20,11 @@ export default function RootLayout({ children }: { children: React.ReactNode })
void listen<string>("tray://launch_game", async (event) => {
await invoke("launch_game", {
steamPath: `${steam.state.steamDir}/steam.exe`,
launchOption: tool.state.launchOptions[tool.state.launchIndex].option || "",
steamPath: `${steamStore.state.steamDir}\\steam.exe`,
launchOption: toolStore.state.launchOptions[toolStore.state.launchIndex].option || "",
server: event.payload || "worldwide",
})
addToast({ title: "启动国服成功" })
addToast({ title: `启动${event.payload === "worldwide" ? "国际服" : "国服"}成功` })
})
void listen("tray://kill_steam", async () => {
@@ -38,7 +38,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
})
void listen<number>("tray://set_powerplan", async (event) => {
if (typeof(event.payload) === "number" && event.payload <= 0 && event.payload > 4) return
if (typeof event.payload === "number" && event.payload <= 0 && event.payload > 4) return
await invoke("set_powerplan", { plan: event.payload })
const current = await invoke<number>("get_powerplan")
tool.setPowerPlan(current)

View File

@@ -4,6 +4,7 @@ import { DEFAULT_STORE_CONFIG } from "./config"
import { emit } from "@tauri-apps/api/event"
import { invoke } from "@tauri-apps/api/core"
import VideoSetting from "@/components/cstb/VideoSetting"
import { useSteamStore } from "./steam"
interface LaunchOption {
option: string