javascript - 不使用 index.html 时的自定义电子标题栏
问题描述
使用以下代码时:
mainWindow.loadURL(`http://www.google.com/`);
我无法使用 css/html 制作自定义标题栏,因为我没有使用 index.html,因为如果我使用此代码则可以:
loaderWindow.loadURL(`file:///${__dirname}/loader.html`);
我尝试过自定义 npm 包,例如电子标题栏窗口和自定义电子标题栏。当我从 loadURL 显示外部页面时,似乎没有任何效果。
这是我当前在渲染器过程中实现的自定义电子标题栏:
let MyTitleBar = new customTitlebar.Titlebar({
backgroundColor: customTitlebar.Color.fromHex('#03a9f4')
});
MyTitleBar.updateTitle('Test Title');
解决方案
您应该能够使用setTitle
文档
mainWindow.webContents.on('did-finish-load', () => {
mainWindow.setTitle('Test Title');
});
推荐阅读
- mongodb - SpringData MongoDB聚合投影排除
- javascript - 如何让打字稿知道函数类型
- java - 在android Java中获取列表文件文档,没有这样的文件或目录
- javascript - 从 JavaScript 更改 WTF 表单选定字段中的选定值
- android - 如何在适用于 Android 10/11 的 Packagemanager 中将 Android 应用列入白名单?
- elasticsearch - 是否可以为一个带有使用 debezium 和 kafka 的表的数据库创建一个 Elasticsearch 索引?
- uiimageview - 如何在另一个 UIImageView 上添加带有 PanGesture 的 UIImageView 然后将其保存为新的一个图像?
- html - Bootstrap 4折叠按钮不可见
- android - LiveData 没有观察具有共享视图模型的子视图页面片段
- flutter - 实现 setstat 和绑定变量