/* 系统动态配置配置 */
import { defineStore } from "pinia";
import { apiGetPublicSetting } from '@/api/common'

export const usePublicSettingStore = defineStore('publicSetting',{
  state: () => {
    return {
      publicSetting: {}
    }
  },

  actions: {
    async getPublicSetting() {
      const res = await apiGetPublicSetting();
      if(res.Ret !== 200) return
      let filterObj = {}
      let data = res.Data||[]
      data.forEach(item => {
        if(!filterObj[item.ConfKey]) {
          filterObj[item.ConfKey] = item.ConfVal;
        }
      })
      this.publicSetting = filterObj
    }
  }
})