feat: 大量管理配方和搜索改进

- 存为我的:修复调用错误API,改用 diaryStore.createDiary
- 存为我的:同名检测(我的配方 + 公共配方库)
- 我的配方:使用 RecipeCard 统一卡片格式
- 管理配方:按钮缩小、编辑时隐藏智能粘贴、精油搜索框支持拼音跳转
- 管理配方:批量操作改为按钮组(打标签/删除/导出卡片/分享到公共库)
- 管理配方:我的配方加勾选框、全选按钮、编辑功能
- 搜索:模糊匹配 + 同义词扩展(37组),精确/相似分层显示
- 搜索:无匹配时通知编辑添加,搜索时隐藏无匹配的收藏/我的配方区
- 搜索:配方按首字母排序
- 共享审核:通知高级编辑+管理员,我的配方显示共享状态
- 通知:搜索未收录→已添加按钮,审核类→去审核按钮跳转
- 贡献统计:非管理员显示已贡献公共配方数
- 登录弹窗:加反馈问题按钮(无需登录)
- 精油编辑:右上角加保存按钮,支持回车保存
- 后端:新增 /api/me/contribution 接口

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-09 20:13:09 +00:00
committed by fam
parent 80397ec7ca
commit 27c46cb803
7 changed files with 645 additions and 154 deletions

View File

@@ -9,7 +9,7 @@
<button class="action-btn action-btn-fav action-btn-sm" @click="handleToggleFavorite">
{{ isFav ? ' 已收藏' : ' 收藏' }}
</button>
<button v-if="!recipe._diary_id" class="action-btn action-btn-diary action-btn-sm" @click="saveToDiary">
<button v-if="!props.isDiary" class="action-btn action-btn-diary action-btn-sm" @click="saveToDiary">
📔 存为我的
</button>
</div>
@@ -359,7 +359,9 @@ import { matchesPinyinInitials } from '../composables/usePinyinMatch'
// TagPicker replaced with inline tag editing
const props = defineProps({
recipeIndex: { type: Number, required: true },
recipeIndex: { type: Number, default: null },
recipeData: { type: Object, default: null },
isDiary: { type: Boolean, default: false },
})
const emit = defineEmits(['close'])
@@ -386,9 +388,10 @@ const generatingImage = ref(false)
const previewOverride = ref(null)
// ---- Source recipe ----
const recipe = computed(() =>
recipesStore.recipes[props.recipeIndex] || { name: '', ingredients: [], tags: [], note: '' }
)
const recipe = computed(() => {
if (props.recipeData) return props.recipeData
return recipesStore.recipes[props.recipeIndex] || { name: '', ingredients: [], tags: [], note: '' }
})
// ---- Display recipe: previewOverride when in preview mode, otherwise saved recipe ----
const displayRecipe = computed(() => {
@@ -710,22 +713,31 @@ async function saveToDiary() {
return
}
const name = await showPrompt('保存为我的配方,名称:', recipe.value.name)
// null = user cancelled (clicked 取消)
if (name === null) return
// empty string = user cleared the name field
if (!name.trim()) {
ui.showToast('请输入配方名称')
return
}
const trimmed = name.trim()
const dupDiary = diaryStore.userDiary.some(d => d.name === trimmed)
const dupPublic = recipesStore.recipes.some(r => r.name === trimmed)
if (dupDiary) {
ui.showToast('我的配方中已有同名配方「' + trimmed + '」')
return
}
if (dupPublic) {
ui.showToast('公共配方库中已有同名配方「' + trimmed + '」')
return
}
try {
const payload = {
name: name.trim(),
note: recipe.value.note || '',
ingredients: recipe.value.ingredients.map(i => ({ oil_name: i.oil, drops: i.drops })),
ingredients: recipe.value.ingredients.map(i => ({ oil: i.oil, drops: i.drops })),
tags: recipe.value.tags || [],
source_recipe_id: recipe.value._id || null,
}
console.log('[saveToDiary] saving recipe:', payload)
await recipesStore.saveRecipe(payload)
await diaryStore.createDiary(payload)
ui.showToast('已保存!可在「配方查询 → 我的配方」查看')
} catch (e) {
console.error('[saveToDiary] failed:', e)