Login:Hooks:UseTheme: change theme initial state
This commit is contained in:
parent
be507f9865
commit
a57f6aaca5
@ -63,18 +63,35 @@ const useTheme = ({ user, colorTheme, systemTheme, i18n }: UseThemeProps) => {
|
|||||||
({} as TColorScheme)
|
({} as TColorScheme)
|
||||||
: ({} as TColorScheme);
|
: ({} as TColorScheme);
|
||||||
|
|
||||||
const newTheme = match<MatchType>([user?.theme, systemTheme])
|
let newTheme;
|
||||||
.returnType<TTheme>()
|
|
||||||
.with([ThemeKeys.DarkStr, P._], () => Dark)
|
if (user?.theme === ThemeKeys.DarkStr) {
|
||||||
.with([ThemeKeys.BaseStr, P._], () => Base)
|
newTheme = Dark;
|
||||||
.with([ThemeKeys.SystemStr, ThemeKeys.BaseStr], () => Base)
|
}
|
||||||
.with([ThemeKeys.SystemStr, ThemeKeys.DarkStr], () => Dark)
|
if (user?.theme === ThemeKeys.BaseStr) {
|
||||||
.with([undefined, ThemeKeys.DarkStr], () => Dark)
|
newTheme = Base;
|
||||||
.with([undefined, ThemeKeys.BaseStr], () => Base)
|
}
|
||||||
.otherwise(() => Base);
|
if (
|
||||||
|
user?.theme === ThemeKeys.SystemStr &&
|
||||||
|
systemTheme === ThemeKeys.BaseStr
|
||||||
|
) {
|
||||||
|
newTheme = Base;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
user?.theme === ThemeKeys.SystemStr &&
|
||||||
|
systemTheme === ThemeKeys.DarkStr
|
||||||
|
) {
|
||||||
|
newTheme = Dark;
|
||||||
|
}
|
||||||
|
if (!user?.theme && systemTheme === ThemeKeys.DarkStr) {
|
||||||
|
newTheme = Dark;
|
||||||
|
}
|
||||||
|
if (!user?.theme && systemTheme === ThemeKeys.BaseStr) {
|
||||||
|
newTheme = Base;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...newTheme,
|
...(newTheme ?? Base),
|
||||||
currentColorScheme: currColorTheme,
|
currentColorScheme: currColorTheme,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user