Skip to content

Commit 4a6af93

Browse files
committed
ui
1 parent 27b3601 commit 4a6af93

File tree

2 files changed

+53
-7
lines changed

2 files changed

+53
-7
lines changed

pages/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ const isVisible = (id: string) => {
296296
:class="hoveredProductId === product.id ? 'opacity-100' : 'opacity-0'"
297297
>
298298
<div class="px-4 sm:px-8 text-center text-white max-w-[90%]">
299-
<h3 class="text-lg sm:text-xl md:text-lg font-light tracking-wide uppercase mb-2 sm:mb-4 leading-snug">{{ product.title }}</h3>
299+
<h3 class="text-lg sm:text-xl md:text-lg font-light tracking-wide uppercase mb-2 sm:mb-4 leading-snug max-w-[220px] sm:max-w-[240px] md:max-w-[260px] truncate whitespace-nowrap overflow-hidden text-ellipsis" :title="product.title">{{ product.title }}</h3>
300300
<p v-if="product.description" class="text-xs sm:text-sm md:text-xs font-light text-white/90 leading-relaxed mb-4 sm:mb-6 line-clamp-2 sm:line-clamp-3 md:line-clamp-2">{{ product.description }}</p>
301301
<button class="px-4 sm:px-6 py-2 sm:py-3 bg-transparent text-white/90 text-xs font-semibold tracking-wide uppercase hover:text-white border border-white/30 hover:border-white/60 transition-all" @click.stop="goToProductDetail(product.id)">
302302
查看详情

pages/product/[id].vue

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@
5151
<button
5252
v-if="productImages.length > 1"
5353
@click="previousImage"
54-
class="absolute left-0 sm:left-2 md:left-4 lg:left-8 xl:left-12 top-1/2 -translate-y-1/2 w-10 h-10 rounded-full bg-white/80 hover:bg-white border border-gray-200 flex items-center justify-center transition-colors shadow-sm z-10"
54+
class="absolute left-0 sm:left-2 md:left-4 lg:left-8 xl:left-12 top-1/2 -translate-y-1/2 w-8 h-8 sm:w-10 sm:h-10 rounded-full bg-white/80 hover:bg-white border border-gray-200 flex items-center justify-center transition-colors shadow-sm z-10"
5555
aria-label="上一张图片"
5656
>
57-
<Icon name="heroicons:chevron-left" class="w-6 h-6 text-black" />
57+
<Icon name="heroicons:chevron-left" class="w-5 h-5 sm:w-6 sm:h-6 text-black" />
5858
</button>
5959

6060
<!-- 图片容器 -->
61-
<div class="relative max-w-2xl w-full ml-12 mr-12 sm:ml-16 sm:mr-16 md:ml-20 md:mr-20" style="aspect-ratio: 4 / 3;">
61+
<div class="relative w-full max-w-full md:max-w-2xl mx-auto px-2 sm:px-4 product-image-container">
6262
<!-- 主图 -->
6363
<img
6464
v-if="currentImage"
@@ -93,10 +93,10 @@
9393
<button
9494
v-if="productImages.length > 1"
9595
@click="nextImage"
96-
class="absolute right-0 sm:right-2 md:right-4 lg:right-8 xl:right-12 top-1/2 -translate-y-1/2 w-10 h-10 rounded-full bg-white/80 hover:bg-white border border-gray-200 flex items-center justify-center transition-colors shadow-sm z-10"
96+
class="absolute right-0 sm:right-2 md:right-4 lg:right-8 xl:right-12 top-1/2 -translate-y-1/2 w-8 h-8 sm:w-10 sm:h-10 rounded-full bg-white/80 hover:bg-white border border-gray-200 flex items-center justify-center transition-colors shadow-sm z-10"
9797
aria-label="下一张图片"
9898
>
99-
<Icon name="heroicons:chevron-right" class="w-6 h-6 text-black" />
99+
<Icon name="heroicons:chevron-right" class="w-5 h-5 sm:w-6 sm:h-6 text-black" />
100100
</button>
101101
</div>
102102

@@ -216,7 +216,13 @@ import { api } from '~/utils/api'
216216
definePageMeta({ layout: 'page' })
217217
useHead({
218218
titleTemplate: '',
219-
title: '商品详情 - 衣设服装设计'
219+
title: '商品详情 - 衣设服装设计',
220+
meta: [
221+
{
222+
name: 'viewport',
223+
content: 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no'
224+
}
225+
]
220226
})
221227
222228
const route = useRoute()
@@ -378,3 +384,43 @@ watch(() => route.params.id, () => {
378384
}, { immediate: true })
379385
380386
</script>
387+
388+
<style scoped>
389+
/* 默认移动端使用 1:1,提升可视面积;md 及以上使用 4:3 */
390+
.product-image-container {
391+
aspect-ratio: 1 / 1;
392+
}
393+
394+
@media (min-width: 768px) {
395+
.product-image-container {
396+
aspect-ratio: 4 / 3;
397+
}
398+
}
399+
400+
/* 减少双击缩放触发几率 */
401+
.product-image-container, .product-image-container img {
402+
touch-action: manipulation;
403+
}
404+
</style>
405+
406+
<!-- global styles to mitigate fast-scroll header gap -->
407+
<style>
408+
html, body {
409+
background-color: #ffffff;
410+
overscroll-behavior-y: contain; /* reduce rubber-band over-scroll revealing gaps */
411+
overscroll-behavior-x: none;
412+
}
413+
414+
/* Ensure the app header stays on its own compositing layer */
415+
header, .site-header, .app-header {
416+
backface-visibility: hidden;
417+
transform: translateZ(0);
418+
will-change: transform;
419+
background-color: #ffffff; /* avoid transparent flash */
420+
}
421+
422+
/* Respect safe area and avoid a visual seam on iOS */
423+
header, .site-header, .app-header {
424+
padding-top: max(env(safe-area-inset-top), 0px);
425+
}
426+
</style>

0 commit comments

Comments
 (0)