From 296469ebf186c2e3cbbf3d63bb7264e7d41ba719 Mon Sep 17 00:00:00 2001 From: IndieKKY Date: Sun, 6 Oct 2024 13:46:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useSubtitleService.ts | 3 --- src/messaging/README.md | 6 +++--- src/messaging/layer2/InjectMessaging.ts | 2 +- src/messaging/layer2/useMessagingService.ts | 2 +- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/hooks/useSubtitleService.ts b/src/hooks/useSubtitleService.ts index c5e8be0..7773516 100644 --- a/src/hooks/useSubtitleService.ts +++ b/src/hooks/useSubtitleService.ts @@ -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}) // 初始获取设置信息 diff --git a/src/messaging/README.md b/src/messaging/README.md index e111b84..7c6947c 100644 --- a/src/messaging/README.md +++ b/src/messaging/README.md @@ -15,9 +15,9 @@ 1. (底层)一层协议为`Layer1Protocol`,内部封装了port,支持双向通信(发送与接收) 2. (高层)二层协议分3个部分,基于一层协议: - 1. `ExtensionMessage`:扩展端的 - 2. `InjectMessage`:注入端端 - 3. `useMessageService`与`useMessage`:应用端的 + 1. `ExtensionMessaging`:扩展端的 + 2. `InjectMessaging`:注入端端 + 3. `useMessagingService`与`useMessaging`:应用端的 ### 通信方向 diff --git a/src/messaging/layer2/InjectMessaging.ts b/src/messaging/layer2/InjectMessaging.ts index 48b3a2a..79542d3 100644 --- a/src/messaging/layer2/InjectMessaging.ts +++ b/src/messaging/layer2/InjectMessaging.ts @@ -14,7 +14,7 @@ class InjectMessaging { } messageHandler = async (req: L2ReqMsg): Promise => { - 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({ diff --git a/src/messaging/layer2/useMessagingService.ts b/src/messaging/layer2/useMessagingService.ts index f24510c..3d21daa 100644 --- a/src/messaging/layer2/useMessagingService.ts +++ b/src/messaging/layer2/useMessagingService.ts @@ -20,7 +20,7 @@ const useMessagingService = (methods?: { [key: string]: (params: any, context: MethodContext) => Promise }) => { const messageHandler = useCallback(async (req: L2ReqMsg): Promise => { - debug(`${req.from} => `, JSON.stringify(req)) + debug(`[${req.from}] ${req.method}`, JSON.stringify(req)) // // check event target // if (req.target !== MESSAGE_TARGET_APP) return {