diff --git a/api/alert/alert.js b/api/alert/alert.js index bad4ecec3eee4c914a085a154b188f8eff14b243..0c93296eb9b218d1a155d8e9fea38c3e6d47837a 100644 --- a/api/alert/alert.js +++ b/api/alert/alert.js @@ -1,6 +1,10 @@ import axios from '@/resources/api/http.js'; const alert = { + //获取ALERT的视图列表 + updateAlertMenu() { + return axios.post('/api/rest/alert/view/list', {}); + }, getAlertViewById(id) { return axios.post('/api/rest/alert/view/get', { id: id }); }, diff --git a/store/modules/topMenu.js b/store/modules/topMenu.js new file mode 100644 index 0000000000000000000000000000000000000000..1f8ac3bd838f0e5d3f9988b290b1d2f23994b952 --- /dev/null +++ b/store/modules/topMenu.js @@ -0,0 +1,25 @@ +import alertApi from '@/community-module/alert/api/alert/alert.js'; +async function updateAlertMenu({ commit, state, rootState, forceUpdate = true, hasCustomMenuAuthority } = {}) { + 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 alertApi.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 + } + ]; + commit('updateMenu', { module: alertModule, startIndex: 0, newMenuGroup }); + return res; +} +export default updateAlertMenu;