import { defineStore } from "pinia";
import { theme } from "@/settings/designSetting";
import { setLocalStorage, getLocalStorage } from "@/utils";
// import { useDarkThemeHook } from '@/hooks'

const DESIGN_THEME = "DESIGN_THEME";
const storageDesign = getLocalStorage(DESIGN_THEME);

export const useDesignStore = defineStore("useDesignStore", {
  state: () =>
    storageDesign || {
      // 是否暗黑
      ...theme,
    },
  persist: true,
  getters: {
    getDarkTheme() {
      return this.darkTheme;
    },
    getAppTheme() {
      return this.appThemeDetail;
    },
  },
  actions: {
    // 切换主题
    changeTheme(e) {
      this.darkTheme = e;
      setLocalStorage(DESIGN_THEME, this.$state);
      // useDarkThemeHook()
    },
    // 设置主题色
    setStateValue(e) {
      this.appThemeDetail = e;
      setLocalStorage(DESIGN_THEME, this.$state);
      // useDarkThemeHook()
    },
  },
});
