fix: 修复托盘菜单状态无法实时更新的问题 (#478)

This commit is contained in:
ayangweb
2025-06-11 23:22:25 +08:00
committed by GitHub
parent 2a190efa15
commit b8ce3e4a39
2 changed files with 9 additions and 4 deletions

View File

@@ -8,6 +8,7 @@ import { TrayIcon } from '@tauri-apps/api/tray'
import { openUrl } from '@tauri-apps/plugin-opener'
import { exit, relaunch } from '@tauri-apps/plugin-process'
import { watchDebounced } from '@vueuse/core'
import { watch } from 'vue'
import { GITHUB_LINK, LISTEN_KEY } from '../constants'
import { showWindow } from '../plugins/window'
@@ -23,9 +24,13 @@ export function useTray() {
const catStore = useCatStore()
const { getSharedMenu } = useSharedMenu()
watchDebounced(() => catStore, () => {
watch([() => catStore.visible, () => catStore.penetrable], () => {
updateTrayMenu()
}, { deep: true, debounce: 500 })
})
watchDebounced([() => catStore.scale, () => catStore.opacity], () => {
updateTrayMenu()
}, { debounce: 200 })
const createTray = async () => {
const tray = await getTrayById()

View File

@@ -23,7 +23,7 @@ const resizing = ref(false)
onUnmounted(handleDestroy)
const handleDebounceResize = useDebounceFn(async () => {
const debouncedResize = useDebounceFn(async () => {
await handleResize()
resizing.value = false
@@ -32,7 +32,7 @@ const handleDebounceResize = useDebounceFn(async () => {
useEventListener('resize', () => {
resizing.value = true
handleDebounceResize()
debouncedResize()
})
watch(pressedMouses, handleMouseDown)