feat: change theme and index style

This commit is contained in:
廖庆斯
2024-11-20 00:09:25 +08:00
parent 6aaf607ed7
commit 9a97a1ee72
19 changed files with 5190 additions and 14633 deletions

15
web/src/store/theme.js Normal file
View File

@@ -0,0 +1,15 @@
// src/store/index.js
import { defineStore } from "pinia";
export const useThemeStore = defineStore("theme", {
state: () => ({
theme: localStorage.getItem("theme") || "light" // 默认从 localStorage 获取主题
}),
actions: {
setTheme(theme) {
this.theme = theme;
document.documentElement.setAttribute("data-theme", theme);
localStorage.setItem("theme", theme); // 保存到 localStorage
}
}
});