2025-03-12 22:20:06 +08:00
|
|
|
import { store } from "tauri-plugin-valtio"
|
|
|
|
|
import { DEFAULT_STORE_CONFIG } from "."
|
2024-09-21 02:25:23 +08:00
|
|
|
|
2025-03-12 11:22:32 +08:00
|
|
|
const defaultValue = {
|
2025-03-12 13:07:16 +08:00
|
|
|
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",
|
2025-03-12 13:07:16 +08:00
|
|
|
] as string[],
|
2025-03-12 11:22:32 +08:00
|
|
|
launchIndex: 0,
|
2025-03-12 22:20:06 +08:00
|
|
|
powerPlan: 0,
|
2024-09-21 02:25:23 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-12 22:20:06 +08:00
|
|
|
export const toolStore = store(
|
|
|
|
|
"tool",
|
|
|
|
|
{ ...defaultValue },
|
|
|
|
|
DEFAULT_STORE_CONFIG,
|
|
|
|
|
)
|
2025-03-12 11:22:32 +08:00
|
|
|
|
|
|
|
|
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),
|
2025-03-12 11:22:32 +08:00
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const setLaunchOptions = (options: string[]) => {
|
|
|
|
|
toolStore.state.launchOptions = options
|
2024-09-27 10:38:40 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-12 11:22:32 +08:00
|
|
|
export const setLaunchIndex = (index: number) => {
|
|
|
|
|
toolStore.state.launchIndex = index
|
|
|
|
|
}
|
2024-09-27 10:38:40 +08:00
|
|
|
|
2025-03-12 11:22:32 +08:00
|
|
|
export const setPowerPlan = (plan: number) => {
|
|
|
|
|
toolStore.state.powerPlan = plan
|
|
|
|
|
}
|
2024-09-21 02:25:23 +08:00
|
|
|
|
2025-03-13 22:04:27 +08:00
|
|
|
export const addLaunchOption = (option: string) => {
|
|
|
|
|
// 限制最高10个
|
|
|
|
|
if (toolStore.state.launchOptions.length >= 10) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
toolStore.state.launchOptions = [
|
|
|
|
|
...toolStore.state.launchOptions,
|
|
|
|
|
option,
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-12 11:22:32 +08:00
|
|
|
export const resetToolStore = () => {
|
2025-03-13 22:25:06 +08:00
|
|
|
setLaunchOptions(defaultValue.launchOptions)
|
|
|
|
|
setLaunchIndex(defaultValue.launchIndex)
|
|
|
|
|
setPowerPlan(defaultValue.powerPlan)
|
2025-03-12 11:22:32 +08:00
|
|
|
}
|