Giter Site home page Giter Site logo

Comments (9)

msojocs avatar msojocs commented on May 16, 2024

基于chromium的浏览器似乎都存在此问题(Linux不兼容)
测试了一下Edge [ Version 100.0.1185.29 (Official build) (64-bit) ],同样不支持亮暗色识别(默认总是亮的)

https://bugs.chromium.org/p/chromium/issues/detail?id=998903
相关代码:
window.matchMedia("(prefers-color-scheme)")
window.matchMedia("(prefers-color-scheme:dark)")
window.matchMedia("(prefers-color-scheme:light)")

可能的处理方案

虽然目前浏览器不支持,但可以间接实现。
执行如gsettings get org.gnome.desktop.interface gtk-theme这样的命令来获取主题的亮暗。
使用上方代码指令替换(prefers-color-scheme)相关的查询语句,这样可以实现目的;
但是,这个实现比较复杂,因为Linux的桌面不是只有一个;
ddegnomekde等,这些桌面的查询方式都不一样。

结论

暂不处理
edit: 考虑到deepin,也使用了gtk的操作,就准备处理,有不兼容再加上

补充

edit: 参考:https://wiki.archlinux.org/title/Dark_mode_switching

deepin

deepin获取当前主题:

  1. gsettings get com.deepin.dde.appearance gtk-theme
  2. gsettings get com.deepin.xsettings theme-name
    相关脚本
#!/bin/bash
for scheme in $(gsettings list-schemas | grep deepin);
do
	echo "=====$scheme====="
	gsettings list-keys $scheme | grep theme
done

gnome

gnome获取当前主题:
gsettings get org.gnome.desktop.interface gtk-theme

from wechat-web-devtools-linux.

msojocs avatar msojocs commented on May 16, 2024

https://github.com/msojocs/wechat-web-devtools-linux/releases/tag/continuous

from wechat-web-devtools-linux.

msojocs avatar msojocs commented on May 16, 2024

请尝试最新的continuous版本是否符合预期

from wechat-web-devtools-linux.

icepie avatar icepie commented on May 16, 2024

辛苦了,一会就测

from wechat-web-devtools-linux.

icepie avatar icepie commented on May 16, 2024

貌似重新构建后在gnome不起作用

可能是我姿势问题,正在下载action的自动构建里的aur包

from wechat-web-devtools-linux.

icepie avatar icepie commented on May 16, 2024

已找到问题所在, 在 gnome 下很多第三方GTK主题都是以 Dark 结尾标明暗色的, 由于我使用了 Flat-Remix-Theme 所以会导致没能切换....这个处理起来相对容易

另外在 gnome42 的环境下, 已经官方支持了亮暗色主题...可以通过

 $ gsettings get org.gnome.desktop.interface color-scheme

判断该值是否为 prefer-dark 来更准确的判断是否处于暗色模式!

from wechat-web-devtools-linux.

msojocs avatar msojocs commented on May 16, 2024

感谢提交PR
新的continuous版本已完成构建

from wechat-web-devtools-linux.

icepie avatar icepie commented on May 16, 2024

感谢, 经测试 continuous 版本主题跟随系统已可用!

但是在aur的构建脚本当中, nwjsnodejs 版本, 还未得到更新...

from wechat-web-devtools-linux.

msojocs avatar msojocs commented on May 16, 2024

好的,感谢测试
aur脚本会进行跟进的。

from wechat-web-devtools-linux.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.