修复伦理与启动管理的显示问题

This commit is contained in:
Cheng Zhou
2025-12-19 11:28:34 +08:00
parent b475d4f763
commit 1e3e064871
4 changed files with 33 additions and 7 deletions
+19 -2
View File
@@ -101,6 +101,23 @@ import { exportAuditCsv } from "../../audit/export/auditExportService";
import { logAudit } from "../../audit";
import { displayDateTime } from "../../utils/display";
const buildLogKey = (log: any) => {
if (log.id) return `id:${log.id}`;
return `${log.action || log.eventType || "event"}-${log.entity_id || log.entityId || ""}-${log.created_at || log.timestamp || ""}`;
};
const dedupeLogs = (list: any[]) => {
const seen = new Set<string>();
const result: any[] = [];
list.forEach((log) => {
const key = buildLogKey(log);
if (seen.has(key)) return;
seen.add(key);
result.push(log);
});
return result;
};
const study = useStudyStore();
const auth = useAuthStore();
const router = useRouter();
@@ -163,7 +180,7 @@ const loadLogs = async () => {
const { data } = await fetchAuditLogs(study.currentStudy.id, params);
const items = Array.isArray(data) ? data : (data as any).items || [];
const local = loadLocalLogs();
const merged = [...items, ...local];
const merged = dedupeLogs([...items, ...local]);
rawLogs.value = merged;
total.value = (data as any).total || merged.length;
enrichLogs();
@@ -233,7 +250,7 @@ const fetchAllForExport = async () => {
const { data } = await fetchAuditLogs(study.currentStudy.id, params);
const items = Array.isArray(data) ? data : (data as any).items || [];
const local = loadLocalLogs();
const merged = [...items, ...local];
const merged = dedupeLogs([...items, ...local]);
const userMap = users.value.reduce<Record<string, string>>((acc, cur) => {
acc[cur.id] = cur.username;
return acc;