feat(background): 添加录制状态持久化和Tab切换处理

- 实现录制状态存储到本地storage,包括isRecording、recordingTabId、events和startTime
- 添加loadRecorderState和saveRecorderState函数用于状态管理
- 监听Tab切换事件,当切换离开录制Tab时发出警告并通知popup
- 监听Tab关闭事件,自动停止录制并清理状态
- 添加录制状态同步检查,确保content script状态一致
- 在开始录制前检查是否已在录制状态,避免重复录制
- 添加错误处理返回详细错误信息
- 优化回放HTML样式和脚本加载方式
- 添加Tab切换消息通信协议支持
This commit is contained in:
雨霖铃
2026-02-21 15:09:07 +08:00
parent 19b7ab141a
commit 80e510225c
5 changed files with 166 additions and 54 deletions
@@ -43,13 +43,18 @@ const RecordeReplayPage = () => {
const toggleRecording = async () => {
try {
if (isRecording) {
await sendMessage('popup:stop', undefined);
const result = await sendMessage('popup:stop', undefined);
if (!result?.ok) {
return;
}
} else {
await sendMessage('popup:start', undefined);
const result = await sendMessage('popup:start', undefined);
if (!result?.ok) {
return;
}
}
} catch (error) {
console.error('Error toggling recording:', error);
setStatus(AppState.READ);
}
};