From bfcf519894082b5c127d25477bf372a3bbf51048 Mon Sep 17 00:00:00 2001 From: Purp1e <47248616+Purple-CSGO@users.noreply.github.com> Date: Thu, 13 Mar 2025 02:34:59 +0800 Subject: [PATCH] [fix] store not saving due to dep, reset to default dir note: changing path or start() in useEffect cause the issue --- src-tauri/cstb/app.json | 1 + src-tauri/cstb/steam.json | 1 + src-tauri/cstb/tool.json | 1 + src-tauri/src/tray.rs | 2 +- src/components/window/Nav.tsx | 14 +++++--------- src/store/index.ts | 22 +++++++++++----------- 6 files changed, 20 insertions(+), 21 deletions(-) create mode 100644 src-tauri/cstb/app.json create mode 100644 src-tauri/cstb/steam.json create mode 100644 src-tauri/cstb/tool.json diff --git a/src-tauri/cstb/app.json b/src-tauri/cstb/app.json new file mode 100644 index 0000000..02041e3 --- /dev/null +++ b/src-tauri/cstb/app.json @@ -0,0 +1 @@ +{"notice":"","inited":false,"hasUpdate":false,"version":"x.y.z","useMirror":true} \ No newline at end of file diff --git a/src-tauri/cstb/steam.json b/src-tauri/cstb/steam.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/src-tauri/cstb/steam.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/src-tauri/cstb/tool.json b/src-tauri/cstb/tool.json new file mode 100644 index 0000000..30cbbb2 --- /dev/null +++ b/src-tauri/cstb/tool.json @@ -0,0 +1 @@ +{"powerPlan":0,"launchOptions":["sdfasdfasdf","-novid -high -w 1920 -h 1080 -freq 144 -sw -noborder","-novid -high -freq 144 -fullscreen -allow_third_party_software"],"launchIndex":0} \ No newline at end of file diff --git a/src-tauri/src/tray.rs b/src-tauri/src/tray.rs index 1436ed0..63425ed 100644 --- a/src-tauri/src/tray.rs +++ b/src-tauri/src/tray.rs @@ -11,7 +11,7 @@ pub fn create_tray(app: &tauri::AppHandle) -> tauri::Result<()> { let _ = TrayIconBuilder::with_id("tray") .icon(app.default_window_icon().unwrap().clone()) .menu(&menu) - .menu_on_left_click(false) + .show_menu_on_left_click(false) .on_menu_event(move |app, event| match event.id.as_ref() { "quit" => { app.exit(0); diff --git a/src/components/window/Nav.tsx b/src/components/window/Nav.tsx index 8e14807..f40abee 100644 --- a/src/components/window/Nav.tsx +++ b/src/components/window/Nav.tsx @@ -16,24 +16,20 @@ import { /* relaunch, */ exit } from "@tauri-apps/plugin-process" import { useTheme } from "next-themes" // import { platform } from "@tauri-apps/plugin-os" import { usePathname, useRouter } from "next/navigation" +import { saveAll } from "tauri-plugin-valtio" const Nav = () => { const { theme, setTheme } = useTheme() const close = async () => { // (await window.hideOnClose) ? getCurrent().hide() : exit(); + await saveAll() await exit() } - const minimize = () => { - getCurrentWindow() - .minimize() - .then(() => { - console.log("minimized") - }) - .catch((err: unknown) => { - console.error(err) - }) + const minimize = async () => { + await saveAll() + await getCurrentWindow().minimize() } const toggleMaximize = async () => { diff --git a/src/store/index.ts b/src/store/index.ts index be93cfb..489d135 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,20 +1,20 @@ // @ts-ignore -import path from "path" -import { appConfigDir } from "@tauri-apps/api/path" -import { setValtioPath } from "tauri-plugin-valtio" +// import path from "path" +// import { appConfigDir } from "@tauri-apps/api/path" +// import { setValtioPath } from "tauri-plugin-valtio" -async function init() { - const configDir = await appConfigDir() - const distDir = path.join(configDir, "cstb") - await setValtioPath(distDir) - // console.log('init valtio', distDir); -} +// async function init() { +// const configDir = await appConfigDir() +// const distDir = path.join(configDir, "cstb") +// await setValtioPath(distDir) +// // console.log('init valtio', distDir); +// } -void init() +// void init() export const DEFAULT_STORE_CONFIG = { saveOnChange: true, saveOnExit: true, saveStrategy: "debounce" as const, - saveInterval: 3000, + saveInterval: 2000, }