更新时间:2023-10-20 08:43:58
制作无框透明窗口
const myWindow = new BrowserWindow({
transparent: true,
frame: false
})
在渲染器中添加类似的内容,或者将样式直接应用于body标签
And have something like this in the renderer, or apply the style directly to the body tag
<div style="width: 500px; height: 500px; border-radius: 5px">My window content</div>
只需确保还添加一个具有 -webkit-app-region:drag
的自定义窗口标题栏,以使该窗口可从此元素拖动.
Just make sure to also add a custom window titlebar that has -webkit-app-region: drag
in order to make the window dragable from this element.
查看电子文档以获取更多信息;) https://github.com/electron/electron/blob/master/docs/api/frameless-window.md#transparent-window
Check out the Electron Docs for further informations ;) https://github.com/electron/electron/blob/master/docs/api/frameless-window.md#transparent-window