【发布时间】:2018-02-19 10:41:14
【问题描述】:
我正在使用 Electron 和 React 开发适用于 Mac OSX 和 Windows 的应用。我们的设计师团队希望应用程序具有圆形边框。他们想要或多或少像这样的东西:
我正在使用以下在 Mac 上运行良好的代码
在我的main.dev.js:
mainWindow = new BrowserWindow({
show: false,
width: 1024,
height: 728,
hasShadow: false,
frame: false, // Important!
transparent: true // Important!
});
在我的app.global.css:
body {
position: relative;
height: 100vh;
font-family: Arial, Helvetica, Helvetica Neue, serif;
overflow-y: hidden;
background-color:rgba(0,0,0,0); /* Important! */
-webkit-app-region: drag;
}
在我的DisplayBar React 组件上:
class DisplayBar extends React.Component {
render() {
return (
<div style={styles.container}>
{this.props.children}
</div>);
}
}
const styles = {
container: {
backgroundColor: '#333333',
borderRadius: 40, // Important!
display: 'flex',
height: '100%',
border: '2px solid white',
alignItems: 'center',
justifyContent: 'flex-end'
}
};
正如我所说,它在 Mac 上运行良好,但在 Windows 上它什么也不显示,只是一个透明屏幕。你知道这个问题的任何解决方案吗?
PS:来自西班牙的问候!
编辑
我发现我有一些缺少依赖项的问题,我运行了以下命令:
npm install --global --production windows-build-tools
我在 this question 上找到它。
我的开发工具控制台上仍然出现以下错误:
【问题讨论】:
标签: javascript electron