审计日志搜索框:防抖检索、回溯进度与补批封顶
CI / test (push) Successful in 27s

This commit is contained in:
2026-07-16 16:36:42 +08:00
parent b8c0ddda6d
commit 6ea222e5ab
3 changed files with 112 additions and 26 deletions
+15 -8
View File
@@ -182,17 +182,24 @@ export function deleteUserApiKeys(
// ---- 审计日志 ----
/** 批式懒加载查询审计事件:cursor 空自当前时刻首查,
* 非空从上次响应游标向更早续取一批(~100 条,服务端分窗回溯) */
* 非空从上次响应游标向更早续取一批(~200 条,服务端分窗回溯);
* q 为服务端全文检索关键字,仅首查生效(续查沿用游标内嵌关键字) */
export function listAuditEvents(
id: number,
opts: { region?: string; cursor?: string; limit?: number } = {},
opts: { region?: string; cursor?: string; limit?: number; q?: string } = {},
): Promise<AuditEventsResult> {
// mock:首批带游标,续查一批后到尽头,演示懒加载链路
if (mockOn)
return mocked(
{ items: mockAuditEvents, cursor: opts.cursor ? undefined : 'mock-cursor', exhausted: !!opts.cursor },
300,
)
// mock:首批带游标,续查一批后到尽头,演示懒加载链路;q 演示不区分大小写的包含匹配
if (mockOn) {
const kw = (opts.q ?? '').replace(/\*/g, '').toLowerCase()
const items = kw
? mockAuditEvents.filter((e) =>
[e.eventName, e.resourceName, e.principalName, e.ipAddress, e.source].some((v) =>
(v ?? '').toLowerCase().includes(kw),
),
)
: mockAuditEvents
return mocked({ items, cursor: opts.cursor ? undefined : 'mock-cursor', exhausted: !!opts.cursor }, 300)
}
return request(`/oci-configs/${id}/audit-events`, { query: { ...opts } })
}