fix: 存为我的改写入 recipes 表,确保在「我的配方」和「管理配方」中显示
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 5s
PR Preview / deploy-preview (pull_request) Successful in 15s
Test / e2e-test (push) Failing after 1m23s

之前 saveToDiary() 调用 POST /api/diary,数据写入 user_diary 表,
只在「我的配方日记」(/mydiary) 中可见。
改为调用 recipesStore.saveRecipe(),写入 recipes 表并以当前用户为 owner,
GET /api/recipes 会返回该用户自己创建的配方,
RecipeSearch 的「我的配方」预览和 RecipeManager 的配方列表均可显示。

Co-Authored-By: YoYo <yoyo@euphon.net>
This commit is contained in:
2026-04-08 19:44:15 +00:00
committed by YoYo
parent dcf516f2de
commit cc79ae1211

View File

@@ -635,13 +635,13 @@ async function saveToDiary() {
const name = await showPrompt('保存为我的配方,名称:', recipe.value.name)
if (!name) return
try {
await api.post('/api/diary', {
await recipesStore.saveRecipe({
name,
source_recipe_id: recipe.value._id || null,
ingredients: recipe.value.ingredients.map(i => ({ oil: i.oil, drops: i.drops })),
note: recipe.value.note || '',
ingredients: recipe.value.ingredients.map(i => ({ oil_name: i.oil, drops: i.drops })),
tags: recipe.value.tags || [],
})
ui.showToast('已保存到「我的配方日记」')
ui.showToast('已保存到「我的配方」')
} catch (e) {
ui.showToast('保存失败: ' + (e?.message || '未知错误'))
}