()
| 20 | } |
| 21 | |
| 22 | private setupIPC(): void { |
| 23 | ipcMain.on('hide-window', () => this.hideWindow()) |
| 24 | ipcMain.on('resize-window', (_event, height: number) => this.resizeWindow(height)) |
| 25 | ipcMain.on('update-launch-context', (_event, context: any) => this.updateLaunchContext(context)) |
| 26 | ipcMain.handle('get-window-position', () => this.getWindowPosition()) |
| 27 | ipcMain.handle('get-window-material', () => this.getWindowMaterial()) |
| 28 | ipcMain.on('set-window-position', (_event, x: number, y: number) => |
| 29 | this.setWindowPosition(x, y) |
| 30 | ) |
| 31 | // 拖动控制:锁定/解锁窗口尺寸 |
| 32 | ipcMain.on('set-window-size-lock', (_event, lock: boolean) => { |
| 33 | if (!this.mainWindow) return |
| 34 | |
| 35 | if (lock) { |
| 36 | // 锁定:记录当前尺寸(宽度使用固定常量,避免多显示器 DPI 缩放导致尺寸漂移) |
| 37 | const [, height] = this.mainWindow.getSize() |
| 38 | this.lockedSize = { width: WINDOW_WIDTH, height } |
| 39 | } else { |
| 40 | // 解锁:验证并恢复尺寸(用 setBounds 保留位置,避免 Windows 下 x 轴偏移) |
| 41 | if (this.lockedSize) { |
| 42 | const [currentX, currentY] = this.mainWindow.getPosition() |
| 43 | const [, height] = this.mainWindow.getSize() |
| 44 | if (WINDOW_WIDTH !== this.lockedSize.width || height !== this.lockedSize.height) { |
| 45 | this.mainWindow.setBounds({ |
| 46 | x: currentX, |
| 47 | y: currentY, |
| 48 | width: this.lockedSize.width, |
| 49 | height: this.lockedSize.height |
| 50 | }) |
| 51 | } |
| 52 | this.lockedSize = null |
| 53 | } |
| 54 | } |
| 55 | }) |
| 56 | ipcMain.on('set-window-opacity', (_event, opacity: number) => this.setWindowOpacity(opacity)) |
| 57 | ipcMain.handle('set-tray-icon-visible', (_event, visible: boolean) => |
| 58 | this.setTrayIconVisible(visible) |
| 59 | ) |
| 60 | ipcMain.handle('set-assembly-target', (_event, token: string) => { |
| 61 | this.currentAssemblyTarget = token |
| 62 | return true |
| 63 | }) |
| 64 | ipcMain.handle('end-assembly-plugin', () => { |
| 65 | return this.currentAssemblyTarget |
| 66 | }) |
| 67 | ipcMain.on('open-settings', () => this.openSettings()) |
| 68 | } |
| 69 | |
| 70 | private setupWindowEvents(): void { |
| 71 | let moveTimeout: NodeJS.Timeout | null = null |
no test coverage detected