[fix] input cursor auto moving to the end
This commit is contained in:
@@ -1,33 +1,47 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { currentUser, setCsDir, setDir, steamStore } from "@/store/steam"
|
import { currentUser, setCsDir, setDir, steamStore } from "@/store/steam"
|
||||||
|
import { useEffect, useState } from "react"
|
||||||
import { useSnapshot } from "valtio"
|
import { useSnapshot } from "valtio"
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
void steamStore.start()
|
void steamStore.start()
|
||||||
const steam = useSnapshot(steamStore.state)
|
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 (
|
return (
|
||||||
<div
|
<div
|
||||||
className="flex flex-col items-center justify-center w-full h-screen gap-6"
|
className="flex flex-col items-center justify-center w-full h-screen gap-6"
|
||||||
data-tauri-drag-region
|
data-tauri-drag-region
|
||||||
>
|
>
|
||||||
<h1 className="text-4xl font-bold tracking-wide text-zinc-800">
|
<h1 className="text-4xl font-bold tracking-wide">CS工具箱</h1>
|
||||||
CS工具箱
|
|
||||||
</h1>
|
|
||||||
<p>准备环节</p>
|
<p>准备环节</p>
|
||||||
|
|
||||||
<div className="flex flex-col w-full gap-6 p-5 border rounded-lg bg-white/40">
|
<div className="flex flex-col w-full gap-2 p-5 border rounded-lg bg-white/40">
|
||||||
|
<p>Steam所在文件夹</p>
|
||||||
<input
|
<input
|
||||||
className="px-2 py-1 rounded-lg"
|
className="px-2 py-1 mb-2 rounded-lg"
|
||||||
value={steam.dir}
|
value={steamDir}
|
||||||
onChange={(e) => setDir(e.target.value)}
|
onChange={(e) => {
|
||||||
|
setSteamDir(e.target.value)
|
||||||
|
setDir(e.target.value)
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
|
<p>CS2所在文件夹</p>
|
||||||
<input
|
<input
|
||||||
className="px-2 py-1 rounded-lg"
|
className="px-2 py-1 mb-2 rounded-lg"
|
||||||
value={steam.csDir}
|
value={cs2Dir}
|
||||||
onChange={(e) => setCsDir(e.target.value)}
|
onChange={(e) => {
|
||||||
|
setCs2Dir(e.target.value)
|
||||||
|
setCsDir(e.target.value)
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
|
<p>当前用户64位SteamID:{currentUser().steamID64}</p>
|
||||||
<p>{currentUser().steamID64}</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,10 +3,16 @@ import { Plus, SettingConfig, Switch } from "@icon-park/react"
|
|||||||
import { useSnapshot } from "valtio"
|
import { useSnapshot } from "valtio"
|
||||||
import { Card, CardBody, CardHeader, CardIcon, CardTool } from "../window/Card"
|
import { Card, CardBody, CardHeader, CardIcon, CardTool } from "../window/Card"
|
||||||
import { ToolButton } from "../window/ToolButton"
|
import { ToolButton } from "../window/ToolButton"
|
||||||
|
import { useEffect, useState } from "react"
|
||||||
|
|
||||||
const LaunchOption = () => {
|
const LaunchOption = () => {
|
||||||
void toolStore.start()
|
void toolStore.start()
|
||||||
const { launchOptions, launchIndex } = useSnapshot(toolStore.state)
|
const { launchOptions, launchIndex } = useSnapshot(toolStore.state)
|
||||||
|
const [launchOpt, setLaunchOpt] = useState(launchOptions[launchIndex] || "")
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setLaunchOpt(launchOptions[launchIndex] || "")
|
||||||
|
}, [launchIndex, launchOptions])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
@@ -17,7 +23,7 @@ const LaunchOption = () => {
|
|||||||
<CardTool>
|
<CardTool>
|
||||||
{launchOptions.map((option, index) => (
|
{launchOptions.map((option, index) => (
|
||||||
<ToolButton key={index} onClick={() => setLaunchIndex(index)}>
|
<ToolButton key={index} onClick={() => setLaunchIndex(index)}>
|
||||||
{index+1}
|
{index + 1}
|
||||||
</ToolButton>
|
</ToolButton>
|
||||||
))}
|
))}
|
||||||
<ToolButton onClick={() => addLaunchOption("")}>
|
<ToolButton onClick={() => addLaunchOption("")}>
|
||||||
@@ -33,8 +39,12 @@ const LaunchOption = () => {
|
|||||||
<CardBody>
|
<CardBody>
|
||||||
<textarea
|
<textarea
|
||||||
placeholder="请输入启动选项"
|
placeholder="请输入启动选项"
|
||||||
value={launchOptions[launchIndex] || ""}
|
value={launchOpt}
|
||||||
onChange={(e) => launchIndex !== -1 && setLaunchOption(e.target.value, launchIndex)}
|
onChange={(e) => {
|
||||||
|
if (launchIndex < 0 || launchIndex > 10) return
|
||||||
|
setLaunchOpt(e.target.value)
|
||||||
|
setLaunchOption(e.target.value, launchIndex)
|
||||||
|
}}
|
||||||
className="w-full font-mono text-base bg-transparent outline-none resize-none min-h-20"
|
className="w-full font-mono text-base bg-transparent outline-none resize-none min-h-20"
|
||||||
/>
|
/>
|
||||||
</CardBody>
|
</CardBody>
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export const addLaunchOption = (option: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const resetToolStore = () => {
|
export const resetToolStore = () => {
|
||||||
toolStore.state.launchOptions = defaultValue.launchOptions
|
setLaunchOptions(defaultValue.launchOptions)
|
||||||
toolStore.state.launchIndex = defaultValue.launchIndex
|
setLaunchIndex(defaultValue.launchIndex)
|
||||||
toolStore.state.powerPlan = defaultValue.powerPlan
|
setPowerPlan(defaultValue.powerPlan)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user