diff --git a/src/App.vue b/src/App.vue
index 80fcc63a..9ca43214 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -42,6 +42,9 @@ const appStore = useAppStore();
const isMain = ref(true as boolean);
onMounted(async () => {
+ // 获取当前主题
+ const theme = appStore.theme;
+ document.documentElement.className = theme;
// 获取当前窗口
const win = window.getCurrent();
isMain.value = win.label === "tauri-genshin";
@@ -93,7 +96,7 @@ async function writeIndex () {
diff --git a/src/assets/index.css b/src/assets/index.css
index 0a27cbf5..15a3a7f3 100644
--- a/src/assets/index.css
+++ b/src/assets/index.css
@@ -1,4 +1,6 @@
@import "fonts/index.css";
+@import url("themes/default.css");
+@import url("themes/dark.css");
/*
* @description 侧边滚动条样式
diff --git a/src/components/t-sidebar.vue b/src/components/t-sidebar.vue
index eb85d5be..755a6ddf 100644
--- a/src/components/t-sidebar.vue
+++ b/src/components/t-sidebar.vue
@@ -1,5 +1,5 @@
-
+
@@ -120,6 +120,13 @@
-->
+
+
+
+ {{ themeGet === 'default' ? 'mdi-weather-sunny' : 'mdi-weather-night' }}
+
+
+
@@ -139,6 +146,18 @@ import { useAppStore } from "../store/modules/app";
const appStore = useAppStore();
const rail = ref(appStore.sidebar.collapse);
+// theme
+const themeGet = computed({
+ get () {
+ return appStore.theme;
+ },
+ set (value: string) {
+ appStore.theme = value;
+ },
+});
+const themeTitle = computed(() => {
+ return themeGet.value === "default" ? "切换为夜间模式" : "切换为日间模式";
+});
const open = computed({
get () {
@@ -154,6 +173,13 @@ function collapse () {
rail.value = !rail.value;
appStore.sidebar.collapse = rail.value;
}
+
+function switchTheme () {
+ themeGet.value = themeGet.value === "default" ? "dark" : "default";
+ appStore.theme = themeGet.value;
+ document.documentElement.className = themeGet.value;
+}
+