[fix] store persistence and switch dir to 'cstb'

This commit is contained in:
Purp1e
2025-03-20 01:46:54 +08:00
parent b90a08d0fe
commit c28cd23b5c
14 changed files with 136 additions and 81 deletions

View File

@@ -1,20 +1,15 @@
// @ts-ignore
// import path from "path"
// import { appConfigDir } from "@tauri-apps/api/path"
// import { setValtioPath } from "tauri-plugin-valtio"
import { appConfigDir } from "@tauri-apps/api/path"
import { setStoreCollectionPath } from "@tauri-store/valtio"
import { appStore } from "./app"
import { steamStore } from "./steam"
import { toolStore } from "./tool"
import path from "path"
// async function init() {
// const configDir = await appConfigDir()
// const distDir = path.join(configDir, "cstb")
// await setValtioPath(distDir)
// // console.log('init valtio', distDir);
// }
// void init()
export const DEFAULT_STORE_CONFIG = {
saveOnChange: true,
saveOnExit: true,
saveStrategy: "debounce" as const,
saveInterval: 2000,
export async function init() {
await appStore.start()
await toolStore.start()
await steamStore.start()
const appConfigDirPath = await appConfigDir()
console.log(appConfigDirPath)
await setStoreCollectionPath(path.resolve(appConfigDirPath, "cstb"))
}