* 创建超级面板窗口
(x: number, y: number)
| 291 | * 创建超级面板窗口 |
| 292 | */ |
| 293 | private createWindow(x: number, y: number): BrowserWindow { |
| 294 | // 新窗口,标记未就绪 |
| 295 | this.windowReady = false |
| 296 | this.pendingMessages = [] |
| 297 | |
| 298 | // 计算窗口位置(防止超出屏幕) |
| 299 | const { position } = this.adjustPosition(x, y) |
| 300 | |
| 301 | const windowConfig: Electron.BrowserWindowConstructorOptions = { |
| 302 | width: SUPER_PANEL_WIDTH, |
| 303 | height: SUPER_PANEL_HEIGHT, |
| 304 | x: position.x, |
| 305 | y: position.y, |
| 306 | frame: false, |
| 307 | alwaysOnTop: true, |
| 308 | skipTaskbar: true, |
| 309 | resizable: false, |
| 310 | show: false, |
| 311 | hasShadow: true, |
| 312 | type: 'panel', |
| 313 | webPreferences: { |
| 314 | preload: path.join(__dirname, '../preload/index.js'), |
| 315 | backgroundThrottling: false, |
| 316 | contextIsolation: true, |
| 317 | nodeIntegration: false, |
| 318 | spellcheck: false, |
| 319 | webSecurity: false |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | // macOS 系统配置 |
| 324 | if (process.platform === 'darwin') { |
| 325 | windowConfig.transparent = true |
| 326 | windowConfig.vibrancy = 'fullscreen-ui' |
| 327 | } |
| 328 | // Windows 系统配置(不设置 transparent,让 setBackgroundMaterial 生效) |
| 329 | else if (process.platform === 'win32') { |
| 330 | windowConfig.backgroundColor = '#00000000' |
| 331 | } |
| 332 | |
| 333 | const win = new BrowserWindow(windowConfig) |
| 334 | |
| 335 | // macOS: 不在 Dock 中显示 |
| 336 | if (process.platform === 'darwin') { |
| 337 | win.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true }) |
| 338 | } |
| 339 | |
| 340 | // 同步窗口材质(Windows) |
| 341 | if (process.platform === 'win32') { |
| 342 | this.applyMaterialToWindow(win) |
| 343 | } |
| 344 | |
| 345 | // 加载超级面板页面(使用独立的 HTML 入口) |
| 346 | if (is.dev && process.env['ELECTRON_RENDERER_URL']) { |
| 347 | win.loadURL(`${process.env['ELECTRON_RENDERER_URL']}/super-panel.html`) |
| 348 | } else { |
| 349 | win.loadFile(path.join(__dirname, '../renderer/super-panel.html')) |
| 350 | } |
no test coverage detected