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