import { $getSiteInfos } from '@/api/manage'
import storage from 'store'
import { useOem } from '@/store/modules/oem'

/** http查询 & 放置到locationstore中 **/
export let setSiteInfos = () => {
    return $getSiteInfos().then((infoRes) => {

        let infos = infoRes.siteInfo

        let agentDomainName = infoRes.agentDomainName || "p.rscygroup.com" as  any
        let mchDomainName = infoRes.mchDomainName || "b.rscygroup.com" as  any
        infos.agentDomainName = "https://"+agentDomainName  as any
        infos.mchDomainName = "https://"+mchDomainName as any

        infos.sysLogoUrl = infos.mch.sysLogoUrl || infos.sysLogoUrl
        infos.sysMinLogoUrl = infos.mch.sysMinLogoUrl || infos.sysMinLogoUrl
        infos.darkSysLogoUrl = infos.mch.darkSysLogoUrl || infos.darkSysLogoUrl
        infos.darkSysMinLogoUrl = infos.mch.darkSysMinLogoUrl || infos.darkSysMinLogoUrl

        // @ts-ignore: 放置到 localstore
        storage.set(window.$SITE_INFO_NAME, infoRes)

        // 放置到store中
        useOem().refInfo(infoRes)
        
    })
}

