chore: conditionally display notification dot (#31)
parent
0eda99ec3b
commit
fbe0fc1738
|
@ -15,10 +15,6 @@ import { $t } from '#/locales';
|
||||||
import { resetRoutes } from '#/router';
|
import { resetRoutes } from '#/router';
|
||||||
import { useAppStore } from '#/store';
|
import { useAppStore } from '#/store';
|
||||||
|
|
||||||
// https://avatar.vercel.sh/vercel.svg?text=Vaa
|
|
||||||
// https://avatar.vercel.sh/1
|
|
||||||
// https://avatar.vercel.sh/nextjs
|
|
||||||
// https://avatar.vercel.sh/satori
|
|
||||||
const notifications = ref<NotificationItem[]>([
|
const notifications = ref<NotificationItem[]>([
|
||||||
{
|
{
|
||||||
avatar: 'https://avatar.vercel.sh/vercel.svg?text=VB',
|
avatar: 'https://avatar.vercel.sh/vercel.svg?text=VB',
|
||||||
|
@ -50,6 +46,10 @@ const notifications = ref<NotificationItem[]>([
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const showDot = computed(() =>
|
||||||
|
notifications.value.some((item) => !item.isRead),
|
||||||
|
);
|
||||||
|
|
||||||
const menus = computed(() => [
|
const menus = computed(() => [
|
||||||
{
|
{
|
||||||
handler: () => {
|
handler: () => {
|
||||||
|
@ -92,6 +92,10 @@ async function handleLogout() {
|
||||||
function handleNoticeClear() {
|
function handleNoticeClear() {
|
||||||
notifications.value = [];
|
notifications.value = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleMakeAll() {
|
||||||
|
notifications.value.forEach((item) => (item.isRead = true));
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -108,9 +112,10 @@ function handleNoticeClear() {
|
||||||
</template>
|
</template>
|
||||||
<template #notification>
|
<template #notification>
|
||||||
<Notification
|
<Notification
|
||||||
|
:dot="showDot"
|
||||||
:notifications="notifications"
|
:notifications="notifications"
|
||||||
dot
|
|
||||||
@clear="handleNoticeClear"
|
@clear="handleNoticeClear"
|
||||||
|
@make-all="handleMakeAll"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</BasicLayout>
|
</BasicLayout>
|
||||||
|
|
Loading…
Reference in New Issue