feat: 优化消息处理逻辑,添加录制开始和停止的消息处理,删除未使用的 chromeUtils 文件

This commit is contained in:
雨霖铃
2026-02-02 22:57:01 +08:00
parent a6d85962b7
commit 37f8ef9c2b
5 changed files with 55 additions and 84 deletions
+21 -4
View File
@@ -31,7 +31,6 @@ export default defineBackground(() => {
chrome.runtime.onMessage.addListener((msg, _sender, sendResponse) => {
if (msg.type === messages.popup.checkStatus) {
console.log('[bg] checkStatus received');
// void chrome.runtime.sendMessage({ type: messages.content.checkStatus });
sendToActiveTab({ type: messages.content.checkStatus })
.then(() => {
sendResponse({ ok: true });
@@ -42,10 +41,28 @@ export default defineBackground(() => {
return true;
}
if (msg.type === messages.offscreen.to.startRecording) {
if (msg.type === messages.popup.from.start) {
console.log('[bg] startRecording received');
sendResponse({ ok: true });
// void browser.runtime.sendMessage({ type: messages.popup.to.started });
sendToActiveTab({ type: messages.content.to.startRecording })
.then(async () => {
await chrome.runtime.sendMessage({ type: messages.popup.to.started });
sendResponse({ ok: true });
})
.catch(() => {
sendResponse({ ok: false });
});
}
if (msg.type === messages.popup.from.stop) {
console.log('[bg] stopRecording received');
sendToActiveTab({ type: messages.content.to.stopRecording })
.then(async () => {
await chrome.runtime.sendMessage({ type: messages.popup.to.stoped });
sendResponse({ ok: true });
})
.catch(() => {
sendResponse({ ok: false });
});
}
return true;