2025-03-12 11:22:32 +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 = {
|
|
|
|
|
launchOptions: [] as string[],
|
|
|
|
|
launchIndex: 0,
|
|
|
|
|
powerPlan: 0
|
2024-09-21 02:25:23 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-12 11:22:32 +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,
|
|
|
|
|
...toolStore.state.launchOptions.slice(index + 1)
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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-12 11:22:32 +08:00
|
|
|
export const resetToolStore = () => {
|
|
|
|
|
toolStore.state.launchOptions = defaultValue.launchOptions
|
|
|
|
|
toolStore.state.launchIndex = defaultValue.launchIndex
|
|
|
|
|
toolStore.state.powerPlan = defaultValue.powerPlan
|
|
|
|
|
}
|