7 Commits

Author SHA1 Message Date
76c9316ede test: 新增PR#22相关单元测试
All checks were successful
Deploy Production / test (push) Successful in 6s
Deploy Production / deploy (push) Successful in 6s
PR Preview / teardown-preview (pull_request) Has been skipped
PR Preview / test (pull_request) Successful in 5s
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
PR Preview / deploy-preview (pull_request) Successful in 12s
Test / e2e-test (push) Successful in 51s
新增12个测试:
- 标签排序和EDITOR_ONLY_TAGS过滤
- Recipe数据格式(oil_name覆盖oil的bug验证)
- loadRecipes映射验证
- 容量检测(single/5/10/15/20/30/custom)
- 稀释比例计算和snap到最近选项

全部通过: 191 unit + 36 e2e

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 22:11:05 +00:00
9635cfe8ef fix: 选择容量时自动显示椰子油行 + 收回标签清除筛选
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 14s
Test / e2e-test (push) Failing after 56s
- 选容量后椰子油行自动出现(单次默认10滴,其他默认填满)
- 收回标签栏时清除所有标签筛选

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 22:03:29 +00:00
476d8bbd6e fix: 无椰子油配方编辑时不显示容量/椰子油/摘要
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 3s
PR Preview / test (pull_request) Successful in 4s
PR Preview / deploy-preview (pull_request) Successful in 16s
Test / e2e-test (push) Failing after 55s
- 无椰子油:容量不选中,摘要不显示,椰子油行不出现
- 有椰子油:自动匹配容量和稀释比例
- 新增配方默认无椰子油

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 21:58:59 +00:00
eff4332aae 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>
2026-04-10 21:34:16 +00:00
3c808be7e5 test: 新增单元测试和更新e2e测试
Some checks failed
Deploy Production / test (push) Successful in 5s
Deploy Production / deploy (push) Successful in 6s
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 10s
Test / e2e-test (push) Has been cancelled
新增单元测试 (11个):
- parseMultiRecipes: 单条/空格/连写/多条/无名称
- getPinyinInitials: 常见精油/忍冬花
- matchesPinyinInitials: 前缀匹配/不匹配子串/忍冬花
- EDITOR_ONLY_TAGS: 导出验证

E2E测试更新:
- recipe-detail: 适配新UI(无编辑按钮)
- 新增卡片视图测试

全部通过: 179 unit + 36 e2e

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 21:22:58 +00:00
0dfef3ab16 fix: 已审核标签对viewer完全不可见
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 4s
Test / build-check (push) Successful in 3s
PR Preview / test (pull_request) Successful in 4s
PR Preview / deploy-preview (pull_request) Successful in 16s
Test / e2e-test (push) Has been cancelled
- EDITOR_ONLY_TAGS常量从recipes store导出,统一引用
- RecipeCard: viewer不显示已审核标签
- RecipeSearch: viewer搜索不匹配已审核标签
- RecipeManager: 标签筛选栏、配方行标签对viewer隐藏
- 所有标签按字母排序(已有)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 21:13:20 +00:00
49aa5a0f3c fix: 防止编辑配方意外清空成分 + 编辑器不直接引用store
All checks were successful
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 14s
Test / e2e-test (push) Successful in 52s
- editRecipe不再直接引用store中的recipe对象(避免副作用)
- 保存时如果成分为空,弹出确认提示防止误操作
- 标签筛选时自动展开配方列表

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 21:03:35 +00:00
6 changed files with 304 additions and 27 deletions

View File

