import { defineStore } from "pinia";
import { type setType, store, getConfig } from "../utils";
import { transformI18n } from "@/plugins/i18n";
export const useSettingStore = defineStore({
  id: "setting",
  state: (): setType => ({
    title: transformI18n("title"),
    fixedHeader: getConfig().FixedHeader,
    hiddenSideBar: getConfig().HiddenSideBar
  }),
  getters: {
    getTitle() {
      return transformI18n("title");
    },
    getFixedHeader(state) {
      return state.fixedHeader;
    },
    getHiddenSideBar(state) {
      return state.hiddenSideBar;
    }
  },
  actions: {
    CHANGE_SETTING({ key, value }) {
      if (Reflect.has(this, key)) {
        this[key] = value;
      }
    },
    changeSetting(data) {
      this.CHANGE_SETTING(data);
    }
  }
});

export function useSettingStoreHook() {
  return useSettingStore(store);
}
