yuan
11 小时以前 31e43b73379326df5d0d06dcc37ef5049a34f0f1
src/layout/components/NotificationCenter/index.vue
@@ -2,12 +2,20 @@
  <div class="notification-popover-content">
    <div class="popover-header">
      <span class="popover-title">消息通知</span>
      <el-button type="primary"
                 size="small"
                 @click="handleMarkAllAsRead"
                 :disabled="unreadCount === 0">
        一键已读
      </el-button>
      <div class="popover-actions">
        <el-button type="primary"
                   size="small"
                   @click="handleMarkAllAsRead"
                   :disabled="unreadCount === 0">
          一键已读
        </el-button>
        <el-button type="danger"
                   size="small"
                   plain
                   @click="handleClearAll">
          清除
        </el-button>
      </div>
    </div>
    <div class="notification-content">
      <el-tabs v-model="activeTab"
@@ -91,10 +99,11 @@
    listMessage,
    markAsRead,
    markAllAsRead,
    clearAllMessage,
    confirmMessage,
    getUnreadCount,
  } from "@/api/system/message";
  import { ElMessage } from "element-plus";
  import { ElMessage, ElMessageBox } from "element-plus";
  import useUserStore from "@/store/modules/user";
  import { useRouter } from "vue-router";
@@ -221,6 +230,35 @@
    }
  };
  // 清除全部消息
  const handleClearAll = async () => {
    try {
      await ElMessageBox.confirm("确认清除全部消息吗?清除后无法恢复。", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      });
    } catch (error) {
      // 取消清除
      return;
    }
    try {
      const res = await clearAllMessage();
      if (res.code === 200) {
        ElMessage.success("清除成功");
        unreadList.value = [];
        readList.value = [];
        total.value = 0;
        pageNum.value = 1;
        loadMessages();
        loadUnreadCount();
      }
    } catch (error) {
      console.error("清除消息失败:", error);
      ElMessage.error("清除失败");
    }
  };
  // 分页大小改变
  const handleSizeChange = size => {
    pageSize.value = size;
@@ -272,6 +310,11 @@
      font-weight: 500;
      color: var(--text-primary);
    }
    .popover-actions {
      display: flex;
      align-items: center;
    }
  }
  .notification-content {