From 3c4d524257916eb15eeb111c4f267045d613cb15 Mon Sep 17 00:00:00 2001 From: gaoshuaixing Date: Mon, 21 Feb 2022 18:35:39 +0800 Subject: [PATCH] window --- electron/controller/example.js | 22 ++++++++++++++++++++++ frontend/src/api/main.js | 1 + frontend/src/views/base/window/Index.vue | 6 +++--- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/electron/controller/example.js b/electron/controller/example.js index 9b7bb01..d575ee1 100644 --- a/electron/controller/example.js +++ b/electron/controller/example.js @@ -182,6 +182,28 @@ class ExampleController extends Controller { this.app.electron.mainWindow.removeBrowserView(browserViewObj); return true } + + /** + * 打开新窗口 + */ + createWindow (args) { + let content = null; + if (args.type == 'html') { + content = path.join('file://', electronApp.getAppPath(), args.content) + } else { + content = args.content; + } + + let winObj = new BrowserWindow({ + x: 10, + y: 10, + width: 980, + height: 650 + }) + winObj.loadURL(content); + + return winObj.id + } } module.exports = ExampleController; diff --git a/frontend/src/api/main.js b/frontend/src/api/main.js index 1b6ec12..7da7b59 100644 --- a/frontend/src/api/main.js +++ b/frontend/src/api/main.js @@ -23,6 +23,7 @@ const ipcApiRoute = { executeJS: 'controller.example.executeJS', loadViewContent: 'controller.example.loadViewContent', removeViewContent: 'controller.example.removeViewContent', + createWindow: 'controller.example.createWindow', } /** diff --git a/frontend/src/views/base/window/Index.vue b/frontend/src/views/base/window/Index.vue index 4b4e69d..4edd00a 100644 --- a/frontend/src/views/base/window/Index.vue +++ b/frontend/src/views/base/window/Index.vue @@ -23,6 +23,7 @@