import { getConfig, getCurrentFloor, getGuideList, getTheme, getIndexList, getQMGoShopData } from '@/http/api' import { useStore } from '@/store/root' import VConsole from 'vconsole' export const useInitConfigAndMallInfo = async () => { const _config = await getConfig() const store = useStore() if (_config.data.debug) new VConsole() { const { data: theme } = await getTheme() const r = document.querySelector(':root') Object.entries(theme).forEach(([cat, obj]) => { Object.entries(obj).forEach(([k, v]) => r.style.setProperty(`--${cat}-${k}`, v)) }) theme.images = Object.entries(theme.image) .map(([k, v]) => [k, _config.data.sourceUrl + v]) .reduce((acc, [k, v]) => ({ ...acc, [k]: v }), {}) store.SET_THEME(theme) } store.SET_CONFIG(_config.data) const _currentFloor = await getCurrentFloor() store.SET_CURRENT_FLOOR(_currentFloor.data) const _guideList = await getGuideList() const { buildingList, shopList } = _guideList.data store.SET_SHOP_LIST(shopList.filter(({ yaxis }) => !!yaxis)) store.SET_BUILDING_LIST(buildingList) const res = await getIndexList() const { data } = res const { data: { searchList, recommendList } } = await getQMGoShopData() store.SET_INDEX_LIST({ ...data, recommendList, hotSearch: searchList }) }