11<script setup lang="ts">
22import { WidgetStage } from ' @proj-airi/stage-ui/components/scenes'
3+ import { useCanvasPixelIsTransparentAtPoint } from ' @proj-airi/stage-ui/composables/canvas-alpha'
34import { useLive2d } from ' @proj-airi/stage-ui/stores/live2d'
45import { storeToRefs } from ' pinia'
5- import { computed , ref , watch } from ' vue'
6+ import { computed , ref , toRef , watch } from ' vue'
67
78import ControlsIsland from ' ../components/Widgets/ControlsIsland/index.vue'
89import ResourceStatusIsland from ' ../components/Widgets/ResourceStatusIsland/index.vue'
910
10- import { useWindowStore } from ' ../stores/window'
11+ import { useElectronRelativeMouse , useWindowStore } from ' ../stores/window'
1112import { useWindowControlStore } from ' ../stores/window-controls'
1213import { WindowControlMode } from ' ../types/window-controls'
1314
14- export interface Point {
15- x: number
16- y: number
17- }
18-
19- const windowControlStore = useWindowControlStore ()
20- const { scale, positionInPercentageString } = storeToRefs (useLive2d ())
21-
22- const { live2dLookAtX, live2dLookAtY } = storeToRefs (useWindowStore ())
23- const widgetStageRef = ref <{ canvasElement: () => HTMLCanvasElement }>()
2415const resourceStatusIslandRef = ref <InstanceType <typeof ResourceStatusIsland >>()
25-
16+ const widgetStageRef = ref <{ canvasElement: () => HTMLCanvasElement }>()
17+ const stageCanvas = toRef (() => widgetStageRef .value ?.canvasElement ())
2618const isClickThrough = ref (false )
27- const isFirstTime = ref (true )
19+ const isPassingThrough = ref (false )
2820const isLoading = ref (true )
2921const componentStateStage = ref <' pending' | ' loading' | ' mounted' >(' pending' )
3022
31- watch (componentStateStage , () => isLoading .value = componentStateStage .value !== ' mounted' , { immediate: true })
23+ const windowControlStore = useWindowControlStore ()
24+ const { x : relativeMouseX, y : relativeMouseY } = useElectronRelativeMouse ()
25+ const isTransparent = useCanvasPixelIsTransparentAtPoint (stageCanvas , relativeMouseX , relativeMouseY )
26+
27+ const { scale, positionInPercentageString } = storeToRefs (useLive2d ())
28+ const { live2dLookAtX, live2dLookAtY } = storeToRefs (useWindowStore ())
3229
3330const modeIndicatorClass = computed (() => {
3431 switch (windowControlStore .controlMode ) {
@@ -42,33 +39,53 @@ const modeIndicatorClass = computed(() => {
4239 return ' '
4340 }
4441})
42+
43+ watch (componentStateStage , () => isLoading .value = componentStateStage .value !== ' mounted' , { immediate: true })
44+ watch (isTransparent , (transparent ) => {
45+ isClickThrough .value = transparent
46+ isPassingThrough .value = transparent
47+ windowControlStore .isIgnoringMouseEvent = ! transparent
48+ })
4549 </script >
4650
4751<template >
4852 <div
49- :class =" [modeIndicatorClass, {
50- 'op-0': windowControlStore.isIgnoringMouseEvent && !isClickThrough && !isFirstTime,
51- }]"
53+ :class =" [modeIndicatorClass]"
5254 max-h =" [100vh]"
5355 max-w =" [100vw]"
5456 flex =" ~ col"
5557 relative z-2 h-full overflow-hidden rounded-xl
5658 transition =" opacity duration-500 ease-in-out"
5759 >
58- <div v-show =" !isLoading" relative h-full w-full items-end gap-2 class =" view" >
59- <ResourceStatusIsland ref =" resourceStatusIslandRef" />
60- <WidgetStage
61- ref =" widgetStageRef"
62- v-model:state =" componentStateStage"
63- h-full w-full
64- flex-1
65- :focus-at =" { x: live2dLookAtX, y: live2dLookAtY }"
66- :scale =" scale"
67- :x-offset =" positionInPercentageString.x"
68- :y-offset =" positionInPercentageString.y"
69- mb =" <md:18"
70- />
71- <ControlsIsland />
60+ <div
61+ v-show =" !isLoading"
62+ :class =" [
63+ 'relative h-full w-full items-end gap-2',
64+ 'transition-opacity duration-250 ease-in-out',
65+ ]"
66+ >
67+ <div
68+ :class =" [
69+ windowControlStore.isIgnoringMouseEvent && !isClickThrough ? 'op-0' : 'op-100',
70+ 'absolute',
71+ 'top-0 left-0 w-full h-full',
72+ 'transition-opacity duration-250 ease-in-out',
73+ ]"
74+ >
75+ <ResourceStatusIsland ref =" resourceStatusIslandRef" />
76+ <WidgetStage
77+ ref =" widgetStageRef"
78+ v-model:state =" componentStateStage"
79+ h-full w-full
80+ flex-1
81+ :focus-at =" { x: live2dLookAtX, y: live2dLookAtY }"
82+ :scale =" scale"
83+ :x-offset =" positionInPercentageString.x"
84+ :y-offset =" positionInPercentageString.y"
85+ mb =" <md:18"
86+ />
87+ <ControlsIsland />
88+ </div >
7289 </div >
7390 <div v-show =" isLoading" h-full w-full >
7491 <div class =" absolute left-0 top-0 z-99 h-full w-full flex cursor-grab items-center justify-center overflow-hidden" >
@@ -138,14 +155,6 @@ const modeIndicatorClass = computed(() => {
138155</template >
139156
140157<style scoped>
141- .view {
142- transition : opacity 0.5s ease-in-out ;
143-
144- .show-on-hover {
145- opacity : 1 ;
146- }
147- }
148-
149158@keyframes wall-move {
150159 0% {
151160 transform : translateX (calc (var (--wall-width ) * -2 ));
0 commit comments