@@ -0,0 +1,87 @@
import { describe, it, expect } from 'vitest'
import { parseMultiRecipes } from '../composables/useSmartPaste'
import { getPinyinInitials, matchesPinyinInitials } from '../composables/usePinyinMatch'
const oilNames = ['薰衣草','茶树','柠檬','芳香调理','永久花','椒样薄荷','乳香','檀香','天竺葵','佛手柑','生姜']
// ---------------------------------------------------------------------------
// parseMultiRecipes
// ---------------------------------------------------------------------------
describe('parseMultiRecipes', () => {
it('parses single recipe with name', () => {
const results = parseMultiRecipes('舒缓放松薰衣草3茶树2', oilNames)
expect(results).toHaveLength(1)
expect(results[0].name).toBe('舒缓放松')
expect(results[0].ingredients).toHaveLength(2)
})
it('parses recipe with space-separated parts', () => {
const results = parseMultiRecipes('长高 芳香调理8 永久花10', oilNames)
expect(results).toHaveLength(1)
expect(results[0].name).toBe('长高')
expect(results[0].ingredients.length).toBeGreaterThanOrEqual(2)
})
it('parses recipe with concatenated name+oil', () => {
const results = parseMultiRecipes('长高芳香调理8永久花10', oilNames)
expect(results).toHaveLength(1)
expect(results[0].name).toBe('长高')
})
it('parses multiple recipes', () => {
const results = parseMultiRecipes('舒缓放松薰衣草3茶树2提神醒脑柠檬5', oilNames)
expect(results).toHaveLength(2)
expect(results[0].name).toBe('舒缓放松')
expect(results[1].name).toBe('提神醒脑')
})
it('handles recipe with no name', () => {
const results = parseMultiRecipes('薰衣草3茶树2', oilNames)
expect(results).toHaveLength(1)
expect(results[0].ingredients).toHaveLength(2)
})
})
// ---------------------------------------------------------------------------
// Pinyin matching
// ---------------------------------------------------------------------------
describe('getPinyinInitials', () => {
it('returns correct initials for common oils', () => {
expect(getPinyinInitials('薰衣草')).toBe('xyc')
expect(getPinyinInitials('茶树')).toBe('cs')
expect(getPinyinInitials('生姜')).toBe('sj')
})
it('handles 忍冬花', () => {
expect(getPinyinInitials('忍冬花呵护')).toBe('rdhhh')
})
})
describe('matchesPinyinInitials', () => {
it('matches prefix only', () => {
expect(matchesPinyinInitials('生姜', 's')).toBe(true)
expect(matchesPinyinInitials('生姜', 'sj')).toBe(true)
expect(matchesPinyinInitials('茶树', 's')).toBe(false) // cs doesn't start with s
expect(matchesPinyinInitials('茶树', 'cs')).toBe(true)
})
it('does not match substring', () => {
expect(matchesPinyinInitials('茶树', 's')).toBe(false)
})
it('matches 忍冬花 with r', () => {
expect(matchesPinyinInitials('忍冬花呵护', 'r')).toBe(true)
expect(matchesPinyinInitials('忍冬花呵护', 'rdh')).toBe(true)
expect(matchesPinyinInitials('忍冬花呵护', 'l')).toBe(false)
})
})
// ---------------------------------------------------------------------------
// EDITOR_ONLY_TAGS
// ---------------------------------------------------------------------------
describe('EDITOR_ONLY_TAGS', () => {
it('exports EDITOR_ONLY_TAGS from recipes store', async () => {
const { EDITOR_ONLY_TAGS } = await import('../stores/recipes')
expect(EDITOR_ONLY_TAGS).toContain('已审核')
})
})

View File

