dev-prepare #2

Merged
purp1e merged 42 commits from dev-prepare into master 2025-03-24 02:16:40 +08:00
15 changed files with 169 additions and 127 deletions
Showing only changes of commit db3cf9aef2 - Show all commits

View File

@@ -0,0 +1,2 @@
**添加规则文件可帮助模型精准理解你的编码偏好,如框架、代码风格等**
**规则文件只对当前工程生效单文件限制10000字符。如果无需将该文件提交到远程 Git 仓库,请将其添加到 .gitignore**

BIN
bun.lockb

Binary file not shown.

View File

@@ -35,7 +35,7 @@
"@types/throttle-debounce": "^5.0.2", "@types/throttle-debounce": "^5.0.2",
"framer-motion": "^12.5.0", "framer-motion": "^12.5.0",
"jotai": "^2.12.2", "jotai": "^2.12.2",
"next": "15.2.0", "next": "15.2.2",
"next-themes": "^0.4.6", "next-themes": "^0.4.6",
"react": "^19.0.0", "react": "^19.0.0",
"react-dom": "^19.0.0", "react-dom": "^19.0.0",
@@ -65,7 +65,7 @@
"eslint": "9.14.0", "eslint": "9.14.0",
"eslint-config-next": "15.0.3", "eslint-config-next": "15.0.3",
"husky": "^9.1.7", "husky": "^9.1.7",
"lint-staged": "^15.4.3", "lint-staged": "^15.5.0",
"postcss": "^8.5.3", "postcss": "^8.5.3",
"postcss-import": "^16.1.0", "postcss-import": "^16.1.0",
"postcss-nesting": "^13.0.1", "postcss-nesting": "^13.0.1",

View File

@@ -1,18 +1,16 @@
"use client" "use client"
import { appStore } from "@/store/app" import { useAppStore } from "@/store/app"
import { useSnapshot } from "valtio"
export default function Page() { export default function Page() {
void appStore.start() const app = useAppStore()
const app = useSnapshot(appStore.state)
return ( return (
<div className="flex flex-col items-start gap-3 pt-2 pb-1"> <div className="flex flex-col items-start gap-3 pt-2 pb-1">
<p>{app.version}</p> <p>{app.state.version}</p>
<p>{app.hasUpdate ? "有" : "无"}</p> <p>{app.state.hasUpdate ? "有" : "无"}</p>
<p>{app.inited ? "是" : "否"}</p> <p>{app.state.inited ? "是" : "否"}</p>
<p>{app.notice}</p> <p>{app.state.notice}</p>
<p>使{app.useMirror ? "是" : "否"}</p> <p>使{app.state.useMirror ? "是" : "否"}</p>
</div> </div>
) )
} }

View File

@@ -1,18 +1,16 @@
"use client" "use client"
import { currentUser, steamStore } from "@/store/steam" import { useSteamStore } from "@/store/steam"
import { useSnapshot } from "valtio"
export default function Page() { export default function Page() {
void steamStore.start() const steam = useSteamStore()
const steam = useSnapshot(steamStore.state)
return ( return (
<div className="flex flex-col items-start gap-3 pt-2 pb-1"> <div className="flex flex-col items-start gap-3 pt-2 pb-1">
<p>Steam路径{steam.dir}</p> <p>Steam路径{steam.state.dir}</p>
<p>{steam.csDir}</p> <p>{steam.state.csDir}</p>
<p>Steam路径有效{steam.isDirValid ? "是" : "否"}</p> <p>Steam路径有效{steam.state.isDirValid ? "是" : "否"}</p>
<p>{steam.isCsDirValid ? "是" : "否"}</p> <p>{steam.state.isCsDirValid ? "是" : "否"}</p>
<p>Steam账号{currentUser().accountName}</p> <p>Steam账号{steam.currentUser().accountName}</p>
</div> </div>
) )
} }

View File

