全局中文化

This commit is contained in:
Cheng Zhou
2026-01-12 11:14:04 +08:00
parent 9021c7fe2b
commit 1338fa7e2b
103 changed files with 2443 additions and 1533 deletions
+9 -8
View File
@@ -2,6 +2,7 @@ import { auditDict } from "./auditDict";
import { roleDict, getDictLabel, statusDict } from "../dictionaries";
import { useAuthStore } from "../store/auth";
import { useStudyStore } from "../store/study";
import { TEXT } from "../locales";
export interface AuditEvent {
eventType: string;
@@ -32,9 +33,9 @@ const buildDiffText = (before?: Record<string, any>, after?: Record<string, any>
const next = after[key];
if (prev === next) return;
if (key.toLowerCase().includes("status")) {
lines.push(`状态:${getDictLabel(statusDict, prev)}${getDictLabel(statusDict, next)}`);
lines.push(`${TEXT.audit.statusLabel}${getDictLabel(statusDict, prev)}${getDictLabel(statusDict, next)}`);
} else {
lines.push(`${key}${prev ?? "-"}${next ?? "-"}`);
lines.push(`${key}${prev ?? TEXT.audit.emptyValue}${next ?? TEXT.audit.emptyValue}`);
}
});
return lines;
@@ -42,9 +43,9 @@ const buildDiffText = (before?: Record<string, any>, after?: Record<string, any>
export const normalizeAuditEvent = (raw: any, userMap: Record<string, string>): AuditEvent => {
const dict = auditDict[raw.action] || {
label: "系统操作",
actionText: "执行了操作",
targetLabel: raw.entity_type || "对象",
label: TEXT.audit.eventFallback,
actionText: TEXT.audit.actionFallback,
targetLabel: raw.entity_type || TEXT.audit.targetFallback,
};
let detailObj: any = {};
if (raw.detail) {
@@ -74,7 +75,7 @@ export const normalizeAuditEvent = (raw: any, userMap: Record<string, string>):
diffText: Array.isArray(diffText) ? diffText : diffText ? [diffText] : [],
reason: detailObj.reason,
result: detailObj.result || "SUCCESS",
resultLabel: detailObj.result === "FAIL" ? "失败" : "成功",
resultLabel: detailObj.result === "FAIL" ? TEXT.audit.resultFail : TEXT.audit.resultSuccess,
timestamp: raw.created_at,
};
};
@@ -105,9 +106,9 @@ export const logAudit = async (eventType: string, payload: Record<string, any>)
const studyId = study.currentStudy?.id || null;
const log = {
action: eventType,
operator_id: user?.id || user?.username || "current_user",
operator_id: user?.id || user?.username || TEXT.audit.currentUser,
operator_role: user?.role || "",
entity_type: payload.targetType || "client",
entity_type: payload.targetType || TEXT.audit.localClient,
entity_id: payload.targetId || "",
created_at: new Date().toISOString(),
detail: JSON.stringify({