diff --git a/src/resources/api/common/index.js b/src/resources/api/common/index.js index 2bb8016fce69dd911fd6f099f02088bf2013de90..04c8344ada67dfd8894bd8376a786ecccf3bf2fa 100644 --- a/src/resources/api/common/index.js +++ b/src/resources/api/common/index.js @@ -166,10 +166,6 @@ const common = { updateCmdbMenu(params) { return axios.post('/api/rest/cmdb/ci/citype/search', params); }, - //后去ALERT的视图列表 - updateAlertMenu() { - return axios.post('/api/rest/alert/view/list', {}); - }, // 获取工单中心分类 updateProcessMenu(params) { return axios.post('/api/rest/workcenter/list', params); diff --git a/src/resources/store/modules/topMenu.js b/src/resources/store/modules/topMenu.js index 0f0fb2bc68de5863435b7fea7d39c1174e65bc3c..cf2871971eee9851baf64bf4f8864516c18d91cd 100644 --- a/src/resources/store/modules/topMenu.js +++ b/src/resources/store/modules/topMenu.js @@ -86,39 +86,27 @@ const actions = { }, // 更新模块菜单 - updateMenu({ dispatch }, { forceUpdate = false } = {}) { + updateMenu({ dispatch, commit, state, rootState }, { forceUpdate = false } = {}) { dispatch('updateProcessMenu', { forceUpdate }); dispatch('updateKnowledgeMenu', { forceUpdate }); dispatch('updateDashboardMenu', { forceUpdate }); dispatch('updateReportMenu', { forceUpdate }); dispatch('updateCmdbMenu', { forceUpdate }); dispatch('updateInspectMenu', { forceUpdate }); - dispatch('updateAlertMenu', { forceUpdate }); - }, - - // alert - async updateAlertMenu({ commit, state, rootState }, { forceUpdate = true } = {}) { - await state.gettingModuleList; - const alertModule = state.moduleList.find(item => item.moduleId === 'alert'); - if (!alertModule || (!forceUpdate && state.dynamicMenu.hasOwnProperty('alert')) || !hasCustomMenuAuthority('alert', 'alert-manage')) { - return; - } - const res = await commonApi.updateAlertMenu(); - if (!res.Return || res.Return.length === 0) return; - const alertViewList = res.Return.map(view => ({ - name: view.label, - path: `/alert-manage/${view.name}`, - url: `/alert-manage/${view.name}`, - icon: 'tsfont-dot' - })); - const newMenuGroup = [ - { - menuTypeName: '告警视图', - menuList: alertViewList - } + + const moduleContexts = [ + require.context('@/community-module/', true, /store\/modules\/topMenu\.js$/), + require.context('@/commercial-module/', true, /store\/modules\/topMenu\.js$/) ]; - commit('updateMenu', { module: alertModule, startIndex: 0, newMenuGroup }); - return res; + const args = { commit, dispatch, state, rootState, forceUpdate, hasCustomMenuAuthority }; + moduleContexts.forEach((context) => { + context.keys().forEach((path) => { + const fn = context(path) && context(path).default; + if (fn && typeof fn === 'function') { + fn(args); + } + }); + }); }, // process