简体   繁体   English

Electron 忽略 @css 首选颜色方案

[英]Electron ignores @css prefers-color-scheme

I have made an Electron project and now added dark mode support to it.我制作了一个 Electron 项目,现在为它添加了暗模式支持。 The problem is that it for some reason doesn't work.问题是它由于某种原因不起作用。

Below is my dark.css styling included in every page下面是每个页面中包含的我的dark.css样式

@media (prefers-color-scheme: dark) {
body, .full-screen, #code {
  transition-duration: 500ms;
  background: #444 !important;
  color: #e4e4e4 !important;
}
.title-bar {
  background: rgb(58, 58, 58) !important;
}
}

How is this possible?这怎么可能? I've heard you can use systemPreferences.isDarkMode() but that is for the main process and I want it to be reflected in the frontend + I want it to update automatically.我听说您可以使用systemPreferences.isDarkMode()但这是用于主进程,我希望它反映在前端 + 我希望它自动更新。

Thanks in advance提前致谢

As it turns out, I had to reinstall NPM and electron.事实证明,我不得不重新安装 NPM 和电子。 I also had to run npm config set ignore-scripts false .我还必须运行npm config set ignore-scripts false That was the trick这就是诀窍

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM