[英]set color of windows titlebar - electron.js
There's no way at the moment to customize the native titlebar.目前无法自定义原生标题栏。 So, first step is to hide the native titlebar by telling your BrowserWindow to hide the frame (that would also hide the menubar).
因此,第一步是通过告诉 BrowserWindow 隐藏框架(这也将隐藏菜单栏)来隐藏本机标题栏。
mainWindow = new BrowserWindow({
frame: false
})
see: https://electronjs.org/docs/api/browser-window见: https ://electronjs.org/docs/api/browser-window
Then, you should create your custom titlebar (or import a third party library like 1 or 2 ) in HTML, CSS and JS.然后,您应该在 HTML、CSS 和 JS 中创建自定义标题栏(或导入第三方库,如1或2 )。 That way, the titlebar lives under the renderer process in Electron.
这样,标题栏就位于 Electron 的渲染器进程之下。 So, to actually for example quit your application when clicking the X button, you should take advantage of the IPC to send an event to the main process and quit the application.
因此,实际上例如在单击 X 按钮时退出应用程序,您应该利用 IPC 向主进程发送事件并退出应用程序。
Example:例子:
# renderer
ipcRenderer.send('app:quit')
# main
ipcMain.on('app:quit', () => { app.quit() })
Or as an alternative: look this answer here on StackOverflow或者作为替代方案: 在 StackOverflow 上查看此答案
您必须隐藏窗口标题栏并在 html、css、js 中构建一个新的窗口标题栏。
There is an API for it. 它有一个API。 Haven't tried it yet.
尚未尝试过。 https://www.npmjs.com/package/electron-titlebar-windows
https://www.npmjs.com/package/electron-titlebar-windows
const titlebar = new ElectronTitlebarWindows(#24628d);
something like that... 类似的东西......
你可能想看看这篇文章
Now can hide the title bar and set the color of buttons in Windows with:现在可以隐藏标题栏并设置 Windows 中按钮的颜色:
//main.js
const { BrowserWindow } = require('electron')
const win = new BrowserWindow({
titleBarStyle: 'hidden',
titleBarOverlay: {
color: '#2f3241',
symbolColor: '#74b1be'
}
})
Here is the Answer:-这是答案:-
// Create the browser window.
const mainWindow = new BrowserWindow({
titleBarStyle: 'hidden',
titleBarOverlay: {
// color of titile bar
color: '#3b3b3b',
// color of titile bar control
symbolColor: '#74b1be',
// height of titile bar
height: 32
},
});
Refence: Electron Docs参考: Electron 文档
mainWindow = new BrowserWindow({
width: 1000,
height: 800,
titleBarStyle: "hiddenInset"
})
https://electronjs.org/docs/api/frameless-window https://electronjs.org/docs/api/frameless-window
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.