From 6d2b553ca4c4e5b88b821a96e0364383d535ef72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=A8=E9=9C=96=E9=93=83?= Date: Thu, 26 Feb 2026 17:15:20 +0800 Subject: [PATCH] =?UTF-8?q?```=20refactor(storage):=20=E5=B0=86storage?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=B1=BB=E9=87=8D=E5=91=BD=E5=90=8D=E4=B8=BA?= =?UTF-8?q?chromeStorage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 重命名utils/storage.ts为utils/chromeStorage.ts以更好地反映其功能用途 feat(messages): 简化消息协议定义并移除过时的消息类型 将messages.tsx中的硬编码消息对象替换为ProtocolMap接口定义, 移除了不再使用的popup、content和offscreen相关消息类型, 使消息系统更加简洁和类型安全 ``` --- components/RoutePersistence.tsx | 2 +- utils/{storage.ts => chromeStorage.ts} | 0 utils/messages.tsx | 32 -------------------------- 3 files changed, 1 insertion(+), 33 deletions(-) rename utils/{storage.ts => chromeStorage.ts} (100%) diff --git a/components/RoutePersistence.tsx b/components/RoutePersistence.tsx index aa146d4..a765ec9 100644 --- a/components/RoutePersistence.tsx +++ b/components/RoutePersistence.tsx @@ -1,6 +1,6 @@ import { useEffect, useRef } from 'react'; import { useLocation, useNavigate } from 'react-router-dom'; -import { storage } from '@/utils/storage'; +import { storage } from '@/utils/chromeStorage'; const RoutePersistence = () => { const location = useLocation(); diff --git a/utils/storage.ts b/utils/chromeStorage.ts similarity index 100% rename from utils/storage.ts rename to utils/chromeStorage.ts diff --git a/utils/messages.tsx b/utils/messages.tsx index 65dc66a..885ef82 100644 --- a/utils/messages.tsx +++ b/utils/messages.tsx @@ -1,37 +1,5 @@ import { defineExtensionMessaging } from '@webext-core/messaging'; -export const messages = { - popup: { - from: { - start: 'popup:start', - stop: 'popup:stop', - }, - to: { - stopped: 'popup:stopped', - started: 'popup:started', - tabChanged: 'popup:tab-changed', - }, - checkStatus: 'popup:check-status', - ready: 'popup:ready', - }, - content: { - from: { - saveTrackEvents: 'content:save-track-events', - }, - to: { - startRecording: 'content:start-recording', - stopRecording: 'content:stop-recording', - }, - checkStatus: 'content:check-status', - }, - offscreen: { - to: { - startRecording: 'offscreen:start-recording', - stopRecording: 'offscreen:stop-recording', - }, - }, -}; - interface ProtocolMap { // --- Popup 相关 --- 'popup:start': () => { ok: boolean; error?: string };