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>
This commit is contained in:
2026-04-10 21:13:20 +00:00
parent 49aa5a0f3c
commit 0dfef3ab16
4 changed files with 15 additions and 9 deletions

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 },

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([])

View File

@@ -49,7 +49,7 @@
</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>
@@ -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'
@@ -1128,6 +1128,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('')

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'))
})