2 Commits

Author SHA1 Message Date
b07b97bf1e fix: 存为我的改写入 recipes 表,确保在「我的配方」和「管理配方」中显示
Some checks failed
Test / unit-test (push) Successful in 4s
Test / build-check (push) Successful in 3s
Test / e2e-test (push) Failing after 1m6s
PR Preview / test (pull_request) Has been skipped
PR Preview / teardown-preview (pull_request) Successful in 13s
PR Preview / deploy-preview (pull_request) Has been skipped
之前 saveToDiary() 调用 POST /api/diary,数据写入 user_diary 表,
只在「我的配方日记」(/mydiary) 中可见。
改为调用 recipesStore.saveRecipe(),写入 recipes 表并以当前用户为 owner,
GET /api/recipes 会返回该用户自己创建的配方,
RecipeSearch 的「我的配方」预览和 RecipeManager 的配方列表均可显示。

Co-Authored-By: YoYo <yoyo@euphon.net>
2026-04-08 19:44:15 +00:00
2ab192c3ba feat: 存为我的提示框改用自定义 CustomDialog
Some checks failed
Test / unit-test (push) Successful in 4s
Test / build-check (push) Successful in 3s
PR Preview / teardown-preview (pull_request) Has been skipped
Test / e2e-test (push) Failing after 1m7s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 15s
将 saveToDiary 中的原生 prompt() 替换为项目内置的
showPrompt(),与全站风格保持一致。
2026-04-07 22:49:07 +00:00

View File

@@ -350,6 +350,7 @@ import { useUiStore } from '../stores/ui'
import { useDiaryStore } from '../stores/diary' import { useDiaryStore } from '../stores/diary'
import { api } from '../composables/useApi' import { api } from '../composables/useApi'
import { oilEn, recipeNameEn } from '../composables/useOilTranslation' import { oilEn, recipeNameEn } from '../composables/useOilTranslation'
import { showPrompt } from '../composables/useDialog'
// TagPicker replaced with inline tag editing // TagPicker replaced with inline tag editing
const props = defineProps({ const props = defineProps({
@@ -576,16 +577,16 @@ async function saveToDiary() {
ui.openLogin() ui.openLogin()
return return
} }
const name = prompt('保存为我的配方,名称:', recipe.value.name) const name = await showPrompt('保存为我的配方,名称:', recipe.value.name)
if (!name) return if (!name) return
try { try {
await api.post('/api/diary', { await recipesStore.saveRecipe({
name, name,
source_recipe_id: recipe.value._id || null,
ingredients: recipe.value.ingredients.map(i => ({ oil: i.oil, drops: i.drops })),
note: recipe.value.note || '', 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) { } catch (e) {
ui.showToast('保存失败: ' + (e?.message || '未知错误')) ui.showToast('保存失败: ' + (e?.message || '未知错误'))
} }