@@ -0,0 +1,126 @@
import { describe, it, expect } from 'vitest'
import { EDITOR_ONLY_TAGS } from '../stores/recipes'
// ---------------------------------------------------------------------------
// Tag sorting
// ---------------------------------------------------------------------------
describe('Tag sorting', () => {
it('sorts tags alphabetically with localeCompare zh', () => {
const tags = ['香水', '呼吸', '消化', '美容']
const sorted = [...tags].sort((a, b) => a.localeCompare(b, 'zh'))
expect(sorted[0]).toBe('呼吸')
// All sorted
for (let i = 1; i < sorted.length; i++) {
expect(sorted[i - 1].localeCompare(sorted[i], 'zh')).toBeLessThanOrEqual(0)
}
})
it('EDITOR_ONLY_TAGS filters correctly', () => {
const allTags = ['呼吸', '已审核', '消化', '香水']
const visible = allTags.filter(t => !EDITOR_ONLY_TAGS.includes(t))
expect(visible).not.toContain('已审核')
expect(visible).toContain('呼吸')
expect(visible).toHaveLength(3)
})
})
// ---------------------------------------------------------------------------
// Recipe save data format
// ---------------------------------------------------------------------------
describe('Recipe data format', () => {
it('oil_name format overwrites oil format when spread', () => {
// This test documents the bug that was fixed
const localRecipe = {
ingredients: [{ oil: '薰衣草', drops: 3 }],
}
const payload = {
ingredients: [{ oil_name: '薰衣草', drops: 3 }],
}
const merged = { ...localRecipe, ...payload }
// After merge, ingredients have oil_name not oil — this was the bug
expect(merged.ingredients[0]).toHaveProperty('oil_name')
expect(merged.ingredients[0]).not.toHaveProperty('oil')
})
it('loadRecipes mapping converts oil_name to oil', () => {
// Simulate what loadRecipes does
const apiData = [
{ id: 1, name: 'test', ingredients: [{ oil_name: '薰衣草', drops: 3 }], tags: [] }
]
const mapped = apiData.map(r => ({
...r,
ingredients: r.ingredients.map(ing => ({
oil: ing.oil_name ?? ing.oil,
drops: ing.drops,
}))
}))
expect(mapped[0].ingredients[0].oil).toBe('薰衣草')
expect(mapped[0].ingredients[0]).not.toHaveProperty('oil_name')
})
})
// ---------------------------------------------------------------------------
// Volume detection from ingredients
// ---------------------------------------------------------------------------
describe('Volume detection', () => {
const DROPS_PER_ML = 18.6
function guessVolume(eoDrops, cocoDrops) {
const totalDrops = eoDrops + cocoDrops
const ml = totalDrops / DROPS_PER_ML
if (ml <= 2) return 'single'
if (Math.abs(ml - 5) < 1.5) return '5'
if (Math.abs(ml - 10) < 2.5) return '10'
if (Math.abs(ml - 15) < 2.5) return '15'
if (Math.abs(ml - 20) < 3) return '20'
if (Math.abs(ml - 30) < 6) return '30'
return 'custom'
}
it('detects single use (small amounts)', () => {
expect(guessVolume(5, 10)).toBe('single')
})
it('detects 5ml', () => {
expect(guessVolume(15, Math.round(5 * DROPS_PER_ML) - 15)).toBe('5')
})
it('detects 10ml', () => {
expect(guessVolume(20, Math.round(10 * DROPS_PER_ML) - 20)).toBe('10')
})
it('detects 30ml', () => {
expect(guessVolume(50, Math.round(30 * DROPS_PER_ML) - 50)).toBe('30')
})
it('no coconut returns no volume', () => {
// When cocoDrops is 0, function still returns based on total
// But in real code, no coconut → formVolume = ''
expect(guessVolume(10, 0)).toBe('single')
})
it('detects custom for large volumes', () => {
expect(guessVolume(100, 1000)).toBe('custom')
})
})
// ---------------------------------------------------------------------------
// Dilution ratio calculation
// ---------------------------------------------------------------------------
describe('Dilution ratio', () => {
it('calculates ratio correctly', () => {
expect(Math.round(60 / 10)).toBe(6) // 1:6
expect(Math.round(30 / 10)).toBe(3) // 1:3
expect(Math.round(100 / 10)).toBe(10) // 1:10
})
it('snaps to nearest option', () => {
const options = [3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 20]
const snap = (ratio) => options.reduce((a, b) => Math.abs(b - ratio) < Math.abs(a - ratio) ? b : a)
expect(snap(6)).toBe(6)
expect([10, 12]).toContain(snap(11)) // equidistant
expect(snap(13)).toBe(12)
expect([12, 15]).toContain(snap(14))
expect(snap(18)).toBe(20)
})
})

