mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-11-14 13:13:43 +08:00
feat: change theme and index style
This commit is contained in:
15
web/src/store/theme.js
Normal file
15
web/src/store/theme.js
Normal 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
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user