From 8738650bce0763eadf144a06f1d847739c06365d Mon Sep 17 00:00:00 2001 From: Hera Zhao Date: Fri, 10 Apr 2026 09:01:45 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=AE=A1=E7=90=86=E9=85=8D=E6=96=B9?= =?UTF-8?q?=E5=8A=A0=E5=85=B1=E4=BA=AB=E6=8C=89=E9=92=AE+=E7=8A=B6?= =?UTF-8?q?=E6=80=81+=E8=B4=A1=E7=8C=AE=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 我的配方每行加📤共享按钮 - 显示共享状态:已共享(绿)/等待审核(橙) - 已共享的隐藏共享按钮 - 非管理员显示"已贡献 X 条"统计 - 配方查询页去掉共享按钮(移到管理配方) Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/src/views/RecipeManager.vue | 66 ++++++++++++++++++++++++++++ frontend/src/views/RecipeSearch.vue | 1 - 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/RecipeManager.vue b/frontend/src/views/RecipeManager.vue index 6cd0750..0b6c0af 100644 --- a/frontend/src/views/RecipeManager.vue +++ b/frontend/src/views/RecipeManager.vue @@ -62,6 +62,7 @@

📖 我的配方 ({{ myRecipes.length }}) + 已贡献 {{ sharedCount }} 条

@@ -84,8 +85,11 @@ {{ t }} {{ oils.fmtPrice(oils.calcCost(d.ingredients || [])) }} + +
+
@@ -609,10 +613,19 @@ async function saveAllParsed() { closeOverlay() } +const sharedCount = ref(0) + // Load diary on mount onMounted(async () => { if (auth.isLoggedIn) { await diaryStore.loadDiary() + try { + const res = await api('/api/me/contribution') + if (res.ok) { + const data = await res.json() + sharedCount.value = data.shared_count || 0 + } + } catch {} } }) @@ -625,6 +638,40 @@ function editDiaryRecipe(diary) { showAddOverlay.value = true } +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' +} + +async function shareDiaryToPublic(diary) { + const ok = await showConfirm(`将「${diary.name}」共享到公共配方库?`) + if (!ok) return + try { + const res = await api('/api/recipes', { + method: 'POST', + body: JSON.stringify({ + name: diary.name, + note: diary.note || '', + ingredients: (diary.ingredients || []).map(i => ({ oil_name: i.oil, drops: i.drops })), + tags: diary.tags || [], + }), + }) + if (res.ok) { + if (auth.isAdmin) { + ui.showToast('已共享到公共配方库') + } else { + ui.showToast('已提交,等待管理员审核') + } + await recipeStore.loadRecipes() + } + } catch { + ui.showToast('共享失败') + } +} + async function removeDiaryRecipe(diary) { const ok = await showConfirm(`确定删除个人配方 "${diary.name}"?`) if (!ok) return @@ -928,6 +975,25 @@ watch(() => recipeStore.recipes, () => { color: #6b6375; } +.share-tag { + font-size: 11px; + padding: 1px 8px; + border-radius: 8px; + font-weight: 500; + white-space: nowrap; +} +.share-tag.shared { background: #e8f5e9; color: #2e7d32; } +.share-tag.pending { background: #fff3e0; color: #e65100; } + +.contrib-tag { + font-size: 11px; + color: #4a9d7e; + background: #e8f5e9; + padding: 2px 8px; + border-radius: 8px; + font-weight: 500; +} + .row-cost { font-size: 13px; color: #4a9d7e; diff --git a/frontend/src/views/RecipeSearch.vue b/frontend/src/views/RecipeSearch.vue index 1f04aa1..eaf465d 100644 --- a/frontend/src/views/RecipeSearch.vue +++ b/frontend/src/views/RecipeSearch.vue @@ -64,7 +64,6 @@ /> -
暂无个人配方