From f69d405924e224b42ff96897d780ea5fa97f7b76 Mon Sep 17 00:00:00 2001 From: cysamurai Date: Fri, 8 Aug 2025 18:23:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A410?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tax-asst-client/src/main/index.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tax-asst-client/src/main/index.ts b/tax-asst-client/src/main/index.ts index bbf602f..93ec8da 100644 --- a/tax-asst-client/src/main/index.ts +++ b/tax-asst-client/src/main/index.ts @@ -27,6 +27,22 @@ function createWindow(): void { mainWindow.show() }) + const allowedOrigins = [ + 'http://192.168.0.117:8092', + 'https://your-production-domain.com' + ]; + + mainWindow.webContents.session.webRequest.onBeforeSendHeaders( + (details, callback) => { + const { origin } = new URL(details.url); + if (allowedOrigins.includes(origin)) { + callback({ requestHeaders: details.requestHeaders }); + } else { + callback({ cancel: true }); // 拦截非白名单请求 + } + } + ); + mainWindow.webContents.setWindowOpenHandler((details) => { shell.openExternal(details.url) return { action: 'deny' }