From be379395f8349ba88682d4b0a109123d6e322973 Mon Sep 17 00:00:00 2001 From: icezhb <860435387@qq.com> Date: Sun, 14 Jul 2024 20:01:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=B7=E6=B1=82=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/index.js | 3 ++- src/preload/index.js | 4 ++++ src/renderer/index.html | 3 ++- src/renderer/src/App.vue | 6 ++++++ src/renderer/src/utils/http.js | 18 ++++++++++++++++-- 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index 81b2fbe..33a7e5b 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -123,7 +123,8 @@ function createWindow() { ...(process.platform === 'linux' ? { icon } : {}), webPreferences: { preload: join(__dirname, '../preload/index.js'), - sandbox: false + sandbox: false, + webSecurity: false } }) diff --git a/src/preload/index.js b/src/preload/index.js index f7c5fb8..bdde965 100644 --- a/src/preload/index.js +++ b/src/preload/index.js @@ -1,6 +1,8 @@ import electron, { contextBridge, ipcRenderer } from 'electron' import { electronAPI } from '@electron-toolkit/preload' +const http = require('http') + // Custom APIs for renderer const api = {} @@ -11,6 +13,7 @@ if (process.contextIsolated) { try { contextBridge.exposeInMainWorld('electron', electronAPI) contextBridge.exposeInMainWorld('api', api) + contextBridge.exposeInMainWorld('http', http) contextBridge.exposeInMainWorld('baseConfig', { getBaseConfig: () => ipcRenderer.invoke('getBaseConfig') }) @@ -23,6 +26,7 @@ if (process.contextIsolated) { } else { window.electron = electronAPI window.api = api + window.http = http window.electronAPI = { getBaseConfig: () => ipcRenderer.invoke('getBaseConfig') } diff --git a/src/renderer/index.html b/src/renderer/index.html index f05fc87..f00b32f 100644 --- a/src/renderer/index.html +++ b/src/renderer/index.html @@ -2,11 +2,12 @@ + Electron diff --git a/src/renderer/src/App.vue b/src/renderer/src/App.vue index 2cae7f3..46f1f99 100644 --- a/src/renderer/src/App.vue +++ b/src/renderer/src/App.vue @@ -1,5 +1,6 @@