css - 窗口透明时ElectronJS没有阴影
问题描述
我是 ElectronJs 的新手,我终于想出了如何获得圆角。
然而,现在我开始工作了,我注意到我失去了窗户上的阴影,为什么?
您可以在下面找到电子特定代码的整个 main.js 文件。
const electron = require("electron");
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
const path = require("path");
const isDev = require("electron-is-dev");
let mainWindow;
function createWindow() {
mainWindow = new BrowserWindow({
width: 900,
height: 680,
frame: false,
transparent: true,
hasShadow: true
});
mainWindow.loadURL(
isDev
? "http://localhost:3000"
: `file://${path.join(__dirname, "../build/index.html")}`
);
if (isDev) {
// Open the DevTools.
//BrowserWindow.addDevToolsExtension('<location to your react chrome extension>');
mainWindow.webContents.openDevTools();
}
mainWindow.on("closed", () => (mainWindow = null));
}
app.on("ready", () => {
createWindow();
});
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
});
app.on("activate", () => {
if (mainWindow === null) {
createWindow();
}
});
});
解决方案
因此,根据他们的文档,这是 ElectronJS 的一个已知限制,这是因为您设置了“transparent = true”:
“在 Mac 上,本机窗口阴影不会显示在透明窗口上。”
https://www.electronjs.org/docs/api/frameless-window#limitations
推荐阅读
- json - 如何在 dhtmlx 甘特图中添加许多属性?
- java - Mono.flatMap 在使用 MockWebServer 模拟响应时不起作用
- amazon-s3 - S3 生命周期 - 删除 x 个月前的文件
- web-scraping - 单击“_blank”后使用 Puppeteer 获取新页面的句柄?
- kotlin - 如何迭代字符列表并比较不同的元素
- asp.net - Json.NET 反序列化选择列表/多选列表
- mysql - IntelliJ 中列名旁边的图标是什么意思?
- c# - 仅使用 MSBuild BuildManager 构建单个项目
- javascript - 在循环中更改组件状态
- arrays - 在 go 中创建异构 json 数组