From c778afe82eace3a2b3b87986e0558099d78735f3 Mon Sep 17 00:00:00 2001 From: LemonNeko Date: Fri, 28 Feb 2025 00:24:33 +0800 Subject: [PATCH] feat(stage-tamagotchi): allow resize window, save window size and position (#37) * feat(stage-tamagotchi): allow resize window, save window size and position * fix(stage-tamagotchi): set default window size --- apps/stage-tamagotchi/src/main/index.ts | 24 +++++++++++++++++++ .../stage-tamagotchi/src/renderer/src/App.vue | 11 +++++++++ .../src/renderer/src/pages/index.vue | 15 ++++++++++++ .../renderer/src/stores/window-controls.ts | 15 ++++++++++++ 4 files changed, 65 insertions(+) diff --git a/apps/stage-tamagotchi/src/main/index.ts b/apps/stage-tamagotchi/src/main/index.ts index ab85349a5..b0523aa6c 100644 --- a/apps/stage-tamagotchi/src/main/index.ts +++ b/apps/stage-tamagotchi/src/main/index.ts @@ -177,4 +177,28 @@ app.whenReady().then(() => { rebuildTrayMenu() createApplicationMenu(i18n, showQuitDialog, createSettingsWindow) }) + + ipcMain.on('start-resize-window', () => { + mainWindow.setResizable(true) + }) + + ipcMain.on('stop-resize-window', () => { + mainWindow.setResizable(false) + }) + + ipcMain.handle('stop-move-window', () => { + return mainWindow.getPosition() + }) + + ipcMain.on('window-size-changed', (_, width: number, height: number) => { + if (width === 0 || height === 0) { + mainWindow.setSize(300 * 1.5, 400 * 1.5) // back to default size + return + } + mainWindow.setSize(width, height) + }) + + ipcMain.on('window-position-changed', (_, x: number, y: number) => { + mainWindow.setPosition(x, y) + }) }) diff --git a/apps/stage-tamagotchi/src/renderer/src/App.vue b/apps/stage-tamagotchi/src/renderer/src/App.vue index 049ccfac7..531da5988 100644 --- a/apps/stage-tamagotchi/src/renderer/src/App.vue +++ b/apps/stage-tamagotchi/src/renderer/src/App.vue @@ -1,11 +1,20 @@ diff --git a/apps/stage-tamagotchi/src/renderer/src/pages/index.vue b/apps/stage-tamagotchi/src/renderer/src/pages/index.vue index f728450e5..214ca0c2f 100644 --- a/apps/stage-tamagotchi/src/renderer/src/pages/index.vue +++ b/apps/stage-tamagotchi/src/renderer/src/pages/index.vue @@ -71,6 +71,21 @@ const modeIndicatorClass = computed(() => { + +
+
+
+