fix: 贡献统计和共享状态基于真实数据
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 4s
PR Preview / deploy-preview (pull_request) Successful in 13s
Test / e2e-test (push) Failing after 56s

- 后端返回 adopted_names 和 pending_names 列表
- 共享状态根据实际被采纳/待审核的配方名匹配
- 不再按公共库同名配方误判为已共享
- 共享后实时刷新统计

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-10 15:58:44 +00:00
parent fc04539b28
commit f3e4329d1f
2 changed files with 29 additions and 18 deletions

View File

@@ -1028,14 +1028,19 @@ async function saveAllParsed() {
closeOverlay()
}
const sharedCount = ref({ adopted: 0, total: 0 })
const sharedCount = ref({ adopted: 0, total: 0, adoptedNames: [], pendingNames: [] })
async function loadContribution() {
try {
const res = await api('/api/me/contribution')
if (res.ok) {
const data = await res.json()
sharedCount.value = { adopted: data.adopted_count || 0, total: data.shared_count || 0 }
sharedCount.value = {
adopted: data.adopted_count || 0,
total: data.shared_count || 0,
adoptedNames: data.adopted_names || [],
pendingNames: data.pending_names || [],
}
}
} catch {}
}
@@ -1136,11 +1141,9 @@ function openRecipeDetail(recipe) {
}
function getDiaryShareStatus(d) {
// Check if a public recipe with same name exists, owned by current user or adopted by admin
const pub = recipeStore.recipes.find(r => r.name === d.name)
if (!pub) return null
if (pub._owner_id === auth.user?.id) return 'pending'
return 'shared'
if (sharedCount.value.adoptedNames.includes(d.name)) return 'shared'
if (sharedCount.value.pendingNames.includes(d.name)) return 'pending'
return null
}
async function shareDiaryToPublic(diary) {