update: persist store fullfiil + launchOptions validation

This commit is contained in:
Purp1e
2024-09-27 10:38:40 +08:00
parent 759cdbab98
commit 46c6dbfa61
7 changed files with 158 additions and 97 deletions

View File

@@ -1,12 +1,10 @@
import { Plus, SettingConfig, Switch } from "@icon-park/react";
import { Card, CardHeader, CardIcon, CardTool, CardBody } from "../window/Card";
import { useState } from "react";
import { ToolButton } from "../window/ToolButton";
import useToolStore from "@/store/tool";
const LaunchOption = () => {
const [LaunchOption, setLaunchOption] = useState<string>(
"-high -refresh 120 -novid -nojoy -tickrate 128 +cl_cmdrate 128 +cl_updaterate 128 +exec auto.cfg +test"
);
const { launchOptions, setLaunchOption, launchIndex, setLaunchIndex } = useToolStore()
return (
<Card>
@@ -15,9 +13,9 @@ const LaunchOption = () => {
<SettingConfig />
</CardIcon>
<CardTool>
<ToolButton>1</ToolButton>
<ToolButton>2</ToolButton>
<ToolButton>3</ToolButton>
<ToolButton onClick={() => setLaunchIndex(0)}>1</ToolButton>
<ToolButton onClick={() => setLaunchIndex(1)}>2</ToolButton>
<ToolButton onClick={() => setLaunchIndex(2)}>3</ToolButton>
<ToolButton>
<Plus />
@@ -31,8 +29,8 @@ const LaunchOption = () => {
<CardBody>
<textarea
placeholder="请输入启动选项"
value={LaunchOption}
onChange={(e) => setLaunchOption(e.target.value)}
value={launchOptions[launchIndex]}
onChange={(e) => setLaunchOption(e.target.value, launchIndex)}
className="w-full font-mono text-base bg-transparent outline-none resize-none min-h-20"
/>
</CardBody>