mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-04-25 11:28:41 +00:00
修复不同的tab,允许使用不同的frame content
This commit is contained in:
parent
30e51657ae
commit
645605c60d
@ -21,7 +21,7 @@ export class PortContent extends PortMan {
|
|||||||
this.onDisconnect = (disPort: chrome.runtime.Port) => {
|
this.onDisconnect = (disPort: chrome.runtime.Port) => {
|
||||||
// content失去链接需要更新Devtools
|
// content失去链接需要更新Devtools
|
||||||
portMgr.removePort(this);
|
portMgr.removePort(this);
|
||||||
if (portMgr.currentUseContentFrameID === this.frameID) {
|
if (portMgr.tabUseFrameID[this.tabID] === this.frameID) {
|
||||||
portMgr.useFrame(0, this.tabID);
|
portMgr.useFrame(0, this.tabID);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -13,8 +13,10 @@ export class PortMgr {
|
|||||||
public portArray: Array<PortMan> = [];
|
public portArray: Array<PortMan> = [];
|
||||||
/**
|
/**
|
||||||
* 当前正在通讯的frameID,因为游戏可能被好几个iframe嵌套
|
* 当前正在通讯的frameID,因为游戏可能被好几个iframe嵌套
|
||||||
|
*
|
||||||
|
* 不同的tab,使用的当前frameID可以不一样
|
||||||
*/
|
*/
|
||||||
public currentUseContentFrameID = 0;
|
public tabUseFrameID: Record<number, number> = {};
|
||||||
private terminal = new Terminal("PortMgr");
|
private terminal = new Terminal("PortMgr");
|
||||||
|
|
||||||
public findPort(id: number): PortMan | null {
|
public findPort(id: number): PortMan | null {
|
||||||
@ -101,12 +103,12 @@ export class PortMgr {
|
|||||||
}
|
}
|
||||||
getCurrentUsePort(tabID: number): PortMan | null {
|
getCurrentUsePort(tabID: number): PortMan | null {
|
||||||
const portMan = this.portArray.find((portMan: PortMan) => {
|
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;
|
return portMan || null;
|
||||||
}
|
}
|
||||||
useFrame(id: number, tabID: number) {
|
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);
|
const event = new PluginEvent(Page.Background, Page.Devtools, Msg.ResponseUpdateFrames, { id } as ResponseUseFrameData);
|
||||||
this.sendDevtoolMsg(event, tabID);
|
this.sendDevtoolMsg(event, tabID);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user