+
-
-
{{ d.name }}
-
{{ (d.ingredients || []).map(i => i.oil).join('、') }}
-
- {{ oils.fmtPrice(oils.calcCost(d.ingredients || [])) }}
-
-
+
+
+ 已共享
+ 审核中
暂无个人配方
+
-
-
+
+
+
+
-
🔍 公共配方搜索结果 ({{ fuzzyResults.length }})
-
-
-
未找到匹配的公共配方
+
+
+ 🔍 搜索结果 ({{ exactResults.length }})
+
+
+
+
+
+
+
+
+ {{ exactResults.length > 0 ? '💡 相关配方' : '💡 没有完全匹配,以下是相关配方' }}
+ ({{ similarResults.length }})
+
+
+
+
+
+
+
+
+
未找到「{{ searchQuery }}」相关配方
+
+
+
+
+
+
已通知编辑,感谢反馈!
@@ -121,9 +155,11 @@
@@ -152,9 +188,11 @@ const searchQuery = ref('')
const selectedCategory = ref(null)
const categories = ref([])
const selectedRecipeIndex = ref(null)
+const selectedDiaryRecipe = ref(null)
const showMyRecipes = ref(true)
const showFavorites = ref(true)
const catIdx = ref(0)
+const sharedCount = ref(0)
onMounted(async () => {
try {
@@ -164,9 +202,16 @@ onMounted(async () => {
}
} catch {}
- // Load personal diary recipes
+ // Load personal diary recipes & contribution stats
if (auth.isLoggedIn) {
await diaryStore.loadDiary()
+ try {
+ const cRes = await api('/api/me/contribution')
+ if (cRes.ok) {
+ const data = await cRes.json()
+ sharedCount.value = data.shared_count || 0
+ }
+ } catch {}
}
// Return to a recipe card after QR upload redirect
@@ -206,21 +251,107 @@ const filteredRecipes = computed(() => {
if (selectedCategory.value) {
list = list.filter(r => r.tags && r.tags.includes(selectedCategory.value))
}
- return list
+ return list.slice().sort((a, b) => a.name.localeCompare(b.name, 'zh'))
})
-// Search results from public recipes
-const fuzzyResults = computed(() => {
+// Synonym groups for broader fuzzy matching
+const synonymGroups = [
+ ['胸', '乳腺', '乳房', '丰胸', '胸部'],
+ ['瘦', '减肥', '减脂', '消脂', '纤体', '塑形', '体重'],
+ ['痘', '痤疮', '粉刺', '暗疮', '长痘', '祛痘'],
+ ['斑', '色斑', '淡斑', '雀斑', '黑色素', '美白', '亮肤'],
+ ['皱', '抗皱', '皱纹', '紧致', '抗衰', '抗老'],
+ ['睡', '眠', '失眠', '助眠', '安眠', '好眠', '入睡'],
+ ['焦虑', '紧张', '压力', '情绪', '放松', '舒缓', '安神', '宁神'],
+ ['头', '头痛', '头疼', '偏头痛', '头晕'],
+ ['咳', '咳嗽', '止咳', '清咽'],
+ ['鼻', '鼻炎', '鼻塞', '过敏性鼻炎', '打喷嚏'],
+ ['感冒', '发烧', '发热', '流感', '风寒', '风热'],
+ ['胃', '消化', '肠胃', '胃痛', '胃胀', '积食', '便秘'],
+ ['肝', '护肝', '养肝', '肝脏', '排毒'],
+ ['肾', '补肾', '养肾', '肾虚'],
+ ['腰', '腰痛', '腰酸', '腰椎'],
+ ['肩', '肩颈', '颈椎', '肩周'],
+ ['关节', '骨骼', '骨质', '风湿', '类风湿'],
+ ['肌肉', '酸痛', '疼痛', '拉伤'],
+ ['月经', '痛经', '经期', '姨妈', '生理期', '调经'],
+ ['子宫', '卵巢', '生殖', '备孕', '怀孕', '孕'],
+ ['前列腺', '男性', '阳'],
+ ['湿', '祛湿', '排湿', '湿气', '化湿'],
+ ['免疫', '免疫力', '抵抗力'],
+ ['脱发', '掉发', '生发', '头发', '发际线', '秃'],
+ ['过敏', '敏感', '荨麻疹', '湿疹', '皮炎'],
+ ['血压', '高血压', '低血压', '血管', '循环'],
+ ['血糖', '糖尿病', '降糖'],
+ ['淋巴', '排毒', '水肿', '浮肿'],
+ ['呼吸', '肺', '支气管', '哮喘', '气管'],
+ ['眼', '眼睛', '视力', '近视', '干眼'],
+ ['耳', '耳鸣', '中耳炎', '耳朵'],
+ ['口', '口腔', '口臭', '牙', '牙龈', '牙疼'],
+ ['皮肤', '护肤', '保湿', '修复', '焕肤'],
+ ['疤', '疤痕', '伤疤', '妊娠纹'],
+ ['心', '心脏', '心悸', '养心'],
+ ['甲状腺', '甲亢', '甲减'],
+ ['高', '长高', '增高', '个子'],
+ ['静脉', '静脉曲张'],
+ ['痔', '痔疮'],
+]
+
+function expandQuery(q) {
+ const terms = [q]
+ for (const group of synonymGroups) {
+ if (group.some(t => q.includes(t) || t.includes(q))) {
+ for (const t of group) {
+ if (!terms.includes(t)) terms.push(t)
+ }
+ }
+ }
+ return terms
+}
+
+// Search results: exact matches (query in recipe name or tags, NOT oil names to avoid noise like 西班牙牛至)
+const exactResults = computed(() => {
if (!searchQuery.value.trim()) return []
const q = searchQuery.value.trim().toLowerCase()
return recipeStore.recipes.filter(r => {
const nameMatch = r.name.toLowerCase().includes(q)
- const oilMatch = r.ingredients.some(ing => ing.oil.toLowerCase().includes(q))
const tagMatch = r.tags && r.tags.some(t => t.toLowerCase().includes(q))
- return nameMatch || oilMatch || tagMatch
- })
+ return nameMatch || tagMatch
+ }).sort((a, b) => a.name.localeCompare(b.name, 'zh'))
})
+// Similar results: synonym expansion, only match against recipe NAME (not ingredients/tags)
+// Filter out single-char expanded terms to avoid overly broad matches
+const similarResults = computed(() => {
+ if (!searchQuery.value.trim()) return []
+ const q = searchQuery.value.trim()
+ const exactIds = new Set(exactResults.value.map(r => r._id))
+ const terms = expandQuery(q).filter(t => t.length >= 2 || t === q)
+
+ return recipeStore.recipes.filter(r => {
+ if (exactIds.has(r._id)) return false
+ const name = r.name
+ // Match by expanded synonyms (name only, not ingredients)
+ if (terms.some(t => name.includes(t))) return true
+ return false
+ }).sort((a, b) => a.name.localeCompare(b.name, 'zh')).slice(0, 30)
+})
+
+const reportedMissing = ref(false)
+
+async function reportMissing() {
+ try {
+ await api('/api/symptom-search', {
+ method: 'POST',
+ body: JSON.stringify({ query: searchQuery.value.trim(), report_missing: true }),
+ })
+ reportedMissing.value = true
+ ui.showToast('已通知编辑,感谢反馈!')
+ } catch {
+ ui.showToast('通知失败')
+ }
+}
+
// Personal recipes from diary (separate from public recipes)
const myDiaryRecipes = computed(() => {
if (!auth.isLoggedIn) return []
@@ -237,9 +368,17 @@ const myDiaryRecipes = computed(() => {
const favoritesPreview = computed(() => {
if (!auth.isLoggedIn) return []
- return recipeStore.recipes
- .filter(r => recipeStore.isFavorite(r))
- .slice(0, 6)
+ let list = recipeStore.recipes.filter(r => recipeStore.isFavorite(r))
+ if (searchQuery.value.trim()) {
+ const q = searchQuery.value.trim().toLowerCase()
+ list = list.filter(r => {
+ const nameMatch = r.name.toLowerCase().includes(q)
+ const oilMatch = r.ingredients.some(ing => ing.oil.toLowerCase().includes(q))
+ const tagMatch = r.tags && r.tags.some(t => t.toLowerCase().includes(q))
+ return nameMatch || oilMatch || tagMatch
+ })
+ }
+ return list.slice(0, 6)
})
function findGlobalIndex(recipe) {
@@ -252,27 +391,24 @@ function openDetail(index) {
}
}
-function openDiaryDetail(diary) {
- // Create a temporary recipe-like object from diary and open it
- const tmpRecipe = {
- _id: null,
- _diary_id: diary.id,
- name: diary.name,
- note: diary.note || '',
- tags: diary.tags || [],
- ingredients: diary.ingredients || [],
- _owner_id: auth.user.id,
+function getDiaryShareStatus(d) {
+ const pub = recipeStore.recipes.find(r => r.name === d.name && r._owner_id === auth.user?.id)
+ if (pub) return 'shared'
+ return null
+}
+
+function diaryAsRecipe(d) {
+ return {
+ _id: 'diary-' + d.id,
+ name: d.name,
+ note: d.note || '',
+ tags: d.tags || [],
+ ingredients: d.ingredients || [],
}
- recipeStore.recipes.push(tmpRecipe)
- const tmpIdx = recipeStore.recipes.length - 1
- selectedRecipeIndex.value = tmpIdx
- // Clean up temp recipe when detail closes
- const unwatch = watch(selectedRecipeIndex, (val) => {
- if (val === null) {
- recipeStore.recipes.splice(tmpIdx, 1)
- unwatch()
- }
- })
+}
+
+function openDiaryDetail(diary) {
+ selectedDiaryRecipe.value = diaryAsRecipe(diary)
}
async function handleToggleFav(recipe) {
@@ -309,12 +445,25 @@ async function shareDiaryToPublic(diary) {
}
function onSearch() {
- // fuzzyResults computed handles the filtering reactively
+ reportedMissing.value = false
}
function clearSearch() {
searchQuery.value = ''
selectedCategory.value = null
+ reportedMissing.value = false
+}
+
+// Carousel swipe
+const carouselTouchStartX = ref(0)
+function onCarouselTouchStart(e) {
+ carouselTouchStartX.value = e.touches[0].clientX
+}
+function onCarouselTouchEnd(e) {
+ const dx = e.changedTouches[0].clientX - carouselTouchStartX.value
+ if (Math.abs(dx) > 50) {
+ slideCat(dx < 0 ? 1 : -1)
+ }
}
@@ -515,6 +664,40 @@ function clearSearch() {
color: #999;
}
+.diary-card-wrap {
+ position: relative;
+}
+
+.share-status {
+ position: absolute;
+ top: 8px;
+ right: 8px;
+ font-size: 10px;
+ padding: 2px 8px;
+ border-radius: 8px;
+ font-weight: 600;
+}
+
+.share-status.shared {
+ background: #e8f5e9;
+ color: #2e7d32;
+}
+
+.share-status.pending {
+ background: #fff3e0;
+ color: #e65100;
+}
+
+.contrib-badge {
+ font-size: 11px;
+ color: #4a9d7e;
+ background: #e8f5e9;
+ padding: 2px 8px;
+ border-radius: 8px;
+ font-weight: 500;
+ margin-left: auto;
+}
+
.section-label {
font-size: 14px;
font-weight: 600;
@@ -542,6 +725,40 @@ function clearSearch() {
padding: 24px 0;
}
+.similar-label {
+ color: #e65100;
+ background: #fff8e1;
+ padding: 8px 14px;
+ border-radius: 10px;
+}
+
+.no-match-box {
+ text-align: center;
+ padding: 12px 0;
+}
+
+.btn-report-missing {
+ background: linear-gradient(135deg, #ffb74d, #e65100);
+ color: #fff;
+ border: none;
+ border-radius: 10px;
+ padding: 10px 20px;
+ font-size: 14px;
+ cursor: pointer;
+ font-family: inherit;
+ margin-top: 8px;
+}
+
+.btn-report-missing:hover {
+ opacity: 0.9;
+}
+
+.reported-hint {
+ color: #4a9d7e;
+ font-size: 13px;
+ font-weight: 500;
+}
+
.diary-card {
background: white;
border-radius: 14px;
diff --git a/frontend/src/views/UserManagement.vue b/frontend/src/views/UserManagement.vue
index f29f7ca..0709927 100644
--- a/frontend/src/views/UserManagement.vue
+++ b/frontend/src/views/UserManagement.vue
@@ -38,27 +38,7 @@