mirror of
https://github.com/rustfs/console.git
synced 2026-09-19 01:47:44 +08:00
25 lines
552 B
TypeScript
25 lines
552 B
TypeScript
import { defineStore } from "pinia";
|
|
|
|
export const useThemeStore = defineStore(
|
|
"theme",
|
|
() => {
|
|
const appTheme = ref();
|
|
|
|
const setTheme = (theme: "dark" | "light") => {
|
|
appTheme.value = theme;
|
|
};
|
|
|
|
const isDarkTheme = () => {
|
|
return appTheme.value === "dark";
|
|
};
|
|
|
|
watch(appTheme, (value, oldValue) => {
|
|
document.body.setAttribute("data-theme", value);
|
|
document.body.classList.remove(oldValue);
|
|
document.body.classList.add(value);
|
|
});
|
|
|
|
return { appTheme, setTheme, isDarkTheme };
|
|
}
|
|
);
|