From 2d85295093e973175988fdc87089cdb78f6e1433 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Apr 2021 06:25:55 +0000 Subject: [PATCH 1/2] build(deps-dev): bump electron from 11.4.3 to 12.0.5 Bumps [electron](https://github.com/electron/electron) from 11.4.3 to 12.0.5. - [Release notes](https://github.com/electron/electron/releases) - [Changelog](https://github.com/electron/electron/blob/master/docs/breaking-changes.md) - [Commits](https://github.com/electron/electron/compare/v11.4.3...v12.0.5) Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2512824c..ea9df433 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,7 @@ "devDependencies": { "babel-eslint": "^10.1.0", "cross-env": "^7.0.2", - "electron": "^11.4.3", + "electron": "^12.0.5", "electron-builder": "^22.9.1", "electron-devtools-installer": "^3.1.1", "electron-webpack": "^2.8.2", From 15948b30c9a3b2b192422607255b821d71b31d4e Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Mon, 26 Apr 2021 10:07:47 +0200 Subject: [PATCH 2/2] refactor: modifications for electron 12 support --- package.json | 5 +-- src/main/index.js | 47 ++++++++++++++----------- src/renderer/App.vue | 7 ++-- src/renderer/components/TheTitleBar.vue | 7 ++-- 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index ea9df433..82af01ee 100644 --- a/package.json +++ b/package.json @@ -67,10 +67,11 @@ } }, "dependencies": { + "@electron/remote": "^1.1.0", "@mdi/font": "^5.9.55", "ace-builds": "^1.4.12", "electron-log": "^4.3.0", - "electron-store": "^7.0.0", + "electron-store": "^8.0.0", "electron-updater": "^4.3.5", "faker": "^5.3.1", "marked": "^2.0.2", @@ -93,7 +94,7 @@ "cross-env": "^7.0.2", "electron": "^12.0.5", "electron-builder": "^22.9.1", - "electron-devtools-installer": "^3.1.1", + "electron-devtools-installer": "^3.2.0", "electron-webpack": "^2.8.2", "electron-webpack-vue": "^2.4.0", "eslint": "^7.24.0", diff --git a/src/main/index.js b/src/main/index.js index 90400c28..f580340a 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -29,6 +29,7 @@ async function createMainWindow () { icon: nativeImage.createFromDataURL(icon.default), webPreferences: { nodeIntegration: true, + contextIsolation: false, 'web-security': false, enableRemoteModule: true, spellcheck: false @@ -37,26 +38,25 @@ async function createMainWindow () { backgroundColor: '#1d1d1d' }); - if (isDevelopment) { - await window.loadURL(`http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}`); + try { + if (isDevelopment) { + await window.loadURL(`http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}`); - const { default: installExtension, VUEJS_DEVTOOLS } = require('electron-devtools-installer'); - window.webContents.openDevTools(); + const { default: installExtension, VUEJS_DEVTOOLS } = require('electron-devtools-installer'); - installExtension(VUEJS_DEVTOOLS) - .then(name => { - console.log(name, 'installed'); - }) - .catch(err => { - console.log(err); - }); + const toolName = await installExtension(VUEJS_DEVTOOLS); + console.log(toolName, 'installed'); + } + else { + await window.loadURL(formatUrl({ + pathname: path.join(__dirname, 'index.html'), + protocol: 'file', + slashes: true + })); + } } - else { - await window.loadURL(formatUrl({ - pathname: path.join(__dirname, 'index.html'), - protocol: 'file', - slashes: true - })); + catch (err) { + console.log(err); } window.on('closed', () => { @@ -76,6 +76,8 @@ async function createMainWindow () { if (!gotTheLock) app.quit(); else { + require('@electron/remote/main').initialize(); + // Initialize ipcHandlers ipcHandlers(); @@ -86,14 +88,17 @@ else { app.quit(); }); - app.on('activate', () => { + app.on('activate', async () => { // on macOS it is common to re-create a window even after all windows have been closed - if (mainWindow === null) - mainWindow = createMainWindow(); + if (mainWindow === null) { + mainWindow = await createMainWindow(); + mainWindow.webContents.openDevTools(); + } }); // create main BrowserWindow when electron is ready app.on('ready', async () => { - mainWindow = createMainWindow(); + mainWindow = await createMainWindow(); + mainWindow.webContents.openDevTools(); }); } diff --git a/src/renderer/App.vue b/src/renderer/App.vue index 56adbb74..6535fa56 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -25,7 +25,8 @@