From eb7c9983f54cbc61562f036d0126f9e49a85e7e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=88=90?= Date: Fri, 28 Nov 2025 18:27:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E9=A6=96=E9=A1=B5=20?= =?UTF-8?q?=E7=95=85=E6=89=93=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ListCard/index.scss | 1 + src/components/ListCard/index.tsx | 49 +++++++++++++++++------------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/components/ListCard/index.scss b/src/components/ListCard/index.scss index fe744b0..04e53cd 100644 --- a/src/components/ListCard/index.scss +++ b/src/components/ListCard/index.scss @@ -349,6 +349,7 @@ .localAreaContainer { display: flex; + flex: 1; gap: 4px; } diff --git a/src/components/ListCard/index.tsx b/src/components/ListCard/index.tsx index b925e8e..eee5a7e 100644 --- a/src/components/ListCard/index.tsx +++ b/src/components/ListCard/index.tsx @@ -59,16 +59,16 @@ const ListCard: React.FC = ({ // 处理地点截断,确保固定信息始终显示 const displayLocation = useMemo(() => { if (!location) return null; // 直接返回 null,不渲染 - + // 获取屏幕宽度,用于计算实际容器宽度 const systemInfo = Taro.getSystemInfoSync(); const screenWidth = systemInfo.windowWidth || 375; // 容器宽度 = 屏幕宽度 - 左右 padding - 图片区域宽度 const containerWidthPx = screenWidth - 130; - + // 计算固定信息宽度 const extraInfo = `${court_type ? `・${court_type}` : ''}${distance_km ? `・${distance_km}km` : ''}`; - + // 估算字符宽度(基于 12px 字体) const getTextWidth = (text: string) => { let width = 0; @@ -81,18 +81,18 @@ const ListCard: React.FC = ({ } return width; }; - + const extraWidth = getTextWidth(extraInfo); const locationWidth = getTextWidth(location); - + // 可用宽度 = 容器宽度 - 固定信息宽度 - 省略号宽度(18px) const availableWidth = containerWidthPx - extraWidth - 18; - + // 如果地点宽度小于可用宽度,不需要截断 if (locationWidth <= availableWidth) { return location; } - + // 需要截断地点 let maxChars = 0; let currentWidth = 0; @@ -105,7 +105,7 @@ const ListCard: React.FC = ({ currentWidth += charWidth; maxChars++; } - + return location.slice(0, maxChars) + '...'; }, [location, court_type, distance_km]); @@ -242,22 +242,29 @@ const ListCard: React.FC = ({ {isShowSmoothPlayingGame && ( - + {/* {game_type} */} - - - 场馆方: - - - {venue_description} - + { + venue_description && () + } + { + venue_description && + ( - + + 场馆方: + + + {venue_description} + + + ) + } )}