* 获取窗口类型 * @param webContents 调用者的 WebContents * @returns 'main' | 'detach' | 'browser'
(webContents: Electron.WebContents)
| 226 | * @returns 'main' | 'detach' | 'browser' |
| 227 | */ |
| 228 | private getWindowType(webContents: Electron.WebContents): 'main' | 'detach' | 'browser' { |
| 229 | // 检查是否是主窗口 |
| 230 | if (this.mainWindow && webContents.id === this.mainWindow.webContents.id) { |
| 231 | return 'main' |
| 232 | } |
| 233 | |
| 234 | // 检查是否是分离窗口 |
| 235 | if (detachedWindowManager.isDetachedWindow(webContents)) { |
| 236 | return 'detach' |
| 237 | } |
| 238 | |
| 239 | // 检查是否是 browser 窗口 |
| 240 | if (pluginWindowManager.isBrowserWindow(webContents)) { |
| 241 | return 'browser' |
| 242 | } |
| 243 | |
| 244 | // 默认返回 main(可能是插件的 WebContentsView) |
| 245 | return 'main' |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | export default new PluginWindowAPI() |
no test coverage detected