@@ -1,18 +1,16 @@
"use client" "use client"
import { currentUser, setCsDir, setDir, steamStore } from "@/store/steam" import { useSteamStore } from "@/store/steam"
import { useEffect, useState } from "react" import { useEffect, useState } from "react"
import { useSnapshot } from "valtio"
export default function Page() { export default function Page() {
void steamStore.start() const steam = useSteamStore()
const steam = useSnapshot(steamStore.state) const [steamDir, setSteamDir] = useState(steam.state.dir)
const [steamDir, setSteamDir] = useState(steam.dir) const [cs2Dir, setCs2Dir] = useState(steam.state.csDir)
const [cs2Dir, setCs2Dir] = useState(steam.csDir)
useEffect(() => { useEffect(() => {
setSteamDir(steam.dir) setSteamDir(steam.state.dir)
setCs2Dir(steam.csDir) setCs2Dir(steam.state.csDir)
}, [steam.dir, steam.csDir]) }, [steam.state.dir, steam.state.csDir])
return ( return (
<div <div
@@ -29,7 +27,7 @@ export default function Page() {
value={steamDir} value={steamDir}
onChange={(e) => { onChange={(e) => {
setSteamDir(e.target.value) setSteamDir(e.target.value)
setDir(e.target.value) steam.setDir(e.target.value)
}} }}
/> />
<p>CS2所在文件夹</p> <p>CS2所在文件夹</p>
@@ -38,10 +36,10 @@ export default function Page() {
value={cs2Dir} value={cs2Dir}
onChange={(e) => { onChange={(e) => {
setCs2Dir(e.target.value) setCs2Dir(e.target.value)
setCsDir(e.target.value) steam.setCsDir(e.target.value)
}} }}
/> />
<p>64SteamID{currentUser().steamID64}</p> <p>64SteamID{steam.currentUser().steamID64}</p>
</div> </div>
</div> </div>
) )

View File

@@ -1,16 +1,13 @@
import { steamStore } from "@/store/steam" import { useSteamStore } from "@/store/steam"
import { toolStore } from "@/store/tool" import { useToolStore } from "@/store/tool"
import { TakeOff } from "@icon-park/react" import { TakeOff } from "@icon-park/react"
import { invoke } from "@tauri-apps/api/core" import { invoke } from "@tauri-apps/api/core"
import { useSnapshot } from "valtio"
import { Card, CardBody, CardHeader, CardIcon } from "../window/Card" import { Card, CardBody, CardHeader, CardIcon } from "../window/Card"
// import { addToast } from "@heroui/react" // import { addToast } from "@heroui/react"
const FastLaunch = () => { const FastLaunch = () => {
void toolStore.start() const steam = useSteamStore()
void steamStore.start() const tool = useToolStore()
const { launchOptions, launchIndex } = useSnapshot(toolStore.state)
const { dir } = useSnapshot(steamStore.state)
return ( return (
<Card> <Card>
@@ -25,8 +22,8 @@ const FastLaunch = () => {
type="button" type="button"
onClick={() => onClick={() =>
invoke("launch_game", { invoke("launch_game", {
steamPath: `${dir}/steam.exe`, steamPath: `${steam.state.dir}/steam.exe`,
launchOption: launchOptions[launchIndex] || "", launchOption: tool.state.launchOptions[tool.state.launchIndex] || "",
server: "perfectworld", server: "perfectworld",
}) })
} }
@@ -38,8 +35,8 @@ const FastLaunch = () => {
type="button" type="button"
onClick={() => onClick={() =>
invoke("launch_game", { invoke("launch_game", {
steamPath: `${dir}/steam.exe`, steamPath: `${steam.state.dir}/steam.exe`,
launchOption: launchOptions[launchIndex] || "", launchOption: tool.state.launchOptions[tool.state.launchIndex] || "",
server: "worldwide", server: "worldwide",
}) })
} }

View File

@@ -1,23 +1,16 @@
import { import { useToolStore } from "@/store/tool"
addLaunchOption,
setLaunchIndex,
setLaunchOption,
toolStore,
} from "@/store/tool"
import { Plus, SettingConfig, Switch } from "@icon-park/react" import { Plus, SettingConfig, Switch } from "@icon-park/react"
import { useEffect, useState } from "react" import { useEffect, useState } from "react"
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"
const LaunchOption = () => { const LaunchOption = () => {
void toolStore.start() const tool = useToolStore()
const { launchOptions, launchIndex } = useSnapshot(toolStore.state) const [launchOpt, setLaunchOpt] = useState(tool.state.launchOptions[tool.state.launchIndex] || "")
const [launchOpt, setLaunchOpt] = useState(launchOptions[launchIndex] || "")
useEffect(() => { useEffect(() => {
setLaunchOpt(launchOptions[launchIndex] || "") setLaunchOpt(tool.state.launchOptions[tool.state.launchIndex] || "")
}, [launchIndex, launchOptions]) }, [tool.state.launchIndex, tool.state.launchOptions])
return ( return (
<Card> <Card>
@@ -26,12 +19,12 @@ const LaunchOption = () => {
<SettingConfig /> <SettingConfig />
</CardIcon> </CardIcon>
<CardTool> <CardTool>
{launchOptions.map((option, index) => ( {tool.state.launchOptions.map((option, index) => (
<ToolButton key={option} onClick={() => setLaunchIndex(index)}> <ToolButton key={option} onClick={() => tool.setLaunchIndex(index)}>
{index + 1} {index + 1}
</ToolButton> </ToolButton>
))} ))}
<ToolButton onClick={() => addLaunchOption("")}> <ToolButton onClick={() => tool.addLaunchOption("")}>
<Plus /> <Plus />
</ToolButton> </ToolButton>
@@ -46,9 +39,9 @@ const LaunchOption = () => {
placeholder="请输入启动选项" placeholder="请输入启动选项"
value={launchOpt} value={launchOpt}
onChange={(e) => { onChange={(e) => {
if (launchIndex < 0 || launchIndex > 10) return if (tool.state.launchIndex < 0 || tool.state.launchIndex > 10) return
setLaunchOpt(e.target.value) setLaunchOpt(e.target.value)
setLaunchOption(e.target.value, launchIndex) tool.setLaunchOption(e.target.value, tool.state.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"
/> />

View File

@@ -6,12 +6,11 @@ import {
CardIcon, CardIcon,
CardTool, CardTool,
} from "@/components/window/Card" } from "@/components/window/Card"
import { appStore } from "@/store/app" import { useAppStore } from "@/store/app"
import { createClient } from "@/utils/supabase/client" import { createClient } from "@/utils/supabase/client"
import { Skeleton } from "@heroui/react" import { Skeleton } from "@heroui/react"
import { Refresh, VolumeNotice } from "@icon-park/react" import { Refresh, VolumeNotice } from "@icon-park/react"
import useSWR, { useSWRConfig } from "swr" import useSWR, { useSWRConfig } from "swr"
import { useSnapshot } from "valtio"
import { ToolButton } from "../window/ToolButton" import { ToolButton } from "../window/ToolButton"
const Notice = () => { const Notice = () => {
@@ -38,8 +37,7 @@ const Notice = () => {
} }
const NoticeBody = () => { const NoticeBody = () => {
void appStore.start() const app = useAppStore()
const app = useSnapshot(appStore.state)
const noticeFetcher = async () => { const noticeFetcher = async () => {
const supabase = createClient() const supabase = createClient()
@@ -68,7 +66,7 @@ const NoticeBody = () => {
return ( return (
<> <>
{notice?.content || {notice?.content ||
app.notice || app.state.notice ||
"不会真的有人要更新CSGO工具箱吧不会吧不会吧 xswl"} "不会真的有人要更新CSGO工具箱吧不会吧不会吧 xswl"}
</> </>
) )

View File

@@ -1,27 +1,26 @@
import { Button, Spinner } from "@heroui/react" import { Button, Spinner } from "@heroui/react"
import { useRouter } from "next/navigation" import { useRouter } from "next/navigation"
import { useEffect, useState } from "react" import { useEffect, useState } from "react"
import { useSnapshot } from "valtio" import { useSteamStore } from "@/store/steam"
import { setCsDir, setDir, steamStore } from "@/store/steam"
import { open } from "@tauri-apps/plugin-dialog" import { open } from "@tauri-apps/plugin-dialog"
export function Prepare() { export function Prepare() {
const steam = useSteamStore()
const router = useRouter() const router = useRouter()
const steam = useSnapshot(steamStore.state)
const [loading, setLoading] = useState(true) const [loading, setLoading] = useState(true)
const [steamDir, setSteamDir] = useState(steam.dir) const [steamDir, setSteamDir] = useState(steam.state.dir)
const [cs2Dir, setCs2Dir] = useState(steam.csDir) const [cs2Dir, setCs2Dir] = useState(steam.state.csDir)
useEffect(() => { useEffect(() => {
const checkPaths = () => { const checkPaths = () => {
if (steam.dir && steam.csDir) { if (steam.state.dir && steam.state.csDir) {
router.push("/home") // router.push("/home")
} else { }
setLoading(false) setLoading(false)
} }
}
checkPaths() checkPaths()
}, [steam.dir, steam.csDir, router]) }, [steam.state.dir, steam.state.csDir, router])
const handleSelectSteamDir = async () => { const handleSelectSteamDir = async () => {
const selected = await open({ const selected = await open({
@@ -31,7 +30,7 @@ export function Prepare() {
if (selected) { if (selected) {
const dir = selected.replace(/\\[^\\]+$/, "") const dir = selected.replace(/\\[^\\]+$/, "")
setSteamDir(dir) setSteamDir(dir)
setDir(dir) steam.setDir(dir)
} }
} }
@@ -42,14 +41,14 @@ export function Prepare() {
}) })
if (selected) { if (selected) {
setCs2Dir(selected) setCs2Dir(selected)
setCsDir(selected) steam.setCsDir(selected)
} }
} }
if (loading) { if (loading) {
return ( return (
<div className="flex flex-col items-center justify-center w-full h-screen gap-6"> <div className="flex flex-col items-center justify-center gap-6">
<Spinner size="lg" /> <Spinner size="lg" variant="simple" />
<p>...</p> <p>...</p>
</div> </div>
) )
@@ -64,7 +63,9 @@ export function Prepare() {
<input <input
className="flex-grow px-2 py-1 mb-2 rounded-lg" className="flex-grow px-2 py-1 mb-2 rounded-lg"
value={steamDir} value={steamDir}
onChange={(e) => setSteamDir(e.target.value)} onChange={(e) => {
setSteamDir(e.target.value), steam.setDir(e.target.value)
}}
/> />
<Button onPress={handleSelectSteamDir} variant="solid" color="primary" size="sm"> <Button onPress={handleSelectSteamDir} variant="solid" color="primary" size="sm">
@@ -75,12 +76,24 @@ export function Prepare() {
<input <input
className="flex-grow px-2 py-1 mb-2 rounded-lg" className="flex-grow px-2 py-1 mb-2 rounded-lg"
value={cs2Dir} value={cs2Dir}
onChange={(e) => setCs2Dir(e.target.value)} onChange={(e) => {
setCs2Dir(e.target.value), steam.setCsDir(e.target.value)
}}
/> />
<Button onPress={handleSelectCs2Dir} variant="solid" color="primary" size="sm"> <Button onPress={handleSelectCs2Dir} variant="solid" color="primary" size="sm">
</Button> </Button>
</div> </div>
<section className="flex justify-center w-full gap-3 mt-6">
<Button
onPress={() => alert("获取")}
variant="ghost"
color="default"
size="sm"
>
</Button>
<Button <Button
onPress={() => router.push("/home")} onPress={() => router.push("/home")}
variant="solid" variant="solid"
@@ -90,6 +103,7 @@ export function Prepare() {
> >
</Button> </Button>
</section>
</div> </div>
) )
} }

View File

@@ -1,7 +1,7 @@
"use client" "use client"
import { setTheme as setTauriTheme } from "@/hooks/tauri/theme" import { setTheme as setTauriTheme } from "@/hooks/tauri/theme"
import { resetAppStore } from "@/store/app" import { useAppStore } from "@/store/app"
import { resetToolStore } from "@/store/tool" import { useToolStore } from "@/store/tool"
import { addToast } from "@heroui/react" import { addToast } from "@heroui/react"
import { Close, Minus, Moon, Refresh, RocketOne, Square, SunOne } from "@icon-park/react" import { Close, Minus, Moon, Refresh, RocketOne, Square, SunOne } from "@icon-park/react"
import { type Theme, getCurrentWindow } from "@tauri-apps/api/window" import { type Theme, getCurrentWindow } from "@tauri-apps/api/window"
@@ -11,6 +11,8 @@ import { usePathname, useRouter } from "next/navigation"
import { saveAllNow } from "tauri-plugin-valtio" import { saveAllNow } from "tauri-plugin-valtio"
const Nav = () => { const Nav = () => {
const app = useAppStore()
const tool = useToolStore()
const { theme, setTheme } = useTheme() const { theme, setTheme } = useTheme()
const setAppTheme = async (theme: Theme) => { const setAppTheme = async (theme: Theme) => {
setTheme(theme) setTheme(theme)
@@ -46,8 +48,8 @@ const Nav = () => {
type="button" type="button"
className="px-2 py-0 transition duration-150 rounded hover:bg-zinc-200/80 dark:hover:bg-zinc-100/10 active:scale-95" className="px-2 py-0 transition duration-150 rounded hover:bg-zinc-200/80 dark:hover:bg-zinc-100/10 active:scale-95"
onClick={() => { onClick={() => {
resetAppStore() app.resetAppStore()
resetToolStore() tool.resetToolStore()
addToast({ addToast({
title: "重置成功", title: "重置成功",
color: "success", color: "success",

View File

@@ -12,8 +12,7 @@ import { usePathname, useRouter } from "next/navigation"
import type { ReactNode } from "react" import type { ReactNode } from "react"
// import { platform } from "@tauri-apps/plugin-os" // import { platform } from "@tauri-apps/plugin-os"
import { appStore, setVersion } from "@/store/app" import { useAppStore } from "@/store/app"
import { useSnapshot } from "valtio"
interface SideButtonProps { interface SideButtonProps {
route: string route: string
@@ -71,8 +70,7 @@ const Avatar = () => {
} }
const SideBar = () => { const SideBar = () => {
void appStore.start() const app = useAppStore()
const { version } = useSnapshot(appStore.state)
return ( return (
<div <div
@@ -119,9 +117,9 @@ const SideBar = () => {
variant="light" variant="light"
size="sm" size="sm"
className="mt-0.5 text-zinc-600" className="mt-0.5 text-zinc-600"
onPress={() => setVersion("x.y.z")} onPress={() => app.setVersion("x.y.z")}
> >
{version} {app.state.version}
</Button> </Button>
</div> </div>
</div> </div>

View File

@@ -1,13 +1,7 @@
import { store } from "tauri-plugin-valtio" import { store } from "tauri-plugin-valtio"
import { useSnapshot } from "valtio"
import { DEFAULT_STORE_CONFIG } from "." import { DEFAULT_STORE_CONFIG } from "."
// Usage:
// import {appStore} from "@/store/app"
// import { useSnapshot } from "valtio"
// const app = useSnapshot(appStore.state)
// { app.version }
// () => appStore.setVersion("0.0.1")
const defaultValue = { const defaultValue = {
version: "0.0.1", version: "0.0.1",
hasUpdate: false, hasUpdate: false,
@@ -18,23 +12,38 @@ const defaultValue = {
export const appStore = store("app", { ...defaultValue }, DEFAULT_STORE_CONFIG) export const appStore = store("app", { ...defaultValue }, DEFAULT_STORE_CONFIG)
export const setVersion = (version: string) => { export const useAppStore = () => {
void appStore.start
const state = useSnapshot(appStore.state)
return {
state,
setVersion,
setHasUpdate,
setInited,
setNotice,
setUseMirror,
resetAppStore,
}
}
const setVersion = (version: string) => {
appStore.state.version = version appStore.state.version = version
} }
export const setHasUpdate = (hasUpdate: boolean) => { const setHasUpdate = (hasUpdate: boolean) => {
appStore.state.hasUpdate = hasUpdate appStore.state.hasUpdate = hasUpdate
} }
export const setInited = (inited: boolean) => { const setInited = (inited: boolean) => {
appStore.state.inited = inited appStore.state.inited = inited
} }
export const setNotice = (notice: string) => { const setNotice = (notice: string) => {
appStore.state.notice = notice appStore.state.notice = notice
} }
export const setUseMirror = (useMirror: boolean) => { const setUseMirror = (useMirror: boolean) => {
appStore.state.useMirror = useMirror appStore.state.useMirror = useMirror
} }
export const resetAppStore = () => { const resetAppStore = () => {
setVersion(defaultValue.version) setVersion(defaultValue.version)
setHasUpdate(defaultValue.hasUpdate) setHasUpdate(defaultValue.hasUpdate)
setInited(defaultValue.inited) setInited(defaultValue.inited)

View File

@@ -1,6 +1,7 @@
import type { SteamUser } from "@/types/steam" import type { SteamUser } from "@/types/steam"
import { store } from "tauri-plugin-valtio" import { store } from "tauri-plugin-valtio"
import { DEFAULT_STORE_CONFIG } from "." import { DEFAULT_STORE_CONFIG } from "."
import { useSnapshot } from "valtio"
const defaultValue = { const defaultValue = {
dir: "C:\\Program Files (x86)\\Steam", dir: "C:\\Program Files (x86)\\Steam",
@@ -18,33 +19,50 @@ const defaultValue = {
isDirValid: false, isDirValid: false,
isCsDirValid: false, isCsDirValid: false,
} }
export const steamStore = store( export const steamStore = store(
"steam", "steam",
{ ...defaultValue }, { ...defaultValue },
DEFAULT_STORE_CONFIG, DEFAULT_STORE_CONFIG,
) )
export const setDir = (dir: string) => { export const useSteamStore = () => {
void steamStore.start
const state = useSnapshot(steamStore.state)
return {
state,
setDir,
setCsDir,
setUsers,
setIsDirValid,
setIsCsDirValid,
currentUser,
resetSteamStore,
}
}
const setDir = (dir: string) => {
steamStore.state.dir = dir steamStore.state.dir = dir
} }
export const setCsDir = (dir: string) => { const setCsDir = (dir: string) => {
steamStore.state.csDir = dir steamStore.state.csDir = dir
} }
export const setUsers = (users: SteamUser[]) => { const setUsers = (users: SteamUser[]) => {
steamStore.state.users = users steamStore.state.users = users
} }
export const setIsDirValid = (valid: boolean) => { const setIsDirValid = (valid: boolean) => {
steamStore.state.isDirValid = valid steamStore.state.isDirValid = valid
} }
export const setIsCsDirValid = (valid: boolean) => { const setIsCsDirValid = (valid: boolean) => {
steamStore.state.isCsDirValid = valid steamStore.state.isCsDirValid = valid
} }
export const currentUser = () => { const currentUser = () => {
return steamStore.state.users[0] || defaultValue.users[0] return steamStore.state.users[0] || defaultValue.users[0]
} }
export const resetSteamStore = () => { const resetSteamStore = () => {
setDir(defaultValue.dir) setDir(defaultValue.dir)
setCsDir(defaultValue.csDir) setCsDir(defaultValue.csDir)
setUsers(defaultValue.users) setUsers(defaultValue.users)

View File

@@ -1,6 +1,8 @@
import { store } from "tauri-plugin-valtio" import { store } from "tauri-plugin-valtio"
import { useSnapshot } from "valtio"
import { DEFAULT_STORE_CONFIG } from "." import { DEFAULT_STORE_CONFIG } from "."
const defaultValue = { const defaultValue = {
launchOptions: [ launchOptions: [
"-novid -high -freq 144 -fullscreen", "-novid -high -freq 144 -fullscreen",
@@ -17,7 +19,22 @@ export const toolStore = store(
DEFAULT_STORE_CONFIG, DEFAULT_STORE_CONFIG,
) )
export const setLaunchOption = (option: string, index: number) => { export const useToolStore = () => {
void toolStore.start
const state = useSnapshot(toolStore.state)
return {
state,
setLaunchOption,
setLaunchOptions,
setLaunchIndex,
setPowerPlan,
addLaunchOption,
resetToolStore,
}
}
const setLaunchOption = (option: string, index: number) => {
toolStore.state.launchOptions = [ toolStore.state.launchOptions = [
...toolStore.state.launchOptions.slice(0, index), ...toolStore.state.launchOptions.slice(0, index),
option, option,
@@ -25,19 +42,19 @@ export const setLaunchOption = (option: string, index: number) => {
] ]
} }
export const setLaunchOptions = (options: string[]) => { const setLaunchOptions = (options: string[]) => {
toolStore.state.launchOptions = options toolStore.state.launchOptions = options
} }
export const setLaunchIndex = (index: number) => { const setLaunchIndex = (index: number) => {
toolStore.state.launchIndex = index toolStore.state.launchIndex = index
} }
export const setPowerPlan = (plan: number) => { const setPowerPlan = (plan: number) => {
toolStore.state.powerPlan = plan toolStore.state.powerPlan = plan
} }
export const addLaunchOption = (option: string) => { const addLaunchOption = (option: string) => {
// 限制最高10个 // 限制最高10个
if (toolStore.state.launchOptions.length >= 10) { if (toolStore.state.launchOptions.length >= 10) {
return return
@@ -45,7 +62,7 @@ export const addLaunchOption = (option: string) => {
toolStore.state.launchOptions = [...toolStore.state.launchOptions, option] toolStore.state.launchOptions = [...toolStore.state.launchOptions, option]
} }
export const resetToolStore = () => { const resetToolStore = () => {
setLaunchOptions(defaultValue.launchOptions) setLaunchOptions(defaultValue.launchOptions)
setLaunchIndex(defaultValue.launchIndex) setLaunchIndex(defaultValue.launchIndex)
setPowerPlan(defaultValue.powerPlan) setPowerPlan(defaultValue.powerPlan)