From a1183a35d3f28c5f41e3646ae6e58a95534351a8 Mon Sep 17 00:00:00 2001 From: Kisechan Date: Tue, 26 Aug 2025 18:58:07 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=20=E4=BF=AE=E5=A4=8D=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E7=95=8C=E9=9D=A2=E7=9A=84=20bug=EF=BC=8C?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E7=A7=BB=E5=8A=A8=E5=92=8C=E9=BC=A0=E6=A0=87?= =?UTF-8?q?=E7=82=B9=E5=87=BB=EF=BC=8C=E5=B9=B6=E5=B0=86=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E4=BF=AE=E6=94=B9=E4=B8=BA=20`200px`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/main.js | 9 ++- main/preload.js | 3 +- renderer/src/App.vue | 127 +++++++++++++++++++++++++------------------ 3 files changed, 84 insertions(+), 55 deletions(-) diff --git a/main/main.js b/main/main.js index 32dc9d9..bfc7078 100644 --- a/main/main.js +++ b/main/main.js @@ -73,8 +73,8 @@ let mainWindow; function createWindow() { mainWindow = new BrowserWindow({ - width: 300, - height: 300, + width: 200, + height: 200, transparent: true, // 开启透明窗口 frame: false, // 无边框窗口 resizable: false, // 禁止调整大小 @@ -85,6 +85,11 @@ function createWindow() { }, }); + // 当渲染进程传来这个事件时,就移动窗口 + ipcMain.on('move-window', (event, { x, y }) => { + mainWindow.setPosition(x, y, true); // true 表示动画平滑移动 + }); + if (process.env.NODE_ENV === "development") { mainWindow.loadURL("http://localhost:5173"); } else { diff --git a/main/preload.js b/main/preload.js index e078257..42a1d6e 100644 --- a/main/preload.js +++ b/main/preload.js @@ -13,5 +13,6 @@ contextBridge.exposeInMainWorld('electronAPI', { showTooltip: (text) => ipcRenderer.send('show-tooltip', text), onUpdatePosition: (callback) => { ipcRenderer.on('update-position', (_, position) => callback(position)) - } + }, + moveWindow: (position) => ipcRenderer.send('move-window', position) }) \ No newline at end of file diff --git a/renderer/src/App.vue b/renderer/src/App.vue index 5fe61c1..f06b800 100644 --- a/renderer/src/App.vue +++ b/renderer/src/App.vue @@ -1,5 +1,5 @@ \ No newline at end of file