fix(stage-tamagotchi): fix first time initialization blank and an overlook (#466)

This commit is contained in:
Ilya Bogdanov
2025-08-26 14:18:12 +08:00
committed by GitHub
parent 932f4a47fe
commit e6048f5af8
3 changed files with 23 additions and 34 deletions
@@ -4,40 +4,25 @@
/** user-defined commands **/
let passThroughEnabled = false;
export const commands = {
async startPassThrough(): Promise<Result<null, string>> {
if (passThroughEnabled) {
return { status: 'ok', data: null };
}
async startPassThrough() : Promise<Result<null, string>> {
try {
passThroughEnabled = true;
return { status: 'ok', data: await TAURI_INVOKE('plugin:window-pass-through-on-hover|start_pass_through') };
}
catch (e) {
passThroughEnabled = false;
if (e instanceof Error)
throw e;
else return { status: 'error', error: e as any };
}
},
async stopPassThrough(): Promise<Result<null, string>> {
if (!passThroughEnabled) {
return { status: 'ok', data: null };
}
return { status: "ok", data: await TAURI_INVOKE("plugin:window-pass-through-on-hover|start_pass_through") };
} catch (e) {
if(e instanceof Error) throw e;
else return { status: "error", error: e as any };
}
},
async stopPassThrough() : Promise<Result<null, string>> {
try {
passThroughEnabled = false;
return { status: 'ok', data: await TAURI_INVOKE('plugin:window-pass-through-on-hover|stop_pass_through') };
}
catch (e) {
passThroughEnabled = true;
if (e instanceof Error)
throw e;
else return { status: 'error', error: e as any };
}
}
};
return { status: "ok", data: await TAURI_INVOKE("plugin:window-pass-through-on-hover|stop_pass_through") };
} catch (e) {
if(e instanceof Error) throw e;
else return { status: "error", error: e as any };
}
}
}
/** user-defined events **/
@@ -36,7 +36,7 @@ export interface WindowFrame {
interface Events {
'tauri://resize': unknown
'tauri://move': { payload: { x: number, y: number } }
'tauri://move': { x: number, y: number }
'tauri://close-requested': unknown
'tauri://destroyed': unknown
'tauri://focus': unknown
+7 -3
View File
@@ -42,17 +42,21 @@ const windowY = ref(0)
const isClickThrough = ref(false)
const isPassingThrough = ref(false)
const isOverUI = ref(false)
const isFirstTime = ref(true)
watchThrottled([mouseX, mouseY], async ([x, y]) => {
const canvas = widgetStageRef.value?.canvasElement()
if (!canvas)
return
isFirstTime.value = false
if (windowControlStore.controlMode === WindowControlMode.RESIZE || windowControlStore.controlMode === WindowControlMode.MOVE) {
if (isPassingThrough.value) {
passThroughCommands.stopPassThrough()
isPassingThrough.value = false
}
return
}
@@ -194,8 +198,8 @@ onMounted(async () => {
windowY.value = pos.y
}
unListenFuncs.push(await listen('tauri://move', (event) => {
windowX.value = event.payload.payload.x
windowY.value = event.payload.payload.y
windowX.value = event.payload.x
windowY.value = event.payload.y
}))
await setupVADModel()
@@ -234,7 +238,7 @@ if (import.meta.hot) { // For better DX
<template>
<div
:class="[modeIndicatorClass, {
'op-0': windowControlStore.isIgnoringMouseEvent && !isClickThrough,
'op-0': windowControlStore.isIgnoringMouseEvent && !isClickThrough && !isFirstTime,
'pointer-events-none': !isClickThrough,
}]"
max-h="[100vh]"