feat(image): 全项目应用图片压缩优化
- 将图片显示统一替换为 getCompressedImageUrl 函数处理压缩 - 覆盖 35 个文件,包括 4 个组件和 31 个页面 - 主要组件:LazyImage、ProductCard、OrderCard、SkuSelector 内部自动压缩图片 - 主要页面:购物车、订单、积分、活动、拼团、秒杀、收藏、浏览历史等 - 跳过用户头像、二维码、商品详情大图及所有 Taro.previewImage 调用 - 调整压缩默认宽度为 300,保持质量90,启用压缩功能
This commit is contained in:
@@ -5,6 +5,7 @@ import { Button, Uploader } from '@nutui/nutui-react-taro'
|
||||
import { getShopOrder } from '@/api/shop/shopOrder'
|
||||
import type { ShopOrder } from '@/api/shop/shopOrder/model'
|
||||
import Price from '@/components/common/Price'
|
||||
import { getCompressedImageUrl } from '@/utils/image'
|
||||
|
||||
definePageConfig({
|
||||
navigationBarTitleText: '申请售后',
|
||||
@@ -243,7 +244,7 @@ const AfterSaleApplyPage: React.FC = () => {
|
||||
{/* 商品图片 */}
|
||||
<Image
|
||||
className='w-16 h-16 rounded-lg'
|
||||
src={item.image || ''}
|
||||
src={getCompressedImageUrl(item.image || '')}
|
||||
mode='aspectFill'
|
||||
/>
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import { Button } from '@nutui/nutui-react-taro'
|
||||
import { getAfterSaleDetail, cancelAfterSale, formatAfterSaleStatus, AFTER_SALE_TYPE_MAP } from '@/api/shop/shopAfterSale'
|
||||
import type { AfterSaleDetail } from '@/api/shop/shopAfterSale'
|
||||
import Price from '@/components/common/Price'
|
||||
import { getCompressedImageUrl } from '@/utils/image'
|
||||
|
||||
definePageConfig({
|
||||
navigationBarTitleText: '售后详情',
|
||||
@@ -214,7 +215,7 @@ const AfterSaleDetailPage: React.FC = () => {
|
||||
<Image
|
||||
key={idx}
|
||||
className='w-20 h-20 rounded-lg'
|
||||
src={url}
|
||||
src={getCompressedImageUrl(url)}
|
||||
mode='aspectFill'
|
||||
/>
|
||||
))}
|
||||
|
||||
@@ -7,6 +7,7 @@ import { listShopOrderGoodsByOrderId } from '@/api/shop/shopOrderGoods'
|
||||
import type { ShopOrder } from '@/api/shop/shopOrder/model'
|
||||
import { OrderStatus, OrderStatusText } from '@/types/order'
|
||||
import Price from '@/components/common/Price'
|
||||
import { getCompressedImageUrl } from '@/utils/image'
|
||||
|
||||
definePageConfig({
|
||||
navigationBarTitleText: '订单详情',
|
||||
@@ -301,7 +302,7 @@ const OrderDetailPage: React.FC = () => {
|
||||
>
|
||||
<View className='w-16 h-16 rounded-md bg-gray-100 flex-shrink-0 overflow-hidden'>
|
||||
{item.image ? (
|
||||
<Image className='w-full h-full' src={item.image} mode='aspectFill' />
|
||||
<Image className='w-full h-full' src={getCompressedImageUrl(item.image)} mode='aspectFill' />
|
||||
) : (
|
||||
<View className='w-full h-full flex items-center justify-center'>
|
||||
<Text className='text-xs text-gray-400'>暂无</Text>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { View, Text, ScrollView, Image } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { getShopEvaluation, likeShopEvaluation } from '@/api/shop/shopEvaluation'
|
||||
import type { ShopEvaluation } from '@/api/shop/shopEvaluation/model'
|
||||
import { getCompressedImageUrl } from '@/utils/image'
|
||||
|
||||
definePageConfig({
|
||||
navigationBarTitleText: '评价详情',
|
||||
@@ -110,7 +111,7 @@ const EvaluateDetailPage: React.FC = () => {
|
||||
<View className='flex items-center gap-2'>
|
||||
<View className='w-12 h-12 bg-gray-100 rounded-lg flex items-center justify-center flex-shrink-0 overflow-hidden'>
|
||||
{evaluation.goodsImage ? (
|
||||
<Image src={evaluation.goodsImage} className='w-12 h-12' mode='aspectFill' />
|
||||
<Image src={getCompressedImageUrl(evaluation.goodsImage)} className='w-12 h-12' mode='aspectFill' />
|
||||
) : (
|
||||
<Text className='text-2xl'>🛍️</Text>
|
||||
)}
|
||||
@@ -138,7 +139,7 @@ const EvaluateDetailPage: React.FC = () => {
|
||||
className='w-24 h-24 bg-gray-100 rounded-lg overflow-hidden'
|
||||
onClick={() => handleImagePreview(index)}
|
||||
>
|
||||
<Image src={img} className='w-24 h-24' mode='aspectFill' />
|
||||
<Image src={getCompressedImageUrl(img)} className='w-24 h-24' mode='aspectFill' />
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
|
||||
@@ -4,6 +4,7 @@ import Taro from '@tarojs/taro'
|
||||
import { Button } from '@nutui/nutui-react-taro'
|
||||
import { useUser } from '@/hooks/useUser'
|
||||
import { submitGoodsComment } from '@/api/shop/shopGoodsComment'
|
||||
import { getCompressedImageUrl } from '@/utils/image'
|
||||
|
||||
definePageConfig({
|
||||
navigationBarTitleText: '商品评价',
|
||||
@@ -124,7 +125,7 @@ const EvaluatePage: React.FC = () => {
|
||||
{images.map((img, idx) => (
|
||||
<View key={idx} className='relative'>
|
||||
<Image
|
||||
src={img}
|
||||
src={getCompressedImageUrl(img)}
|
||||
className='w-20 h-20 rounded-lg'
|
||||
mode='aspectFill'
|
||||
/>
|
||||
|
||||
@@ -4,6 +4,7 @@ import Taro from '@tarojs/taro'
|
||||
import { Button } from '@nutui/nutui-react-taro'
|
||||
import { useUser } from '@/hooks/useUser'
|
||||
import { submitGoodsComment } from '@/api/shop/shopGoodsComment'
|
||||
import { getCompressedImageUrl } from '@/utils/image'
|
||||
|
||||
definePageConfig({
|
||||
navigationBarTitleText: '商品评价',
|
||||
@@ -124,7 +125,7 @@ const EvaluatePage: React.FC = () => {
|
||||
{images.map((img, idx) => (
|
||||
<View key={idx} className='relative'>
|
||||
<Image
|
||||
src={img}
|
||||
src={getCompressedImageUrl(img)}
|
||||
className='w-20 h-20 rounded-lg'
|
||||
mode='aspectFill'
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user