refactor: ♻️ 主题色、主题、布局等设置重构

This commit is contained in:
郝先瑞
2024-02-22 23:09:41 +08:00
parent 11645b5df1
commit 56996ff213
12 changed files with 655 additions and 306 deletions

View File

@@ -35,8 +35,6 @@ export const useSettingsStore = defineStore("setting", () => {
tagsView,
sidebarLogo,
layout,
themeColor,
theme,
watermarkEnabled,
};
@@ -50,21 +48,41 @@ export const useSettingsStore = defineStore("setting", () => {
const setting = settingsMap[key];
if (setting) {
setting.value = value;
// Special handling for theme changes
if (key === "theme") {
document.documentElement.classList.toggle("dark", value === "dark");
}
}
}
/**
* 切换主题
*/
function changeTheme(val: string) {
theme.value = val;
}
/**
* 切换主题颜色
*/
function changeThemeColor(val: string) {
themeColor.value = val;
}
/**
* 切换布局
*/
function changeLayout(val: string) {
layout.value = val;
}
return {
tagsView,
fixedHeader,
sidebarLogo,
layout,
themeColor,
changeSetting,
theme,
watermarkEnabled,
changeSetting,
changeTheme,
changeThemeColor,
changeLayout,
};
});