Files
cstb-next/src/store/tool.ts

56 lines
1.4 KiB
TypeScript
Raw Normal View History

2025-03-12 22:20:06 +08:00
import { store } from "tauri-plugin-valtio"
import { DEFAULT_STORE_CONFIG } from "."
const defaultValue = {
launchOptions: [
"-novid -high -freq 144 -fullscreen",
"-novid -high -w 1920 -h 1080 -freq 144 -sw -noborder",
2025-03-12 22:20:06 +08:00
"-novid -high -freq 144 -fullscreen -allow_third_party_software",
] as string[],
launchIndex: 0,
2025-03-12 22:20:06 +08:00
powerPlan: 0,
}
2025-03-12 22:20:06 +08:00
export const toolStore = store(
"tool",
{ ...defaultValue },
DEFAULT_STORE_CONFIG,
)
export const setLaunchOption = (option: string, index: number) => {
toolStore.state.launchOptions = [
...toolStore.state.launchOptions.slice(0, index),
option,
2025-03-12 22:20:06 +08:00
...toolStore.state.launchOptions.slice(index + 1),
]
}
export const setLaunchOptions = (options: string[]) => {
toolStore.state.launchOptions = options
}
export const setLaunchIndex = (index: number) => {
toolStore.state.launchIndex = index
}
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
toolStore.state.powerPlan = defaultValue.powerPlan
}