diff --git a/src/messaging/ExtensionMessage.ts b/src/messaging/ExtensionMessage.ts index 640c552..3a7d797 100644 --- a/src/messaging/ExtensionMessage.ts +++ b/src/messaging/ExtensionMessage.ts @@ -1,4 +1,4 @@ -import { MESSAGE_TARGET_EXTENSION, MESSAGE_TARGET_INJECT, MESSAGE_TO_EXTENSION_ROUTE_MSG } from '@/consts/const' +import { MESSAGE_TARGET_INJECT, MESSAGE_TO_EXTENSION_ROUTE_MSG } from '@/consts/const' import Layer1Protocol from './Layer1Protocol' export type PortContext = { @@ -96,9 +96,7 @@ class ExtensionMessage { port.onMessage.removeListener(listener) // 开始监听 portMessageHandler.startListen() - - console.log('start listen>>>', name) - }else { + } else { console.log('no tabId>>>', name) } } diff --git a/src/messaging/Layer1Protocol.ts b/src/messaging/Layer1Protocol.ts index 6d3c2d3..d7c03be 100644 --- a/src/messaging/Layer1Protocol.ts +++ b/src/messaging/Layer1Protocol.ts @@ -22,8 +22,6 @@ class Layer1Protocol { private timeout: number private messageMap: Map void, timer: number }> private handler: (value: L1Req) => Promise - private type?: 'inject' | 'app' - private tabId?: number constructor(handler: (value: L1Req) => Promise, port: chrome.runtime.Port, timeout = 30000) { // 默认超时 30 秒 this.port = port; @@ -33,8 +31,6 @@ class Layer1Protocol { } init(type: 'inject' | 'app', tabId?: number) { - this.type = type - this.tabId = tabId this.port.postMessage({ type, tabId,