Skip to content

Instantly share code, notes, and snippets.

@WhiteO

WhiteO/background.js

Last active Sep 16, 2020
Embed
What would you like to do?
trouble with VUEJS_DEVTOOLS and electron
"use strict";
import {app, BrowserWindow, protocol} from "electron";
import {createProtocol} from "vue-cli-plugin-electron-builder/lib";
import installExtension, {VUEJS_DEVTOOLS} from "electron-devtools-installer";
import {server} from "feature-server-core";
server.start();
const isDevelopment = process.env.NODE_ENV !== "production";
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win;
// Scheme must be registered before the app is ready
protocol.registerSchemesAsPrivileged([
{scheme: "app", privileges: {secure: true, standard: true}}
]);
function createWindow() {
// Create the browser window.
win = new BrowserWindow({
width: 1400,
height: 900,
minWidth: 1280,
minHeight: 800,
closable: false,
center: true,
type: "tool",
titleBarStyle: "hidden",
webPreferences: {
devTools: false,
nodeIntegration: process.env.ELECTRON_NODE_INTEGRATION
}
});
win.menuBarVisible = false;
if (process.env.WEBPACK_DEV_SERVER_URL) {
// Load the url of the dev server if in development mode
win.loadURL(process.env.WEBPACK_DEV_SERVER_URL);
//if (!process.env.IS_TEST) win.webContents.openDevTools()
} else {
createProtocol("app");
// Load the index.html when not in development
win.loadURL("app://./index.html");
}
win.on("closed", () => {
win = null;
});
}
// Quit when all windows are closed.
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();
}
});
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 (win === null) {
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 () => {
if (isDevelopment && !process.env.IS_TEST) {
// Install Vue Devtools
try {
await installExtension(VUEJS_DEVTOOLS);
} catch (e) {
console.error("Vue Devtools failed to install:", e.toString());
}
}
createWindow();
});
// Exit cleanly on request from parent process in development mode.
if (isDevelopment) {
if (process.platform === "win32") {
process.on("message", (data) => {
if (data === "graceful-exit") {
app.quit();
}
});
} else {
process.on("SIGTERM", () => {
app.quit();
});
}
}
@WhiteO

This comment has been minimized.

Copy link
Owner Author

@WhiteO WhiteO commented Sep 15, 2020

(node:15736) ExtensionLoadWarning: Warnings loading extension at C:\Users\Sky-1\AppData\Roaming\bgs-feature-server\extensions\nhdogjmejiglipccpnnnanhbledajbpd: Unrecognized manifest key 'browser_action'. Unrecognized manifest ke
y 'update_url'. Permission 'contextMenus' is unknown or URL pattern is malformed. Cannot load extension with file or directory name metadata. Filenames starting with "" are reserved for use by the system.
webpack:///./node_modules/vue-cli-plugin-electron-builder/lib/installVueDevtools/utils.js?:19
const savePath = (electron__WEBPACK_IMPORTED_MODULE_0__["remote"] || electron__WEBPACK_IMPORTED_MODULE_0___default.a).app.getPath('userData')

@WhiteO

This comment has been minimized.

Copy link
Owner Author

@WhiteO WhiteO commented Sep 15, 2020

TypeError: Cannot read property 'getPath' of undefined
at getPath (webpack:///./node_modules/vue-cli-plugin-electron-builder/lib/installVueDevtools/utils.js?:19:125)
at getIDMapPath (webpack:///./node_modules/vue-cli-plugin-electron-builder/lib/installVueDevtools/index.js?:20:134)
at eval (wewebpack:///./node_modules/vbpack:///./node_modules/vue-cli-plugin-electron-builder/lib/installVueDevtools/index.js?:21:58)
at Module../node_modules/vue-cli-plugin-electron-builder/lib/installVueDevtools/index.js (C:\Code\feature-server-ui\dist_electron\index.js:16801:1)
at webpack_require (C:\Code\feature-server-ui\dist_electron\index.js:20:30)
at eval (webpack:///./node_modules/vue-cli-plugin-electron-builder/lib/index.js?:2:77)
at Module../node_modules/vue-cli-plugin-electron-builder/lib/index.js (C:\Code\feature-server-ui\dist_electron\index.js:16777:1)
at webpack_require (C:\Code\feature-server-ui\dist_electron\index.js:20:30)
at eval (webpack:///./src/background.js?:4:93)
at Module../src/background.js (C:\Code\feature-server-ui\dist_electron\index.js:17576:1)
ue-cli-plugin-electron-builder/lib/installVueDevtools/utils.js?:19
const savePath = (electron__WEBPACK_IMPORTED_MODULE_0__["remote"] || electron__WEBPACK_IMPORTED_MODULE_0___default.a).app.getPath('userData')

@WhiteO

This comment has been minimized.

Copy link
Owner Author

@WhiteO WhiteO commented Sep 15, 2020

"electron": "^10.1.2",
"electron-devtools-installer": "^3.1.1",
"vue-cli-plugin-electron-builder": "^2.0.0-rc.4",

node 14.10.1

@WhiteO

This comment has been minimized.

Copy link
Owner Author

@WhiteO WhiteO commented Sep 15, 2020

@nklayman please help me solve this problem

@nklayman

This comment has been minimized.

Copy link

@nklayman nklayman commented Sep 16, 2020

Please open an issue on vue-cli-plugin-electron-builder that follows the bug report template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.