Files
2026-07-29 10:25:13 +08:00

92 lines
4.4 KiB
Markdown

## ADDED Requirements
### Requirement: Home notification entry
The authenticated home page SHALL expose a notification entry for both supported account types. The entry MUST use `src/static/icons/通知.png`, display the current unread count when available, and open the notification page. Notification content MUST NOT resolve controlled targets or navigate to business resources.
#### Scenario: Agent sees notification entry
- **GIVEN** an authenticated agent is viewing the home page
- **WHEN** the unread-count request succeeds
- **THEN** the home page shows the notification icon and the returned unread badge text
- **AND** activating the entry opens the notification page without resolving a target
#### Scenario: Enterprise sees notification entry
- **GIVEN** an authenticated enterprise user is viewing the home page
- **WHEN** the home page renders its shortcuts
- **THEN** the notification entry is available with the same icon and behavior
#### Scenario: Unread-count failure does not block home
- **GIVEN** the authenticated home page has loaded
- **WHEN** the unread-count request fails
- **THEN** the home page remains usable
- **AND** no fabricated unread count is displayed
### Requirement: Notification list display
The notification page SHALL request the current account's non-expired notifications from `GET /api/admin/notifications`, display them newest first using the server order, and show each notification's title, body, category, severity, and creation time. Notification rows MUST be display-only and MUST NOT invoke `GET /api/admin/notifications/{id}/target` or navigate to another business page.
#### Scenario: Latest notifications are displayed
- **GIVEN** the notification page is opened
- **WHEN** the notification list request succeeds
- **THEN** the newest notification is rendered first
- **AND** each rendered notification shows its text content and read state
#### Scenario: No notifications
- **GIVEN** the notification page is opened
- **WHEN** the server returns an empty item list
- **THEN** the page shows an empty state
- **AND** it does not attempt target resolution
### Requirement: Post-login unread reminder
After a successful login redirects to the home page, the system SHALL request the newest unread notification and show it in a reminder modal when one exists. The newest unread notification MUST be the default displayed message. The reminder MUST not navigate to a controlled target.
#### Scenario: Newest unread notification is shown after login
- **GIVEN** a user has successfully logged in and is redirected to the home page
- **AND** at least one unread notification exists
- **WHEN** the home page finishes loading the authenticated session
- **THEN** a reminder modal displays the newest unread notification's title and body by default
#### Scenario: No unread notification
- **GIVEN** a user has successfully logged in and is redirected to the home page
- **WHEN** the unread notification query returns no items
- **THEN** no reminder modal is shown
#### Scenario: Reminder query failure
- **GIVEN** a user has successfully logged in and is redirected to the home page
- **WHEN** the newest unread notification query fails
- **THEN** the home page remains usable
- **AND** no reminder modal is shown
### Requirement: Read on visibility
The system SHALL mark an unread notification as read when its content becomes visible in the reminder modal or notification list. The UI MUST NOT require a manual read button, and it MUST update the local read state after initiating the read request.
#### Scenario: Reminder marks visible notification read
- **GIVEN** the newest unread notification is shown in the post-login reminder modal
- **WHEN** the modal becomes visible
- **THEN** the client calls `PUT /api/admin/notifications/{id}/read` for that notification
- **AND** the notification is treated as read locally without a manual action
#### Scenario: List marks visible unread notifications read
- **GIVEN** the notification page renders one or more unread notifications
- **WHEN** those notification rows become visible
- **THEN** the client initiates an idempotent read request for each visible unread notification
- **AND** no manual read control is rendered
#### Scenario: Read request is idempotent
- **GIVEN** a notification has already been marked read
- **WHEN** the client repeats the read request
- **THEN** the UI remains in the read state and the repeated request does not create a user-visible error