Skip to content

Commit 2e1de64

Browse files
committed
feat: chrome.downloads.download
1 parent 17a88c0 commit 2e1de64

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

packages/chrome-debugger/src/manifest/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const __MANIFEST__: Record<string, unknown> = {
3737
service_worker: "worker.js",
3838
},
3939
host_permissions: [...__URL_MATCH__],
40-
permissions: ["activeTab", "tabs", "scripting", "debugger"],
40+
permissions: ["activeTab", "tabs", "scripting", "debugger", "downloads"],
4141
minimum_chrome_version: "88.0",
4242
};
4343

packages/chrome-debugger/src/worker/channel/popup.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { isEmptyValue, TSON } from "laser-utils";
22

33
import { PWBridge } from "@/bridge/popup-worker";
44
import type { PWRequestType } from "@/bridge/popup-worker/request";
5-
import { WCBridge } from "@/bridge/worker-content";
65
import { URL_MATCH } from "@/utils/constant";
76
import { cross } from "@/utils/global";
87
import { logger } from "@/utils/logger";
@@ -87,7 +86,7 @@ export const onPopupMessage = (data: PWRequestType) => {
8786
.then(res => {
8887
// @ts-expect-error object
8988
const base64 = res.data as string;
90-
WCBridge.postToContent({ type: WCBridge.REQUEST.PDF_DATA, payload: base64 });
89+
chrome.downloads.download({ url: `data:application/pdf;base64,${base64}` });
9190
})
9291
.finally(() => {
9392
chrome.debugger.detach({ tabId });

0 commit comments

Comments
 (0)