From 7e1e542a6c434650eb0872ba1c56a517aa7f6e40 Mon Sep 17 00:00:00 2001 From: Qi <3194726156@qq.com> Date: Sun, 10 Aug 2025 21:46:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=95=86=E5=93=81=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/ProductDetail.vue | 365 +++++++++++++++++++++++++++++++++--- src/views/Products.vue | 75 +++++++- 2 files changed, 407 insertions(+), 33 deletions(-) diff --git a/src/views/ProductDetail.vue b/src/views/ProductDetail.vue index c196c56..9dc791e 100644 --- a/src/views/ProductDetail.vue +++ b/src/views/ProductDetail.vue @@ -20,22 +20,34 @@
-
- - - - {{ (product.productName || product.name || '产品').substring(0, 2) }} + +
+ + + +
-
-
- - - {{ i }} - +
+
+ +
+ +
@@ -266,13 +278,71 @@

加载中...

+ + + +
+
+ +
+ + +
+ + + + + + {{ currentImageIndex + 1 }} / {{ previewImages.length }} + + + + + +
+ + +
+
+ +
+
+
+
\ No newline at end of file diff --git a/src/views/Products.vue b/src/views/Products.vue index 59ddfb9..c7f7e77 100644 --- a/src/views/Products.vue +++ b/src/views/Products.vue @@ -63,12 +63,18 @@ @click="$router.push(`/product/${product.id}`)" >
-
- - - - {{ product.productName ? product.productName.substring(0, 2) : '产品' }} + +
+ + + +
@@ -300,6 +306,34 @@ const onCategoryChange = () => { getProducts() } +// 处理图片路径 +const getFileAccessHttpUrl = (path: string) => { + if (!path) return '' + + // 如果已经是完整的HTTP URL或blob URL,直接返回 + if (path.startsWith('http://') || path.startsWith('https://') || path.startsWith('blob:')) { + return path + } + + // 如果是相对路径,转换为静态资源URL + if (path.startsWith('/')) { + return `http://localhost:8080/jeecg-boot/sys/common/static${path}` + } + + // 为产品图片添加默认路径 + return `http://localhost:8080/jeecg-boot/sys/common/static/${path}` +} + +// 图片加载错误处理 +const handleImageError = (event: Event) => { + const img = event.target as HTMLImageElement + img.style.display = 'none' + const placeholder = img.nextElementSibling as HTMLElement + if (placeholder) { + placeholder.style.display = 'flex' + } +} + // 生命周期 onMounted(() => { getCategories() @@ -405,7 +439,22 @@ onMounted(() => { .product-image { position: relative; width: 100%; - height: 200px; + height: 250px; + border-radius: 12px; + overflow: hidden; + background: linear-gradient(135deg, #f8f9fa, #e9ecef); + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); +} + +.product-cover-image { + width: 100%; + height: 100%; + object-fit: cover; + transition: all 0.3s ease; +} + +.product-cover-image:hover { + transform: scale(1.05); } .image-placeholder { @@ -414,7 +463,17 @@ onMounted(() => { display: flex; align-items: center; justify-content: center; - background: var(--background-light); + background: linear-gradient(135deg, #f8f9fa, #e9ecef); + border: 2px dashed #dee2e6; +} + +.image-placeholder svg { + opacity: 0.6; + transition: opacity 0.3s ease; +} + +.product-image:hover .image-placeholder svg { + opacity: 0.8; } .product-badges {