feat(admin): A6 通知页前端 — 统一通知/事件中心(管理面板#16)
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled

- Notifications.tsx(254行): 类型筛选(全部/system/channel/backthink/audit,服务端重拉) + before游标加载更多(id去重/到底判定) + 空态/错误(后端文案) + 30s静默刷新; 卡片行(非AdminTable,避其rowKey升序与倒序feed冲突); Miuix
- api.ts adminListNotifications + types.ts AdminNotification(Query) + sections.tsx 侧栏项{id:notifications,group:运行时,icon:light} + AdminApp renderSection + router.ts VALID_SECTIONS
- 契约: GET /admin/notifications?type=&before=&limit= → {data:[{id,type,title,body,source,createdAt}]}; 未读/清空需后端read端点(诚实Notice,不做前端假实现)
- 前端 build 绿(157 modules); 后端端点由并发代理[194]落地
- icon 用现有 light(Icon.tsx 无 bell; 如需铃铛另加 path)
This commit is contained in:
AskaEth committed 2026-09-30 08:57:15 +08:00
1 parent 1a85de555d
commit 34c8cc4dca
6 files changed
+302 -1

No files matched your search

+17
View File
@@ -5,6 +5,8 @@ import type {
AdminIoTDevice,
AdminLlmConfig,
AdminLlmProvider,
AdminNotification,
AdminNotificationQuery,
AdminObservabilityMetrics,
AdminPluginRecord,
AdminRagHit,
@@ -738,6 +740,21 @@ export function adminBackthink(limit?: number): Promise<BackthinkItem[]> {
return request<BackthinkItem[]>(`/admin/backthink${limitQuery(limit)}`);
}
/** GET /api/v1/admin/notifications?type=&before=&limit= — the unified notification
* feed (design/10 §3 #16: audit + channel + backthink + system aggregated).
* `type` omitted = all types, `before` = createdAt(ms) cursor for older pages,
* `limit` defaults to 50 (backend caps at 200). Returned newest first. */
export function adminListNotifications(
params: AdminNotificationQuery = {}
): Promise<AdminNotification[]> {
const qs = new URLSearchParams();
if (params.type) qs.set("type", params.type);
if (params.before !== undefined) qs.set("before", String(params.before));
if (params.limit !== undefined) qs.set("limit", String(params.limit));
const q = qs.toString();
return request<AdminNotification[]>(`/admin/notifications${q ? `?${q}` : ""}`);
}
/* ----------------------------------------------------------------------------
* System management admin writes (owner-only, audited). Reference:
* internal/services/gateway/admin_system.go + Docs/api-client.md §系统设置契约.
+26
View File
@@ -774,3 +774,29 @@ export interface KookViewResponse {
members?: KookGuildUser[];
errors?: Record<string, string>;
}
/** Notification families of the unified feed (design/10 §3 #16). The endpoint
* aggregates pre-existing sources instead of a new model: audit = 系统/安全审计,
* channel = 渠道连接/断开/重连, backthink = 主动推送历史, system = 其余系统事件. */
export type AdminNotificationType = "system" | "channel" | "backthink" | "audit";
/** One item of GET /api/v1/admin/notifications (newest first). `createdAt` is
* epoch milliseconds; `source` records which source produced it (audit /
* backthink / a channel name), so the page can show provenance honestly. */
export interface AdminNotification {
id: string;
type: AdminNotificationType;
title: string;
body?: string;
source: string;
createdAt: number;
}
/** Query for GET /api/v1/admin/notifications. An absent `type` means “all”;
* `before` is a `createdAt` (ms) cursor walking toward older items; `limit`
* defaults to 50 and is clamped to 200 by the backend. */
export interface AdminNotificationQuery {
type?: AdminNotificationType;
before?: number;
limit?: number;
}