fix: 完成: 诊所设置中心,消息中心
This commit is contained in:
@@ -60,37 +60,6 @@ const typeBorderColors = {
|
||||
2: 'border-emerald-200',
|
||||
};
|
||||
|
||||
// const notifications = ref<NotificationItem[]>([
|
||||
// // TODO 通知列表
|
||||
// {
|
||||
// avatar: 'https://avatar.vercel.sh/vercel.svg?text=VB',
|
||||
// date: '3小时前',
|
||||
// isRead: true,
|
||||
// message: '描述信息描述信息描述信息',
|
||||
// title: '收到了 14 份新周报',
|
||||
// },
|
||||
// {
|
||||
// avatar: 'https://avatar.vercel.sh/1',
|
||||
// date: '刚刚',
|
||||
// isRead: false,
|
||||
// message: '描述信息描述信息描述信息',
|
||||
// title: '朱偏右 回复了你',
|
||||
// },
|
||||
// {
|
||||
// avatar: 'https://avatar.vercel.sh/1',
|
||||
// date: '2024-01-01',
|
||||
// isRead: false,
|
||||
// message: '描述信息描述信息描述信息',
|
||||
// title: '曲丽丽 评论了你',
|
||||
// },
|
||||
// {
|
||||
// avatar: 'https://avatar.vercel.sh/satori',
|
||||
// date: '1天前',
|
||||
// isRead: false,
|
||||
// message: '描述信息描述信息描述信息',
|
||||
// title: '代办提醒',
|
||||
// },
|
||||
// ]);
|
||||
const notifications = ref<NotificationItem[]>([]);
|
||||
|
||||
// 获取消息列表数据
|
||||
@@ -99,16 +68,31 @@ const getNoticeList = async () => {
|
||||
const res = await getNoticeListApi({
|
||||
status: 0,
|
||||
});
|
||||
notifications.value = res.items.map(item => ({
|
||||
id: item.id,
|
||||
icon: typeIcons[item.type],
|
||||
// 将API返回的数据映射到组件需要的格式
|
||||
message: item.title,
|
||||
title: getMessageTypeName(item.type),
|
||||
date: formatTimeToRelative(item.created_at),
|
||||
color: typeColors[item.type],
|
||||
isRead: item.status
|
||||
}));
|
||||
let message = '未读消息';
|
||||
if (res.items.length > 0) {
|
||||
if (res.items.length > notifications.value.length) {
|
||||
if (notifications.value.length === 0) {
|
||||
message = '新消息';
|
||||
}
|
||||
notification.info({
|
||||
message: `您有${message}`,
|
||||
description: `您有 ${res.items.length} 条${message}请注意查收`,
|
||||
duration: 5,
|
||||
});
|
||||
}
|
||||
|
||||
notifications.value = res.items.map(item => ({
|
||||
id: item.id,
|
||||
icon: typeIcons[item.type],
|
||||
// 将API返回的数据映射到组件需要的格式
|
||||
message: item.title,
|
||||
title: getMessageTypeName(item.type),
|
||||
date: formatTimeToRelative(item.created_at),
|
||||
color: typeColors[item.type],
|
||||
isRead: item.status
|
||||
}));
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('获取消息列表失败:', error);
|
||||
} finally {
|
||||
@@ -177,8 +161,8 @@ const goNoticeList = () => {
|
||||
const handleItemClick = (item) => {
|
||||
notifications.value.forEach((value) => {
|
||||
if (value.id === item.id) {
|
||||
// 删除这个对象
|
||||
value.status = 1;
|
||||
value.isRead = 1;
|
||||
}
|
||||
});
|
||||
router.push(`/notice/detail/${item.id}`);
|
||||
|
||||
Reference in New Issue
Block a user