From aa8f914f909ed495374c31bae6a88964bd65fc12 Mon Sep 17 00:00:00 2001 From: Neko Ayaka Date: Mon, 30 Jun 2025 02:11:57 +0800 Subject: [PATCH] fix(stage-tamagotchi): hide on hover --- .../src/composables/tauri-click-through.ts | 8 +++++++- apps/stage-tamagotchi/src/pages/index.vue | 6 ++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/stage-tamagotchi/src/composables/tauri-click-through.ts b/apps/stage-tamagotchi/src/composables/tauri-click-through.ts index 637dcdd86..7dff79fd9 100644 --- a/apps/stage-tamagotchi/src/composables/tauri-click-through.ts +++ b/apps/stage-tamagotchi/src/composables/tauri-click-through.ts @@ -80,7 +80,9 @@ export function useTauriWindowClickThrough(live2DLookAtDefault: MaybeRefOrGetter live2dLookAtY.value = mousePos.value.y - windowFrame.value.origin.y } - watch(mousePos, () => updateLive2DLookAt()) + watch(mousePos, () => { + updateLive2DLookAt() + }) function updateIsCursorInside() { isCursorInside.value @@ -90,6 +92,10 @@ export function useTauriWindowClickThrough(live2DLookAtDefault: MaybeRefOrGetter && mousePos.value.y <= windowFrame.value.origin.y + windowFrame.value.size.height } + watch([mousePos, windowFrame], () => { + updateIsCursorInside() + }) + watch(isInitialized, async (initialized) => { if (initialized) { updateLive2DLookAt() diff --git a/apps/stage-tamagotchi/src/pages/index.vue b/apps/stage-tamagotchi/src/pages/index.vue index e3f6b371c..b33c0c9f6 100644 --- a/apps/stage-tamagotchi/src/pages/index.vue +++ b/apps/stage-tamagotchi/src/pages/index.vue @@ -24,12 +24,10 @@ const { width, height } = useWindowSize() const centerPos = computed(() => ({ x: width.value / 2, y: height.value / 2 })) const live2dFocusAt = ref(centerPos.value) -const isCursorInside = ref(false) -const shouldHideView = computed(() => isCursorInside.value && !windowStore.isControlActive && windowStore.isIgnoringMouseEvent) - const { listen } = useTauriEvent() const { invoke } = useTauriCore() -const { live2dLookAtX, live2dLookAtY } = useTauriWindowClickThrough(centerPos) +const { live2dLookAtX, live2dLookAtY, isCursorInside } = useTauriWindowClickThrough(centerPos) +const shouldHideView = computed(() => isCursorInside.value && !windowStore.isControlActive && windowStore.isIgnoringMouseEvent) const mcpStore = useMcpStore() const { connected, serverCmd, serverArgs } = storeToRefs(mcpStore)