feat(站内通知): 铃铛支持按类型大类筛选(系统异常/任务异常/配置异常/系统通知)
原来铃铛只能按关键字和日期筛,任务失败、密钥欠费、麦象异常全混在一起, 用户没法只看自己关心的那类。 后端 NotificationService 增加 scene→大类映射(未知 scene 归「系统通知」兜底), 列表接口新增 category 参数,落到 SQL 是 scene IN (...);「系统通知」作兜底类 还要纳入未登记的 scene,故表达为「= system 或 不在其它三类里」。列表项返回 category,前端不必各自维护一份 scene 映射。前后端两个通知接口同步加参数。 前端铃铛筛选区新增一行类型 chip(全部 + 四类),与关键字、日期一起参与 hasFilter 与重置;空分类不下发,避免后端查询落空。
This commit is contained in:
@@ -11,11 +11,33 @@ export type NotificationScene =
|
||||
| 'maixiang_anomaly'
|
||||
| 'system'
|
||||
|
||||
/**
|
||||
* 通知类型大类:后端按 scene 归并出的四类,铃铛筛选与标签都用它。
|
||||
* 未知/历史遗留 scene 由后端兜底归入 system_notice。
|
||||
*/
|
||||
export type NotificationCategory =
|
||||
| 'system_error'
|
||||
| 'task_error'
|
||||
| 'config_error'
|
||||
| 'system_notice'
|
||||
|
||||
/** 类型筛选项(顺序即下拉顺序):全部 + 四个大类。 */
|
||||
export const NOTIFICATION_CATEGORY_OPTIONS: ReadonlyArray<{
|
||||
value: NotificationCategory
|
||||
label: string
|
||||
}> = [
|
||||
{ value: 'system_error', label: '系统异常' },
|
||||
{ value: 'task_error', label: '任务异常' },
|
||||
{ value: 'config_error', label: '配置异常' },
|
||||
{ value: 'system_notice', label: '系统通知' },
|
||||
]
|
||||
|
||||
export type NotificationLevel = 'info' | 'warning' | 'error'
|
||||
|
||||
export interface NotificationItem {
|
||||
id: number
|
||||
scene: string
|
||||
category: string
|
||||
level: string
|
||||
title: string
|
||||
content: string
|
||||
@@ -44,19 +66,24 @@ export function fetchNotificationSummary() {
|
||||
)
|
||||
}
|
||||
|
||||
/** 列表查询参数:关键字匹配标题/内容;startDate/endDate 为年月日闭区间(yyyy-MM-dd)。 */
|
||||
/**
|
||||
* 列表查询参数:关键字匹配标题/内容;category 按类型大类筛选;
|
||||
* startDate/endDate 为年月日闭区间(yyyy-MM-dd)。
|
||||
*/
|
||||
export interface NotificationListParams {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
onlyUnread?: boolean
|
||||
keyword?: string
|
||||
category?: string
|
||||
startDate?: string
|
||||
endDate?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询参数:关键字匹配标题/内容;startDate/endDate 为年月日闭区间(yyyy-MM-dd)。
|
||||
* 空关键字/日期一律不下发(空串会让后端日期绑定失败返回 400)。
|
||||
* 列表查询参数:关键字匹配标题/内容;category 按类型大类筛选;
|
||||
* startDate/endDate 为年月日闭区间(yyyy-MM-dd)。
|
||||
* 空关键字/日期/分类一律不下发(空串会让后端日期绑定失败返回 400)。
|
||||
*/
|
||||
export function buildNotificationListQuery(
|
||||
params: NotificationListParams = {},
|
||||
@@ -70,6 +97,10 @@ export function buildNotificationListQuery(
|
||||
if (keyword) {
|
||||
query.keyword = keyword
|
||||
}
|
||||
const category = (params.category ?? '').trim()
|
||||
if (category) {
|
||||
query.category = category
|
||||
}
|
||||
if (params.startDate) {
|
||||
query.startDate = params.startDate
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user