You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

34 lines
1.2 KiB

import { getConfig, getCurrentFloor, getGuideList, getTheme, 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 {
data: { searchList, recommendList }
} = await getQMGoShopData()
store.SET_INDEX_LIST({ recommendList, hotSearch: searchList })
}