123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <template>
- <div :class="prefixCls">
- <Popover title="" trigger="click" :overlayClassName="`${prefixCls}__overlay`">
- <Badge size="small" dot :count="count" :numberStyle="numberStyle" @click="onNoticeClick">
- <BellOutlined />
- </Badge>
- <!-- <template #content>
- <Tabs>
- <template v-for="item in listData" :key="item.key">
- <TabPane>
- <template #tab>
- {{ item.name }}
- <span v-if="item.list.length !== 0">({{ item.list.length }})</span>
- </template>
- <NoticeList :list="item.list" v-if="item.key === '1'" @title-click="onNoticeClick" />
- <NoticeList :list="item.list" v-else />
- </TabPane>
- </template>
- </Tabs>
- </template> -->
- </Popover>
- </div>
- </template>
- <script lang="ts">
- import { onMounted, defineComponent, ref } from 'vue';
- // Tabs, Badge
- import { Popover, Badge } from 'ant-design-vue';
- import { BellOutlined } from '@ant-design/icons-vue';
- import { tabListData } from './data';
- // import NoticeList from './NoticeList.vue';
- import { useDesign } from '/@/hooks/web/useDesign';
- // import { useMessage } from '/@/hooks/web/useMessage';
- import { unreadNoticeApi } from '/@/api/notification/list';
- import { useGo } from '/@/hooks/web/usePage';
- // Tabs, TabPane: Tabs.TabPane, Badge, NoticeList
- export default defineComponent({
- components: { Popover, BellOutlined, Badge },
- setup() {
- const { prefixCls } = useDesign('header-notify');
- // const { createMessage } = useMessage();
- const listData = ref(tabListData);
- const go = useGo();
- const count = ref(0);
- onMounted(async () => {
- const unread = await unreadNoticeApi();
- console.log('unread', unread.totalCount);
- count.value = unread.totalCount;
- });
- function onNoticeClick() {
- if (count.value > 0) {
- go('/notification/list');
- }
- // createMessage.success('你点击了通知,ID=' + record.id);
- }
- return {
- prefixCls,
- listData,
- count,
- onNoticeClick,
- numberStyle: {},
- };
- },
- });
- </script>
- <style lang="less">
- @prefix-cls: ~'@{namespace}-header-notify';
- .@{prefix-cls} {
- padding-top: 2px;
- &__overlay {
- max-width: 360px;
- }
- .ant-tabs-content {
- width: 300px;
- }
- .ant-badge {
- font-size: 18px;
- .ant-badge-multiple-words {
- padding: 0 4px;
- transform: translate(50%, 50%);
- }
- svg {
- width: 0.9em;
- }
- }
- }
- </style>
|