ReMe/reme_studio/app/theme.ts
jinliyl ef3f99f019
refactor(packaging): reorganize published packages (#495)
* refactor(packaging): reorganize published packages

* fix(packaging): install AgentScope extra in wheel smoke

* docs: align package guides and documentation site

* ci(workflow): add core dependency verification step in Python package build

- Add a workflow step to verify released core dependencies by installing the wheel with core extras
- Assert the presence of the static index.html file to ensure proper package contents
- Create and use a temporary virtual environment for isolation during verification
- Keep existing artifacts upload step intact and conditional on inputs.upload_artifacts flag

* fix(ci): update package installation dependencies in Windows workflow

- Change pip install from editable reme_studio and core to only dev and as extras
- Remove installation of reme_studio and core to streamline dependency setup
- Ensure Windows CI uses the correct extras for testing environment

* fix(tests): add missing commas in toml file reads in package version tests

- Added trailing commas in the tomllib.loads calls for auto-fin and daily_paper configs
- Ensured consistent syntax to prevent potential tuple misinterpretation
- Improved readability and correctness of the test setup code

* fix(packaging): protect qwenpaw releases and test Studio health
2026-08-27 14:02:09 +08:00

57 lines
1.7 KiB
TypeScript

"use client";
import { create } from "zustand";
export type ThemePreference = "light" | "dark" | "system";
export type ResolvedTheme = "light" | "dark";
const STORAGE_KEY = "reme-theme";
let listeningForSystemTheme = false;
const resolveTheme = (preference: ThemePreference): ResolvedTheme =>
preference === "system" && typeof window !== "undefined"
? window.matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "light"
: preference === "dark"
? "dark"
: "light";
const applyTheme = (preference: ThemePreference) => {
const resolved = resolveTheme(preference);
if (typeof document !== "undefined")
document.documentElement.dataset.theme = resolved;
return resolved;
};
interface ThemeState {
preference: ThemePreference;
resolved: ResolvedTheme;
hydrate: () => void;
setPreference: (preference: ThemePreference) => void;
}
export const useThemeStore = create<ThemeState>((set, get) => ({
preference: "system",
resolved: "light",
hydrate: () => {
const saved = localStorage.getItem(STORAGE_KEY);
const preference: ThemePreference =
saved === "light" || saved === "dark" || saved === "system"
? saved
: "system";
set({ preference, resolved: applyTheme(preference) });
if (listeningForSystemTheme) return;
listeningForSystemTheme = true;
window
.matchMedia("(prefers-color-scheme: dark)")
.addEventListener("change", () => {
if (get().preference === "system")
set({ resolved: applyTheme("system") });
});
},
setPreference: (preference) => {
localStorage.setItem(STORAGE_KEY, preference);
set({ preference, resolved: applyTheme(preference) });
},
}));