[fix] store persistence and switch dir to 'cstb'
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
// "use client"
|
||||
"use client"
|
||||
import { steamStore } from "@/store/steam"
|
||||
import { useEffect } from "react"
|
||||
import "./globals.css"
|
||||
import Providers from "./providers"
|
||||
import { init } from "@/store"
|
||||
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
||||
useEffect(() => {
|
||||
void init()
|
||||
})
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<body>
|
||||
|
||||
@@ -8,7 +8,7 @@ import { type Theme, getCurrentWindow } from "@tauri-apps/api/window"
|
||||
import { /* relaunch, */ exit } from "@tauri-apps/plugin-process"
|
||||
import { useTheme } from "next-themes"
|
||||
import { usePathname, useRouter } from "next/navigation"
|
||||
import { saveAllNow } from "tauri-plugin-valtio"
|
||||
import { saveAllNow } from "@tauri-store/valtio"
|
||||
|
||||
const Nav = () => {
|
||||
const app = useAppStore()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { store } from "tauri-plugin-valtio"
|
||||
import { store } from "@tauri-store/valtio"
|
||||
import { useSnapshot } from "valtio"
|
||||
import { DEFAULT_STORE_CONFIG } from "."
|
||||
import { DEFAULT_STORE_CONFIG } from "./config"
|
||||
|
||||
const defaultValue = {
|
||||
version: "0.0.1",
|
||||
|
||||
6
src/store/config.ts
Normal file
6
src/store/config.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export const DEFAULT_STORE_CONFIG = {
|
||||
saveOnChange: true,
|
||||
saveOnExit: true,
|
||||
saveStrategy: "debounce" as const,
|
||||
saveInterval: 2000,
|
||||
}
|
||||
@@ -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"))
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { SteamUser } from "@/types/steam"
|
||||
import { store } from "tauri-plugin-valtio"
|
||||
import { DEFAULT_STORE_CONFIG } from "."
|
||||
import { store } from "@tauri-store/valtio"
|
||||
import { DEFAULT_STORE_CONFIG } from "./config"
|
||||
import { useSnapshot } from "valtio"
|
||||
|
||||
const defaultValue = {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { store } from "tauri-plugin-valtio"
|
||||
import { store } from "@tauri-store/valtio"
|
||||
import { useSnapshot } from "valtio"
|
||||
import { DEFAULT_STORE_CONFIG } from "."
|
||||
import { DEFAULT_STORE_CONFIG } from "./config"
|
||||
|
||||
|
||||
const defaultValue = {
|
||||
|
||||
Reference in New Issue
Block a user