Browse Source

登陆了

yanghao 19 giờ trước cách đây
mục cha
commit
b1828ab79e
3 tập tin đã thay đổi với 34 bổ sung18 xóa
  1. 20 4
      src/components/home/header.vue
  2. 3 3
      src/config/axios/service.ts
  3. 11 11
      src/views/index.vue

+ 20 - 4
src/components/home/header.vue

@@ -347,6 +347,7 @@ import {
   getNotifyMessages,
   getNotifyMessageList,
   markMessageAsRead,
+  getUnreadNotifyMessageCount,
 } from "@api/user";
 
 import {
@@ -404,16 +405,31 @@ const unreadMessageCount = computed(() => {
 
 // oa未读
 const oaMessagesList = ref([]);
+
+const unreadCount = ref(0); // 未读消息数量
+const getUnreadCount = async () => {
+  getUnreadNotifyMessageCount().then((data) => {
+    unreadCount.value = data;
+  });
+};
 onMounted(async () => {
-  console.log("用户信息>>>>>>>>>>>>", isLoggedIn.value);
   if (isLoggedIn.value) {
     await getNotifyMessages(userStore.getUser.username);
-
     const messageList = await getNotifyMessageList(userStore.getUser.username);
     messages.value = messageList;
-
-    console.log("消息中心数据:", messages.value);
   }
+
+  setInterval(
+    () => {
+      if (userStore.getIsSetUser) {
+        console.log("轮询刷新小红点");
+        getUnreadCount();
+      } else {
+        unreadCount.value = 0;
+      }
+    },
+    1000 * 60 * 1,
+  );
 });
 
 function timestampToDateTime(timestamp) {

+ 3 - 3
src/config/axios/service.ts

@@ -208,12 +208,12 @@ const handleAuthorized = () => {
       return;
     }
     isRelogin.show = true;
-    ElMessageBox.confirm("登陆超时,请重新登陆", "确定", {
+    ElMessageBox.confirm("登录超时,请重新登录", "确定", {
       showCancelButton: true,
       closeOnClickModal: false,
       showClose: false,
       closeOnPressEscape: false,
-      confirmButtonText: "重新登",
+      confirmButtonText: "重新登",
       cancelButtonText: "取消",
       type: "warning",
     })
@@ -230,7 +230,7 @@ const handleAuthorized = () => {
         window.location.href = "/";
       });
   }
-  return Promise.reject("登陆超时,请重新登陆");
+  return Promise.reject("登录超时,请重新登录");
 };
 
 export { service };

+ 11 - 11
src/views/index.vue

@@ -251,17 +251,17 @@ onMounted(() => {
   // 首次加载小红点
   // getUnreadCount();
   // 轮询刷新小红点
-  setInterval(
-    () => {
-      if (userStore.getIsSetUser) {
-        console.log("轮询刷新小红点");
-        getUnreadCount();
-      } else {
-        unreadCount.value = 0;
-      }
-    },
-    1000 * 60 * 1,
-  );
+  // setInterval(
+  //   () => {
+  //     if (userStore.getIsSetUser) {
+  //       console.log("轮询刷新小红点");
+  //       getUnreadCount();
+  //     } else {
+  //       unreadCount.value = 0;
+  //     }
+  //   },
+  //   1000 * 60 * 1,
+  // );
 });
 
 onUnmounted(() => {