diff --git a/src/components/Layout/components/Notice.vue b/src/components/Layout/components/Notice.vue index a803abdc..d1685f21 100644 --- a/src/components/Layout/components/Notice.vue +++ b/src/components/Layout/components/Notice.vue @@ -11,7 +11,7 @@ @@ -27,6 +27,7 @@ import { changeStatus_api } from '@/api/account/notificationRecord'; import { useUserInfo } from '@/store/userInfo'; import { useMenuStore } from '@/store/menu'; +import { getAllNotice } from '@/api/account/center'; const updateCount = computed(() => useUserInfo().alarmUpdateCount); const menuStory = useMenuStore(); @@ -100,6 +101,7 @@ const read = (type: string, data: any) => { // 查询未读数量 const getList = () => { + if(tabs.value.length <= 0) return; loading.value = true; const params = { sorts: [{ @@ -137,9 +139,51 @@ const handleRead = () => { watch(updateCount, () => getList()); +const tab = [ + { + key: 'alarm', + tab: '告警', + type: [ + 'alarm-product', + 'alarm-device', + 'alarm-other', + 'alarm-org', + 'alarm', + ], + }, + { + key: 'system-monitor', + tab: '系统监控', + type: ['system-event'], + }, + { + key: 'system-business', + tab: '业务监控', + type: ['device-transparent-codec'], + }, +]; + +const tabs = ref([]); + +const queryTypeList = async () => { + const resp: any = await getAllNotice(); + if (resp.status === 200) { + const provider = resp.result.map((i: any) => i.provider) || []; + const arr = tab.filter((item: any) => { + const _arr = [...provider, item.type] + return new Set(_arr).size < _arr.length + }); + + tabs.value = arr; + if(arr.length > 0) { + subscribeNotice(); + getList(); + } + } +}; + onMounted(() => { - subscribeNotice(); - getList(); + queryTypeList() }) diff --git a/src/components/Layout/components/NoticeInfo.vue b/src/components/Layout/components/NoticeInfo.vue index 645edb6f..41fb3a44 100644 --- a/src/components/Layout/components/NoticeInfo.vue +++ b/src/components/Layout/components/NoticeInfo.vue @@ -4,8 +4,9 @@ v-model:activeKey="activeKey" :destroyInactiveTabPane="true" @change="onChange" + v-if="tabs.length" > - + -
这是最后一条数据了
+
+ 这是最后一条数据了 +
- 查看更多 + 查看更多
+
+ +
@@ -50,30 +65,6 @@ const emits = defineEmits(['action']); type DataType = 'alarm' | 'system-monitor' | 'system-business'; -const tab = [ - { - key: 'alarm', - tab: '告警', - type: [ - 'alarm-product', - 'alarm-device', - 'alarm-other', - 'alarm-org', - 'alarm', - ], - }, - { - key: 'system-monitor', - tab: '系统监控', - type: ['system-event'], - }, - { - key: 'system-business', - tab: '业务监控', - type: ['device-transparent-codec'], - }, -]; - const refreshObj = ref({ alarm: true, 'system-monitor': true, @@ -89,6 +80,13 @@ const route = useRoute(); const userInfo = useUserInfo(); +const props = defineProps({ + tabs: { + type: Array, + default: () => [] + } +}) + const getData = (type: string[]) => { loading.value = true; const params = { @@ -121,11 +119,11 @@ const getData = (type: string[]) => { }; const onChange = (_key: string) => { - const type = tab.find((item) => item.key === _key)?.type || []; + const type = props.tabs.find((item: any) => item.key === _key)?.type || []; getData(type); }; -onMounted(() => { +onMounted(async () => { onChange('alarm'); }); diff --git a/src/views/account/Center/bind/index.vue b/src/views/account/Center/bind/index.vue index 07f16835..62c3e87c 100644 --- a/src/views/account/Center/bind/index.vue +++ b/src/views/account/Center/bind/index.vue @@ -25,7 +25,7 @@ shape="square" style="margin-bottom: 16px;" :src=" - bindUser?.avatar || + bindUser.result?.avatar || iconMap.get( bindUser?.applicationProvider, ) || getImage('/apply/internal-standalone.png') diff --git a/src/views/account/Center/index.vue b/src/views/account/Center/index.vue index 3cf92fb1..f76ba905 100644 --- a/src/views/account/Center/index.vue +++ b/src/views/account/Center/index.vue @@ -169,6 +169,10 @@ watchEffect(() => { } }); +onMounted(() => { + user.getUserInfo(); +}) + onUnmounted(() => { user.tabKey = 'HomeView' user.other.tabKey = ''