mirror of
https://github.com/msojocs/wechat-web-devtools-linux.git
synced 2025-07-22 00:00:04 +08:00
update: theme-check
This commit is contained in:
parent
cc8bf6af19
commit
a7a2c98d25
@ -24,6 +24,9 @@ class CheckDark {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
console.warn(
|
||||||
|
`NOT SUPPORTED !!! DESKTOP_SESSION: ${DESKTOP_SESSION}`
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
monitor &&
|
monitor &&
|
||||||
@ -32,8 +35,13 @@ class CheckDark {
|
|||||||
});
|
});
|
||||||
monitor &&
|
monitor &&
|
||||||
monitor.stdout.on("data", (chunk) => {
|
monitor.stdout.on("data", (chunk) => {
|
||||||
|
// TODO: 防抖动包装
|
||||||
const data = chunk.toString();
|
const data = chunk.toString();
|
||||||
|
const t = data.includes("dark");
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
console.log("dark", t);
|
||||||
|
// (this._theme = t ? i.Dark : i.Light),
|
||||||
|
// this._onDidThemeChange.fire(this._theme);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
get isDark() {
|
get isDark() {
|
||||||
@ -80,6 +88,7 @@ function original() {
|
|||||||
exports.OSThemeController = class {
|
exports.OSThemeController = class {
|
||||||
constructor() {
|
constructor() {
|
||||||
(this._onDidThemeChange = new t.EasyEmitter()),
|
(this._onDidThemeChange = new t.EasyEmitter()),
|
||||||
|
// debounce, 防抖动, 该函数会从上一次被调用后,延迟 400 毫秒后调用 func 方法
|
||||||
(this.onMediaQueryChange = e.debounce((e) => {
|
(this.onMediaQueryChange = e.debounce((e) => {
|
||||||
console.warn("onMediaQueryChange", e);
|
console.warn("onMediaQueryChange", e);
|
||||||
const t = e.matches;
|
const t = e.matches;
|
||||||
@ -134,6 +143,7 @@ function original() {
|
|||||||
}
|
}
|
||||||
tryGetCurrentTheme() {
|
tryGetCurrentTheme() {
|
||||||
if (this.isEnabled()) {
|
if (this.isEnabled()) {
|
||||||
|
// return this.isDark ? i.Dark : i.Light;
|
||||||
return this.mediaQuery.matches ? i.Dark : i.Light;
|
return this.mediaQuery.matches ? i.Dark : i.Light;
|
||||||
}
|
}
|
||||||
return i.Unknown;
|
return i.Unknown;
|
||||||
@ -159,6 +169,28 @@ function original() {
|
|||||||
this._mediaQuery2
|
this._mediaQuery2
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
get isDark() {
|
||||||
|
const { DESKTOP_SESSION } = process.env;
|
||||||
|
console.log(DESKTOP_SESSION);
|
||||||
|
let theme = "";
|
||||||
|
switch (DESKTOP_SESSION) {
|
||||||
|
case "deepin":
|
||||||
|
theme = execSync(
|
||||||
|
`gsettings get com.deepin.dde.appearance gtk-theme`
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case "gnome":
|
||||||
|
case "gnome-classic":
|
||||||
|
theme = execSync(
|
||||||
|
`gsettings get org.gnome.desktop.interface gtk-theme`
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return theme.includes("dark");
|
||||||
|
}
|
||||||
getDefaultTheme() {
|
getDefaultTheme() {
|
||||||
return i.Dark;
|
return i.Dark;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user