agent-ecosystem/landing/stores/theme.ts
777genius d018002c3e feat(docs): restructure VitePress IA, improve onboarding/troubleshooting docs
- Restructure sidebar: Start → Guide → Operations → Developers → Reference
- Fix EN/RU sidebar order (Installation before Quickstart)
- Expand troubleshooting with diagnostics commands and task-log triage
- Improve quickstart with prerequisites, pitfalls, and contributor links
- Expand installation docs with verification commands
- Add cyberpunk hero theme to landing page
- Add atomicFile utility with tests and stage-runtime script
- Harden team provisioning with better error handling and progress output
- Add cross-team communication, kanban, and workSync improvements
2026-05-15 23:34:06 +03:00

31 lines
824 B
TypeScript

import { defineStore } from "pinia";
type ThemeName = "light" | "dark";
export const useThemeStore = defineStore("theme", {
state: () => ({
current: "dark" as ThemeName,
userSelected: false
}),
actions: {
getInitialTheme(): ThemeName {
if (!import.meta.client) return "dark";
const saved = localStorage.getItem("theme");
if (saved === "dark" || saved === "light") {
this.userSelected = true;
return saved;
}
if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
return "dark";
}
return "dark";
},
setTheme(theme: ThemeName, fromUser: boolean) {
this.current = theme;
if (import.meta.client && fromUser) {
this.userSelected = true;
localStorage.setItem("theme", theme);
}
}
}
});