feat(store): 引入 theme

This commit is contained in:
BTMuli
2023-04-21 12:57:51 +08:00
parent 9b53cfc187
commit 7b443ee5b5

View File

@@ -38,6 +38,8 @@ export const useAppStore = defineStore(
}); });
// 开发者模式 // 开发者模式
const devMode = ref(false); const devMode = ref(false);
// 应用主题
const theme = ref("default");
const dataPath = reactive({ const dataPath = reactive({
appDataDir, appDataDir,
@@ -62,6 +64,7 @@ export const useAppStore = defineStore(
devMode.value = false; devMode.value = false;
sidebar.submenu.mihoyo = false; sidebar.submenu.mihoyo = false;
sidebar.submenu.wiki = false; sidebar.submenu.wiki = false;
theme.value = "default";
} }
function getSubmenu (): string[] { function getSubmenu (): string[] {
@@ -71,7 +74,13 @@ export const useAppStore = defineStore(
return open; return open;
} }
function changeTheme (): void {
if (theme.value === "default") theme.value = "dark";
else theme.value = "default";
}
return { return {
theme,
loading, loading,
sidebar, sidebar,
devMode, devMode,
@@ -80,6 +89,7 @@ export const useAppStore = defineStore(
userPath, userPath,
init, init,
getSubmenu, getSubmenu,
changeTheme,
}; };
}, },
{ {
@@ -99,6 +109,11 @@ export const useAppStore = defineStore(
storage: window.localStorage, storage: window.localStorage,
paths: ["sidebar"], paths: ["sidebar"],
}, },
{
key: "theme",
storage: window.localStorage,
paths: ["theme"],
},
], ],
}, },
); );