1
0
Эх сурвалжийг харах

feat(notification): Add relative time display and improve layout

Jacky 2 сар өмнө
parent
commit
59ec9136fa

+ 27 - 13
app/src/components/Notification/Notification.vue

@@ -9,12 +9,16 @@ import { NotificationTypeT } from '@/constants'
 import { useUserStore } from '@/pinia'
 import { useUserStore } from '@/pinia'
 import { BellOutlined, CheckCircleOutlined, CloseCircleOutlined, DeleteOutlined, InfoCircleOutlined, WarningOutlined } from '@ant-design/icons-vue'
 import { BellOutlined, CheckCircleOutlined, CloseCircleOutlined, DeleteOutlined, InfoCircleOutlined, WarningOutlined } from '@ant-design/icons-vue'
 import { message, notification } from 'ant-design-vue'
 import { message, notification } from 'ant-design-vue'
+import dayjs from 'dayjs'
+import relativeTime from 'dayjs/plugin/relativeTime'
 import { SSE } from 'sse.js'
 import { SSE } from 'sse.js'
 
 
 defineProps<{
 defineProps<{
   headerRef: HTMLElement
   headerRef: HTMLElement
 }>()
 }>()
 
 
+dayjs.extend(relativeTime)
+
 const loading = ref(false)
 const loading = ref(false)
 
 
 const { token, unreadCount } = storeToRefs(useUserStore())
 const { token, unreadCount } = storeToRefs(useUserStore())
@@ -145,19 +149,7 @@ function viewAll() {
         >
         >
           <template #renderItem="{ item }">
           <template #renderItem="{ item }">
             <AListItem>
             <AListItem>
-              <template #actions>
-                <span
-                  key="list-loadmore-remove"
-                  class="cursor-pointer"
-                  @click="remove(item.id)"
-                >
-                  <DeleteOutlined />
-                </span>
-              </template>
-              <AListItemMeta
-                :title="$gettext(item.title)"
-                :description="detailRender({ text: item.details, record: item } as CustomRender)"
-              >
+              <AListItemMeta>
                 <template #avatar>
                 <template #avatar>
                   <div>
                   <div>
                     <CloseCircleOutlined
                     <CloseCircleOutlined
@@ -178,6 +170,28 @@ function viewAll() {
                     />
                     />
                   </div>
                   </div>
                 </template>
                 </template>
+                <template #title>
+                  <div class="flex justify-between items-center">
+                    {{ $gettext(item.title) }}
+                    <span class="text-xs text-trueGray-400 font-normal">
+                      {{ dayjs(item.created_at).fromNow() }}
+                    </span>
+                  </div>
+                </template>
+                <template #description>
+                  <div class="flex justify-between items-center">
+                    <div>
+                      {{ detailRender({ text: item.details, record: item } as CustomRender) }}
+                    </div>
+                    <span
+                      key="list-loadmore-remove"
+                      class="cursor-pointer"
+                      @click="remove(item.id)"
+                    >
+                      <DeleteOutlined />
+                    </span>
+                  </div>
+                </template>
               </AListItemMeta>
               </AListItemMeta>
             </AListItem>
             </AListItem>
           </template>
           </template>