main.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. "use strict";
  2. const { app, BrowserWindow, ipcMain, shell, session, Menu, Tray, nativeImage, webContents } = require("electron");
  3. const { join } = require("path");
  4. require("fs");
  5. let mainWindow = null;
  6. let tray = null;
  7. let isQuitting = false;
  8. const VITE_DEV_SERVER_URL = process.env.VITE_DEV_SERVER_URL;
  9. function getIconPath() {
  10. return VITE_DEV_SERVER_URL ? join(__dirname, "../public/icons/icon-256.png") : join(__dirname, "../dist/icons/icon-256.png");
  11. }
  12. function getTrayIconPath() {
  13. return VITE_DEV_SERVER_URL ? join(__dirname, "../public/icons/tray-icon.png") : join(__dirname, "../dist/icons/tray-icon.png");
  14. }
  15. function createTrayIcon() {
  16. const trayIconPath = getTrayIconPath();
  17. return nativeImage.createFromPath(trayIconPath);
  18. }
  19. function createTray() {
  20. const trayIcon = createTrayIcon();
  21. tray = new Tray(trayIcon);
  22. const contextMenu = Menu.buildFromTemplate([
  23. {
  24. label: "显示主窗口",
  25. click: () => {
  26. if (mainWindow) {
  27. mainWindow.show();
  28. mainWindow.focus();
  29. }
  30. }
  31. },
  32. {
  33. label: "最小化到托盘",
  34. click: () => {
  35. mainWindow == null ? void 0 : mainWindow.hide();
  36. }
  37. },
  38. { type: "separator" },
  39. {
  40. label: "退出",
  41. click: () => {
  42. isQuitting = true;
  43. app.quit();
  44. }
  45. }
  46. ]);
  47. tray.setToolTip("多平台媒体管理系统");
  48. tray.setContextMenu(contextMenu);
  49. tray.on("click", () => {
  50. if (mainWindow) {
  51. if (mainWindow.isVisible()) {
  52. mainWindow.focus();
  53. } else {
  54. mainWindow.show();
  55. mainWindow.focus();
  56. }
  57. }
  58. });
  59. tray.on("double-click", () => {
  60. if (mainWindow) {
  61. mainWindow.show();
  62. mainWindow.focus();
  63. }
  64. });
  65. }
  66. function createWindow() {
  67. Menu.setApplicationMenu(null);
  68. const iconPath = getIconPath();
  69. mainWindow = new BrowserWindow({
  70. width: 1400,
  71. height: 900,
  72. minWidth: 1200,
  73. minHeight: 700,
  74. icon: iconPath,
  75. webPreferences: {
  76. preload: join(__dirname, "preload.js"),
  77. nodeIntegration: false,
  78. contextIsolation: true,
  79. webviewTag: true
  80. // 启用 webview 标签
  81. },
  82. frame: false,
  83. // 无边框窗口,自定义标题栏
  84. transparent: false,
  85. backgroundColor: "#f0f2f5",
  86. show: false
  87. });
  88. mainWindow.once("ready-to-show", () => {
  89. mainWindow == null ? void 0 : mainWindow.show();
  90. setupWindowEvents();
  91. });
  92. if (VITE_DEV_SERVER_URL) {
  93. mainWindow.loadURL(VITE_DEV_SERVER_URL);
  94. mainWindow.webContents.openDevTools();
  95. } else {
  96. mainWindow.loadFile(join(__dirname, "../dist/index.html"));
  97. }
  98. mainWindow.webContents.setWindowOpenHandler(({ url }) => {
  99. shell.openExternal(url);
  100. return { action: "deny" };
  101. });
  102. mainWindow.on("close", (event) => {
  103. if (!isQuitting) {
  104. event.preventDefault();
  105. mainWindow == null ? void 0 : mainWindow.hide();
  106. if (tray && !app.isPackaged) ;
  107. }
  108. });
  109. mainWindow.on("closed", () => {
  110. mainWindow = null;
  111. });
  112. }
  113. const gotTheLock = app.requestSingleInstanceLock();
  114. if (!gotTheLock) {
  115. app.quit();
  116. } else {
  117. app.on("second-instance", () => {
  118. if (mainWindow) {
  119. mainWindow.show();
  120. if (mainWindow.isMinimized()) mainWindow.restore();
  121. mainWindow.focus();
  122. }
  123. });
  124. app.whenReady().then(() => {
  125. createTray();
  126. createWindow();
  127. setupWebviewSessions();
  128. app.on("activate", () => {
  129. if (BrowserWindow.getAllWindows().length === 0) {
  130. createWindow();
  131. } else if (mainWindow) {
  132. mainWindow.show();
  133. }
  134. });
  135. });
  136. }
  137. function setupWebviewSessions() {
  138. app.on("web-contents-created", (_event, contents) => {
  139. if (contents.getType() === "webview") {
  140. contents.setUserAgent(
  141. "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
  142. );
  143. contents.on("will-navigate", (event, url) => {
  144. if (!isAllowedUrl(url)) {
  145. console.log("[WebView] 阻止导航到自定义协议:", url);
  146. event.preventDefault();
  147. }
  148. });
  149. contents.setWindowOpenHandler(({ url }) => {
  150. if (!isAllowedUrl(url)) {
  151. console.log("[WebView] 阻止打开自定义协议窗口:", url);
  152. return { action: "deny" };
  153. }
  154. console.log("[WebView] 拦截新窗口,在当前页面打开:", url);
  155. contents.loadURL(url);
  156. return { action: "deny" };
  157. });
  158. contents.session.setPermissionRequestHandler((_webContents, permission, callback) => {
  159. callback(true);
  160. });
  161. contents.session.webRequest.onBeforeSendHeaders((details, callback) => {
  162. delete details.requestHeaders["X-DevTools-Emulate-Network-Conditions-Client-Id"];
  163. if (!details.requestHeaders["Origin"] && !details.requestHeaders["origin"]) ;
  164. callback({ requestHeaders: details.requestHeaders });
  165. });
  166. }
  167. });
  168. }
  169. function isAllowedUrl(url) {
  170. if (!url) return false;
  171. const lowerUrl = url.toLowerCase();
  172. return lowerUrl.startsWith("http://") || lowerUrl.startsWith("https://") || lowerUrl.startsWith("about:") || lowerUrl.startsWith("data:");
  173. }
  174. app.on("window-all-closed", () => {
  175. });
  176. app.on("before-quit", () => {
  177. isQuitting = true;
  178. });
  179. app.on("quit", () => {
  180. if (tray) {
  181. tray.destroy();
  182. tray = null;
  183. }
  184. });
  185. ipcMain.handle("get-app-version", () => {
  186. return app.getVersion();
  187. });
  188. ipcMain.handle("get-platform", () => {
  189. return process.platform;
  190. });
  191. ipcMain.on("window-minimize", () => {
  192. mainWindow == null ? void 0 : mainWindow.minimize();
  193. });
  194. ipcMain.on("window-maximize", () => {
  195. if (mainWindow == null ? void 0 : mainWindow.isMaximized()) {
  196. mainWindow.unmaximize();
  197. } else {
  198. mainWindow == null ? void 0 : mainWindow.maximize();
  199. }
  200. });
  201. ipcMain.on("window-close", () => {
  202. mainWindow == null ? void 0 : mainWindow.hide();
  203. });
  204. ipcMain.on("app-quit", () => {
  205. isQuitting = true;
  206. app.quit();
  207. });
  208. ipcMain.handle("window-is-maximized", () => {
  209. return (mainWindow == null ? void 0 : mainWindow.isMaximized()) || false;
  210. });
  211. function setupWindowEvents() {
  212. mainWindow == null ? void 0 : mainWindow.on("maximize", () => {
  213. mainWindow == null ? void 0 : mainWindow.webContents.send("window-maximized", true);
  214. });
  215. mainWindow == null ? void 0 : mainWindow.on("unmaximize", () => {
  216. mainWindow == null ? void 0 : mainWindow.webContents.send("window-maximized", false);
  217. });
  218. }
  219. ipcMain.handle("open-backend-external", async (_event, payload) => {
  220. const { url, cookieData, title } = payload || {};
  221. if (!url || typeof url !== "string") return;
  222. const partition = "persist:backend-popup-" + Date.now();
  223. const ses = session.fromPartition(partition);
  224. if (cookieData && typeof cookieData === "string" && cookieData.trim()) {
  225. const raw = cookieData.trim();
  226. let cookiesToSet = [];
  227. try {
  228. if (raw.startsWith("[") || raw.startsWith("{")) {
  229. const parsed = JSON.parse(raw);
  230. const arr = Array.isArray(parsed) ? parsed : (parsed == null ? void 0 : parsed.cookies) || [];
  231. cookiesToSet = arr.map((c) => ({
  232. name: String((c == null ? void 0 : c.name) ?? "").trim(),
  233. value: String((c == null ? void 0 : c.value) ?? "").trim(),
  234. domain: (c == null ? void 0 : c.domain) ? String(c.domain) : void 0,
  235. path: (c == null ? void 0 : c.path) ? String(c.path) : "/"
  236. })).filter((c) => c.name);
  237. } else {
  238. raw.split(";").forEach((p) => {
  239. const idx = p.indexOf("=");
  240. if (idx > 0) {
  241. const name = p.slice(0, idx).trim();
  242. const value = p.slice(idx + 1).trim();
  243. if (name) cookiesToSet.push({ name, value, path: "/" });
  244. }
  245. });
  246. }
  247. } catch (e) {
  248. console.warn("[open-backend-external] 解析 cookie 失败", e);
  249. }
  250. const origin = new URL(url).origin;
  251. const hostname = new URL(url).hostname;
  252. const defaultDomain = hostname.startsWith("www.") ? hostname.slice(4) : hostname;
  253. const domainWithDot = defaultDomain.includes(".") ? "." + defaultDomain.split(".").slice(-2).join(".") : void 0;
  254. for (const c of cookiesToSet) {
  255. try {
  256. await ses.cookies.set({
  257. url: origin + "/",
  258. name: c.name,
  259. value: c.value,
  260. domain: c.domain || domainWithDot || hostname,
  261. path: c.path || "/"
  262. });
  263. } catch (err) {
  264. console.warn("[open-backend-external] 设置 cookie 失败", c.name, err);
  265. }
  266. }
  267. }
  268. const win = new BrowserWindow({
  269. width: 1280,
  270. height: 800,
  271. title: title || "平台后台",
  272. icon: getIconPath(),
  273. webPreferences: {
  274. session: ses,
  275. nodeIntegration: false,
  276. contextIsolation: true
  277. },
  278. show: false
  279. });
  280. win.once("ready-to-show", () => {
  281. win.show();
  282. });
  283. await win.loadURL(url);
  284. return { ok: true };
  285. });
  286. ipcMain.handle("get-webview-cookies", async (_event, partition, url) => {
  287. try {
  288. const ses = session.fromPartition(partition);
  289. const cookies = await ses.cookies.get({ url });
  290. return cookies;
  291. } catch (error) {
  292. console.error("获取 cookies 失败:", error);
  293. return [];
  294. }
  295. });
  296. ipcMain.handle("clear-webview-cookies", async (_event, partition) => {
  297. try {
  298. const ses = session.fromPartition(partition);
  299. await ses.clearStorageData({ storages: ["cookies"] });
  300. return true;
  301. } catch (error) {
  302. console.error("清除 cookies 失败:", error);
  303. return false;
  304. }
  305. });
  306. ipcMain.handle("set-webview-cookies", async (_event, partition, cookies) => {
  307. try {
  308. console.log(`[Main] 设置 webview cookies, partition=${partition}, count=${cookies.length}`);
  309. const ses = session.fromPartition(partition);
  310. let successCount = 0;
  311. for (const cookie of cookies) {
  312. try {
  313. const cookieToSet = {
  314. url: cookie.url,
  315. name: cookie.name,
  316. value: cookie.value,
  317. domain: cookie.domain,
  318. path: cookie.path || "/"
  319. };
  320. if (cookie.expirationDate) {
  321. cookieToSet.expirationDate = cookie.expirationDate;
  322. }
  323. if (cookie.httpOnly !== void 0) {
  324. cookieToSet.httpOnly = cookie.httpOnly;
  325. }
  326. if (cookie.secure !== void 0) {
  327. cookieToSet.secure = cookie.secure;
  328. }
  329. if (cookie.sameSite) {
  330. cookieToSet.sameSite = cookie.sameSite;
  331. }
  332. await ses.cookies.set(cookieToSet);
  333. successCount++;
  334. if (cookie.name === "BDUSS" || cookie.name === "STOKEN" || cookie.name === "sessionid") {
  335. console.log(`[Main] 成功设置关键 Cookie: ${cookie.name}, domain: ${cookie.domain}`);
  336. }
  337. } catch (error) {
  338. console.error(`[Main] 设置 cookie 失败 (${cookie.name}):`, error);
  339. }
  340. }
  341. console.log(`[Main] 成功设置 ${successCount}/${cookies.length} 个 cookies`);
  342. try {
  343. const setCookies = await ses.cookies.get({ domain: ".baidu.com" });
  344. console.log(`[Main] 验证:当前 session 中有 ${setCookies.length} 个百度 Cookie`);
  345. const keyNames = setCookies.slice(0, 5).map((c) => c.name).join(", ");
  346. console.log(`[Main] 关键 Cookie 名称: ${keyNames}`);
  347. } catch (verifyError) {
  348. console.error("[Main] 验证 Cookie 失败:", verifyError);
  349. }
  350. return true;
  351. } catch (error) {
  352. console.error("[Main] 设置 cookies 失败:", error);
  353. return false;
  354. }
  355. });
  356. ipcMain.handle("capture-webview-page", async (_event, webContentsId) => {
  357. try {
  358. const wc = webContents.fromId(webContentsId);
  359. if (!wc) {
  360. console.error("找不到 webContents:", webContentsId);
  361. return null;
  362. }
  363. const image = await wc.capturePage();
  364. if (!image || image.isEmpty()) {
  365. console.warn("截图为空");
  366. return null;
  367. }
  368. const buffer = image.toJPEG(80);
  369. return buffer.toString("base64");
  370. } catch (error) {
  371. console.error("截图失败:", error);
  372. return null;
  373. }
  374. });
  375. ipcMain.handle("webview-send-mouse-click", async (_event, webContentsId, x, y) => {
  376. try {
  377. const wc = webContents.fromId(webContentsId);
  378. if (!wc) {
  379. console.error("找不到 webContents:", webContentsId);
  380. return false;
  381. }
  382. wc.sendInputEvent({
  383. type: "mouseMove",
  384. x: Math.round(x),
  385. y: Math.round(y)
  386. });
  387. await new Promise((resolve) => setTimeout(resolve, 50));
  388. wc.sendInputEvent({
  389. type: "mouseDown",
  390. x: Math.round(x),
  391. y: Math.round(y),
  392. button: "left",
  393. clickCount: 1
  394. });
  395. await new Promise((resolve) => setTimeout(resolve, 50));
  396. wc.sendInputEvent({
  397. type: "mouseUp",
  398. x: Math.round(x),
  399. y: Math.round(y),
  400. button: "left",
  401. clickCount: 1
  402. });
  403. console.log(`[webview-send-mouse-click] Clicked at (${x}, ${y})`);
  404. return true;
  405. } catch (error) {
  406. console.error("发送点击事件失败:", error);
  407. return false;
  408. }
  409. });
  410. ipcMain.handle("webview-send-text-input", async (_event, webContentsId, text) => {
  411. try {
  412. const wc = webContents.fromId(webContentsId);
  413. if (!wc) {
  414. console.error("找不到 webContents:", webContentsId);
  415. return false;
  416. }
  417. for (const char of text) {
  418. wc.sendInputEvent({
  419. type: "char",
  420. keyCode: char
  421. });
  422. await new Promise((resolve) => setTimeout(resolve, 30));
  423. }
  424. console.log(`[webview-send-text-input] Typed: ${text}`);
  425. return true;
  426. } catch (error) {
  427. console.error("发送输入事件失败:", error);
  428. return false;
  429. }
  430. });
  431. ipcMain.handle("webview-get-element-position", async (_event, webContentsId, selector) => {
  432. try {
  433. const wc = webContents.fromId(webContentsId);
  434. if (!wc) {
  435. console.error("找不到 webContents:", webContentsId);
  436. return null;
  437. }
  438. const result = await wc.executeJavaScript(`
  439. (function() {
  440. const el = document.querySelector('${selector.replace(/'/g, "\\'")}');
  441. if (!el) return null;
  442. const rect = el.getBoundingClientRect();
  443. return {
  444. x: rect.left + rect.width / 2,
  445. y: rect.top + rect.height / 2,
  446. width: rect.width,
  447. height: rect.height
  448. };
  449. })()
  450. `);
  451. return result;
  452. } catch (error) {
  453. console.error("获取元素位置失败:", error);
  454. return null;
  455. }
  456. });
  457. ipcMain.handle("webview-click-by-text", async (_event, webContentsId, text) => {
  458. try {
  459. const wc = webContents.fromId(webContentsId);
  460. if (!wc) {
  461. console.error("找不到 webContents:", webContentsId);
  462. return false;
  463. }
  464. const position = await wc.executeJavaScript(`
  465. (function() {
  466. const searchText = '${text.replace(/'/g, "\\'")}';
  467. // 查找可点击元素
  468. const clickables = document.querySelectorAll('a, button, [role="button"], [onclick], input[type="submit"], input[type="button"]');
  469. for (const el of clickables) {
  470. if (el.textContent?.includes(searchText) || el.getAttribute('aria-label')?.includes(searchText) || el.getAttribute('title')?.includes(searchText)) {
  471. const rect = el.getBoundingClientRect();
  472. if (rect.width > 0 && rect.height > 0) {
  473. return { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 };
  474. }
  475. }
  476. }
  477. // 查找所有包含文本的元素
  478. const allElements = document.querySelectorAll('*');
  479. for (const el of allElements) {
  480. const text = el.innerText?.trim();
  481. if (text && text.length < 100 && text.includes(searchText)) {
  482. const rect = el.getBoundingClientRect();
  483. if (rect.width > 0 && rect.height > 0 && rect.width < 500) {
  484. return { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 };
  485. }
  486. }
  487. }
  488. return null;
  489. })()
  490. `);
  491. if (!position) {
  492. console.warn(`[webview-click-by-text] 未找到包含 "${text}" 的元素`);
  493. return false;
  494. }
  495. wc.sendInputEvent({ type: "mouseMove", x: Math.round(position.x), y: Math.round(position.y) });
  496. await new Promise((resolve) => setTimeout(resolve, 50));
  497. wc.sendInputEvent({ type: "mouseDown", x: Math.round(position.x), y: Math.round(position.y), button: "left", clickCount: 1 });
  498. await new Promise((resolve) => setTimeout(resolve, 50));
  499. wc.sendInputEvent({ type: "mouseUp", x: Math.round(position.x), y: Math.round(position.y), button: "left", clickCount: 1 });
  500. console.log(`[webview-click-by-text] Clicked "${text}" at (${position.x}, ${position.y})`);
  501. return true;
  502. } catch (error) {
  503. console.error("通过文本点击失败:", error);
  504. return false;
  505. }
  506. });
  507. const networkInterceptors = /* @__PURE__ */ new Map();
  508. ipcMain.handle("enable-network-intercept", async (_event, webContentsId, patterns) => {
  509. var _a;
  510. try {
  511. const wc = webContents.fromId(webContentsId);
  512. if (!wc) {
  513. console.error("[CDP] 找不到 webContents:", webContentsId);
  514. return false;
  515. }
  516. if (networkInterceptors.has(webContentsId)) {
  517. try {
  518. wc.debugger.detach();
  519. } catch (e) {
  520. }
  521. }
  522. networkInterceptors.set(webContentsId, {
  523. patterns,
  524. pendingRequests: /* @__PURE__ */ new Map()
  525. });
  526. try {
  527. wc.debugger.attach("1.3");
  528. } catch (err) {
  529. const error = err;
  530. if (!((_a = error.message) == null ? void 0 : _a.includes("Already attached"))) {
  531. throw err;
  532. }
  533. }
  534. await wc.debugger.sendCommand("Network.enable");
  535. wc.debugger.on("message", async (_e, method, params) => {
  536. const config = networkInterceptors.get(webContentsId);
  537. if (!config) return;
  538. if (method === "Network.responseReceived") {
  539. const { requestId, response } = params;
  540. if (!requestId || !(response == null ? void 0 : response.url)) return;
  541. if (response.url.includes("baijiahao.baidu.com")) {
  542. if (response.url.includes("/pcui/") || response.url.includes("/article")) {
  543. console.log(`[CDP DEBUG] 百家号 API: ${response.url}`);
  544. }
  545. }
  546. for (const pattern of config.patterns) {
  547. if (response.url.includes(pattern.match)) {
  548. config.pendingRequests.set(requestId, {
  549. url: response.url,
  550. timestamp: Date.now()
  551. });
  552. console.log(`[CDP] 匹配到 API: ${pattern.key} - ${response.url}`);
  553. break;
  554. }
  555. }
  556. }
  557. if (method === "Network.loadingFinished") {
  558. const { requestId } = params;
  559. if (!requestId) return;
  560. const pending = config.pendingRequests.get(requestId);
  561. if (!pending) return;
  562. config.pendingRequests.delete(requestId);
  563. try {
  564. const result = await wc.debugger.sendCommand("Network.getResponseBody", { requestId });
  565. let body = result.body;
  566. if (result.base64Encoded) {
  567. body = Buffer.from(body, "base64").toString("utf8");
  568. }
  569. const data = JSON.parse(body);
  570. let matchedKey = "";
  571. for (const pattern of config.patterns) {
  572. if (pending.url.includes(pattern.match)) {
  573. matchedKey = pattern.key;
  574. break;
  575. }
  576. }
  577. if (matchedKey) {
  578. console.log(`[CDP] 获取到响应: ${matchedKey}`, JSON.stringify(data).substring(0, 200));
  579. mainWindow == null ? void 0 : mainWindow.webContents.send("network-intercept-data", {
  580. webContentsId,
  581. key: matchedKey,
  582. url: pending.url,
  583. data
  584. });
  585. }
  586. } catch (err) {
  587. console.warn(`[CDP] 获取响应体失败:`, err);
  588. }
  589. }
  590. });
  591. console.log(`[CDP] 已启用网络拦截,webContentsId: ${webContentsId}, patterns:`, patterns.map((p) => p.key));
  592. return true;
  593. } catch (error) {
  594. console.error("[CDP] 启用网络拦截失败:", error);
  595. return false;
  596. }
  597. });
  598. ipcMain.handle("disable-network-intercept", async (_event, webContentsId) => {
  599. try {
  600. const wc = webContents.fromId(webContentsId);
  601. if (wc) {
  602. try {
  603. wc.debugger.detach();
  604. } catch (e) {
  605. }
  606. }
  607. networkInterceptors.delete(webContentsId);
  608. console.log(`[CDP] 已禁用网络拦截,webContentsId: ${webContentsId}`);
  609. return true;
  610. } catch (error) {
  611. console.error("[CDP] 禁用网络拦截失败:", error);
  612. return false;
  613. }
  614. });
  615. ipcMain.handle("update-network-patterns", async (_event, webContentsId, patterns) => {
  616. const config = networkInterceptors.get(webContentsId);
  617. if (config) {
  618. config.patterns = patterns;
  619. console.log(`[CDP] 已更新 patterns,webContentsId: ${webContentsId}`);
  620. return true;
  621. }
  622. return false;
  623. });
  624. //# sourceMappingURL=main.js.map