You've already forked bilibili-subtitle
优化
This commit is contained in:
@@ -3,7 +3,7 @@ import { L2ReqMsg, L2ResMsg, MESSAGE_TO_EXTENSION_HANDSHAKE, MESSAGE_TO_EXTENSIO
|
|||||||
|
|
||||||
export type PortContext = {
|
export type PortContext = {
|
||||||
id: string
|
id: string
|
||||||
name: string
|
name: string //暂时没什么用
|
||||||
port: chrome.runtime.Port
|
port: chrome.runtime.Port
|
||||||
portMessageHandler: Layer1Protocol
|
portMessageHandler: Layer1Protocol
|
||||||
ready: boolean
|
ready: boolean
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import { MESSAGE_TARGET_INJECT } from '@/consts/const'
|
|
||||||
import Layer1Protocol from '../layer1/Layer1Protocol'
|
import Layer1Protocol from '../layer1/Layer1Protocol'
|
||||||
import { L2ReqMsg, L2ResMsg, MESSAGE_TO_EXTENSION_HANDSHAKE, MESSAGE_TO_EXTENSION_ROUTE_MSG, TAG_TARGET_APP, TAG_TARGET_INJECT } from '../const'
|
import { L2ReqMsg, L2ResMsg, MESSAGE_TO_EXTENSION_HANDSHAKE, MESSAGE_TO_EXTENSION_ROUTE_MSG, TAG_TARGET_APP, TAG_TARGET_INJECT } from '../const'
|
||||||
|
|
||||||
@@ -64,7 +63,7 @@ class InjectMessage {
|
|||||||
}) {
|
}) {
|
||||||
this.methods = methods
|
this.methods = methods
|
||||||
this.port = chrome.runtime.connect(import.meta.env.VITE_EXTENSION_ID, {
|
this.port = chrome.runtime.connect(import.meta.env.VITE_EXTENSION_ID, {
|
||||||
name: MESSAGE_TARGET_INJECT,
|
name: 'bilibili-inject',
|
||||||
})
|
})
|
||||||
this.portMessageHandler = new Layer1Protocol<L2ReqMsg, L2ResMsg>(this.messageHandler, this.port)
|
this.portMessageHandler = new Layer1Protocol<L2ReqMsg, L2ResMsg>(this.messageHandler, this.port)
|
||||||
this.portMessageHandler.sendMessage({
|
this.portMessageHandler.sendMessage({
|
||||||
|
@@ -1,7 +1,4 @@
|
|||||||
import { useCallback, useMemo } from 'react'
|
import { useCallback, useMemo } from 'react'
|
||||||
import {
|
|
||||||
MESSAGE_TARGET_APP,
|
|
||||||
} from '@/consts/const'
|
|
||||||
import { Waiter } from '@kky002/kky-util'
|
import { Waiter } from '@kky002/kky-util'
|
||||||
import Layer1Protocol from '../layer1/Layer1Protocol'
|
import Layer1Protocol from '../layer1/Layer1Protocol'
|
||||||
import { L2ReqMsg, L2ResMsg, MESSAGE_TO_EXTENSION_HANDSHAKE, TAG_TARGET_APP } from '../const'
|
import { L2ReqMsg, L2ResMsg, MESSAGE_TO_EXTENSION_HANDSHAKE, TAG_TARGET_APP } from '../const'
|
||||||
@@ -67,7 +64,7 @@ const useMessageService = (methods?: {
|
|||||||
|
|
||||||
const port = useMemo(() => {
|
const port = useMemo(() => {
|
||||||
return chrome.runtime.connect(import.meta.env.VITE_EXTENSION_ID, {
|
return chrome.runtime.connect(import.meta.env.VITE_EXTENSION_ID, {
|
||||||
name: MESSAGE_TARGET_APP,
|
name: 'bilibili-app',
|
||||||
})
|
})
|
||||||
}, [])
|
}, [])
|
||||||
portMessageHandler = useMemo(() => {
|
portMessageHandler = useMemo(() => {
|
||||||
|
Reference in New Issue
Block a user