feat: 添加离屏文档创建和下载功能,优化录制逻辑

This commit is contained in:
雨霖铃
2026-01-29 19:35:55 +08:00
parent ed5e90f0fc
commit 0ff33cbeb3
8 changed files with 87 additions and 33 deletions
+28
View File
@@ -0,0 +1,28 @@
import { useRef } from 'react';
console.log('[offscreen] loaded');
const events = [];
chrome.runtime.onMessage.addListener((msg) => {
if (msg.type === 'SAVE_EVENT') {
console.log('[offscreen] rrweb event', msg.event);
events.push(msg.event);
// 这里你可以存 IndexedDB / memory / file
}
if (msg.type === 'SAVE_EVENTS') {
console.log('[offscreen] SAVE_EVENTS received');
console.log('[offscreen] total events:', events.length);
console.log('[offscreen] events:', JSON.stringify(events));
// const blob = new Blob([JSON.stringify(events)], {
// type: 'application/json',
// });
// reader.onload = () => {
// chrome.runtime.sendMessage({
// type: 'DOWNLOAD',
// dataUrl: reader.result,
// });
// };
// reader.readAsDataURL(blob);
}
});