auth-web/src/layout/components/lay-notice/index.vue

83 lines
2.3 KiB
Vue
Raw Normal View History

2024-09-26 09:38:02 +08:00
<script lang="ts" setup>
2024-10-31 16:14:22 +08:00
import { useI18n } from 'vue-i18n';
import { onMounted } from 'vue';
import { activeKey, computedNoticesNum, getLabel, notices, noticesNum } from './data';
2024-10-31 16:14:22 +08:00
import NoticeList from './components/NoticeList.vue';
import BellIcon from '@iconify-icons/ep/bell';
2024-11-02 17:03:59 +08:00
import { useMessageTypeStore } from '@/store/message/messageType';
2024-09-26 09:38:02 +08:00
const { t } = useI18n();
2024-11-02 17:03:59 +08:00
const messageTypeStore = useMessageTypeStore();
2024-11-01 00:08:57 +08:00
onMounted(() => {
2025-04-27 22:16:06 +08:00
messageTypeStore.loadMessageTypeList();
2025-04-24 13:43:37 +08:00
computedNoticesNum();
});
2024-09-26 09:38:02 +08:00
</script>
<template>
2025-04-24 13:43:37 +08:00
<el-dropdown placement="bottom-end" trigger="click">
<span
:class="['dropdown-badge', 'navbar-bg-hover', 'select-none', Number(noticesNum) !== 0 && 'mr-[10px]']"
@dblclick="$router.push(`/message-detail/${messageTypeStore?.allMessageTypeList[0]?.messageType}`)"
>
<el-badge :max="99" :value="Number(noticesNum) === 0 ? '' : noticesNum">
<span class="header-notice-icon">
<IconifyIconOffline :icon="BellIcon" />
</span>
</el-badge>
</span>
<template #dropdown>
<el-dropdown-menu>
2025-04-28 09:39:28 +08:00
<el-tabs v-model="activeKey" :stretch="true" :style="{ width: notices.length === 0 ? '200px' : '330px' }" class="dropdown-tabs">
2025-04-24 13:43:37 +08:00
<el-empty v-if="notices.length === 0" :description="t('status.pureNoMessage')" :image-size="60" />
<span v-else>
<template v-for="item in notices" :key="item.key">
<el-tab-pane :label="getLabel(item)" :name="`${item.key}`">
<el-scrollbar max-height="330px">
<div class="noticeList-container">
<NoticeList :emptyText="item.emptyText" :list="item.list" />
</div>
</el-scrollbar>
</el-tab-pane>
</template>
</span>
</el-tabs>
</el-dropdown-menu>
</template>
</el-dropdown>
2024-09-26 09:38:02 +08:00
</template>
<style lang="scss" scoped>
.dropdown-badge {
2025-04-24 13:43:37 +08:00
display: flex;
align-items: center;
justify-content: center;
width: 40px;
height: 48px;
cursor: pointer;
2024-09-26 09:38:02 +08:00
2025-04-24 13:43:37 +08:00
.header-notice-icon {
font-size: 18px;
}
2024-09-26 09:38:02 +08:00
}
.dropdown-tabs {
2025-04-24 13:43:37 +08:00
.noticeList-container {
padding: 15px 24px 0;
}
2024-09-26 09:38:02 +08:00
2025-04-24 13:43:37 +08:00
:deep(.el-tabs__header) {
margin: 0;
}
2024-09-26 09:38:02 +08:00
2025-04-24 13:43:37 +08:00
:deep(.el-tabs__nav-wrap)::after {
height: 1px;
}
2024-09-26 09:38:02 +08:00
2025-04-24 13:43:37 +08:00
:deep(.el-tabs__nav-wrap) {
padding: 0 36px;
}
2024-09-26 09:38:02 +08:00
}
</style>