import { getConfigAPI } from '@/api/system'
import type { ConfigItem } from '@/types/system'
import { defineStore } from 'pinia'
import { ref } from 'vue'

export const system = defineStore(
  'system',
  () => {
    const config = ref<ConfigItem>({
      qcc: '',
      captcha: '',
      background: '',
      name: '',
      sms: '',
      logo: '',
      weblogo: '',
      email: '',
      register: ''
    })
    const getConfigData = async () => {
      const res = await getConfigAPI()
      config.value = res.data
    }
    // 工作台是否已加载
    const isLoad = ref(false)
    const setLoad = (val: boolean) => {
      isLoad.value = val
    }
    // 清空所有信息
    const clearInfo = () => {
      isLoad.value = false
    }
    return {
      config,
      isLoad,
      getConfigData,
      clearInfo,
      setLoad
    }
  }
  // 持久化配置
  // {
  //   persist: {
  //     paths: [],
  //     storage: {

  //     }
  //   }
  // }
)
