Răsfoiți Sursa

feat: 打开置为已读接口

zhouyuhao 8 luni în urmă
părinte
comite
6e5f5d956c

+ 8 - 11
src/stores/modules/notificationMessage.ts

@@ -48,19 +48,16 @@ export const useNotificationMessage = defineStore('notificationMessage', {
     },
     async markMessageAsRead() {
       if (this.readCardMap.length === 0) return
-      console.log('置为已读')
-      this.readCardMap = []
-      localStorage.setItem('readCardMap', JSON.stringify(this.readCardMap))
 
-      // await $api.setMessageRead({ id: this.readCardMap }).then((res) => {
-      //   if (res.code === 200) {
-      //     this.readCardMap = []
-      //     localStorage.setItem('readCardMap', JSON.stringify(this.readCardMap))
+      await $api.setMessageRead({ id: this.readCardMap }).then((res) => {
+        if (res.code === 200) {
+          this.readCardMap = []
+          localStorage.setItem('readCardMap', JSON.stringify(this.readCardMap))
 
-      //     // 在将消息标记为已读后,再次检查是否有新消息
-      //     this.hasUnreadMessages()
-      //   }
-      // })
+          // 在将消息标记为已读后,再次检查是否有新消息
+          this.hasUnreadMessages()
+        }
+      })
     },
     clearData() {
       this.notificationMsgList = []

+ 47 - 47
src/views/Layout/src/components/Menu/MenuView.vue

@@ -17,54 +17,54 @@ watch(
   }
 )
 const getMenuList = () => {
-  // $api.getMenuList().then((res) => {
-  //   if (res.code === 200) {
-  //     menuList.value = res.data
-  //   }
-  // })
-  menuList.value = [
-    {
-      index: '1',
-      label: 'Dashboard',
-      icon: 'icon_data_fill_b',
-      path: '/dashboard'
-    },
-    {
-      index: '2',
-      label: 'Booking',
-      icon: 'icon_booking__fill_b',
-      path: '/booking'
-    },
-    {
-      index: '3',
-      label: 'Tracking',
-      icon: 'icon_tracking__fill_b',
-      path: '/tracking'
-    },
-    {
-      index: '4',
-      label: 'System Management',
-      icon: 'icon_system__management_fill_b',
-      type: 'list',
-      children: [
-        {
-          index: '4-1',
-          label: 'System Message',
-          path: '/system-message'
-        },
-        {
-          index: '4-2',
-          label: 'System Settings',
-          path: '/SystemSettings'
-        },
-        {
-          index: '4-3',
-          label: 'Operation Log',
-          path: '/Operationlog'
-        }
-      ]
+  $api.getMenuList().then((res) => {
+    if (res.code === 200) {
+      menuList.value = res.data
     }
-  ]
+  })
+  // menuList.value = [
+  //   {
+  //     index: '1',
+  //     label: 'Dashboard',
+  //     icon: 'icon_data_fill_b',
+  //     path: '/dashboard'
+  //   },
+  //   {
+  //     index: '2',
+  //     label: 'Booking',
+  //     icon: 'icon_booking__fill_b',
+  //     path: '/booking'
+  //   },
+  //   {
+  //     index: '3',
+  //     label: 'Tracking',
+  //     icon: 'icon_tracking__fill_b',
+  //     path: '/tracking'
+  //   },
+  //   {
+  //     index: '4',
+  //     label: 'System Management',
+  //     icon: 'icon_system__management_fill_b',
+  //     type: 'list',
+  //     children: [
+  //       {
+  //         index: '4-1',
+  //         label: 'System Message',
+  //         path: '/system-message'
+  //       },
+  //       {
+  //         index: '4-2',
+  //         label: 'System Settings',
+  //         path: '/SystemSettings'
+  //       },
+  //       {
+  //         index: '4-3',
+  //         label: 'Operation Log',
+  //         path: '/Operationlog'
+  //       }
+  //     ]
+  //   }
+  // ]
 }
 getMenuList()
 //监听窗口大小

+ 10 - 4
src/views/SystemMessage/src/components/SystemMessageDetail.vue

@@ -1,8 +1,10 @@
 <script setup lang="ts">
 import { useRoute } from 'vue-router'
 import EventCard from '@/components/NotificationMessageCard/src/components/EventCard.vue'
+import { useNotificationMessage } from '@/stores/modules/notificationMessage'
 
 const route = useRoute()
+const notificationMsgStore = useNotificationMessage()
 const notificationData = ref({
   title: '',
   type: 'delay',
@@ -13,6 +15,9 @@ const notificationData = ref({
 })
 
 const loading = ref(false)
+if (route.query.type === 'feature') {
+  loading.value = true
+}
 const getNotificationList = () => {
   loading.value = true
   $api
@@ -24,6 +29,7 @@ const getNotificationList = () => {
     .then((res) => {
       if (res.code === 200) {
         notificationData.value = res.data
+        notificationMsgStore.hasUnreadMessages()
       }
     })
     .finally(() => {
@@ -42,9 +48,9 @@ onMounted(() => {
 })
 
 const iframeRef = ref(null)
-const errorAA = (e) => {
+const handleIframeLoaded = () => {
   nextTick(() => {
-    console.dir(iframeRef.value, 'iframeRef')
+    loading.value = false
   })
 }
 
@@ -53,7 +59,7 @@ const iframeUrl = `${import.meta.env.VITE_API_HOST}/main_new_version.php?action=
 
 <template>
   <div class="system-message-detail" v-vloading="loading">
-    <!-- <el-button @click="errorAA">测试</el-button> -->
+    <!-- <el-button @click="handleIframeLoaded">测试</el-button> -->
     <div class="content" v-if="route.query.type !== 'feature'">
       <div class="header" v-if="notificationData.title">
         <div class="status-icon"></div>
@@ -99,7 +105,7 @@ const iframeUrl = `${import.meta.env.VITE_API_HOST}/main_new_version.php?action=
           :src="iframeUrl"
           width="100%"
           height="100%"
-          @load="errorAA"
+          @load="handleIframeLoaded"
         ></iframe>
       </div>
     </div>