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

80 lines
2.1 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 { computed, ref } from 'vue';
import { noticesData } from './data';
import NoticeList from './components/NoticeList.vue';
import BellIcon from '@iconify-icons/ep/bell';
2024-09-26 09:38:02 +08:00
const { t } = useI18n();
const noticesNum = ref(0);
const notices = ref(noticesData);
const activeKey = ref(noticesData[0]?.key);
notices.value.map(v => (noticesNum.value += v.list.length));
2024-10-31 16:14:22 +08:00
const getLabel = computed(() => item => item.name + (item.list.length > 0 ? `(${item.list.length})` : ''));
2024-09-26 09:38:02 +08:00
</script>
<template>
2024-10-31 16:14:22 +08:00
<el-dropdown placement="bottom-end" trigger="click">
<span :class="['dropdown-badge', 'navbar-bg-hover', 'select-none', Number(noticesNum) !== 0 && 'mr-[10px]']">
<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>
<el-tabs v-model="activeKey" :stretch="true" :style="{ width: notices.length === 0 ? '200px' : '330px' }" class="dropdown-tabs">
<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 {
2024-10-31 16:14:22 +08:00
display: flex;
align-items: center;
justify-content: center;
width: 40px;
height: 48px;
cursor: pointer;
2024-09-26 09:38:02 +08:00
2024-10-31 16:14:22 +08:00
.header-notice-icon {
font-size: 18px;
}
2024-09-26 09:38:02 +08:00
}
.dropdown-tabs {
2024-10-31 16:14:22 +08:00
.noticeList-container {
padding: 15px 24px 0;
}
2024-09-26 09:38:02 +08:00
2024-10-31 16:14:22 +08:00
:deep(.el-tabs__header) {
margin: 0;
}
2024-09-26 09:38:02 +08:00
2024-10-31 16:14:22 +08:00
:deep(.el-tabs__nav-wrap)::after {
height: 1px;
}
2024-09-26 09:38:02 +08:00
2024-10-31 16:14:22 +08:00
:deep(.el-tabs__nav-wrap) {
padding: 0 36px;
}
2024-09-26 09:38:02 +08:00
}
</style>