MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / initAppTheme

Function initAppTheme

frontend/src/stores/useAppConfigStore.ts:83–103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

81 const resetTheme = () => (currentTheme.value = AppTheme.LIGHT);
82
83 const initAppTheme = async () => {
84 if (
85 isNaN(currentTheme.value) ||
86 currentTheme.value < AppTheme.AUTO ||
87 currentTheme.value > AppTheme.DARK
88 ) {
89 resetTheme();
90 }
91 const fn = {
92 [AppTheme.AUTO]: () => (isPreferredDark.value ? setDark() : setLight()),
93 [AppTheme.LIGHT]: () => setLight(),
94 [AppTheme.DARK]: () => setDark()
95 };
96 fn[currentTheme.value]?.();
97
98 const frontendSettings = await getSettingsConfig();
99 if (frontendSettings?.theme?.backgroundImage)
100 setBackgroundImage(frontendSettings.theme.backgroundImage);
101 const pos = frontendSettings?.theme?.sidebarPosition;
102 sidebarPosition.value = pos === "left" || pos === "right" ? pos : "left";
103 };
104
105 const setTheme = (t: AppTheme) => {
106 currentTheme.value = t;

Callers 2

setThemeFunction · 0.85

Calls 5

resetThemeFunction · 0.85
setDarkFunction · 0.85
setLightFunction · 0.85
getSettingsConfigFunction · 0.85
setBackgroundImageFunction · 0.85

Tested by

no test coverage detected