javascript - 电子“-webkit-app-region:拖动”在 BrowserView 内容中不起作用
问题描述
在我的 Electron 应用程序中,我正在创建一个BrowserWindow
:
let window = new BrowserView({
title: "My App",
frame: false,
show: false
}
然后我正在加载BrowserView
:
let view = new BrowserView();
window.setBrowserView(view);
view.setBounds({ x: 0, y: 0, width: window.getContentBounds().width, height: window.getContentBounds().height });
view.setAutoResize({ width: true, height: true});
view.webContents.loadURL("MY URL HERE");
在加载到的内容中BrowserView
,我正在尝试创建一个自定义标题栏,并且我做了类似的事情:
<div id="windowBar">
<div id="draggableArea">
<div id="title"><span>My App</span></div>
<div id="controls">
<!-- The window controls to minimize/maximize/close the window here !-->
</div>
</div>
</div>
我想让它拖动整个 Electron 窗口,所以我添加了 CSS:
#windowBar {
height: 30px;
width: 100%;
position: fixed;
}
#draggableArea {
width: 100%;
height: 100%;
-webkit-app-region: drag;
}
#title {
-webkit-app-region: drag;
user-select: none;
}
#controls {
-webkit-app-region: no-drag;
}
我无法从文档以及我在网上找到的所有其他内容中判断这是否应该有效。或者是否需要将标题栏的 HTML 直接加载到其中BrowserWindow
才能正常工作?
解决方案
推荐阅读
- python - 在文本块的末尾添加缺少的句号
- solidity - Solidity:这些句子是一样的吗?还是他们的意思不同?
- azure - 通过 ADF 按交易日期拆分文件
- mysql - 我找不到文件“my.cnf”或“my.ini”
- firebase - Firebase 检查项目是否不在 Flutter 中的数组中
- android - 服务器证书不受信任 - Android Studio
- r - For循环包括零
- sql - 我正在尝试做的是获得每个项目过去一年中每一天的运行库存水平
- javascript - 如何在javascript中使用axios发送文件和正文?
- amazon-web-services - 适用于 kafka 消费者应用程序的 AWS 自动扩展策略