This commit is contained in:
IndieKKY
2024-10-05 20:28:42 +08:00
parent 4189818939
commit 69453f7bce
2 changed files with 2 additions and 8 deletions

View File

@@ -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,8 +96,6 @@ class ExtensionMessage {
port.onMessage.removeListener(listener)
// 开始监听
portMessageHandler.startListen()
console.log('start listen>>>', name)
} else {
console.log('no tabId>>>', name)
}

View File

@@ -22,8 +22,6 @@ class Layer1Protocol<L1Req = any, L1Res = any> {
private timeout: number
private messageMap: Map<string, { resolve: (value: L1Res) => void, timer: number }>
private handler: (value: L1Req) => Promise<L1Res>
private type?: 'inject' | 'app'
private tabId?: number
constructor(handler: (value: L1Req) => Promise<L1Res>, port: chrome.runtime.Port, timeout = 30000) { // 默认超时 30 秒
this.port = port;
@@ -33,8 +31,6 @@ class Layer1Protocol<L1Req = any, L1Res = any> {
}
init(type: 'inject' | 'app', tabId?: number) {
this.type = type
this.tabId = tabId
this.port.postMessage({
type,
tabId,