Bläddra i källkod

fix(组件): notify - readAll

gemercheung 2 år sedan
förälder
incheckning
41168d9fab
1 ändrade filer med 11 tillägg och 3 borttagningar
  1. 11 3
      src/layouts/default/header/components/notify/index.vue

+ 11 - 3
src/layouts/default/header/components/notify/index.vue

@@ -30,7 +30,7 @@
   // import NoticeList from './NoticeList.vue';
   import { useDesign } from '/@/hooks/web/useDesign';
   // import { useMessage } from '/@/hooks/web/useMessage';
-  import { unreadNoticeApi } from '/@/api/notification/list';
+  import { unreadNoticeApi, readAllApi } from '/@/api/notification/list';
   import { useGo } from '/@/hooks/web/usePage';
   import { useMessage } from '/@/hooks/web/useMessage';
   // Tabs, TabPane: Tabs.TabPane, Badge, NoticeList
@@ -43,7 +43,6 @@
       const go = useGo();
       const { createWarningModal } = useMessage();
       const count = ref(0);
-
       async function fetchNotice() {
         const unread = await unreadNoticeApi();
         console.log('unread', unread.totalCount);
@@ -56,12 +55,21 @@
         if (unread.list?.length) {
           const list = unread.list[0] as unknown as Unread;
           if (list.type === 0) {
-            createWarningModal({ title: list.title, content: list.content });
+            createWarningModal({
+              title: list.title,
+              content: list.content,
+              onOk: async () => {
+                await readAllApi();
+              },
+            });
           }
           if (list.type === 1) {
             createWarningModal({
               title: list.title,
               content: `<img style="margin:0 auto" src="${list.content}"/>`,
+              onOk: async () => {
+                await readAllApi();
+              },
             });
           }
         }