[英]How to make a semi-transparent app background with electron?
在main.js文件中设置浏览器窗口时,将vibrancy选项设置为电子选项之一。
下面是electrons documents
的片段
"vibrancy String (optional) - Add a type of vibrancy effect to the window, only on macOS.
Can be appearance-based, light, dark, titlebar, selection, menu, popover, sidebar, medium-light or ultra-dark."
https://github.com/arkenthera/electron-vibrancy/blob/master/README.md
示例js代码,如果使用超暗主题
让mainWindow;
const createWindow = () => {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 800,
height: 600,
vibrancy: 'ultra-dark',
});
};
在设置了主窗口的背景和振动设置后,只需用侧边栏和主要内容将窗口分开。 将main的背景颜色设置为您希望离开侧边栏的任何颜色仍然具有OSX样式透明度
我希望这有帮助
你可以在window setOpacity(number)
上使用一个函数,其中number可以根据你的喜好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.