diff --git a/frontend/src/components/RecipeCard.vue b/frontend/src/components/RecipeCard.vue index 2d633e7..7606d35 100644 --- a/frontend/src/components/RecipeCard.vue +++ b/frontend/src/components/RecipeCard.vue @@ -56,13 +56,10 @@ const volumeLabel = computed(() => { if (ml <= 2) return '单次' return `${Math.round(ml)}ml` } - // Non-coconut: check if has portion product, extract volume from note - const hasPortion = ings.some(i => oilsStore.isPortionUnit(i.oil)) - if (hasPortion) { - const note = props.recipe.note || '' - const m = note.match(/(\d+)\s*(ml|毫升|克|g)/i) - if (m) return `${m[1]}${m[2].toLowerCase()}` - return '调配' + // Non-coconut: find portion product and show its amount + unit + const portionIng = ings.find(i => oilsStore.isPortionUnit(i.oil)) + if (portionIng) { + return `${portionIng.drops}${oilsStore.unitLabel(portionIng.oil)}` } return '' }) diff --git a/frontend/src/stores/oils.js b/frontend/src/stores/oils.js index 234573f..256b5fe 100644 --- a/frontend/src/stores/oils.js +++ b/frontend/src/stores/oils.js @@ -77,14 +77,16 @@ export const useOilsStore = defineStore('oils', () => { oilsMeta.value = newMeta } - async function saveOil(name, bottlePrice, dropCount, retailPrice, enName = null) { - await api.post('/api/oils', { + async function saveOil(name, bottlePrice, dropCount, retailPrice, enName = null, unit = null) { + const payload = { name, bottle_price: bottlePrice, drop_count: dropCount, retail_price: retailPrice, en_name: enName, - }) + } + if (unit) payload.unit = unit + await api.post('/api/oils', payload) await loadOils() } diff --git a/frontend/src/views/OilReference.vue b/frontend/src/views/OilReference.vue index 4123a5f..ced2b89 100644 --- a/frontend/src/views/OilReference.vue +++ b/frontend/src/views/OilReference.vue @@ -107,7 +107,12 @@