From 645605c60d89acf299dcbf5608763919bfa0673b Mon Sep 17 00:00:00 2001 From: xu_yanfeng Date: Wed, 8 Jan 2025 16:53:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8D=E5=90=8C=E7=9A=84ta?= =?UTF-8?q?b=EF=BC=8C=E5=85=81=E8=AE=B8=E4=BD=BF=E7=94=A8=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=E7=9A=84frame=20content?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cc-inspector/src/scripts/background/portContent.ts | 2 +- cc-inspector/src/scripts/background/portMgr.ts | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cc-inspector/src/scripts/background/portContent.ts b/cc-inspector/src/scripts/background/portContent.ts index 758b085..beca410 100644 --- a/cc-inspector/src/scripts/background/portContent.ts +++ b/cc-inspector/src/scripts/background/portContent.ts @@ -21,7 +21,7 @@ export class PortContent extends PortMan { this.onDisconnect = (disPort: chrome.runtime.Port) => { // content失去链接需要更新Devtools portMgr.removePort(this); - if (portMgr.currentUseContentFrameID === this.frameID) { + if (portMgr.tabUseFrameID[this.tabID] === this.frameID) { portMgr.useFrame(0, this.tabID); } }; diff --git a/cc-inspector/src/scripts/background/portMgr.ts b/cc-inspector/src/scripts/background/portMgr.ts index 8c5619a..7457abd 100644 --- a/cc-inspector/src/scripts/background/portMgr.ts +++ b/cc-inspector/src/scripts/background/portMgr.ts @@ -13,8 +13,10 @@ export class PortMgr { public portArray: Array = []; /** * 当前正在通讯的frameID,因为游戏可能被好几个iframe嵌套 + * + * 不同的tab,使用的当前frameID可以不一样 */ - public currentUseContentFrameID = 0; + public tabUseFrameID: Record = {}; private terminal = new Terminal("PortMgr"); public findPort(id: number): PortMan | null { @@ -101,12 +103,12 @@ export class PortMgr { } getCurrentUsePort(tabID: number): PortMan | null { const portMan = this.portArray.find((portMan: PortMan) => { - return portMan.isContent() && portMan.tabID === tabID && portMan.isUseing(this.currentUseContentFrameID); + return portMan.isContent() && portMan.tabID === tabID && portMan.isUseing(this.tabUseFrameID[tabID]); }); return portMan || null; } useFrame(id: number, tabID: number) { - this.currentUseContentFrameID = id; + this.tabUseFrameID[tabID] = id; const event = new PluginEvent(Page.Background, Page.Devtools, Msg.ResponseUpdateFrames, { id } as ResponseUseFrameData); this.sendDevtoolMsg(event, tabID); }