From 35ecf4ce0aebd9c80173b5afcb4d1e1fdf189d2f Mon Sep 17 00:00:00 2001 From: purp1e Date: Tue, 8 Jul 2025 11:31:43 +0800 Subject: [PATCH] [feat] launch option edit and remove --- src/components/cstb/LaunchOption.tsx | 80 ++++++++++++++++++++++++---- src/components/cstb/Prepare.tsx | 1 + src/components/cstb/VideoSetting.tsx | 25 +++++---- src/components/window/Card.tsx | 8 +-- src/components/window/SideBar.tsx | 2 +- src/components/window/ToolButton.tsx | 2 +- src/store/tool.ts | 14 +++-- 7 files changed, 102 insertions(+), 30 deletions(-) diff --git a/src/components/cstb/LaunchOption.tsx b/src/components/cstb/LaunchOption.tsx index d493efd..78e379c 100644 --- a/src/components/cstb/LaunchOption.tsx +++ b/src/components/cstb/LaunchOption.tsx @@ -1,13 +1,15 @@ -import { useToolStore } from "@/store/tool" -import { Plus, SettingConfig, Switch } from "@icon-park/react" +import { LaunchOption as iLaunchOption, useToolStore } from "@/store/tool" +import { Badge, Close, Edit, Plus, Save, SettingConfig, Switch } from "@icon-park/react" import { useEffect, useState } from "react" import { Card, CardBody, CardHeader, CardIcon, CardTool } from "../window/Card" import { ToolButton } from "../window/ToolButton" -import { Tooltip } from "@heroui/react" +import { Button, Input, Tooltip } from "@heroui/react" +import { remove } from "@tauri-apps/plugin-fs" const LaunchOption = () => { const tool = useToolStore() const [launchOpt, setLaunchOpt] = useState(tool.state.launchOptions[tool.state.launchIndex] || "") + const [editMode, setEditMode] = useState(false) useEffect(() => { setLaunchOpt(tool.state.launchOptions[tool.state.launchIndex] || "") @@ -19,22 +21,78 @@ const LaunchOption = () => { 启动选项 - - {tool.state.launchOptions.map((option, index) => ( - tool.setLaunchIndex(index)}> - {option.name || index + 1} - - ))} + + {tool.state.launchOptions.map((option, index) => + editMode ? ( + {tool.removeLaunchOption(index)}}> + + + } + > + { + tool.setLaunchOption({ ...option, name: value } as iLaunchOption, index) + }} + variant="bordered" + size="sm" + placeholder="名称" + fullWidth={false} + /> + + ) : ( + // { + // setSteamDir(value) + // steam.setDir(value) + // }} + // description="steam.exe所在文件夹" + // errorMessage={"路径无效"} + // isInvalid={!steam.state.steamDirValid} + // /> + tool.setLaunchIndex(index)}> + {option.name || index + 1} + + ) + )} tool.addLaunchOption({ option: "", name: "" })}> 添加 - + {/* 切换模式 - + */} + setEditMode(!editMode)}> + {editMode ? ( + <> + + 保存 + + ) : ( + <> + + 修改 + + )} + diff --git a/src/components/cstb/Prepare.tsx b/src/components/cstb/Prepare.tsx index e83505c..8d1515e 100644 --- a/src/components/cstb/Prepare.tsx +++ b/src/components/cstb/Prepare.tsx @@ -66,6 +66,7 @@ export function Prepare() { setLoading(false) }, 1200) } + // router.push("/home") }, [inited]) const handleSelectSteamDir = async () => { diff --git a/src/components/cstb/VideoSetting.tsx b/src/components/cstb/VideoSetting.tsx index b2e62b4..252f99a 100644 --- a/src/components/cstb/VideoSetting.tsx +++ b/src/components/cstb/VideoSetting.tsx @@ -401,6 +401,7 @@ const VideoSetting = () => { defaultres: value.toString(), }) }} + isDisabled={!edit} radius="full" step={10} className="max-w-28" @@ -408,18 +409,22 @@ const VideoSetting = () => { /> { - const _ = edit - ? setVconfig({ - ...vconfig, - defaultresheight: value.toString(), - }) - : tool.setVideoSetting({ - ...tool.state.videoSetting, - defaultresheight: value.toString(), - }) + const _ = edit + ? setVconfig({ + ...vconfig, + defaultresheight: value.toString(), + }) + : tool.setVideoSetting({ + ...tool.state.videoSetting, + defaultresheight: value.toString(), + }) }} + isDisabled={!edit} radius="full" step={10} className="max-w-28" diff --git a/src/components/window/Card.tsx b/src/components/window/Card.tsx index da170d5..5226c0d 100644 --- a/src/components/window/Card.tsx +++ b/src/components/window/Card.tsx @@ -24,7 +24,7 @@ const Card = ({ children, className, ...props }: CardProps) => { const CardHeader = ({ children }: CardProps) => { return ( -
+
{children}
) @@ -34,7 +34,7 @@ const CardIcon = ({ children, type, className, ...rest }: CardProps) => { return (
{ ) } -const CardTool = ({ children }: CardProps) => { +const CardTool = ({ children, className }: CardProps) => { return ( -
+
{children}
) diff --git a/src/components/window/SideBar.tsx b/src/components/window/SideBar.tsx index cb3335e..1f9d742 100644 --- a/src/components/window/SideBar.tsx +++ b/src/components/window/SideBar.tsx @@ -118,7 +118,7 @@ const SideBar = () => {

版本号

-

{app.state.version}

+

{app.state.version}

) diff --git a/src/components/window/ToolButton.tsx b/src/components/window/ToolButton.tsx index 235b706..582e902 100644 --- a/src/components/window/ToolButton.tsx +++ b/src/components/window/ToolButton.tsx @@ -7,7 +7,7 @@ export const ToolButton = ({ children, ...rest }: ToolButtonProps) => { return (