修复云端数据一致性问题

This commit is contained in:
2026-07-29 11:03:44 +08:00
parent a3dd080b6f
commit 17727ab1dd
12 changed files with 389 additions and 41 deletions
+19
View File
@@ -0,0 +1,19 @@
const crypto = require('crypto')
const memberKey = (openid) =>
crypto.createHash('sha256').update(String(openid || '')).digest('hex')
const publicEntry = (entry) => {
if (!entry) return null
const { memberKey: _memberKey, openid: _openid, ...publicData } = entry
return publicData
}
const publicRanked = (ranked) => (ranked || []).map(publicEntry)
const findMyEntry = (ranked, key) => {
const item = (ranked || []).find(entry => entry.memberKey === key)
return item ? { ...publicEntry(item), isMe: true } : null
}
module.exports = { memberKey, publicEntry, publicRanked, findMyEntry }