mirror of
https://github.com/ayangweb/BongoCat.git
synced 2026-03-12 17:51:48 +08:00
fix: 修复托盘菜单状态无法实时更新的问题 (#478)
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user