F2-11: 消息中心前端 — Drawer、顶栏铃铛、工作台通知卡、e2e

- src/api/notice.ts:新增 fetchNotices/fetchUnreadCount/markNoticeRead/markAllNoticesRead
- src/shell/NoticeDrawer.tsx:消息中心抽屉(未读蓝点/展开内容/全部已读/过滤标签)
- src/shell/Topbar.tsx:新增消息图标按钮(doc 图标,noticeBadge badge)
- src/shell/AppShell.tsx:消息未读数 60s 轮询 + NoticeDrawer 状态管理
- src/pages/WorkbenchPage.tsx:点亮通知公告卡片(原占位注释替换为真实卡片)
- e2e/notice.spec.ts:5 个用例(API 3 + UI 2),50/50 全绿
- e2e/artifacts/f2-11/:截图(工作台卡片/Drawer 展开/全部已读后)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-12 02:27:05 +08:00
parent c8d3209e4d
commit a1c60f8a42
9 changed files with 845 additions and 1 deletions

48
src/api/notice.ts Normal file
View File

@@ -0,0 +1,48 @@
// 消息中心 API — F2-11
// 数据源:eip3.sys_message + eip3.sys_messageuser
import { http } from './http';
/** 消息列表条目 */
export interface NoticeItem {
id: string;
title: string;
summary: string | null;
type: number | null;
createtime: number | null;
isread: number;
}
/** 消息列表响应 */
export interface NoticeListResult {
items: NoticeItem[];
total: number;
}
/** 获取当前用户消息列表 */
export async function fetchNotices(
params: { unreadOnly?: boolean; page?: number; perPage?: number } = {},
): Promise<NoticeListResult> {
const { data } = await http.get<{ status: number; data: NoticeListResult }>(
'/api/notice',
{ params },
);
return data.data;
}
/** 获取未读消息数(顶栏轮询用) */
export async function fetchUnreadCount(): Promise<number> {
const { data } = await http.get<{ status: number; data: { count: number } }>(
'/api/notice/unread-count',
);
return data.data?.count ?? 0;
}
/** 单条消息置已读 */
export async function markNoticeRead(id: string): Promise<void> {
await http.post(`/api/notice/${encodeURIComponent(id)}/read`);
}
/** 当前用户全部消息置已读 */
export async function markAllNoticesRead(): Promise<void> {
await http.post('/api/notice/read-all');
}