6d2b553ca4
refactor(storage): 将storage工具类重命名为chromeStorage 重命名utils/storage.ts为utils/chromeStorage.ts以更好地反映其功能用途 feat(messages): 简化消息协议定义并移除过时的消息类型 将messages.tsx中的硬编码消息对象替换为ProtocolMap接口定义, 移除了不再使用的popup、content和offscreen相关消息类型, 使消息系统更加简洁和类型安全 ```
25 lines
959 B
TypeScript
25 lines
959 B
TypeScript
import { defineExtensionMessaging } from '@webext-core/messaging';
|
|
|
|
interface ProtocolMap {
|
|
// --- Popup 相关 ---
|
|
'popup:start': () => { ok: boolean; error?: string };
|
|
'popup:stop': () => { ok: boolean; error?: string };
|
|
'popup:started': () => void;
|
|
'popup:stopped': () => void;
|
|
'popup:tab-changed': (data: { currentTabId: number; recordingTabId: number | undefined }) => void;
|
|
'popup:check-status': () => { active: boolean; startTime?: number };
|
|
'popup:ready': () => void;
|
|
|
|
// --- Content 相关 ---
|
|
'content:save-track-events': (event: unknown) => boolean;
|
|
'content:start-recording': () => { ok: boolean; error?: string };
|
|
'content:stop-recording': () => { ok: boolean };
|
|
'content:check-status': () => boolean;
|
|
|
|
// --- Offscreen 相关 ---
|
|
'offscreen:start-recording': (streamId: string) => void;
|
|
'offscreen:stop-recording': () => void;
|
|
}
|
|
|
|
export const { sendMessage, onMessage } = defineExtensionMessaging<ProtocolMap>();
|