File tree 4 files changed +65
-0
lines changed
apps/stage-tamagotchi/src
4 files changed +65
-0
lines changed Original file line number Diff line number Diff line change @@ -177,4 +177,28 @@ app.whenReady().then(() => {
177
177
rebuildTrayMenu ( )
178
178
createApplicationMenu ( i18n , showQuitDialog , createSettingsWindow )
179
179
} )
180
+
181
+ ipcMain . on ( 'start-resize-window' , ( ) => {
182
+ mainWindow . setResizable ( true )
183
+ } )
184
+
185
+ ipcMain . on ( 'stop-resize-window' , ( ) => {
186
+ mainWindow . setResizable ( false )
187
+ } )
188
+
189
+ ipcMain . handle ( 'stop-move-window' , ( ) => {
190
+ return mainWindow . getPosition ( )
191
+ } )
192
+
193
+ ipcMain . on ( 'window-size-changed' , ( _ , width : number , height : number ) => {
194
+ if ( width === 0 || height === 0 ) {
195
+ mainWindow . setSize ( 300 * 1.5 , 400 * 1.5 ) // back to default size
196
+ return
197
+ }
198
+ mainWindow . setSize ( width , height )
199
+ } )
200
+
201
+ ipcMain . on ( 'window-position-changed' , ( _ , x : number , y : number ) => {
202
+ mainWindow . setPosition ( x , y )
203
+ } )
180
204
} )
Original file line number Diff line number Diff line change 1
1
<script setup lang="ts">
2
2
import { useSettings } from ' @proj-airi/stage-ui/stores'
3
+ import { useEventListener } from ' @vueuse/core'
3
4
import { onMounted , watch } from ' vue'
4
5
import { useI18n } from ' vue-i18n'
5
6
import { RouterView } from ' vue-router'
6
7
8
+ import { useWindowControlStore } from ' ./stores/window-controls'
9
+
7
10
const settings = useSettings ()
8
11
const i18n = useI18n ()
12
+ const windowControlStore = useWindowControlStore ()
13
+
14
+ useEventListener (window , ' resize' , () => {
15
+ windowControlStore .size .width = window .innerWidth
16
+ windowControlStore .size .height = window .innerHeight
17
+ })
9
18
10
19
watch (() => settings .language , (language ) => {
11
20
i18n .locale .value = language
@@ -15,6 +24,8 @@ watch(() => settings.language, (language) => {
15
24
// FIXME: store settings to file
16
25
onMounted (() => {
17
26
window .electron .ipcRenderer .send (' locale-changed' , settings .language )
27
+ window .electron .ipcRenderer .send (' window-size-changed' , windowControlStore .size .width , windowControlStore .size .height )
28
+ window .electron .ipcRenderer .send (' window-position-changed' , windowControlStore .position .x , windowControlStore .position .y )
18
29
})
19
30
</script >
20
31
Original file line number Diff line number Diff line change @@ -71,6 +71,21 @@ const modeIndicatorClass = computed(() => {
71
71
</div >
72
72
</div >
73
73
</Transition >
74
+ <Transition
75
+ enter-active-class =" transition-opacity duration-250"
76
+ enter-from-class =" opacity-0"
77
+ enter-to-class =" opacity-100"
78
+ leave-active-class =" transition-opacity duration-250"
79
+ leave-from-class =" opacity-100"
80
+ leave-to-class =" opacity-0"
81
+ >
82
+ <div
83
+ v-if =" windowStore.controlMode === WindowControlMode.RESIZE"
84
+ class =" absolute left-0 top-0 z-999 h-full w-full"
85
+ >
86
+ <div h-full w-full animate-flash animate-duration-2.5s animate-count-infinite b-8 b-pink rounded-2xl />
87
+ </div >
88
+ </Transition >
74
89
</template >
75
90
76
91
<style scoped>
Original file line number Diff line number Diff line change
1
+ import { useLocalStorage } from '@vueuse/core'
1
2
import { defineStore } from 'pinia'
2
3
import { ref } from 'vue'
3
4
@@ -6,9 +7,21 @@ import { WindowControlMode } from '../types/window-controls'
6
7
export const useWindowControlStore = defineStore ( 'windowControl' , ( ) => {
7
8
const controlMode = ref < WindowControlMode > ( WindowControlMode . DEFAULT )
8
9
const isControlActive = ref ( false )
10
+ const size = useLocalStorage ( 'window/control/size' , { width : 300 * 1.5 , height : 400 * 1.5 } )
11
+ const position = useLocalStorage ( 'window/control/position' , { x : 0 , y : 0 } )
9
12
10
13
function setMode ( mode : WindowControlMode ) {
11
14
controlMode . value = mode
15
+
16
+ if ( mode === WindowControlMode . RESIZE ) {
17
+ window . electron . ipcRenderer . send ( 'start-resize-window' )
18
+ return
19
+ }
20
+
21
+ window . electron . ipcRenderer . invoke ( 'stop-move-window' ) . then ( ( p : [ number , number ] ) => {
22
+ position . value = { x : p [ 0 ] , y : p [ 1 ] }
23
+ } )
24
+ window . electron . ipcRenderer . send ( 'stop-resize-window' )
12
25
}
13
26
14
27
function toggleControl ( ) {
@@ -21,6 +34,8 @@ export const useWindowControlStore = defineStore('windowControl', () => {
21
34
return {
22
35
controlMode,
23
36
isControlActive,
37
+ size,
38
+ position,
24
39
setMode,
25
40
toggleControl,
26
41
}
You can’t perform that action at this time.
0 commit comments