diff --git a/frontend/package.json b/frontend/package.json index 9253efe..cf227c7 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -31,7 +31,6 @@ "postuninstall": "electron-builder install-app-deps" }, "main": "./src/background.js", - "type": "module", "repository": "https://github.com/Troplo/Colubrina", "dependencies": { "@babel/preset-env": "^7.17.10", diff --git a/frontend/src/background.js b/frontend/src/background.js index f09bdce..5531471 100644 --- a/frontend/src/background.js +++ b/frontend/src/background.js @@ -1,25 +1,28 @@ "use strict" -import { app, protocol, BrowserWindow, screen } from "electron" -import { createProtocol } from "vue-cli-plugin-electron-builder/lib" -import installExtension, { VUEJS_DEVTOOLS } from "electron-devtools-installer" +const electron = require("electron") +const VueCLI = require("vue-cli-plugin-electron-builder/lib") +const { + default: installExtension, + VUEJS_DEVTOOLS +} = require("electron-devtools-installer") const isDevelopment = process.env.NODE_ENV !== "production" // Scheme must be registered before the app is ready -protocol.registerSchemesAsPrivileged([ +electron.protocol.registerSchemesAsPrivileged([ { scheme: "app", privileges: { secure: true, standard: true } } ]) async function createWindow() { // Create the browser window. - const { bounds } = screen.getDisplayNearestPoint( - screen.getCursorScreenPoint() + const { bounds } = electron.screen.getDisplayNearestPoint( + electron.screen.getCursorScreenPoint() ) const height = Math.floor(bounds.height * (2 / 3)) const width = Math.floor(bounds.width * (2 / 3)) const y = Math.floor(bounds.y + (bounds.height - height) / 2) const x = Math.floor(bounds.x + (bounds.width - width) / 2) - const win = new BrowserWindow({ + const win = new electron.BrowserWindow({ width, height, x, @@ -40,31 +43,31 @@ async function createWindow() { await win.loadURL(process.env.WEBPACK_DEV_SERVER_URL) if (!process.env.IS_TEST) win.webContents.openDevTools() } else { - createProtocol("app") + VueCLI.createProtocol("app") // Load the index.html when not in development win.loadURL("app://./index.html") } } // Quit when all windows are closed. -app.on("window-all-closed", () => { +electron.app.on("window-all-closed", () => { // On macOS it is common for applications and their menu bar // to stay active until the user quits explicitly with Cmd + Q if (process.platform !== "darwin") { - app.quit() + electron.app.quit() } }) -app.on("activate", () => { +electron.app.on("activate", () => { // On macOS it's common to re-create a window in the app when the // dock icon is clicked and there are no other windows open. - if (BrowserWindow.getAllWindows().length === 0) createWindow() + if (electron.BrowserWindow.getAllWindows().length === 0) createWindow() }) // This method will be called when Electron has finished // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs. -app.on("ready", async () => { +electron.app.on("ready", async () => { if (isDevelopment && !process.env.IS_TEST) { // Install Vue Devtools try { @@ -81,12 +84,12 @@ if (isDevelopment) { if (process.platform === "win32") { process.on("message", (data) => { if (data === "graceful-exit") { - app.quit() + electron.app.quit() } }) } else { process.on("SIGTERM", () => { - app.quit() + electron.app.quit() }) } }