[feat] better store operation
This commit is contained in:
@@ -1,18 +1,16 @@
|
||||
"use client"
|
||||
import { appStore } from "@/store/app"
|
||||
import { useSnapshot } from "valtio"
|
||||
import { useAppStore } from "@/store/app"
|
||||
|
||||
export default function Page() {
|
||||
void appStore.start()
|
||||
const app = useSnapshot(appStore.state)
|
||||
const app = useAppStore()
|
||||
|
||||
return (
|
||||
<div className="flex flex-col items-start gap-3 pt-2 pb-1">
|
||||
<p>版本号:{app.version}</p>
|
||||
<p>是否有更新:{app.hasUpdate ? "有" : "无"}</p>
|
||||
<p>初始化:{app.inited ? "是" : "否"}</p>
|
||||
<p>公告:{app.notice}</p>
|
||||
<p>是否使用镜像源:{app.useMirror ? "是" : "否"}</p>
|
||||
<p>版本号:{app.state.version}</p>
|
||||
<p>是否有更新:{app.state.hasUpdate ? "有" : "无"}</p>
|
||||
<p>初始化:{app.state.inited ? "是" : "否"}</p>
|
||||
<p>公告:{app.state.notice}</p>
|
||||
<p>是否使用镜像源:{app.state.useMirror ? "是" : "否"}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
"use client"
|
||||
import { currentUser, steamStore } from "@/store/steam"
|
||||
import { useSnapshot } from "valtio"
|
||||
import { useSteamStore } from "@/store/steam"
|
||||
|
||||
export default function Page() {
|
||||
void steamStore.start()
|
||||
const steam = useSnapshot(steamStore.state)
|
||||
const steam = useSteamStore()
|
||||
|
||||
return (
|
||||
<div className="flex flex-col items-start gap-3 pt-2 pb-1">
|
||||
<p>Steam路径:{steam.dir}</p>
|
||||
<p>游戏路径:{steam.csDir}</p>
|
||||
<p>Steam路径有效:{steam.isDirValid ? "是" : "否"}</p>
|
||||
<p>游戏路径有效:{steam.isCsDirValid ? "是" : "否"}</p>
|
||||
<p>Steam账号:{currentUser().accountName}</p>
|
||||
<p>Steam路径:{steam.state.dir}</p>
|
||||
<p>游戏路径:{steam.state.csDir}</p>
|
||||
<p>Steam路径有效:{steam.state.isDirValid ? "是" : "否"}</p>
|
||||
<p>游戏路径有效:{steam.state.isCsDirValid ? "是" : "否"}</p>
|
||||
<p>Steam账号:{steam.currentUser().accountName}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
"use client"
|
||||
|
||||
import { currentUser, setCsDir, setDir, steamStore } from "@/store/steam"
|
||||
import { useSteamStore } from "@/store/steam"
|
||||
import { useEffect, useState } from "react"
|
||||
import { useSnapshot } from "valtio"
|
||||
export default function Page() {
|
||||
void steamStore.start()
|
||||
const steam = useSnapshot(steamStore.state)
|
||||
const [steamDir, setSteamDir] = useState(steam.dir)
|
||||
const [cs2Dir, setCs2Dir] = useState(steam.csDir)
|
||||
const steam = useSteamStore()
|
||||
const [steamDir, setSteamDir] = useState(steam.state.dir)
|
||||
const [cs2Dir, setCs2Dir] = useState(steam.state.csDir)
|
||||
|
||||
useEffect(() => {
|
||||
setSteamDir(steam.dir)
|
||||
setCs2Dir(steam.csDir)
|
||||
}, [steam.dir, steam.csDir])
|
||||
setSteamDir(steam.state.dir)
|
||||
setCs2Dir(steam.state.csDir)
|
||||
}, [steam.state.dir, steam.state.csDir])
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -29,7 +27,7 @@ export default function Page() {
|
||||
value={steamDir}
|
||||
onChange={(e) => {
|
||||
setSteamDir(e.target.value)
|
||||
setDir(e.target.value)
|
||||
steam.setDir(e.target.value)
|
||||
}}
|
||||
/>
|
||||
<p>CS2所在文件夹</p>
|
||||
@@ -38,10 +36,10 @@ export default function Page() {
|
||||
value={cs2Dir}
|
||||
onChange={(e) => {
|
||||
setCs2Dir(e.target.value)
|
||||
setCsDir(e.target.value)
|
||||
steam.setCsDir(e.target.value)
|
||||
}}
|
||||
/>
|
||||
<p>当前用户64位SteamID:{currentUser().steamID64}</p>
|
||||
<p>当前用户64位SteamID:{steam.currentUser().steamID64}</p>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user