fix(fe/theme): enable theme immediately if auto theme is enabled
This commit is contained in:
parent
20b7cdaa7f
commit
3b42272d53
2 changed files with 16 additions and 9 deletions
|
@ -80,10 +80,14 @@ export class RootFrame extends React.Component<Props, State, {}> {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const bgStyle = this.makeBgStyle();
|
const bgStyle = this.makeBgStyle();
|
||||||
const theme =
|
const autoTheme =
|
||||||
|
updater().getCurrentTheme() === "light" ? "theme-default" : "theme-dark";
|
||||||
|
const fixedTheme =
|
||||||
this.props.login.preferences.theme === "light"
|
this.props.login.preferences.theme === "light"
|
||||||
? "theme-default"
|
? "theme-default"
|
||||||
: "theme-dark";
|
: "theme-dark";
|
||||||
|
const theme = this.props.ui.clientCfg.autoTheme ? autoTheme : fixedTheme;
|
||||||
|
|
||||||
const fontSizeClass = "font-m";
|
const fontSizeClass = "font-m";
|
||||||
|
|
||||||
const displaying = this.props.ui.control.controls.get(controlName);
|
const displaying = this.props.ui.control.controls.get(controlName);
|
||||||
|
|
|
@ -789,20 +789,23 @@ export class Updater {
|
||||||
this.props.login.preferences.theme = theme;
|
this.props.login.preferences.theme = theme;
|
||||||
};
|
};
|
||||||
|
|
||||||
autoSwitchTheme = () => {
|
getCurrentTheme = () => {
|
||||||
if (!this.props.ui.clientCfg.autoTheme) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(date.getHours() >= 18 && date.getHours() <= 23) ||
|
(date.getHours() >= 18 && date.getHours() <= 23) ||
|
||||||
(date.getHours() >= 0 && date.getHours() <= 6)
|
(date.getHours() >= 0 && date.getHours() <= 6)
|
||||||
) {
|
) {
|
||||||
this.setTheme("dark");
|
return "dark";
|
||||||
} else {
|
|
||||||
this.setTheme("light");
|
|
||||||
}
|
}
|
||||||
|
return "light";
|
||||||
|
};
|
||||||
|
|
||||||
|
autoSwitchTheme = () => {
|
||||||
|
if (!this.props.ui.clientCfg.autoTheme) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.setTheme(this.getCurrentTheme());
|
||||||
};
|
};
|
||||||
|
|
||||||
setControlOption = (controlName: string, option: string): boolean => {
|
setControlOption = (controlName: string, option: string): boolean => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue