[feat] tray powerplan items and seperators

This commit is contained in:
Purp1e
2025-03-27 00:58:18 +08:00
parent 27439593b4
commit 21cdc7c32d
6 changed files with 162 additions and 86 deletions

View File

@@ -1,6 +1,8 @@
import { store } from "@tauri-store/valtio"
import { useSnapshot } from "valtio"
import { DEFAULT_STORE_CONFIG } from "./config"
import { emit } from "@tauri-apps/api/event"
import { send } from "process"
interface LaunchOption {
option: string
@@ -50,6 +52,13 @@ export const useToolStore = () => {
void toolStore.start
const state = useSnapshot(toolStore.state)
if (typeof window !== 'undefined') {
setTimeout(() => {
sendCurrentLaunchOptionToTray(state.launchIndex)
sendPowerPlanToTray(state.powerPlan)
}, 500)
}
return {
state,
store: toolStore,
@@ -77,10 +86,18 @@ const setLaunchOptions = (options: LaunchOption[]) => {
const setLaunchIndex = (index: number) => {
toolStore.state.launchIndex = index
sendCurrentLaunchOptionToTray(index)
}
const sendCurrentLaunchOptionToTray = (index: number) => {
emit("tray://get_current_launch_option", toolStore.state.launchOptions[index].name || index + 1)
}
const setPowerPlan = (plan: number) => {
toolStore.state.powerPlan = plan
sendPowerPlanToTray(plan)
}
const sendPowerPlanToTray = (plan: number) => {
emit("tray://get_powerplan", plan)
}
const setVideoSetting = (setting: VideoSetting) => {