mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-14 09:38:13 +08:00
✨ feat(store): 引入 theme
This commit is contained in:
@@ -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"],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user