[feat] better store saving logic + more launch options
This commit is contained in:
@@ -10,7 +10,6 @@ body {
|
||||
height: 100%;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
|
||||
Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
|
||||
border-radius: 10px;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { setLaunchIndex, setLaunchOption, toolStore } from "@/store/tool"
|
||||
import { addLaunchOption, setLaunchIndex, setLaunchOption, toolStore } from "@/store/tool"
|
||||
import { Plus, SettingConfig, Switch } from "@icon-park/react"
|
||||
import { useSnapshot } from "valtio"
|
||||
import { Card, CardBody, CardHeader, CardIcon, CardTool } from "../window/Card"
|
||||
@@ -15,10 +15,12 @@ const LaunchOption = () => {
|
||||
<SettingConfig /> 启动选项
|
||||
</CardIcon>
|
||||
<CardTool>
|
||||
<ToolButton onClick={() => setLaunchIndex(0)}>1</ToolButton>
|
||||
<ToolButton onClick={() => setLaunchIndex(1)}>2</ToolButton>
|
||||
<ToolButton onClick={() => setLaunchIndex(2)}>3</ToolButton>
|
||||
<ToolButton>
|
||||
{launchOptions.map((option, index) => (
|
||||
<ToolButton key={index} onClick={() => setLaunchIndex(index)}>
|
||||
{index+1}
|
||||
</ToolButton>
|
||||
))}
|
||||
<ToolButton onClick={() => addLaunchOption("")}>
|
||||
<Plus />
|
||||
添加
|
||||
</ToolButton>
|
||||
@@ -32,9 +34,7 @@ const LaunchOption = () => {
|
||||
<textarea
|
||||
placeholder="请输入启动选项"
|
||||
value={launchOptions[launchIndex] || ""}
|
||||
onChange={(e) =>
|
||||
launchIndex !== -1 && setLaunchOption(e.target.value, launchIndex)
|
||||
}
|
||||
onChange={(e) => launchIndex !== -1 && setLaunchOption(e.target.value, launchIndex)}
|
||||
className="w-full font-mono text-base bg-transparent outline-none resize-none min-h-20"
|
||||
/>
|
||||
</CardBody>
|
||||
|
||||
@@ -16,19 +16,19 @@ import { /* relaunch, */ exit } from "@tauri-apps/plugin-process"
|
||||
import { useTheme } from "next-themes"
|
||||
// import { platform } from "@tauri-apps/plugin-os"
|
||||
import { usePathname, useRouter } from "next/navigation"
|
||||
import { saveAll } from "tauri-plugin-valtio"
|
||||
import { saveAllNow } from "tauri-plugin-valtio"
|
||||
|
||||
const Nav = () => {
|
||||
const { theme, setTheme } = useTheme()
|
||||
|
||||
const close = async () => {
|
||||
// (await window.hideOnClose) ? getCurrent().hide() : exit();
|
||||
await saveAll()
|
||||
await saveAllNow()
|
||||
await exit()
|
||||
}
|
||||
|
||||
const minimize = async () => {
|
||||
await saveAll()
|
||||
await saveAllNow()
|
||||
await getCurrentWindow().minimize()
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,17 @@ export const setPowerPlan = (plan: number) => {
|
||||
toolStore.state.powerPlan = plan
|
||||
}
|
||||
|
||||
export const addLaunchOption = (option: string) => {
|
||||
// 限制最高10个
|
||||
if (toolStore.state.launchOptions.length >= 10) {
|
||||
return
|
||||
}
|
||||
toolStore.state.launchOptions = [
|
||||
...toolStore.state.launchOptions,
|
||||
option,
|
||||
]
|
||||
}
|
||||
|
||||
export const resetToolStore = () => {
|
||||
toolStore.state.launchOptions = defaultValue.launchOptions
|
||||
toolStore.state.launchIndex = defaultValue.launchIndex
|
||||
|
||||
Reference in New Issue
Block a user