Skip to content

Commit fbe0fc1

Browse files
authored
chore: conditionally display notification dot (vbenjs#31)
1 parent 0eda99e commit fbe0fc1

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

apps/web-antd/src/layouts/basic.vue

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ import { $t } from '#/locales';
1515
import { resetRoutes } from '#/router';
1616
import { useAppStore } from '#/store';
1717
18-
// https://avatar.vercel.sh/vercel.svg?text=Vaa
19-
// https://avatar.vercel.sh/1
20-
// https://avatar.vercel.sh/nextjs
21-
// https://avatar.vercel.sh/satori
2218
const notifications = ref<NotificationItem[]>([
2319
{
2420
avatar: 'https://avatar.vercel.sh/vercel.svg?text=VB',
@@ -50,6 +46,10 @@ const notifications = ref<NotificationItem[]>([
5046
},
5147
]);
5248
49+
const showDot = computed(() =>
50+
notifications.value.some((item) => !item.isRead),
51+
);
52+
5353
const menus = computed(() => [
5454
{
5555
handler: () => {
@@ -92,6 +92,10 @@ async function handleLogout() {
9292
function handleNoticeClear() {
9393
notifications.value = [];
9494
}
95+
96+
function handleMakeAll() {
97+
notifications.value.forEach((item) => (item.isRead = true));
98+
}
9599
</script>
96100

97101
<template>
@@ -108,9 +112,10 @@ function handleNoticeClear() {
108112
</template>
109113
<template #notification>
110114
<Notification
115+
:dot="showDot"
111116
:notifications="notifications"
112-
dot
113117
@clear="handleNoticeClear"
118+
@make-all="handleMakeAll"
114119
/>
115120
</template>
116121
</BasicLayout>

0 commit comments

Comments
 (0)