panqiuyao 9 mesiacov pred
rodič
commit
dfadc4877c
1 zmenil súbory, kde vykonal 9 pridanie a 1 odobranie
  1. 9 1
      electron/controller/utils.js

+ 9 - 1
electron/controller/utils.js

@@ -40,7 +40,15 @@ class UtilsController extends Controller {
 
   async openMain (config) {
     if( this.app.electron[config.id]) return;
-    const win = new BrowserWindow(config);
+    const win = new BrowserWindow({
+      ...config,
+
+      webPreferences: {
+        contextIsolation: false, // false -> 可在渲染进程中使用electron的api,true->需要bridge.js(contextBridge)
+        nodeIntegration: true,
+        preload: path.join('../preload/bridge.js'),
+      },
+    });
     win.loadURL(config.url); // 设置窗口的 URL
     // 监听窗口关闭事件
     win.on('close', () => {