feat: 添加录制功能,优化消息处理,修复拼写错误,更新下载逻辑
This commit is contained in:
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user