[fix] store not saving due to dep, reset to default dir

note: changing path or start() in useEffect cause the issue
This commit is contained in:
Purp1e
2025-03-13 02:34:59 +08:00
parent 06e6c5c3eb
commit bfcf519894
6 changed files with 20 additions and 21 deletions

1
src-tauri/cstb/app.json Normal file
View File

@@ -0,0 +1 @@
{"notice":"","inited":false,"hasUpdate":false,"version":"x.y.z","useMirror":true}

View File

@@ -0,0 +1 @@
{}

1
src-tauri/cstb/tool.json Normal file
View File

@@ -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}

View File

@@ -11,7 +11,7 @@ pub fn create_tray<R: Runtime>(app: &tauri::AppHandle<R>) -> 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);

View File

@@ -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 () => {

View File

@@ -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,
}