feat 完善注释

This commit is contained in:
Ironsp
2026-10-01 17:24:57 +08:00
parent 2b59f68fd7
commit 9f4a5c7cda
183 changed files with 485 additions and 3615 deletions

View File

@@ -3,7 +3,6 @@ import type { Message, MessageQuery } from '@/types/business/message'
// TODO(api): 待接口文档到位后,将以下 mock 替换为 request<T> 调用
/** 消息 mock(可变,已读状态在前端内存中翻转演示) */
const MOCK_MESSAGES: Message[] = [
{
id: 'msg-001',
@@ -107,7 +106,6 @@ function applyFilters(query: MessageQuery): Message[] {
})
}
/** 消息列表(筛选 + 分页) */
export function getMessageList(query: MessageQuery): Promise<PageResult<Message>> {
const filtered = applyFilters(query)
const start = (query.page - 1) * query.pageSize
@@ -117,13 +115,11 @@ export function getMessageList(query: MessageQuery): Promise<PageResult<Message>
})
}
/** 消息详情(不存在返回 null) */
export function getMessageDetail(id: string): Promise<Message | null> {
const found = MOCK_MESSAGES.find((item) => item.id === id) ?? null
return Promise.resolve(found ? { ...found } : null)
}
/** 全部标记已读 */
export function markAllRead(): Promise<void> {
for (const item of MOCK_MESSAGES) {
item.isRead = true
@@ -131,14 +127,12 @@ export function markAllRead(): Promise<void> {
return Promise.resolve()
}
/** 单条标记已读 */
export function markRead(id: string): Promise<void> {
const found = MOCK_MESSAGES.find((item) => item.id === id)
if (found) found.isRead = true
return Promise.resolve()
}
/** 各分类消息总数(tab 角标) */
export function getTabCounts(): Promise<{ all: number; 在线客服: number; 状态通知: number; 系统通知: number }> {
const counts = { all: MOCK_MESSAGES.length, 在线客服: 0, 状态通知: 0, 系统通知: 0 }
for (const item of MOCK_MESSAGES) {
@@ -147,7 +141,6 @@ export function getTabCounts(): Promise<{ all: number; 在线客服: number; 状
return Promise.resolve(counts)
}
/** 未读消息总数(头部角标) */
export function getUnreadCount(): Promise<number> {
return Promise.resolve(MOCK_MESSAGES.filter((item) => !item.isRead).length)
}