import { useDark, useToggle } from "@vueuse/core";
const useThemeStore = defineStore("themeStore", {
  state: () => {
    return {
      currentTheme: "light", //light 白色 drak 深色模式
    };
  },
  persist: {
    enabled: true,
    strategies: [{ key: "theme_store", storage: localStorage }],
  },
  actions: {
    changeCurreneTheme() {
      this.currentTheme = this.currentTheme === "light" ? "dark" : "light";
      this.transferClass();
    },
    transferClass() {
      if (this.currentTheme === "dark") {
        document.documentElement.classList.add("dark");
      } else {
        document.documentElement.classList.remove("dark");
      }
    },
  },
});
export default useThemeStore;
