Files
testing-tool/entrypoints/popup/pages/TestPage.tsx
T
雨霖铃 4d52cbb12f refactor: 移除所有录制功能代码
- 删除录制相关页面组件(RecordReplayPage、ReplayListPage、ReplayPlayerPage)
- 删除录制工具文件(recordEventsDb、recordUtils、useRecorder、tabUtils)
- 清理 background.ts 和 content.ts 中的录制代码
- 更新 App.tsx 移除录制路由
- 清理 messages.tsx 中的消息定义
- 删除 types.tsx 中的录制状态
- 移除 package.json 中的 rrweb 相关依赖
- 更新 wxt.config.ts 移除 offscreen、downloads 权限
- 删除 offscreen 目录

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 23:57:32 +08:00

78 lines
2.0 KiB
TypeScript

import { Button } from '@mui/material';
import { useState, useEffect } from 'react';
const TestPage = () => {
const [tabId, setTabId] = useState(-1);
useEffect(() => {
(async () => {
const activeTabs = await chrome.tabs.query({
active: true,
currentWindow: true,
});
console.log(`activeTabs:`, activeTabs[0].id);
if (activeTabs[0].id && activeTabs[0].id > 0) setTabId(activeTabs[0].id);
else throw new Error('no active tab');
})();
});
const handleAttach = () => {
try {
chrome.debugger.attach({ tabId: tabId }, '1.2', () => {
console.log('[debugger] attached');
});
} catch (err) {
console.error(err);
}
};
const handleDetach = async () => {
try {
chrome.debugger.detach({ tabId: tabId }, () => {
console.log('[debugger] detached');
});
} catch (err) {
console.error(err);
}
};
const handleGetTarget = () => {
chrome.debugger.getTargets((targets) => {
console.log('[debugger] targets:', targets);
});
};
const enableRuntime = () => {
chrome.debugger.sendCommand({ tabId: tabId }, 'Runtime.enable', {}, (res) => {
console.log('[debugger] Runtime.enable:', res);
});
};
const disableRuntime = () => {
chrome.debugger.sendCommand({ tabId: tabId }, 'Runtime.disable', {}, (res) => {
console.log('[debugger] Runtime.disable:', res);
});
};
return (
<div>
<Button variant="contained" color="primary" onClick={handleAttach}>
attach
</Button>
<Button variant="contained" color="primary" onClick={handleDetach}>
detach
</Button>
<Button variant="contained" color="primary" onClick={handleGetTarget}>
getTargets
</Button>
<Button variant="contained" color="primary" onClick={enableRuntime}>
enableRuntime
</Button>
<Button variant="contained" color="primary" onClick={disableRuntime}>
disableRuntime
</Button>
</div>
);
};
export default TestPage;