diff --git a/package.json b/package.json index 74b8c1ca..772e6f56 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", @@ -91,9 +92,9 @@ "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-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 @@