@@ -15,25 +15,24 @@ if (denied) Astro.response.status = 403;
1515const PER_PAGE = 50 ;
1616const page = getPage (Astro .url .searchParams );
1717const action = (Astro .url .searchParams .get (' action' ) || ' ' ).trim ();
18- const result = Astro .url .searchParams .get (' result' ) || ' ' ;
18+ const resultQ = Astro .url .searchParams .get (' result' ) || ' ' ;
1919
2020const parts: string [] = [];
2121if (action ) parts .push (` action ~ "${action .replace (/ "/ g , ' \\ "' )}" ` );
22- if (result === ' success' ) parts .push (` result = "success" ` );
23- if (result === ' failure' ) parts .push (` result = "failure" ` );
22+ if (resultQ ) parts .push (` result = "${resultQ }" ` );
2423const filter = parts .join (' && ' );
2524
26- const { data : result } = denied ? { data: undefined } : await safe (
25+ const { data : auditList } = denied ? { data: undefined } : await safe (
2726 () => pb .collection (' audits' ).getList (page , PER_PAGE , {
2827 sort: ' -created' ,
2928 expand: ' actor' ,
3029 filter: filter || undefined ,
3130 }),
3231 ' admin/audits'
3332);
34- const audits = result ?.items ?? [];
35- const totalAudits = result ?.totalItems ?? 0 ;
36- const totalPages = result ?.totalPages ?? 1 ;
33+ const audits = auditList ?.items ?? [];
34+ const totalAudits = auditList ?.totalItems ?? 0 ;
35+ const totalPages = auditList ?.totalPages ?? 1 ;
3736
3837function expandName(a : any ): string {
3938 const u = a ?.expand ?.actor ;
@@ -51,16 +50,16 @@ function expandName(a: any): string {
5150 <form method = " get" class = " flex gap-2 flex-wrap items-center my-3 text-sm" >
5251 <input name = " action" value = { action } placeholder = " 动作关键字 (如 auth.login)" class = " px-1.5 py-0.5 w-56" />
5352 <select name = " result" class = " px-1.5 py-0.5" >
54- <option value = " " selected = { ! result } >全部结果</option >
55- <option value = " success" selected = { result === ' success' } >成功</option >
56- <option value = " failure" selected = { result === ' failure' } >失败</option >
53+ <option value = " " selected = { ! resultQ } >全部结果</option >
54+ <option value = " success" selected = { resultQ === ' success' } >成功</option >
55+ <option value = " failure" selected = { resultQ === ' failure' } >失败</option >
5756 </select >
5857 <button type = " submit" >筛选</button >
59- { (action || result ) && <a href = " /admin/audits" class = " text-[var(--color-text-muted)]" >清除</a >}
58+ { (action || resultQ ) && <a href = " /admin/audits" class = " text-[var(--color-text-muted)]" >清除</a >}
6059 </form >
6160
6261 { audits .length === 0 ? (
63- <p >{ (action || result ) ? ' 没有匹配的记录。' : ' 暂无审计记录。' } </p >
62+ <p >{ (action || resultQ ) ? ' 没有匹配的记录。' : ' 暂无审计记录。' } </p >
6463 ) : (
6564 <table class = " w-full border-collapse text-xs" >
6665 <thead >
0 commit comments