This commit is contained in:
IndieKKY
2024-10-06 13:46:30 +08:00
parent 3140b91f72
commit 296469ebf1
4 changed files with 5 additions and 8 deletions

View File

@@ -21,7 +21,6 @@ import {useAsyncEffect, useInterval} from 'ahooks'
import {getModelMaxTokens, getWholeText} from '../utils/biz_util'
import {MESSAGE_TO_INJECT_GET_SUBTITLE} from '../consts/const'
import useMessage from '../messaging/layer2/useMessaging'
import { msgWaiter } from '@/messaging/layer2/useMessagingService'
/**
* Service是单例类似后端的服务概念
@@ -94,8 +93,6 @@ const useSubtitleService = () => {
}, [curFetched, curInfo])
useAsyncEffect(async () => {
// 等待inject准备好
await msgWaiter.wait()
// 初始获取列表
sendInject(MESSAGE_TO_INJECT_REFRESH_VIDEO_INFO, {force: true})
// 初始获取设置信息

View File

@@ -15,9 +15,9 @@
1. (底层)一层协议为`Layer1Protocol`内部封装了port支持双向通信发送与接收
2. 高层二层协议分3个部分基于一层协议
1. `ExtensionMessage`:扩展端的
2. `InjectMessage`:注入端端
3. `useMessageService``useMessage`:应用端的
1. `ExtensionMessaging`:扩展端的
2. `InjectMessaging`:注入端端
3. `useMessagingService``useMessaging`:应用端的
### 通信方向

View File

@@ -14,7 +14,7 @@ class InjectMessaging {
}
messageHandler = async (req: L2ReqMsg): Promise<L2ResMsg> => {
this.debug(`${req.from} => `, JSON.stringify(req))
this.debug(`[${req.from}] ${req.method}`, JSON.stringify(req))
// check event target
// if (req.target !== MESSAGE_TARGET_INJECT) return Promise.resolve({

View File

@@ -20,7 +20,7 @@ const useMessagingService = (methods?: {
[key: string]: (params: any, context: MethodContext) => Promise<any>
}) => {
const messageHandler = useCallback(async (req: L2ReqMsg): Promise<L2ResMsg> => {
debug(`${req.from} => `, JSON.stringify(req))
debug(`[${req.from}] ${req.method}`, JSON.stringify(req))
// // check event target
// if (req.target !== MESSAGE_TARGET_APP) return {