11import { Button } from '@/components/ui/button'
22import { Input } from '@/components/ui/input'
3+ import { useBoundStore } from '@/store'
4+ import { useImmerStore } from '@/store/immer/immer-store'
5+ import usePersistStore from '@/store/persist/persist-store'
36import { invoke } from '@tauri-apps/api/core'
47import { useState } from 'react'
58import {
@@ -10,15 +13,15 @@ import {
1013 CardTitle
1114} from './components/ui/card'
1215import { Label } from './components/ui/label'
13- import { useBoundStore } from './store'
14- import usePersistStore from './store/persist/persist-store'
1516
1617function App ( ) {
1718 const [ greetMsg , setGreetMsg ] = useState ( '' )
1819 const [ name , setName ] = useState ( '' )
1920 const bears = useBoundStore . use . bears ( )
2021 const addBear = useBoundStore . use . addBear ( )
2122
23+ const { position, setX, setY } = useImmerStore ( )
24+
2225 const { fishes, addFish } = usePersistStore ( )
2326
2427 async function greet ( ) {
@@ -27,7 +30,7 @@ function App() {
2730 }
2831
2932 return (
30- < main className = "container flex h-screen flex-col items-center justify-center gap-8" >
33+ < main className = "flex h-screen flex-col items-center justify-center gap-8" >
3134 < div className = "text-center" >
3235 < h1 className = "text-2xl font-bold" > Welcome to Tauri + Vite</ h1 >
3336 < h2 className = "text-lg font-medium" >
@@ -67,11 +70,15 @@ function App() {
6770 </ Button >
6871 </ div >
6972 < p > Click on the Tauri, Vite, and React logos to learn more.</ p >
70- < div className = "flex w-[400px] items-center justify-center gap-2 " >
71- < Card className = "w-full" >
73+ < div className = "grid grid-cols-3 gap-4 " >
74+ < Card >
7275 < CardHeader >
7376 < CardTitle > Normal Store</ CardTitle >
74- < CardDescription > This store is memory-only.</ CardDescription >
77+ < CardDescription >
78+ This store is memory-only.
79+ < br />
80+ < br />
81+ </ CardDescription >
7582 </ CardHeader >
7683 < CardContent className = "flex flex-col gap-2" >
7784 < Label > Bears: { bears } </ Label >
@@ -80,7 +87,7 @@ function App() {
8087 </ Button >
8188 </ CardContent >
8289 </ Card >
83- < Card className = "w-full" >
90+ < Card >
8491 < CardHeader >
8592 < CardTitle > Persist Store</ CardTitle >
8693 < CardDescription >
@@ -94,6 +101,27 @@ function App() {
94101 </ Button >
95102 </ CardContent >
96103 </ Card >
104+ < Card >
105+ < CardHeader >
106+ < CardTitle > Immer Store</ CardTitle >
107+ < CardDescription >
108+ This store is using Immer to manage state.
109+ </ CardDescription >
110+ </ CardHeader >
111+ < CardContent className = "flex flex-col gap-2" >
112+ < Label >
113+ Position: { position . x } , { position . y }
114+ </ Label >
115+ < div className = "flex gap-2" >
116+ < Button variant = "outline" onClick = { ( ) => setX ( position . x + 1 ) } >
117+ Move X
118+ </ Button >
119+ < Button variant = "outline" onClick = { ( ) => setY ( position . y + 1 ) } >
120+ Move Y
121+ </ Button >
122+ </ div >
123+ </ CardContent >
124+ </ Card >
97125 </ div >
98126
99127 < form
0 commit comments