|
|
@@ -1,7 +1,7 @@
|
|
|
<script lang="ts" setup>
|
|
|
import type { NotificationItem } from './types';
|
|
|
|
|
|
-import { Bell, MailCheck } from '@vben/icons';
|
|
|
+import { Bell, CircleCheckBig, CircleX, MailCheck } from '@vben/icons';
|
|
|
import { $t } from '@vben/locales';
|
|
|
|
|
|
import {
|
|
|
@@ -35,6 +35,7 @@ const emit = defineEmits<{
|
|
|
clear: [];
|
|
|
makeAll: [];
|
|
|
read: [NotificationItem];
|
|
|
+ remove: [NotificationItem];
|
|
|
viewAll: [];
|
|
|
}>();
|
|
|
|
|
|
@@ -91,7 +92,7 @@ function handleClick(item: NotificationItem) {
|
|
|
</div>
|
|
|
<VbenScrollbar v-if="notifications.length > 0">
|
|
|
<ul class="!flex max-h-[360px] w-full flex-col">
|
|
|
- <template v-for="item in notifications" :key="item.title">
|
|
|
+ <template v-for="item in notifications" :key="item.id ?? item.title">
|
|
|
<li
|
|
|
class="hover:bg-accent border-border relative flex w-full cursor-pointer items-start gap-5 border-t px-3 py-3"
|
|
|
@click="handleClick(item)"
|
|
|
@@ -107,7 +108,6 @@ function handleClick(item: NotificationItem) {
|
|
|
<img
|
|
|
:src="item.avatar"
|
|
|
class="aspect-square h-full w-full object-cover"
|
|
|
- role="img"
|
|
|
/>
|
|
|
</span>
|
|
|
<div class="flex flex-col gap-1 leading-none">
|
|
|
@@ -119,6 +119,30 @@ function handleClick(item: NotificationItem) {
|
|
|
{{ item.date }}
|
|
|
</p>
|
|
|
</div>
|
|
|
+ <div
|
|
|
+ class="absolute right-3 top-1/2 flex -translate-y-1/2 flex-col gap-2"
|
|
|
+ >
|
|
|
+ <VbenIconButton
|
|
|
+ v-if="!item.isRead"
|
|
|
+ size="xs"
|
|
|
+ variant="ghost"
|
|
|
+ class="h-6 px-2"
|
|
|
+ :tooltip="$t('common.confirm')"
|
|
|
+ @click.stop="emit('read', item)"
|
|
|
+ >
|
|
|
+ <CircleCheckBig class="size-4" />
|
|
|
+ </VbenIconButton>
|
|
|
+ <VbenIconButton
|
|
|
+ v-if="item.isRead"
|
|
|
+ size="xs"
|
|
|
+ variant="ghost"
|
|
|
+ class="text-destructive h-6 px-2"
|
|
|
+ :tooltip="$t('common.delete')"
|
|
|
+ @click.stop="emit('remove', item)"
|
|
|
+ >
|
|
|
+ <CircleX class="size-4" />
|
|
|
+ </VbenIconButton>
|
|
|
+ </div>
|
|
|
</li>
|
|
|
</template>
|
|
|
</ul>
|