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>
133 lines
2.9 KiB
Vue
133 lines
2.9 KiB
Vue
<template>
|
|
<div class="recipe-card" @click="$emit('click', index)">
|
|
<div class="recipe-card-name">{{ recipe.name }}</div>
|
|
<div v-if="visibleTags.length" class="recipe-card-tags">
|
|
<span v-for="tag in visibleTags" :key="tag" class="tag" :class="{ 'tag-reviewed': tag === '已审核' }">{{ tag }}</span>
|
|
</div>
|
|
<div class="recipe-card-oils">{{ oilNames }}</div>
|
|
<div class="recipe-card-bottom">
|
|
<div class="recipe-card-price">💰 {{ priceInfo.cost }}</div>
|
|
<button
|
|
class="fav-btn"
|
|
:class="{ favorited: isFav }"
|
|
@click.stop="$emit('toggle-fav', recipe._id)"
|
|
:title="isFav ? '取消收藏' : '收藏'"
|
|
>{{ isFav ? '★' : '☆' }}</button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { computed } from 'vue'
|
|
import { useOilsStore } from '../stores/oils'
|
|
import { useRecipesStore, EDITOR_ONLY_TAGS } from '../stores/recipes'
|
|
import { useAuthStore } from '../stores/auth'
|
|
|
|
const props = defineProps({
|
|
recipe: { type: Object, required: true },
|
|
index: { type: Number, required: true },
|
|
})
|
|
|
|
defineEmits(['click', 'toggle-fav'])
|
|
|
|
const oilsStore = useOilsStore()
|
|
const recipesStore = useRecipesStore()
|
|
const auth = useAuthStore()
|
|
|
|
const visibleTags = computed(() => {
|
|
if (!props.recipe.tags) return []
|
|
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(() =>
|
|
props.recipe.ingredients.map(i => i.oil).join('、')
|
|
)
|
|
const priceInfo = computed(() => oilsStore.fmtCostWithRetail(props.recipe.ingredients))
|
|
const isFav = computed(() => recipesStore.isFavorite(props.recipe))
|
|
</script>
|
|
|
|
<style scoped>
|
|
.recipe-card {
|
|
background: white;
|
|
border-radius: 14px;
|
|
padding: 18px;
|
|
cursor: pointer;
|
|
box-shadow: 0 4px 20px rgba(90, 60, 30, 0.08);
|
|
border: 2px solid transparent;
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
.recipe-card:hover {
|
|
transform: translateY(-3px);
|
|
box-shadow: 0 8px 32px rgba(90, 60, 30, 0.15);
|
|
border-color: #c8ddc9;
|
|
}
|
|
|
|
.recipe-card-name {
|
|
font-family: 'Noto Serif SC', serif;
|
|
font-size: 16px;
|
|
font-weight: 600;
|
|
color: #2c2416;
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
.recipe-card-tags {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 5px;
|
|
margin-bottom: 6px;
|
|
}
|
|
|
|
.tag {
|
|
font-size: 11px;
|
|
padding: 2px 8px;
|
|
border-radius: 8px;
|
|
background: #eef4ee;
|
|
color: #5a7d5e;
|
|
}
|
|
|
|
.tag-reviewed {
|
|
background: #e3f2fd;
|
|
color: #1565c0;
|
|
}
|
|
|
|
.recipe-card-oils {
|
|
font-size: 12px;
|
|
color: #9a8570;
|
|
line-height: 1.7;
|
|
}
|
|
|
|
.recipe-card-bottom {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-top: 8px;
|
|
}
|
|
|
|
.recipe-card-price {
|
|
font-size: 13px;
|
|
color: #5a7d5e;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.fav-btn {
|
|
background: none;
|
|
border: none;
|
|
font-size: 20px;
|
|
cursor: pointer;
|
|
color: #d4cfc7;
|
|
padding: 2px 4px;
|
|
line-height: 1;
|
|
transition: color 0.2s;
|
|
}
|
|
|
|
.fav-btn.favorited {
|
|
color: #f5a623;
|
|
}
|
|
|
|
.fav-btn:hover {
|
|
color: #f5a623;
|
|
}
|
|
</style>
|