MCPcopy
hub / github.com/ZToolsCenter/ZTools / getPluginPrefix

Method getPluginPrefix

src/main/api/shared/database.ts:47–61  ·  view source on GitHub ↗

* 获取插件专属前缀 * 如果请求来自插件,返回对应 runtime namespace 的私有前缀 * 否则返回 null(主程序使用)

(event: IpcMainEvent | IpcMainInvokeEvent)

Source from the content-addressed store, hash-verified

45 * 否则返回 null(主程序使用)
46 */
47 private getPluginPrefix(event: IpcMainEvent | IpcMainInvokeEvent): string | null {
48 // 1. 检查是否来自插件主 BrowserView
49 const pluginInfo = this.pluginManager?.getPluginInfoByWebContents(event.sender)
50 if (pluginInfo) {
51 return getPluginDataPrefix(pluginInfo.name)
52 }
53
54 // 2. 检查是否来自插件创建的子窗口(BrowserWindow)
55 const pluginName = pluginWindowManager.getPluginNameByWebContentsId(event.sender.id)
56 if (pluginName) {
57 return getPluginDataPrefix(pluginName)
58 }
59
60 return null
61 }
62
63 private setupIPC(): void {
64 // ============ 同步API(供插件使用) ============

Callers 2

setupIPCMethod · 0.95

Calls 3

getPluginDataPrefixFunction · 0.90

Tested by

no test coverage detected