1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
mainWindow.webContents.setWindowOpenHandler((details) => { console.log('⚡️ 检测到 Tab 被拖出,正在请求创建窗口:', details.url)
return { action: 'allow', overrideBrowserWindowOptions: { autoHideMenuBar: true, webPreferences: { preload: join(__dirname, '../preload/index.js'), backgroundThrottling: false, } } } })
mainWindow.webContents.on('did-create-window', (childWindow, details) => { console.log('✅ 新窗口实例已创建 (Tab 弹出成功)') mainWindow.webContents.send('popout-window-created', { id: childWindow.id, title: childWindow.getTitle() })
childWindow.on('closed', () => { console.log('❌ 子窗口已关闭') mainWindow.webContents.send('popout-window-closed', { id: childWindow.id }) }) })
|
Prev: 单例 Tab 策略” (Singleton Tab Strategy)
Next: 上传到npm仓库