Files
jinshen-website/app/components/shared/ProductCard.vue
R2m1liA 58e91ed67c
All checks were successful
deploy to server / build-and-deploy (push) Successful in 2m59s
fix: 调整部分图像显示问题
- 产品/解决方案卡片图片宽度调整为100%并将比例设定为16/10
- 产品页在竖屏状态下的文字边距
2025-11-07 14:36:21 +08:00

88 lines
1.7 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<el-card class="product-card" @click="handleClick">
<template #header>
<!-- Image -->
<el-image class="product-image" :src="imageUrl" fit="contain" />
</template>
<div class="card-body">
<!-- Name -->
<div class="text-center">
<span class="product-name">{{ name }}</span>
</div>
<!-- Description -->
<div class="card-description text-left opacity-25">{{ description }}</div>
</div>
</el-card>
</template>
<script setup lang="ts">
interface Props {
name: string;
description: string;
imageUrl: string;
id?: string | number;
slug?: string;
}
const props = defineProps<Props>();
const localePath = useLocalePath();
const handleClick = () => {
// 优先使用 slug如果没有则使用 id
const routeParam = props.slug || props.id;
if (routeParam) {
navigateTo(localePath(`/products/${routeParam}`));
}
};
</script>
<style scoped>
.product-card {
width: 30%;
cursor: pointer;
transition: all 0.3s ease;
text-align: center;
}
.product-card:hover {
transform: translateY(-4px);
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}
.product-name {
font-size: 1rem;
font-weight: 600;
}
.card-description {
font-size: 0.8rem;
margin-top: 5px;
}
.product-card .el-image {
width: 100%;
aspect-ratio: 16 / 10;
border-radius: 4px;
}
.card-body {
margin: 10px auto;
padding: 0px auto;
height: 100px;
}
/* 响应式设计 */
@media (max-width: 1200px) {
.product-card {
width: 45%;
}
}
@media (max-width: 768px) {
.product-card {
width: 90%;
}
}
</style>