重构background对port的管理,彻底修复多标签页面数据相互串的bug

This commit is contained in:
xu_yanfeng
2025-01-27 13:07:35 +08:00
parent f7bd7790e1
commit 63e842deb3
10 changed files with 239 additions and 243 deletions

View File

@@ -22,7 +22,9 @@ class Bridge implements TestClient {
}
this._inited = true;
if (CCP.Adaptation.Env.isChromeRuntime) {
this.connect = chrome.runtime.connect({ name: Page.Devtools });
// 调试的标签ID
const id = chrome.devtools.inspectedWindow.tabId;
this.connect = chrome.runtime.connect({ name: `${Page.Devtools}-${id}` });
this.connect.onDisconnect.addListener(() => {
debugLog && console.log(...this.terminal.disconnect(""));
this.connect = null;