fix: 保存配方后0元bug + 标签字母排序
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
PR Preview / test (pull_request) Successful in 5s
Test / unit-test (push) Successful in 4s
Test / build-check (push) Successful in 4s
PR Preview / deploy-preview (pull_request) Successful in 14s
Test / e2e-test (push) Successful in 50s

- 保存公共配方后reload从服务器重新获取(修复oil_name覆盖oil导致显示0元)
- 配方卡片标签按字母排序

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-10 21:34:16 +00:00
parent 3c808be7e5
commit eff4332aae
2 changed files with 4 additions and 6 deletions

View File

@@ -36,8 +36,8 @@ const auth = useAuthStore()
const visibleTags = computed(() => {
if (!props.recipe.tags) return []
if (auth.canEdit) return props.recipe.tags
return props.recipe.tags.filter(t => !EDITOR_ONLY_TAGS.includes(t))
const tags = auth.canEdit ? [...props.recipe.tags] : props.recipe.tags.filter(t => !EDITOR_ONLY_TAGS.includes(t))
return tags.sort((a, b) => a.localeCompare(b, 'zh'))
})
const oilNames = computed(() =>

View File

@@ -48,10 +48,8 @@ export const useRecipesStore = defineStore('recipes', () => {
async function saveRecipe(recipe) {
if (recipe._id) {
const data = await api.put(`/api/recipes/${recipe._id}`, recipe)
const idx = recipes.value.findIndex((r) => r._id === recipe._id)
if (idx !== -1) {
recipes.value[idx] = { ...recipes.value[idx], ...recipe, _version: data._version ?? data.version ?? recipe._version }
}
// Reload from server to get properly formatted data (oil_name → oil mapping)
await loadRecipes()
return data
} else {
const data = await api.post('/api/recipes', recipe)