feat(image): 全项目应用图片压缩优化
- 将图片显示统一替换为 getCompressedImageUrl 函数处理压缩 - 覆盖 35 个文件,包括 4 个组件和 31 个页面 - 主要组件:LazyImage、ProductCard、OrderCard、SkuSelector 内部自动压缩图片 - 主要页面:购物车、订单、积分、活动、拼团、秒杀、收藏、浏览历史等 - 跳过用户头像、二维码、商品详情大图及所有 Taro.previewImage 调用 - 调整压缩默认宽度为 300,保持质量90,启用压缩功能
This commit is contained in:
@@ -8,6 +8,7 @@ import type { ShopGoods } from '@/api/shop/shopGoods/model'
|
||||
import EmptyState from '@/components/common/EmptyState'
|
||||
import Loading from '@/components/common/Loading'
|
||||
import { isGuest } from '@/utils/auth'
|
||||
import { getCompressedImageUrl } from '@/utils/image'
|
||||
import { requireLogin } from '@/utils/login-guard'
|
||||
import { isVipMember } from '@/utils/vip'
|
||||
|
||||
@@ -102,7 +103,7 @@ const CartPage: React.FC = () => {
|
||||
>
|
||||
<Image
|
||||
className='w-full rounded-md bg-gray-100'
|
||||
src={goods.image || ''}
|
||||
src={getCompressedImageUrl(goods.image || '')}
|
||||
mode='aspectFill'
|
||||
style={{ height: '90px' }}
|
||||
/>
|
||||
@@ -169,7 +170,7 @@ const CartPage: React.FC = () => {
|
||||
</View>
|
||||
<Image
|
||||
className="w-20 h-20 rounded-md bg-gray-100 flex-shrink-0"
|
||||
src={item.goodsImage || item.product?.image || ''}
|
||||
src={getCompressedImageUrl(item.goodsImage || item.product?.image || '')}
|
||||
mode="aspectFill"
|
||||
/>
|
||||
<View className="flex-1 flex flex-col justify-between">
|
||||
@@ -221,7 +222,7 @@ const CartPage: React.FC = () => {
|
||||
>
|
||||
<Image
|
||||
className="w-full rounded-md bg-gray-100"
|
||||
src={goods.image || ''}
|
||||
src={getCompressedImageUrl(goods.image || '')}
|
||||
mode="aspectFill"
|
||||
style={{ height: '90px' }}
|
||||
/>
|
||||
|
||||
@@ -8,6 +8,7 @@ import type { ShopGoodsCategory } from '@/api/shop/shopGoodsCategory/model'
|
||||
import type { ShopGoods, ShopGoodsParam } from '@/api/shop/shopGoods/model'
|
||||
import { isGuest } from '@/utils/auth'
|
||||
import { isVipMember } from '@/utils/vip'
|
||||
import { getCompressedImageUrl } from '@/utils/image'
|
||||
import { requireLogin } from '@/utils/login-guard'
|
||||
import LoadMore from '@/components/common/LoadMore'
|
||||
import EmptyState from '@/components/common/EmptyState'
|
||||
@@ -215,7 +216,7 @@ const CategoryPage: React.FC = () => {
|
||||
<View className='w-20 h-20 rounded-lg bg-gray-100 overflow-hidden flex-shrink-0'>
|
||||
<Image
|
||||
className='w-full h-full'
|
||||
src={item.image || item.files || ''}
|
||||
src={getCompressedImageUrl(item.image || item.files || '')}
|
||||
mode='aspectFill'
|
||||
lazyLoad
|
||||
/>
|
||||
|
||||
@@ -14,6 +14,7 @@ import type { ShopGoods } from '@/api/shop/shopGoods/model'
|
||||
import type { ShopUserCoupon } from '@/api/shop/shopUserCoupon/model'
|
||||
import type { OrderGoodsItem, OrderCreateRequest } from '@/api/shop/shopOrder/model'
|
||||
import { isVipMember } from '@/utils/vip'
|
||||
import { getCompressedImageUrl } from '@/utils/image'
|
||||
|
||||
// 满减门槛配置
|
||||
const THRESHOLDS = [
|
||||
@@ -344,7 +345,7 @@ const CheckoutPage: React.FC = () => {
|
||||
<View key={`${item.goodsId}-${item.skuId}-${idx}`} className='flex gap-3 py-3 border-b border-gray-50'>
|
||||
<Image
|
||||
className='w-16 h-16 rounded-md bg-gray-100'
|
||||
src={item.goodsImage || item.product?.image || item.sku?.image || ''}
|
||||
src={getCompressedImageUrl(item.goodsImage || item.product?.image || item.sku?.image || '')}
|
||||
mode='aspectFill'
|
||||
/>
|
||||
<View className='flex-1'>
|
||||
@@ -495,7 +496,7 @@ const CheckoutPage: React.FC = () => {
|
||||
>
|
||||
<Image
|
||||
className='w-full h-20 rounded bg-gray-100'
|
||||
src={product.image || ''}
|
||||
src={getCompressedImageUrl(product.image || '')}
|
||||
mode='aspectFill'
|
||||
/>
|
||||
<Text className='text-xs text-gray-700 block line-clamp-1 mt-1'>
|
||||
|
||||
@@ -7,6 +7,7 @@ import type { ShopGroupBuy, ShopGroupBuyRecord } from '@/api/shop/shopGroupBuy/m
|
||||
import type { ShopGoods } from '@/api/shop/shopGoods/model'
|
||||
import type { ShopGoodsSku } from '@/api/shop/shopGoodsSku/model'
|
||||
import SkuSelector from '@/components/business/SkuSelector'
|
||||
import { getCompressedImageUrl } from '@/utils/image'
|
||||
|
||||
definePageConfig({
|
||||
navigationBarTitleText: '拼团详情',
|
||||
@@ -184,7 +185,7 @@ const GroupBuyDetailPage: React.FC = () => {
|
||||
<View className="bg-white p-4 flex gap-3">
|
||||
<Image
|
||||
className="w-24 h-24 rounded-md bg-gray-100"
|
||||
src={groupBuy.goodsImage || groupBuy.product?.image || ''}
|
||||
src={getCompressedImageUrl(groupBuy.goodsImage || groupBuy.product?.image || '')}
|
||||
mode="aspectFill"
|
||||
/>
|
||||
<View className="flex-1 flex flex-col justify-between">
|
||||
|
||||
@@ -4,6 +4,7 @@ import Taro from '@tarojs/taro'
|
||||
import { pageShopGroupBuy } from '@/api/shop/shopGroupBuy'
|
||||
import type { ShopGroupBuy } from '@/api/shop/shopGroupBuy/model'
|
||||
import EmptyState from '@/components/common/EmptyState'
|
||||
import { getCompressedImageUrl } from '@/utils/image'
|
||||
|
||||
definePageConfig({
|
||||
navigationBarTitleText: '拼团活动',
|
||||
@@ -72,7 +73,7 @@ const GroupBuyListPage: React.FC = () => {
|
||||
>
|
||||
<Image
|
||||
className='w-24 h-24 rounded-md bg-gray-100 flex-shrink-0'
|
||||
src={item.goodsImage || item.product?.image || ''}
|
||||
src={getCompressedImageUrl(item.goodsImage || item.product?.image || '')}
|
||||
mode='aspectFill'
|
||||
/>
|
||||
<View className='flex-1 flex flex-col justify-between'>
|
||||
|
||||
@@ -8,6 +8,7 @@ import type { ShopGoodsCategory } from '@/api/shop/shopGoodsCategory/model'
|
||||
import type { ShopGoods, ShopGoodsParam } from '@/api/shop/shopGoods/model'
|
||||
import { isGuest } from '@/utils/auth'
|
||||
import { isVipMember } from '@/utils/vip'
|
||||
import { getCompressedImageUrl } from '@/utils/image'
|
||||
import { requireLogin } from '@/utils/login-guard'
|
||||
import EmptyState from '@/components/common/EmptyState'
|
||||
import LoadMore from '@/components/common/LoadMore'
|
||||
@@ -269,7 +270,7 @@ const ShopPage: React.FC = () => {
|
||||
<View className='w-20 h-20 rounded-lg bg-gray-100 overflow-hidden flex-shrink-0'>
|
||||
<Image
|
||||
className='w-full h-full'
|
||||
src={item.image || item.files || ''}
|
||||
src={getCompressedImageUrl(item.image || item.files || '')}
|
||||
mode='aspectFill'
|
||||
lazyLoad
|
||||
/>
|
||||
|
||||
@@ -4,6 +4,7 @@ import Taro from '@tarojs/taro'
|
||||
import { pageShopSeckill } from '@/api/shop/shopSeckill'
|
||||
import type { ShopSeckill } from '@/api/shop/shopSeckill/model'
|
||||
import EmptyState from '@/components/common/EmptyState'
|
||||
import { getCompressedImageUrl } from '@/utils/image'
|
||||
|
||||
definePageConfig({
|
||||
navigationBarTitleText: '限时秒杀',
|
||||
@@ -94,7 +95,7 @@ const SeckillListPage: React.FC = () => {
|
||||
>
|
||||
<Image
|
||||
className='w-24 h-24 rounded-md bg-gray-100 flex-shrink-0'
|
||||
src={item.goodsImage || item.product?.image || ''}
|
||||
src={getCompressedImageUrl(item.goodsImage || item.product?.image || '')}
|
||||
mode='aspectFill'
|
||||
/>
|
||||
<View className='flex-1 flex flex-col justify-between'>
|
||||
|
||||
Reference in New Issue
Block a user