message.fixture.js
1.48 KB
export const MESSAGE_STATUS = {
unread: 'send',
read: 'read',
}
export const MESSAGE_TITLE_POOL = [
'法会安排更新通知',
'预约审核结果提醒',
'地图导览功能已开放',
'支付状态同步通知',
'活动报名成功提醒',
'系统维护时间说明',
]
export const MESSAGE_CONTENT_POOL = [
'这是一条用于前端联调的 Mock 消息。后续拿到真实接口后,可以直接对照字段结构替换。',
'如果页面已经能完整跑通列表、详情和已读状态,后面只需要把接口 action 与返回字段切到真实后端即可。',
'当前数据由本地 Mock 生成,适合在 API 尚未确定时提前联调页面交互和状态切换。',
]
export const createMessageFixtureList = (count = 12) => (
Array.from({ length: count }).map((_, index) => {
const id = `msg_${index + 1}`
const createdAt = new Date(Date.now() - index * 1000 * 60 * 60 * 6)
return {
id,
title: MESSAGE_TITLE_POOL[index % MESSAGE_TITLE_POOL.length],
summary: `第 ${index + 1} 条消息摘要,可用于测试列表样式与详情跳转。`,
content: `${MESSAGE_CONTENT_POOL[index % MESSAGE_CONTENT_POOL.length]}\n\n消息编号:${id}\n建议后续把这里替换成真实富文本或业务说明。`,
status: index < 4 ? MESSAGE_STATUS.unread : MESSAGE_STATUS.read,
category: index % 2 === 0 ? '系统通知' : '业务提醒',
created_time: createdAt.toISOString().slice(0, 16).replace('T', ' '),
}
})
)