* 将窗口移动到鼠标所在显示器 * 优先恢复该显示器记忆的位置,否则居中显示
()
| 825 | * 优先恢复该显示器记忆的位置,否则居中显示 |
| 826 | */ |
| 827 | private moveWindowToCursor(): void { |
| 828 | if (!this.mainWindow) return |
| 829 | |
| 830 | const { width, height, x: displayX, y: displayY, id: displayId } = this.getDisplayAtCursor() |
| 831 | |
| 832 | const savedPosition = this.windowPositionsByDisplay[displayId] |
| 833 | |
| 834 | let x: number, y: number |
| 835 | |
| 836 | if (savedPosition) { |
| 837 | // 恢复该显示器记忆的位置 |
| 838 | x = savedPosition.x |
| 839 | y = savedPosition.y |
| 840 | } else { |
| 841 | // 计算默认居中位置(基于最大窗口高度) |
| 842 | x = displayX + Math.floor((width - WINDOW_WIDTH) / 2) |
| 843 | y = displayY + Math.floor((height - WINDOW_DEFAULT_HEIGHT) / 2) |
| 844 | } |
| 845 | |
| 846 | this.mainWindow.setPosition(x, y, false) |
| 847 | } |
| 848 | |
| 849 | /** |
| 850 | * 显示窗口 |
no test coverage detected