From fed756f6bd6464266b8a1967ca9774017e4f95cc Mon Sep 17 00:00:00 2001 From: qier222 <qier222@outlook.com> Date: Tue, 24 Nov 2020 13:54:58 +0800 Subject: [PATCH] fix(electron): open new window in browser --- src/background.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/background.js b/src/background.js index e56d773..1f7293a 100644 --- a/src/background.js +++ b/src/background.js @@ -1,5 +1,5 @@ "use strict"; -import { app, protocol, BrowserWindow } from "electron"; +import { app, protocol, BrowserWindow, shell } from "electron"; import { createProtocol } from "vue-cli-plugin-electron-builder/lib"; import installExtension, { VUEJS_DEVTOOLS } from "electron-devtools-installer"; import { startNeteaseMusicApi } from "./electron/services"; @@ -53,6 +53,10 @@ function createWindow() { win.loadURL("app://./index.html"); } + win.webContents.on("new-window", function (e, url) { + e.preventDefault(); + shell.openExternal(url); + }); win.on("closed", () => { win = null; });