(page, options = {})
| 83 | } |
| 84 | |
| 85 | openWindow (page, options = {}) { |
| 86 | const pageOptions = this.getPageOptions(page) |
| 87 | const { hidden } = options |
| 88 | const autoHideWindow = this.userConfig['auto-hide-window'] |
| 89 | let window = this.windows[page] || null |
| 90 | if (window) { |
| 91 | window.show() |
| 92 | window.focus() |
| 93 | return window |
| 94 | } |
| 95 | |
| 96 | window = new BrowserWindow({ |
| 97 | ...defaultBrowserOptions, |
| 98 | ...pageOptions.attrs, |
| 99 | webPreferences: { |
| 100 | enableRemoteModule: true, |
| 101 | contextIsolation: false, |
| 102 | nodeIntegration: true, |
| 103 | nodeIntegrationInWorker: true |
| 104 | } |
| 105 | }) |
| 106 | |
| 107 | const bounds = this.getPageBounds(page) |
| 108 | if (bounds) { |
| 109 | window.setBounds(bounds) |
| 110 | } |
| 111 | |
| 112 | if (is.dev() && pageOptions.openDevTools) { |
| 113 | window.webContents.openDevTools() |
| 114 | } |
| 115 | |
| 116 | window.webContents.setWindowOpenHandler(({ url }) => { |
| 117 | shell.openExternal(url) |
| 118 | return { action: 'deny' } |
| 119 | }) |
| 120 | |
| 121 | if (pageOptions.url) { |
| 122 | window.loadURL(pageOptions.url) |
| 123 | } |
| 124 | |
| 125 | window.once('ready-to-show', () => { |
| 126 | if (!hidden) { |
| 127 | window.show() |
| 128 | } |
| 129 | }) |
| 130 | |
| 131 | window.on('enter-full-screen', () => { |
| 132 | this.emit('enter-full-screen', window) |
| 133 | }) |
| 134 | |
| 135 | window.on('leave-full-screen', () => { |
| 136 | this.emit('leave-full-screen', window) |
| 137 | }) |
| 138 | |
| 139 | this.handleWindowState(page, window) |
| 140 | |
| 141 | this.handleWindowClose(pageOptions, page, window) |
| 142 |
no test coverage detected