This commit is contained in:
freedakgmail
2025-11-24 16:07:24 +08:00
parent 3d075c6076
commit b25f4bea02
426 changed files with 3619 additions and 4468 deletions
+7 -5
View File
@@ -24,10 +24,10 @@ export async function recordMemberHistory(params: {
const nextVersion = (lastHistory?.version || 0) + 1
// 计算变更的字段
let changes: Record<string, { old: any, new: any }> | null = null
let changes: Record<string, { old: any, new: any }> | undefined = undefined
if (changeType === 'UPDATE' && oldData) {
changes = {}
const tempChanges: Record<string, { old: any, new: any }> = {}
const fieldsToTrack = [
'fullName', 'surname', 'givenName', 'gender', 'birthDate', 'deathDate',
'birthPlace', 'ancestralHome', 'generation', 'bio', 'phone', 'email',
@@ -43,14 +43,16 @@ export async function recordMemberHistory(params: {
// 比较值是否真的变化了
const isChanged = JSON.stringify(oldValue) !== JSON.stringify(newValue)
if (isChanged) {
changes[field] = { old: oldValue, new: newValue }
tempChanges[field] = { old: oldValue, new: newValue }
}
}
// 如果没有实际变更,不记录
if (Object.keys(changes).length === 0) {
if (Object.keys(tempChanges).length === 0) {
return null
}
changes = tempChanges
}
// 创建历史记录
@@ -62,7 +64,7 @@ export async function recordMemberHistory(params: {
snapshot: newData,
changedBy,
changeType,
changes,
changes: changes || undefined,
}
})