feat: 已下架标签隐藏配方,搜索/列表/收藏均过滤
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@ import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
import { api } from '../composables/useApi'
|
||||
|
||||
export const EDITOR_ONLY_TAGS = ['已审核']
|
||||
export const EDITOR_ONLY_TAGS = ['已审核', '已下架']
|
||||
|
||||
export const useRecipesStore = defineStore('recipes', () => {
|
||||
const recipes = ref([])
|
||||
|
||||
@@ -250,7 +250,7 @@ function slideCat(dir) {
|
||||
|
||||
// Public recipes (all recipes in the public library)
|
||||
const filteredRecipes = computed(() => {
|
||||
let list = recipeStore.recipes
|
||||
let list = recipeStore.recipes.filter(r => !r.tags || !r.tags.includes('已下架'))
|
||||
if (selectedCategory.value) {
|
||||
list = list.filter(r => r.tags && r.tags.includes(selectedCategory.value))
|
||||
}
|
||||
@@ -318,6 +318,7 @@ const exactResults = computed(() => {
|
||||
const q = searchQuery.value.trim().toLowerCase()
|
||||
const isEn = /^[a-zA-Z\s]+$/.test(q)
|
||||
return recipeStore.recipes.filter(r => {
|
||||
if (r.tags && r.tags.includes('已下架')) return false
|
||||
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))
|
||||
@@ -336,6 +337,7 @@ const similarResults = computed(() => {
|
||||
const terms = expandQuery(q).filter(t => t.length >= 2 || t === q)
|
||||
|
||||
return recipeStore.recipes.filter(r => {
|
||||
if (r.tags && r.tags.includes('已下架')) return false
|
||||
if (exactIds.has(r._id)) return false
|
||||
const name = r.name
|
||||
// Match by expanded synonyms (name only, not ingredients)
|
||||
@@ -375,7 +377,7 @@ const myDiaryRecipes = computed(() => {
|
||||
|
||||
const favoritesPreview = computed(() => {
|
||||
if (!auth.isLoggedIn) return []
|
||||
let list = recipeStore.recipes.filter(r => recipeStore.isFavorite(r))
|
||||
let list = recipeStore.recipes.filter(r => recipeStore.isFavorite(r) && !(r.tags && r.tags.includes('已下架')))
|
||||
if (searchQuery.value.trim()) {
|
||||
const q = searchQuery.value.trim().toLowerCase()
|
||||
list = list.filter(r => {
|
||||
|
||||
Reference in New Issue
Block a user