feat: 添加录制功能,优化消息处理,修复拼写错误,更新下载逻辑

This commit is contained in:
雨霖铃
2026-02-04 23:29:42 +08:00
parent e6f41032c8
commit 2c0df95104
7 changed files with 117 additions and 54 deletions
+5 -1
View File
@@ -1,12 +1,12 @@
import * as rrweb from 'rrweb';
import { listenerHandler } from '@rrweb/types';
import { getRecordConsolePlugin } from '@rrweb/rrweb-plugin-console-record';
export const createRecorder = () => {
let stopFn: listenerHandler | null = null;
const startRecord = async (msg: string) => {
try {
// const handler = null;
const handler = rrweb.record({
emit(event) {
chrome.runtime.sendMessage({
@@ -14,13 +14,16 @@ export const createRecorder = () => {
payload: event,
});
},
plugins: [getRecordConsolePlugin()],
});
stopFn = handler || null;
console.log('[content] rrweb started');
return true;
} catch (error) {
console.error('Failed to start recording:', error);
return false;
}
};
@@ -30,6 +33,7 @@ export const createRecorder = () => {
stopFn = null;
console.log('[content] rrweb stopped');
}
return false;
};
return { startRecord, stopRecord };