fix: 下载移到 background.js 执行,和原插件一致
This commit is contained in:
@@ -259,6 +259,18 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 下载 PPTX(由 popup 调用,background 执行下载)
|
||||
if (message?.type === "WEB_TO_PPT_DOWNLOAD") {
|
||||
(async () => {
|
||||
const dataUrl = 'data:application/vnd.openxmlformats-officedocument.presentationml.presentation;base64,' + message.base64;
|
||||
await chrome.downloads.download({ url: dataUrl, filename: message.filename });
|
||||
return { ok: true };
|
||||
})()
|
||||
.then(sendResponse)
|
||||
.catch(error => sendResponse({ ok: false, error: error.message || String(error) }));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user