const state = () => { return { platformInfo: null, menuShrink: false, size: 'small', activeRoute: '', } } // getters const getters = { platformName(state) { return state?.platformInfo?.name }, logo(state) { return state?.platformInfo?.logo }, noAnswerTip(state) { return state?.platformInfo?.noAnswerTip }, } // actions const actions = { async getPlatformInfo({ commit }) { const { code, data } = await this.$elBusHttp.request('api/ua/platform/info') if (code === 0) { commit('SET_PLATFORM_INFO', data) } }, } // mutations const mutations = { SET_PLATFORM_INFO(state, platformInfo) { state.platformInfo = platformInfo }, // 设置菜单的展开和收缩 SET_MENU_SHRINK(state, shrink) { state.menuShrink = shrink }, // 设置当前选中的路由 SET_ACTIVE_ROUTE(state, route) { state.activeRoute = route }, SET_SIZE(state, size) { this.$elBusCookie.set('size', size) state.size = size }, } export default { namespaced: true, state, getters, actions, mutations, }