I'm trying make a custom titlebar on electron. But when i started my app, i take "ReferenceError: navigator is not defined" issue. Please help. This is the code snippet from my main.js
My Codes
// 1. Require the installed module
const customTitlebar = require('custom-electron-titlebar');
// 2. Create the custom titlebar with your own settings
// To make it work, we just need to provide the backgroundColor property
// Other properties are optional.
let MyTitleBar = new customTitlebar.Titlebar({ backgroundColor: customTitlebar.Color.fromHex('#03a9f4')});
I'm trying make a custom titlebar on electron. But when i started my app, i take "ReferenceError: navigator is not defined" issue. Please help. This is the code snippet from my main.js
My Codes
// 1. Require the installed module
const customTitlebar = require('custom-electron-titlebar');
// 2. Create the custom titlebar with your own settings
// To make it work, we just need to provide the backgroundColor property
// Other properties are optional.
let MyTitleBar = new customTitlebar.Titlebar({ backgroundColor: customTitlebar.Color.fromHex('#03a9f4')});
Share
Improve this question
edited Jan 20, 2020 at 12:56
tpikachu
4,8442 gold badges21 silver badges45 bronze badges
asked Jan 17, 2020 at 14:39
ValorValor
431 silver badge5 bronze badges
4
-
lmk where you import this
custom-electron-titlebar
– tpikachu Commented Jan 17, 2020 at 17:50 - in main.js m8 :. – Valor Commented Jan 18, 2020 at 21:26
- please use this at your renderer – tpikachu Commented Jan 20, 2020 at 10:47
- your main process is just for managing the renderer process. there is no navigator at main – tpikachu Commented Jan 20, 2020 at 10:47
1 Answer
Reset to default 4This can't be executed in main process. The main process is for managing the renderer process. There won't be any navigator at Electron main process. And navigator is property of browser.
The renderer is responsible to render the code to browserWindow. So you can access the navigator of browserWindow at renderer not main.
So please move this to your renderer where you'd like to customize the title bar.
This will be working very well.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745379767a4625169.html
评论列表(0条)