[feat] better store operation
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"use client"
|
||||
import { setTheme as setTauriTheme } from "@/hooks/tauri/theme"
|
||||
import { resetAppStore } from "@/store/app"
|
||||
import { resetToolStore } from "@/store/tool"
|
||||
import { useAppStore } from "@/store/app"
|
||||
import { useToolStore } from "@/store/tool"
|
||||
import { addToast } from "@heroui/react"
|
||||
import { Close, Minus, Moon, Refresh, RocketOne, Square, SunOne } from "@icon-park/react"
|
||||
import { type Theme, getCurrentWindow } from "@tauri-apps/api/window"
|
||||
@@ -11,6 +11,8 @@ import { usePathname, useRouter } from "next/navigation"
|
||||
import { saveAllNow } from "tauri-plugin-valtio"
|
||||
|
||||
const Nav = () => {
|
||||
const app = useAppStore()
|
||||
const tool = useToolStore()
|
||||
const { theme, setTheme } = useTheme()
|
||||
const setAppTheme = async (theme: Theme) => {
|
||||
setTheme(theme)
|
||||
@@ -46,8 +48,8 @@ const Nav = () => {
|
||||
type="button"
|
||||
className="px-2 py-0 transition duration-150 rounded hover:bg-zinc-200/80 dark:hover:bg-zinc-100/10 active:scale-95"
|
||||
onClick={() => {
|
||||
resetAppStore()
|
||||
resetToolStore()
|
||||
app.resetAppStore()
|
||||
tool.resetToolStore()
|
||||
addToast({
|
||||
title: "重置成功",
|
||||
color: "success",
|
||||
|
||||
@@ -12,8 +12,7 @@ import { usePathname, useRouter } from "next/navigation"
|
||||
import type { ReactNode } from "react"
|
||||
|
||||
// import { platform } from "@tauri-apps/plugin-os"
|
||||
import { appStore, setVersion } from "@/store/app"
|
||||
import { useSnapshot } from "valtio"
|
||||
import { useAppStore } from "@/store/app"
|
||||
|
||||
interface SideButtonProps {
|
||||
route: string
|
||||
@@ -71,8 +70,7 @@ const Avatar = () => {
|
||||
}
|
||||
|
||||
const SideBar = () => {
|
||||
void appStore.start()
|
||||
const { version } = useSnapshot(appStore.state)
|
||||
const app = useAppStore()
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -119,9 +117,9 @@ const SideBar = () => {
|
||||
variant="light"
|
||||
size="sm"
|
||||
className="mt-0.5 text-zinc-600"
|
||||
onPress={() => setVersion("x.y.z")}
|
||||
onPress={() => app.setVersion("x.y.z")}
|
||||
>
|
||||
{version}
|
||||
{app.state.version}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user