diff --git a/src/app/prepare/page.tsx b/src/app/prepare/page.tsx
index e854e17..9e7767b 100644
--- a/src/app/prepare/page.tsx
+++ b/src/app/prepare/page.tsx
@@ -1,33 +1,47 @@
"use client"
import { currentUser, setCsDir, setDir, steamStore } 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)
+
+ useEffect(() => {
+ setSteamDir(steam.dir)
+ setCs2Dir(steam.csDir)
+ }, [steam.dir, steam.csDir])
+
return (
-
- CS工具箱
-
+
CS工具箱
准备环节
-
+
+
Steam所在文件夹
setDir(e.target.value)}
+ className="px-2 py-1 mb-2 rounded-lg"
+ value={steamDir}
+ onChange={(e) => {
+ setSteamDir(e.target.value)
+ setDir(e.target.value)
+ }}
/>
+
CS2所在文件夹
setCsDir(e.target.value)}
+ className="px-2 py-1 mb-2 rounded-lg"
+ value={cs2Dir}
+ onChange={(e) => {
+ setCs2Dir(e.target.value)
+ setCsDir(e.target.value)
+ }}
/>
-
-
{currentUser().steamID64}
+
当前用户64位SteamID:{currentUser().steamID64}
)
diff --git a/src/components/cstb/LaunchOption.tsx b/src/components/cstb/LaunchOption.tsx
index 6f16bec..c2b900f 100644
--- a/src/components/cstb/LaunchOption.tsx
+++ b/src/components/cstb/LaunchOption.tsx
@@ -3,10 +3,16 @@ import { Plus, SettingConfig, Switch } from "@icon-park/react"
import { useSnapshot } from "valtio"
import { Card, CardBody, CardHeader, CardIcon, CardTool } from "../window/Card"
import { ToolButton } from "../window/ToolButton"
+import { useEffect, useState } from "react"
const LaunchOption = () => {
void toolStore.start()
const { launchOptions, launchIndex } = useSnapshot(toolStore.state)
+ const [launchOpt, setLaunchOpt] = useState(launchOptions[launchIndex] || "")
+
+ useEffect(() => {
+ setLaunchOpt(launchOptions[launchIndex] || "")
+ }, [launchIndex, launchOptions])
return (
@@ -17,7 +23,7 @@ const LaunchOption = () => {
{launchOptions.map((option, index) => (
setLaunchIndex(index)}>
- {index+1}
+ {index + 1}
))}
addLaunchOption("")}>
@@ -33,8 +39,12 @@ const LaunchOption = () => {
diff --git a/src/store/tool.ts b/src/store/tool.ts
index 90b2816..7aeb388 100644
--- a/src/store/tool.ts
+++ b/src/store/tool.ts
@@ -49,7 +49,7 @@ export const addLaunchOption = (option: string) => {
}
export const resetToolStore = () => {
- toolStore.state.launchOptions = defaultValue.launchOptions
- toolStore.state.launchIndex = defaultValue.launchIndex
- toolStore.state.powerPlan = defaultValue.powerPlan
+ setLaunchOptions(defaultValue.launchOptions)
+ setLaunchIndex(defaultValue.launchIndex)
+ setPowerPlan(defaultValue.powerPlan)
}