MCPcopy Create free account
hub / github.com/ZToolsCenter/ZTools / getWindowType

Method getWindowType

src/main/api/plugin/window.ts:228–246  ·  view source on GitHub ↗

* 获取窗口类型 * @param webContents 调用者的 WebContents * @returns 'main' | 'detach' | 'browser'

(webContents: Electron.WebContents)

Source from the content-addressed store, hash-verified

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
249export default new PluginWindowAPI()

Callers 1

setupIPCMethod · 0.95

Calls 2

isDetachedWindowMethod · 0.80
isBrowserWindowMethod · 0.80

Tested by

no test coverage detected