82 lines
3.6 KiB
Markdown
82 lines
3.6 KiB
Markdown
## ADDED Requirements
|
|
|
|
### Requirement: Global Notification Bell
|
|
|
|
The admin frontend SHALL provide a global notification bell in the top navigation near the settings and user avatar entries.
|
|
|
|
#### Scenario: Display unread count
|
|
|
|
- **GIVEN** 用户已登录后台
|
|
- **WHEN** 顶部导航加载未读通知数量
|
|
- **THEN** 铃铛 MUST call `GET /api/admin/notifications/unread-count`
|
|
- **AND** 数量 MUST display as `0`, `1` through `99`, or `99+`
|
|
|
|
#### Scenario: Open recent notification drawer
|
|
|
|
- **WHEN** 用户点击顶部通知铃铛
|
|
- **THEN** 页面 MUST display the latest 10 notifications from the unread summary contract
|
|
- **AND** 抽屉 MUST provide 全部、审批、临期、同步/系统分类
|
|
- **AND** 抽屉 MUST provide an entry to `/notifications`
|
|
|
|
### Requirement: Notification Center Filtering
|
|
|
|
The admin frontend SHALL provide a `/notifications` notification center with server-backed filtering.
|
|
|
|
#### Scenario: Filter notifications
|
|
|
|
- **WHEN** 用户打开通知中心或调整筛选条件
|
|
- **THEN** 页面 MUST support category, notification type, severity and read-state filters
|
|
- **AND** 页面 MUST load results from `GET /api/admin/notifications`
|
|
- **AND** 页面 MUST display notification title, content, category, severity, read state and created time
|
|
|
|
#### Scenario: Mark all notifications read
|
|
|
|
- **WHEN** 用户点击全部已读
|
|
- **THEN** 页面 MUST call `PUT /api/admin/notifications/read-all`
|
|
- **AND** 页面 MUST refresh the unread count and visible notification read states after success
|
|
|
|
### Requirement: Notification Read State Synchronization
|
|
|
|
The notification drawer and notification center SHALL keep read state and unread count synchronized with the backend.
|
|
|
|
#### Scenario: Mark a notification read
|
|
|
|
- **WHEN** 用户点击一条未读通知
|
|
- **THEN** 页面 MUST call `PUT /api/admin/notifications/{id}/read` before navigation
|
|
- **AND** 页面 MUST refresh or update the shared unread count after the read request succeeds
|
|
|
|
#### Scenario: Preserve read state after refresh
|
|
|
|
- **GIVEN** 用户已完成单条已读或全部已读操作
|
|
- **WHEN** 用户关闭抽屉、切换页面或刷新通知中心
|
|
- **THEN** 页面 MUST use the latest backend response rather than restoring stale local unread state
|
|
|
|
### Requirement: Controlled Notification Navigation
|
|
|
|
The admin frontend SHALL navigate from notifications only through controlled internal targets.
|
|
|
|
#### Scenario: Navigate to a valid notification target
|
|
|
|
- **GIVEN** 通知包含受支持的 `ref_type` 或业务引用
|
|
- **WHEN** 单条已读成功后页面请求 `GET /api/admin/notifications/{id}/target`
|
|
- **THEN** 页面 MUST navigate only to a target recognized by the frontend route table
|
|
- **AND** 页面 MUST preserve the target route parameters returned by the backend
|
|
|
|
#### Scenario: Handle an unknown target safely
|
|
|
|
- **GIVEN** 通知的 `ref_type` 未知、目标已删除或目标无权限
|
|
- **WHEN** 页面处理通知点击
|
|
- **THEN** 页面 MUST not navigate to an arbitrary URL
|
|
- **AND** 页面 MUST still display the notification content and a stable unavailable-target state
|
|
|
|
### Requirement: Consistent Notification Categories
|
|
|
|
The notification drawer and notification center SHALL present balance warnings, expiry reminders, approval results and system alerts through the same notification data contract.
|
|
|
|
#### Scenario: Display supported notification types
|
|
|
|
- **GIVEN** 后端返回余额预警、临期提醒、审批结果或系统告警
|
|
- **WHEN** 用户查看抽屉或通知中心
|
|
- **THEN** 页面 MUST display each item using its backend category, type and severity
|
|
- **AND** 页面 MUST not replace the item with hardcoded mock notification content
|