feat(notice): 新增公告优先级和未读状态功能,优化公告展示逻辑

This commit is contained in:
2025-12-30 22:49:14 +08:00
parent 88a4e58130
commit 10e738edd9

View File

@@ -241,7 +241,9 @@ const loadNotices = async () => {
try { try {
const res = await getUserNotices() const res = await getUserNotices()
if (res.code === 200) { if (res.code === 200) {
noticeList.value = res.data || [] noticeList.value = (res.data || []).sort((a, b) => {
return new Date(b.createTime) - new Date(a.createTime)
})
// 设置第一个未读公告为激活状态,如果没有未读则设置第一个 // 设置第一个未读公告为激活状态,如果没有未读则设置第一个
const firstUnread = noticeList.value.find(n => !n.isRead) const firstUnread = noticeList.value.find(n => !n.isRead)
if (firstUnread) { if (firstUnread) {
@@ -359,7 +361,8 @@ defineExpose({
} }
.notice-list { .notice-list {
width: 380px; width: 25%;
min-width: 200px;
border-right: 1px solid #e4e7ed; border-right: 1px solid #e4e7ed;
background: #fafafa; background: #fafafa;
@@ -368,6 +371,7 @@ defineExpose({
cursor: pointer; cursor: pointer;
border-bottom: 1px solid #e4e7ed; border-bottom: 1px solid #e4e7ed;
transition: all 0.3s; transition: all 0.3s;
position: relative;
&:hover { &:hover {
background: #f0f2f5; background: #f0f2f5;