View File

@@ -20,11 +20,9 @@
<script setup>
import { computed } from 'vue'
import { useOilsStore } from '../stores/oils'
import { useRecipesStore } from '../stores/recipes'
import { useRecipesStore, EDITOR_ONLY_TAGS } from '../stores/recipes'
import { useAuthStore } from '../stores/auth'
const EDITOR_ONLY_TAGS = ['已审核']
const props = defineProps({
recipe: { type: Object, required: true },
index: { type: Number, required: true },
@@ -38,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

@@ -2,6 +2,8 @@ import { defineStore } from 'pinia'
import { ref } from 'vue'
import { api } from '../composables/useApi'
export const EDITOR_ONLY_TAGS = ['已审核']
export const useRecipesStore = defineStore('recipes', () => {
const recipes = ref([])
const allTags = ref([])
@@ -46,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)

View File

@@ -42,14 +42,14 @@
<button class="action-chip" :class="{ active: isAllSelected }" @click="toggleSelectAll">
全选<span v-if="totalSelected > 0" class="chip-count">{{ totalSelected }}</span>
</button>
<button class="action-chip" :class="{ active: showTagFilter }" @click="showTagFilter = !showTagFilter">标签</button>
<button class="action-chip" :class="{ active: showTagFilter }" @click="toggleTagFilter">标签</button>
<button v-if="totalSelected > 0" class="action-chip" :class="{ active: showBatchMenu }" @click="showBatchMenu = !showBatchMenu">批量</button>
<button v-if="totalSelected > 0" class="action-chip cancel" @click="clearSelection">取消</button>
<button v-if="auth.isAdmin" class="export-btn" @click="exportExcel" title="导出Excel">📥</button>
</div>
<div v-if="showTagFilter" class="tag-list-bar">
<span
v-for="tag in recipeStore.allTags"
v-for="tag in visibleAllTags"
:key="tag"
class="tag-chip"
:class="{ active: selectedTags.includes(tag) }"
@@ -126,7 +126,7 @@
<div class="row-info" @click="editDiaryRecipe(d)">
<span class="row-name">{{ d.name }}</span>
<span class="row-tags">
<span v-for="t in (d.tags || [])" :key="t" class="mini-tag">{{ t }}</span>
<span v-for="t in (d.tags || []).filter(t => auth.canEdit || !EDITOR_ONLY_TAGS.includes(t))" :key="t" class="mini-tag">{{ t }}</span>
</span>
<span class="row-cost">{{ oils.fmtPrice(oils.calcCost(d.ingredients || [])) }}</span>
<span v-if="getDiaryShareStatus(d) === 'shared'" class="share-tag shared">已共享</span>
@@ -165,7 +165,7 @@
<div class="row-info" @click="editRecipe(r)">
<span class="row-name">{{ r.name }}</span>
<span class="row-tags">
<span v-for="t in r.tags" :key="t" class="mini-tag">{{ t }}</span>
<span v-for="t in (r.tags || []).filter(t => auth.canEdit || !EDITOR_ONLY_TAGS.includes(t))" :key="t" class="mini-tag">{{ t }}</span>
</span>
<span class="row-cost">{{ oils.fmtPrice(oils.calcCost(r.ingredients)) }}</span>
</div>
@@ -317,8 +317,8 @@
<button class="add-row-btn" @click="addOilRow">+ 添加精油</button>
</div>
<!-- Real-time summary -->
<div class="recipe-summary">
<!-- Real-time summary (only when volume selected) -->
<div v-if="formVolume" class="recipe-summary">
{{ recipeSummaryText }}
</div>
@@ -397,7 +397,7 @@
import { ref, computed, reactive, onMounted, watch } from 'vue'
import { useAuthStore } from '../stores/auth'
import { useOilsStore } from '../stores/oils'
import { useRecipesStore } from '../stores/recipes'
import { useRecipesStore, EDITOR_ONLY_TAGS } from '../stores/recipes'
import { useDiaryStore } from '../stores/diary'
import { useUiStore } from '../stores/ui'
import { api } from '../composables/useApi'
@@ -443,7 +443,13 @@ const formCustomVolume = ref(null)
const formCustomUnit = ref('drops')
const formDilution = ref(6)
const formCocoRow = ref({ oil: '椰子油', drops: 10, _search: '椰子油', _open: false })
const formCocoRow = ref(null)
watch(() => formVolume.value, (vol) => {
if (vol && !formCocoRow.value) {
formCocoRow.value = { oil: '椰子油', drops: vol === 'single' ? 10 : 0, _search: '椰子油', _open: false }
}
})
// EO ingredients (everything except coconut)
const formEoIngredients = computed(() =>
@@ -562,6 +568,15 @@ async function deleteGlobalTag(tag) {
}
}
function toggleTagFilter() {
if (showTagFilter.value) {
showTagFilter.value = false
selectedTags.value = []
} else {
showTagFilter.value = true
}
}
function toggleTag(tag) {
const idx = selectedTags.value.indexOf(tag)
if (idx >= 0) selectedTags.value.splice(idx, 1)
@@ -744,15 +759,36 @@ function calcDilutionFromIngs() {
}
function editRecipe(recipe) {
editingRecipe.value = recipe
editingRecipe.value = { _id: recipe._id, _version: recipe._version, name: recipe.name }
formName.value = recipe.name
const ings = recipe.ingredients || []
formIngredients.value = ings.filter(i => i.oil !== '椰子油').map(i => ({ ...i, _search: i.oil, _open: false }))
const coco = ings.find(i => i.oil === '椰子油')
formCocoRow.value = coco ? { ...coco, _search: '椰子油', _open: false } : { oil: '椰子油', drops: 10, _search: '椰子油', _open: false }
if (coco) {
formCocoRow.value = { ...coco, _search: '椰子油', _open: false }
// Guess volume from total drops
const eoDrops = ings.filter(i => i.oil && i.oil !== '椰子油').reduce((s, i) => s + (i.drops || 0), 0)
const totalDrops = eoDrops + coco.drops
const ml = totalDrops / DROPS_PER_ML
if (ml <= 2) formVolume.value = 'single'
else if (Math.abs(ml - 5) < 1.5) formVolume.value = '5'
else if (Math.abs(ml - 10) < 2.5) formVolume.value = '10'
else if (Math.abs(ml - 15) < 2.5) formVolume.value = '15'
else if (Math.abs(ml - 20) < 3) formVolume.value = '20'
else if (Math.abs(ml - 30) < 6) formVolume.value = '30'
else { formVolume.value = 'custom'; formCustomVolume.value = Math.round(ml) }
// Guess dilution
if (eoDrops > 0 && coco.drops > 0) {
const ratio = Math.round(coco.drops / eoDrops)
const options = [3,4,5,6,7,8,9,10,12,15,20]
formDilution.value = options.reduce((a, b) => Math.abs(b - ratio) < Math.abs(a - ratio) ? b : a)
}
} else {
formCocoRow.value = null
formVolume.value = ''
}
formNote.value = recipe.note || ''
formTags.value = [...(recipe.tags || [])]
calcDilutionFromIngs(recipe.ingredients)
showAddOverlay.value = true
}
@@ -765,7 +801,7 @@ function closeOverlay() {
function resetForm() {
formName.value = ''
formIngredients.value = [{ oil: '', drops: 1, _search: '', _open: false }]
formCocoRow.value = { oil: '椰子油', drops: 10, _search: '椰子油', _open: false }
formCocoRow.value = null
formNote.value = ''
formTags.value = []
smartPasteText.value = ''
@@ -1016,12 +1052,17 @@ async function saveCurrentRecipe() {
}
if (editingRecipe.value && editingRecipe.value._id) {
// Editing an existing public recipe
// Editing an existing public recipe — safety check
const mappedIngs = cleanIngs.map(i => ({ oil_name: i.oil, drops: i.drops }))
if (mappedIngs.length === 0) {
const ok = await showConfirm('配方中没有精油成分,确定保存吗?这将清空所有成分。')
if (!ok) return
}
const payload = {
_id: editingRecipe.value._id,
_version: editingRecipe.value._version,
name: formName.value.trim(),
ingredients: cleanIngs.map(i => ({ oil_name: i.oil, drops: i.drops })),
ingredients: mappedIngs,
note: formNote.value,
tags: formTags.value,
}
@@ -1123,6 +1164,11 @@ async function loadContribution() {
const previewRecipeIndex = ref(null)
const previewRecipeData = ref(null)
const showBatchMenu = ref(false)
const visibleAllTags = computed(() => {
const tags = recipeStore.allTags
if (auth.canEdit) return tags
return tags.filter(t => !EDITOR_ONLY_TAGS.includes(t))
})
const showBatchTagPicker = ref(false)
const batchTagsSelected = ref([])
const batchNewTag = ref('')
@@ -1208,10 +1254,29 @@ function editDiaryRecipe(diary) {
const ings = diary.ingredients || []
formIngredients.value = ings.filter(i => i.oil !== '椰子油').map(i => ({ ...i, _search: i.oil, _open: false }))
const coco = ings.find(i => i.oil === '椰子油')
formCocoRow.value = coco ? { ...coco, _search: '椰子油', _open: false } : { oil: '椰子油', drops: 10, _search: '椰子油', _open: false }
if (coco) {
formCocoRow.value = { ...coco, _search: '椰子油', _open: false }
const eoDrops = ings.filter(i => i.oil && i.oil !== '椰子油').reduce((s, i) => s + (i.drops || 0), 0)
const totalDrops = eoDrops + coco.drops
const ml = totalDrops / DROPS_PER_ML
if (ml <= 2) formVolume.value = 'single'
else if (Math.abs(ml - 5) < 1.5) formVolume.value = '5'
else if (Math.abs(ml - 10) < 2.5) formVolume.value = '10'
else if (Math.abs(ml - 15) < 2.5) formVolume.value = '15'
else if (Math.abs(ml - 20) < 3) formVolume.value = '20'
else if (Math.abs(ml - 30) < 6) formVolume.value = '30'
else { formVolume.value = 'custom'; formCustomVolume.value = Math.round(ml) }
if (eoDrops > 0 && coco.drops > 0) {
const ratio = Math.round(coco.drops / eoDrops)
const options = [3,4,5,6,7,8,9,10,12,15,20]
formDilution.value = options.reduce((a, b) => Math.abs(b - ratio) < Math.abs(a - ratio) ? b : a)
}
} else {
formCocoRow.value = null
formVolume.value = ''
}
formNote.value = diary.note || ''
formTags.value = [...(diary.tags || [])]
calcDilutionFromIngs(diary.ingredients)
showAddOverlay.value = true
}

View File

@@ -169,7 +169,7 @@ import { ref, computed, onMounted, nextTick, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useAuthStore } from '../stores/auth'
import { useOilsStore } from '../stores/oils'
import { useRecipesStore } from '../stores/recipes'
import { useRecipesStore, EDITOR_ONLY_TAGS } from '../stores/recipes'
import { useDiaryStore } from '../stores/diary'
import { useUiStore } from '../stores/ui'
import { api } from '../composables/useApi'
@@ -315,7 +315,8 @@ const exactResults = computed(() => {
const q = searchQuery.value.trim().toLowerCase()
return recipeStore.recipes.filter(r => {
const nameMatch = r.name.toLowerCase().includes(q)
const tagMatch = r.tags && r.tags.some(t => t.toLowerCase().includes(q))
const visibleTags = auth.canEdit ? (r.tags || []) : (r.tags || []).filter(t => !EDITOR_ONLY_TAGS.includes(t))
const tagMatch = visibleTags.some(t => t.toLowerCase().includes(q))
return nameMatch || tagMatch
}).sort((a, b) => a.name.localeCompare(b.name, 'zh'))
})