import { configList } from '@/api/login'
import Vue from 'vue'

const appConfig = {
    namespaced: true,
    state: {
        configList: {} ,//系统配置,
    },
    mutations: {
        SET_CONFIGLIST: (state, configList) => {
            state.configList = configList
        },
    },
    actions: {
        // 获取配置信息
        ConfigList({ commit }) {
			
            configList({envCode: Vue.prototype.$PLATFORM}).then(res => {
                let { data } = res
                commit('SET_CONFIGLIST', data)

                //设置图标
                // #ifdef H5
                let url = data?.h5_tab_icon?.configValue
                let favicon = document.querySelector('link[rel="icon"]');
                if (favicon !== null) {
                    favicon.href = url;
                } else {
                    favicon = document.createElement("link");
                    favicon.rel = "icon";
                    favicon.href = url;
                    document.head.appendChild(favicon);
                }
                // console.log('设置图标', favicon)
                // #endif
            })
        },
		
    }
}

export default appConfig