From 5cd954ccad8bee3e4bd3f4ac219bc4de9a839955 Mon Sep 17 00:00:00 2001 From: Hera Zhao Date: Sat, 11 Apr 2026 11:17:27 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=8B=B1=E6=96=87=E6=90=9C=E7=B4=A2+?= =?UTF-8?q?=E5=85=A8=E9=83=A8=E9=85=8D=E6=96=B9=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 搜索框支持英文:自动匹配配方英文名和精油英文名 - 292条配方全部翻译英文名(本地+线上同步) - 输入英文时搜索范围包含en_name和精油英文名 Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/src/views/RecipeSearch.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/RecipeSearch.vue b/frontend/src/views/RecipeSearch.vue index 6f142f2..1cac3b2 100644 --- a/frontend/src/views/RecipeSearch.vue +++ b/frontend/src/views/RecipeSearch.vue @@ -175,6 +175,7 @@ import { useUiStore } from '../stores/ui' import { api } from '../composables/useApi' import RecipeCard from '../components/RecipeCard.vue' import RecipeDetailOverlay from '../components/RecipeDetailOverlay.vue' +import { oilEn } from '../composables/useOilTranslation' const auth = useAuthStore() const oils = useOilsStore() @@ -313,11 +314,14 @@ function expandQuery(q) { const exactResults = computed(() => { if (!searchQuery.value.trim()) return [] const q = searchQuery.value.trim().toLowerCase() + const isEn = /^[a-zA-Z\s]+$/.test(q) return recipeStore.recipes.filter(r => { const nameMatch = r.name.toLowerCase().includes(q) + const enNameMatch = isEn && (r.en_name || '').toLowerCase().includes(q) + const oilEnMatch = isEn && r.ingredients.some(ing => (oilEn(ing.oil) || '').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 + return nameMatch || enNameMatch || oilEnMatch || tagMatch }).sort((a, b) => a.name.localeCompare(b.name, 'zh')) })