bug修复
This commit is contained in:
1 parent
654d08c8c8
commit
659ff74568
18 files changed
+182
-19
No files matched your search
@@ -0,0 +1,11 @@
|
||||
package com.shoplix.admin.modules.product.req;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
/** 后台产品图片请求。 */
|
||||
public record ProductImageAdminReq(
|
||||
/** 媒体资源业务编号。 */ @NotBlank @Size(max = 16) String mediaCode,
|
||||
/** 图片排序值。 */ @NotNull Integer sortNo) {
|
||||
}
|
||||
@@ -20,6 +20,7 @@ public record SaveProductAdminReq(
|
||||
@Size(max = 500) String summary,
|
||||
@NotBlank String productContent,
|
||||
@Size(max = 16) String coverMediaCode,
|
||||
@Valid @Size(max = 12) List<ProductImageAdminReq> images,
|
||||
@NotNull Boolean featured,
|
||||
@NotNull Boolean inquiryEnabled,
|
||||
@NotNull Integer sortNo,
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
package com.shoplix.admin.modules.product.res; import java.util.List;
|
||||
/** 后台产品详情响应。 */ public record ProductDetailAdminRes(String productCode,String primaryCategoryCode,String productName,String slug,String model,String summary,String productContent,String coverMediaCode,String coverMediaUrl,Boolean featured,Boolean inquiryEnabled,Integer sortNo,String status,List<ProductAttributeValueAdminRes> attributes,List<ProductSpecificationAdminRes> specifications) {}
|
||||
/** 后台产品详情响应。 */ public record ProductDetailAdminRes(String productCode,String primaryCategoryCode,String productName,String slug,String model,String summary,String productContent,String coverMediaCode,String coverMediaUrl,List<ProductImageAdminRes> images,Boolean featured,Boolean inquiryEnabled,Integer sortNo,String status,List<ProductAttributeValueAdminRes> attributes,List<ProductSpecificationAdminRes> specifications) {}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.shoplix.admin.modules.product.res;
|
||||
|
||||
/** 后台产品图片响应。 */
|
||||
public record ProductImageAdminRes(
|
||||
/** 媒体资源业务编号。 */ String mediaCode,
|
||||
/** 图片访问地址。 */ String url,
|
||||
/** 图片排序值。 */ Integer sortNo) {
|
||||
}
|
||||
@@ -16,12 +16,14 @@ import com.shoplix.modules.product.repository.entity.ProductCategoryEntity;
|
||||
import com.shoplix.modules.product.repository.entity.ProductSpecificationEntity;
|
||||
import com.shoplix.modules.product.repository.entity.ProductAttributeEntity;
|
||||
import com.shoplix.modules.product.repository.entity.ProductAttributeValueEntity;
|
||||
import com.shoplix.modules.product.repository.entity.ProductMediaRelationEntity;
|
||||
import com.shoplix.modules.media.repository.service.MediaAssetRepositoryService;
|
||||
import com.shoplix.modules.product.repository.service.ProductRepositoryService;
|
||||
import com.shoplix.modules.product.repository.service.ProductCategoryRepositoryService;
|
||||
import com.shoplix.modules.product.repository.service.ProductSpecificationRepositoryService;
|
||||
import com.shoplix.modules.product.repository.service.ProductAttributeRepositoryService;
|
||||
import com.shoplix.modules.product.repository.service.ProductAttributeValueRepositoryService;
|
||||
import com.shoplix.modules.product.repository.service.ProductMediaRelationRepositoryService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -35,6 +37,7 @@ public class AdminProductService {
|
||||
private final ProductCategoryRepositoryService categoryRepository;
|
||||
private final ProductAttributeRepositoryService attributeRepository;
|
||||
private final ProductAttributeValueRepositoryService attributeValueRepository;
|
||||
private final ProductMediaRelationRepositoryService productMediaRepository;
|
||||
private final MediaAssetRepositoryService mediaRepository;
|
||||
private final BusinessCodeUtils codeUtils;
|
||||
/** 注入产品业务依赖。 */
|
||||
@@ -43,11 +46,13 @@ public class AdminProductService {
|
||||
ProductCategoryRepositoryService categoryRepository,
|
||||
ProductAttributeRepositoryService attributeRepository,
|
||||
ProductAttributeValueRepositoryService attributeValueRepository,
|
||||
ProductMediaRelationRepositoryService productMediaRepository,
|
||||
MediaAssetRepositoryService mediaRepository,
|
||||
BusinessCodeUtils codeUtils) {
|
||||
this.repository = repository; this.specificationRepository = specificationRepository;
|
||||
this.categoryRepository = categoryRepository; this.attributeRepository = attributeRepository;
|
||||
this.attributeValueRepository = attributeValueRepository; this.mediaRepository = mediaRepository; this.codeUtils = codeUtils;
|
||||
this.attributeValueRepository = attributeValueRepository; this.productMediaRepository = productMediaRepository;
|
||||
this.mediaRepository = mediaRepository; this.codeUtils = codeUtils;
|
||||
}
|
||||
/** 保存产品并原子替换弱规格。 */
|
||||
@Transactional
|
||||
@@ -59,11 +64,25 @@ public class AdminProductService {
|
||||
entity.setPrimaryCategoryCode(request.primaryCategoryCode() == null ? "" : request.primaryCategoryCode());
|
||||
entity.setProductName(request.productName()); entity.setSlug(request.slug()); entity.setModel(request.model());
|
||||
entity.setSummary(request.summary()); entity.setProductContent(request.productContent());
|
||||
entity.setCoverMediaCode(request.coverMediaCode()); entity.setFeaturedFlag(request.featured() ? 1 : 0);
|
||||
List<String> imageCodes = request.images() == null || request.images().isEmpty()
|
||||
? request.coverMediaCode() == null || request.coverMediaCode().isBlank() ? List.of() : List.of(request.coverMediaCode())
|
||||
: request.images().stream().sorted(java.util.Comparator.comparingInt(x -> x.sortNo())).map(x -> x.mediaCode()).toList();
|
||||
if (imageCodes.stream().distinct().count() != imageCodes.size()) throw new BusinessException("PRODUCT_IMAGE_DUPLICATED", "产品图片不能重复");
|
||||
imageCodes.forEach(mediaCode -> mediaRepository.find(request.siteCode(), mediaCode)
|
||||
.orElseThrow(() -> new BusinessException("PRODUCT_IMAGE_NOT_FOUND", "产品图片不存在")));
|
||||
entity.setCoverMediaCode(imageCodes.isEmpty() ? null : imageCodes.getFirst()); entity.setFeaturedFlag(request.featured() ? 1 : 0);
|
||||
entity.setInquiryEnabled(request.inquiryEnabled() ? 1 : 0); entity.setSortNo(request.sortNo()); entity.setStatus(request.status().name());
|
||||
if (request.status().name().equals("PUBLISHED") && entity.getPublishTime() == null) entity.setPublishTime(System.currentTimeMillis());
|
||||
int affected = creating ? repository.insert(entity) : repository.updateByCode(entity);
|
||||
if (affected != 1) throw new BusinessException("PRODUCT_SAVE_FAILED", "产品保存失败");
|
||||
productMediaRepository.delete(entity.getSiteCode(), entity.getProductCode());
|
||||
for (int index = 0; index < imageCodes.size(); index++) {
|
||||
ProductMediaRelationEntity relation = new ProductMediaRelationEntity();
|
||||
relation.setRelationCode(codeUtils.generate(BusinessCodePrefixEnum.PRODUCT_MEDIA_RELATION));
|
||||
relation.setSiteCode(entity.getSiteCode()); relation.setProductCode(entity.getProductCode());
|
||||
relation.setMediaCode(imageCodes.get(index)); relation.setSortNo(index);
|
||||
if (productMediaRepository.insert(relation) != 1) throw new BusinessException("PRODUCT_IMAGE_SAVE_FAILED", "产品图片保存失败");
|
||||
}
|
||||
specificationRepository.delete(entity.getSiteCode(), entity.getProductCode());
|
||||
for (ProductSpecificationAdminReq item : request.specifications() == null ? List.<ProductSpecificationAdminReq>of() : request.specifications()) {
|
||||
ProductSpecificationEntity specification = new ProductSpecificationEntity();
|
||||
@@ -93,12 +112,16 @@ public class AdminProductService {
|
||||
public ProductDetailAdminRes detail(String siteCode, String productCode) {
|
||||
ProductEntity item = repository.findByCode(siteCode, productCode).orElseThrow(() -> new BusinessException("PRODUCT_NOT_FOUND", "产品不存在"));
|
||||
String mediaUrl = item.getCoverMediaCode() == null ? null : mediaRepository.find(siteCode, item.getCoverMediaCode()).map(x -> x.getRelativeUrl()).orElse(null);
|
||||
List<ProductImageAdminRes> images = productMediaRepository.list(siteCode, productCode).stream()
|
||||
.map(relation -> new ProductImageAdminRes(relation.getMediaCode(), mediaRepository.find(siteCode, relation.getMediaCode()).map(x -> x.getRelativeUrl()).orElse(null), relation.getSortNo()))
|
||||
.filter(image -> image.url() != null).toList();
|
||||
if (images.isEmpty() && item.getCoverMediaCode() != null && mediaUrl != null) images = List.of(new ProductImageAdminRes(item.getCoverMediaCode(), mediaUrl, 0));
|
||||
List<ProductAttributeValueAdminRes> attributes = attributeValueRepository.list(siteCode, productCode).stream().map(value -> {
|
||||
ProductAttributeEntity definition = attributeRepository.find(siteCode, value.getAttributeCode()).orElse(null);
|
||||
return new ProductAttributeValueAdminRes(value.getAttributeCode(), definition == null ? value.getAttributeCode() : definition.getAttributeName(), value.getTextValue(), definition == null ? null : definition.getUnit(), value.getSortNo());
|
||||
}).toList();
|
||||
List<ProductSpecificationAdminRes> specifications = specificationRepository.list(siteCode, productCode).stream().map(x -> new ProductSpecificationAdminRes(x.getGroupName(), x.getSpecificationName(), x.getSpecificationValue(), x.getUnit(), x.getSortNo())).toList();
|
||||
return new ProductDetailAdminRes(item.getProductCode(), item.getPrimaryCategoryCode(), item.getProductName(), item.getSlug(), item.getModel(), item.getSummary(), item.getProductContent(), item.getCoverMediaCode(), mediaUrl, item.getFeaturedFlag() == 1, item.getInquiryEnabled() == 1, item.getSortNo(), item.getStatus(), attributes, specifications);
|
||||
return new ProductDetailAdminRes(item.getProductCode(), item.getPrimaryCategoryCode(), item.getProductName(), item.getSlug(), item.getModel(), item.getSummary(), item.getProductContent(), item.getCoverMediaCode(), mediaUrl, images, item.getFeaturedFlag() == 1, item.getInquiryEnabled() == 1, item.getSortNo(), item.getStatus(), attributes, specifications);
|
||||
}
|
||||
/** 查询后台产品列表。 */
|
||||
public List<ProductItemAdminRes> list(String siteCode) {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
CREATE TABLE product_media_relation (
|
||||
id BIGINT NOT NULL AUTO_INCREMENT COMMENT '数据库内部主键',
|
||||
relation_code VARCHAR(16) NOT NULL COMMENT '产品图片关系业务编号',
|
||||
site_code VARCHAR(16) NOT NULL COMMENT '站点业务编号',
|
||||
product_code VARCHAR(16) NOT NULL COMMENT '产品业务编号',
|
||||
media_code VARCHAR(16) NOT NULL COMMENT '媒体资源业务编号',
|
||||
sort_no INT NOT NULL DEFAULT 0 COMMENT '图片排序值,数值越小越靠前',
|
||||
deleted TINYINT NOT NULL DEFAULT 0 COMMENT '逻辑删除状态:0-正常,1-已删除',
|
||||
create_time BIGINT NOT NULL DEFAULT (ROUND(UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000)) COMMENT '创建毫秒时间戳',
|
||||
update_time BIGINT NOT NULL DEFAULT (ROUND(UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000)) COMMENT '更新毫秒时间戳',
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uk_product_media_relation_code (relation_code),
|
||||
UNIQUE KEY uk_product_media_relation_media (site_code, product_code, media_code),
|
||||
KEY idx_product_media_relation_sort (site_code, product_code, sort_no)
|
||||
) COMMENT='产品图片关系表';
|
||||
|
||||
INSERT INTO product_media_relation
|
||||
(relation_code, site_code, product_code, media_code, sort_no, deleted, create_time, update_time)
|
||||
SELECT CONCAT('PMG', LPAD(id, 13, '0')), site_code, product_code, cover_media_code, 0, 0,
|
||||
COALESCE(create_time, UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000),
|
||||
COALESCE(update_time, UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000)
|
||||
FROM product
|
||||
WHERE cover_media_code IS NOT NULL AND cover_media_code <> '' AND deleted = 0;
|
||||
@@ -39,6 +39,7 @@ class CategoryHierarchyValidationTest {
|
||||
AdminProductService service = new AdminProductService(mock(ProductRepositoryService.class),
|
||||
mock(ProductSpecificationRepositoryService.class), categoryRepository,
|
||||
mock(ProductAttributeRepositoryService.class), mock(ProductAttributeValueRepositoryService.class),
|
||||
mock(ProductMediaRelationRepositoryService.class),
|
||||
mock(MediaAssetRepositoryService.class), codeUtils);
|
||||
SaveProductCategoryAdminReq request = new SaveProductCategoryAdminReq(null, "SIT0000000000001",
|
||||
"PCT0000000000003", "Level Four", "level-four", "", null, 30, PublishStatusEnum.DRAFT);
|
||||
|
||||
@@ -4,7 +4,7 @@ package com.shoplix.common.code.enums;
|
||||
public enum BusinessCodePrefixEnum {
|
||||
SITE("SIT"), DOMAIN("DOM"), PRODUCT("PRD"), SKU("SKU"), CATEGORY("CAT"),
|
||||
PRODUCT_CATEGORY("PCT"), PRODUCT_CATEGORY_RELATION("PCR"), PRODUCT_ATTRIBUTE("PAT"),
|
||||
PRODUCT_ATTRIBUTE_OPTION("PAO"), PRODUCT_ATTRIBUTE_VALUE("PAV"), PRODUCT_SPECIFICATION("PSP"),
|
||||
PRODUCT_ATTRIBUTE_OPTION("PAO"), PRODUCT_ATTRIBUTE_VALUE("PAV"), PRODUCT_SPECIFICATION("PSP"), PRODUCT_MEDIA_RELATION("PMG"),
|
||||
PRODUCT_RELATION("PRR"), CONTENT("CNT"), CONTENT_CATEGORY("CCT"),
|
||||
CONTENT_CATEGORY_RELATION("CCR"), CONTENT_PRODUCT_RELATION("CPR"),
|
||||
CASE("CAS"), NEWS("NWS"), PAGE("PAG"), SERVICE("SRV"), HELP("HLP"),
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.shoplix.modules.product.repository.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
/** 产品图片关系持久化实体。 */
|
||||
@Data
|
||||
@TableName("product_media_relation")
|
||||
public class ProductMediaRelationEntity {
|
||||
/** 数据库内部主键。 */ @TableId(type = IdType.AUTO) private Long id;
|
||||
/** 产品图片关系业务编号。 */ private String relationCode;
|
||||
/** 站点业务编号。 */ private String siteCode;
|
||||
/** 产品业务编号。 */ private String productCode;
|
||||
/** 媒体资源业务编号。 */ private String mediaCode;
|
||||
/** 图片排序值。 */ private Integer sortNo;
|
||||
/** 逻辑删除状态。 */ private Integer deleted;
|
||||
/** 创建毫秒时间戳。 */ private Long createTime;
|
||||
/** 更新毫秒时间戳。 */ private Long updateTime;
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.shoplix.modules.product.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.shoplix.modules.product.repository.entity.ProductMediaRelationEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/** 产品图片关系 Mapper。 */
|
||||
@Mapper
|
||||
public interface ProductMediaRelationMapper extends BaseMapper<ProductMediaRelationEntity> {
|
||||
/** 按产品物理删除图片关系,便于原子替换相同媒体。 */
|
||||
@Delete("DELETE FROM product_media_relation WHERE site_code = #{siteCode} AND product_code = #{productCode}")
|
||||
int deletePermanentlyByProduct(@Param("siteCode") String siteCode, @Param("productCode") String productCode);
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.shoplix.modules.product.repository.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.shoplix.modules.product.repository.entity.ProductMediaRelationEntity;
|
||||
import com.shoplix.modules.product.repository.mapper.ProductMediaRelationMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** 产品图片关系单表数据源服务。 */
|
||||
@Service
|
||||
public class ProductMediaRelationRepositoryService {
|
||||
private final ProductMediaRelationMapper mapper;
|
||||
|
||||
/** 注入产品图片关系 Mapper。 */
|
||||
public ProductMediaRelationRepositoryService(ProductMediaRelationMapper mapper) { this.mapper = mapper; }
|
||||
|
||||
/** 查询产品有序图片关系。 */
|
||||
public List<ProductMediaRelationEntity> list(String siteCode, String productCode) {
|
||||
return mapper.selectList(Wrappers.<ProductMediaRelationEntity>lambdaQuery()
|
||||
.eq(ProductMediaRelationEntity::getSiteCode, siteCode)
|
||||
.eq(ProductMediaRelationEntity::getProductCode, productCode)
|
||||
.orderByAsc(ProductMediaRelationEntity::getSortNo));
|
||||
}
|
||||
|
||||
/** 删除产品全部图片关系。 */
|
||||
public int delete(String siteCode, String productCode) {
|
||||
return mapper.deletePermanentlyByProduct(siteCode, productCode);
|
||||
}
|
||||
|
||||
/** 新增产品图片关系。 */
|
||||
public int insert(ProductMediaRelationEntity entity) { return mapper.insert(entity); }
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import java.util.List;
|
||||
/** 前台站产品详情响应。 */
|
||||
public record ProductDetailSiteRes(String productCode, String productName, String slug, String model,
|
||||
String summary, String content, String coverMediaCode,
|
||||
String coverMediaUrl, Boolean inquiryEnabled,
|
||||
String coverMediaUrl, List<ProductImageSiteRes> images, Boolean inquiryEnabled,
|
||||
List<ProductAttributeSiteRes> attributes,
|
||||
List<ProductSpecificationSiteRes> specifications) {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.shoplix.site.modules.product.res;
|
||||
|
||||
/** 前台产品图片响应。 */
|
||||
public record ProductImageSiteRes(
|
||||
/** 媒体资源业务编号。 */ String mediaCode,
|
||||
/** 图片访问地址。 */ String url,
|
||||
/** 图片排序值。 */ Integer sortNo) {
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import com.shoplix.modules.product.repository.service.ProductRepositoryService;
|
||||
import com.shoplix.modules.product.repository.service.ProductSpecificationRepositoryService;
|
||||
import com.shoplix.modules.product.repository.service.ProductAttributeRepositoryService;
|
||||
import com.shoplix.modules.product.repository.service.ProductAttributeValueRepositoryService;
|
||||
import com.shoplix.modules.product.repository.service.ProductMediaRelationRepositoryService;
|
||||
import com.shoplix.modules.media.repository.service.MediaAssetRepositoryService;
|
||||
import com.shoplix.site.modules.product.res.*;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,14 +21,17 @@ public class SiteProductService {
|
||||
private final ProductSpecificationRepositoryService specificationRepository;
|
||||
private final ProductAttributeRepositoryService attributeRepository;
|
||||
private final ProductAttributeValueRepositoryService attributeValueRepository;
|
||||
private final ProductMediaRelationRepositoryService productMediaRepository;
|
||||
private final MediaAssetRepositoryService mediaRepository;
|
||||
/** 注入产品数据源。 */
|
||||
public SiteProductService(ProductRepositoryService repository, ProductSpecificationRepositoryService specificationRepository,
|
||||
ProductAttributeRepositoryService attributeRepository,
|
||||
ProductAttributeValueRepositoryService attributeValueRepository,
|
||||
ProductMediaRelationRepositoryService productMediaRepository,
|
||||
MediaAssetRepositoryService mediaRepository) {
|
||||
this.repository = repository; this.specificationRepository = specificationRepository;
|
||||
this.attributeRepository = attributeRepository; this.attributeValueRepository = attributeValueRepository;
|
||||
this.productMediaRepository = productMediaRepository;
|
||||
this.mediaRepository = mediaRepository;
|
||||
}
|
||||
/** 查询当前站点已发布产品。 */
|
||||
@@ -52,8 +56,12 @@ public class SiteProductService {
|
||||
}).toList();
|
||||
String mediaUrl = item.getCoverMediaCode() == null ? null : mediaRepository.find(siteCode, item.getCoverMediaCode())
|
||||
.map(value -> value.getRelativeUrl()).orElse(null);
|
||||
List<ProductImageSiteRes> images = productMediaRepository.list(siteCode, item.getProductCode()).stream()
|
||||
.map(relation -> new ProductImageSiteRes(relation.getMediaCode(), mediaRepository.find(siteCode, relation.getMediaCode()).map(value -> value.getRelativeUrl()).orElse(null), relation.getSortNo()))
|
||||
.filter(image -> image.url() != null).toList();
|
||||
if (images.isEmpty() && item.getCoverMediaCode() != null && mediaUrl != null) images = List.of(new ProductImageSiteRes(item.getCoverMediaCode(), mediaUrl, 0));
|
||||
return new ProductDetailSiteRes(item.getProductCode(), item.getProductName(), item.getSlug(), item.getModel(),
|
||||
item.getSummary(), item.getProductContent(), item.getCoverMediaCode(), mediaUrl,
|
||||
item.getSummary(), item.getProductContent(), item.getCoverMediaCode(), mediaUrl, images,
|
||||
item.getInquiryEnabled() == 1, attributes, specifications);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import {EditorContent,useEditor} from '@tiptap/react';
|
||||
import StarterKit from '@tiptap/starter-kit';
|
||||
import Link from '@tiptap/extension-link';
|
||||
import Image from '@tiptap/extension-image';
|
||||
import {ArrowLeft,Bold,Heading2,Heading3,Image as ImageIcon,Italic,Link as LinkIcon,List,Plus,Save,Trash2,Undo2,Redo2} from 'lucide-react';
|
||||
import {ArrowDown,ArrowLeft,ArrowUp,Bold,Heading2,Heading3,Image as ImageIcon,Italic,Link as LinkIcon,List,Plus,Save,Trash2,Undo2,Redo2} from 'lucide-react';
|
||||
import {API,assetUrl} from './api';
|
||||
|
||||
const SITE='SIT0000000000001';
|
||||
@@ -11,6 +11,7 @@ async function post(path:string,body:unknown){const r=await fetch(API+path,{meth
|
||||
type Attribute={attributeCode?:string;attributeName:string;value:string;unit:string;sortNo:number};
|
||||
type Specification={groupName:string;name:string;value:string;unit:string;sortNo:number};
|
||||
type Heading={level:number;text:string;sortNo:number};
|
||||
type ProductImage={mediaCode:string;url:string;sortNo:number};
|
||||
type ProductCategory={categoryCode:string;parentCategoryCode:string;categoryName:string;status:string};
|
||||
type ProductCategoryOption=ProductCategory&{depth:number};
|
||||
type Props={productCode?:string;onBack:()=>void};
|
||||
@@ -51,6 +52,7 @@ function normalizeRichTextHtml(content:string):string{
|
||||
|
||||
export default function ProductEditor({productCode,onBack}:Props){
|
||||
const [form,setForm]=useState({productName:'',slug:'',model:'',summary:'',primaryCategoryCode:'',coverMediaCode:'',coverMediaUrl:'',featured:false,inquiryEnabled:true,sortNo:30,status:'DRAFT'});
|
||||
const [images,setImages]=useState<ProductImage[]>([]);
|
||||
const [attributes,setAttributes]=useState<Attribute[]>([]);const [specifications,setSpecifications]=useState<Specification[]>([]);const [categories,setCategories]=useState<ProductCategoryOption[]>([]);
|
||||
const [categoriesLoading,setCategoriesLoading]=useState(true);const [categoriesError,setCategoriesError]=useState('');
|
||||
const [seo,setSeo]=useState({title:'',description:'',keywords:'',h1:'',canonicalUrl:'',robots:'index,follow',ogTitle:'',ogDescription:'',ogImageUrl:'',status:'DRAFT'});const [headings,setHeadings]=useState<Heading[]>([]);
|
||||
@@ -58,14 +60,16 @@ export default function ProductEditor({productCode,onBack}:Props){
|
||||
const [uploading,setUploading]=useState(false);const coverInputRef=useRef<HTMLInputElement>(null);
|
||||
const editor=useEditor({extensions:[StarterKit,Link.configure({openOnClick:false}),Image],content:'<p></p>'});
|
||||
useEffect(()=>{let active=true;setCategoriesLoading(true);setCategoriesError('');post('/products/categories/list',{siteCode:SITE}).then(data=>{if(active)setCategories(buildCategoryOptions(data.items||[]))}).catch(error=>{if(active)setCategoriesError(error instanceof Error?error.message:'产品分类加载失败')}).finally(()=>{if(active)setCategoriesLoading(false)});return()=>{active=false}},[]);
|
||||
useEffect(()=>{if(!productCode)return;post('/products/detail',{siteCode:SITE,productCode}).then(d=>{setForm({...d,coverMediaUrl:d.coverMediaUrl||''});setAttributes(d.attributes||[]);setSpecifications(mergeSpecifications(d.specifications||[]));editor?.commands.setContent(normalizeRichTextHtml(d.productContent||'<p></p>'))});post('/seo/detail',{siteCode:SITE,pageType:'PRODUCT_DETAIL',targetCode:productCode}).then(d=>{setSeo({title:d.title,description:d.description,keywords:d.keywords||'',h1:d.h1,canonicalUrl:d.canonicalUrl||'',robots:d.robots,ogTitle:d.ogTitle||'',ogDescription:d.ogDescription||'',ogImageUrl:d.ogImageUrl||'',status:d.status});setHeadings(d.headings||[])}).catch(()=>{})},[productCode,editor]);
|
||||
/** 校验并上传产品主图,选择相同文件时也允许重新触发上传。 */
|
||||
const upload=async(file?:File)=>{if(!file)return;if(file.size>10*1024*1024){setNotice('图片不能超过 10MB');return}try{setUploading(true);setNotice('');const body=new FormData();body.append('siteCode',SITE);body.append('altText',form.productName);body.append('file',file);const r=await fetch(API+'/media/upload-image',{method:'POST',body});if(r.status===413)throw new Error('图片超过服务器上传限制,请联系管理员调整 Nginx 上传上限');if(!r.ok)throw new Error((await r.json().catch(()=>({}))).message||'上传失败');const d=await r.json();setForm(current=>({...current,coverMediaCode:d.mediaCode,coverMediaUrl:d.url}));setNotice('产品主图上传成功')}catch(e){setNotice(e instanceof Error?e.message:'上传失败')}finally{setUploading(false);if(coverInputRef.current)coverInputRef.current.value=''}};
|
||||
const save=async()=>{if(!editor)return;try{setSaving(true);setNotice('');const result=await post('/products/save',{productCode,siteCode:SITE,primaryCategoryCode:form.primaryCategoryCode,productName:form.productName,slug:form.slug,model:form.model,summary:form.summary,productContent:normalizeRichTextHtml(editor.getHTML()),coverMediaCode:form.coverMediaCode,featured:form.featured,inquiryEnabled:form.inquiryEnabled,sortNo:form.sortNo,status:form.status,specifications,attributes});await post('/seo/save',{siteCode:SITE,pageType:'PRODUCT_DETAIL',targetCode:result.productCode,title:seo.title||form.productName,description:seo.description||form.summary,keywords:seo.keywords,h1:seo.h1||form.productName,canonicalUrl:seo.canonicalUrl||`/products/${form.slug}`,robots:seo.robots,ogTitle:seo.ogTitle,ogDescription:seo.ogDescription,ogImageUrl:seo.ogImageUrl,structuredData:null,status:form.status,headings});setNotice('产品与 SEO 已保存');if(!productCode)setTimeout(onBack,500)}catch(e){setNotice(e instanceof Error?e.message:'保存失败')}finally{setSaving(false)}};
|
||||
useEffect(()=>{if(!productCode)return;post('/products/detail',{siteCode:SITE,productCode}).then(d=>{setForm({...d,coverMediaUrl:d.coverMediaUrl||''});setImages(d.images?.length?d.images:(d.coverMediaCode&&d.coverMediaUrl?[{mediaCode:d.coverMediaCode,url:d.coverMediaUrl,sortNo:0}]:[]));setAttributes(d.attributes||[]);setSpecifications(mergeSpecifications(d.specifications||[]));editor?.commands.setContent(normalizeRichTextHtml(d.productContent||'<p></p>'))});post('/seo/detail',{siteCode:SITE,pageType:'PRODUCT_DETAIL',targetCode:productCode}).then(d=>{setSeo({title:d.title,description:d.description,keywords:d.keywords||'',h1:d.h1,canonicalUrl:d.canonicalUrl||'',robots:d.robots,ogTitle:d.ogTitle||'',ogDescription:d.ogDescription||'',ogImageUrl:d.ogImageUrl||'',status:d.status});setHeadings(d.headings||[])}).catch(()=>{})},[productCode,editor]);
|
||||
/** 校验并批量上传产品图片,保持用户选择顺序。 */
|
||||
const upload=async(files?:FileList|null)=>{if(!files?.length)return;const selected=[...files];if(images.length+selected.length>12){setNotice('产品图片最多 12 张');return}if(selected.some(file=>file.size>10*1024*1024)){setNotice('单张图片不能超过 10MB');return}try{setUploading(true);setNotice('');const uploaded:ProductImage[]=[];for(const file of selected){const body=new FormData();body.append('siteCode',SITE);body.append('altText',form.productName);body.append('file',file);const r=await fetch(API+'/media/upload-image',{method:'POST',body});if(r.status===413)throw new Error('图片超过服务器上传限制,请联系管理员调整 Nginx 上传上限');if(!r.ok)throw new Error((await r.json().catch(()=>({}))).message||'上传失败');const d=await r.json();uploaded.push({mediaCode:d.mediaCode,url:d.url,sortNo:images.length+uploaded.length})}setImages(current=>[...current,...uploaded].map((image,index)=>({...image,sortNo:index})));setNotice(`成功上传 ${uploaded.length} 张产品图片`)}catch(e){setNotice(e instanceof Error?e.message:'上传失败')}finally{setUploading(false);if(coverInputRef.current)coverInputRef.current.value=''}};
|
||||
/** 调整产品图片顺序。 */
|
||||
const moveImage=(index:number,direction:-1|1)=>{const target=index+direction;if(target<0||target>=images.length)return;const next=[...images];[next[index],next[target]]=[next[target],next[index]];setImages(next.map((image,position)=>({...image,sortNo:position})))};
|
||||
const save=async()=>{if(!editor)return;try{setSaving(true);setNotice('');const result=await post('/products/save',{productCode,siteCode:SITE,primaryCategoryCode:form.primaryCategoryCode,productName:form.productName,slug:form.slug,model:form.model,summary:form.summary,productContent:normalizeRichTextHtml(editor.getHTML()),coverMediaCode:images[0]?.mediaCode||'',images:images.map((image,index)=>({mediaCode:image.mediaCode,sortNo:index})),featured:form.featured,inquiryEnabled:form.inquiryEnabled,sortNo:form.sortNo,status:form.status,specifications,attributes});await post('/seo/save',{siteCode:SITE,pageType:'PRODUCT_DETAIL',targetCode:result.productCode,title:seo.title||form.productName,description:seo.description||form.summary,keywords:seo.keywords,h1:seo.h1||form.productName,canonicalUrl:seo.canonicalUrl||`/products/${form.slug}`,robots:seo.robots,ogTitle:seo.ogTitle,ogDescription:seo.ogDescription,ogImageUrl:seo.ogImageUrl,structuredData:null,status:form.status,headings});setNotice('产品与 SEO 已保存');if(!productCode)setTimeout(onBack,500)}catch(e){setNotice(e instanceof Error?e.message:'保存失败')}finally{setSaving(false)}};
|
||||
const addLink=()=>{const href=window.prompt('请输入链接地址');if(href)editor?.chain().focus().setLink({href}).run()};const addImage=()=>{const src=window.prompt('请输入图片地址');if(src)editor?.chain().focus().setImage({src}).run()};
|
||||
return <div className="product-editor"><div className="editor-top"><div className="breadcrumb-title"><button className="back" onClick={onBack}><ArrowLeft size={17}/>产品管理</button><span>/</span><h1>{productCode?'编辑产品':'新增产品'}</h1>{notice&&<em>{notice}</em>}</div><div className="editor-actions"><button onClick={onBack}>取消</button><button className="primary" disabled={saving||!form.productName||!form.slug} onClick={save}><Save size={16}/>{saving?'保存中':'保存'}</button></div></div><div className="editor-layout"><div className="editor-main">
|
||||
<section className="edit-section"><h2>基础信息</h2><div className="edit-grid"><Field label="产品标题 *"><input value={form.productName} onChange={e=>setForm({...form,productName:e.target.value})}/></Field><Field label="英文路径 *"><input value={form.slug} onChange={e=>setForm({...form,slug:e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,'-')})}/></Field><Field label="产品分类"><select disabled={categoriesLoading||Boolean(categoriesError)} value={form.primaryCategoryCode} onChange={e=>setForm({...form,primaryCategoryCode:e.target.value})}><option value="">{categoriesLoading?'分类加载中...':categoriesError||'请选择'}</option>{categories.map(category=><option key={category.categoryCode} value={category.categoryCode}>{`${' '.repeat(category.depth)}${category.categoryName}`}</option>)}</select></Field><Field label="产品型号"><input value={form.model||''} onChange={e=>setForm({...form,model:e.target.value})}/></Field><Field label="排序"><input type="number" value={form.sortNo} onChange={e=>setForm({...form,sortNo:Number(e.target.value)})}/></Field><Field wide label="产品简介 *"><textarea rows={4} value={form.summary||''} onChange={e=>setForm({...form,summary:e.target.value})}/></Field></div></section>
|
||||
<section className="edit-section product-cover-section"><h2>产品主图</h2><div className="cover-upload">{form.coverMediaUrl?<img src={assetUrl(form.coverMediaUrl)} alt="产品主图预览"/>:<ImageIcon size={34}/>}<label className={uploading?'uploading':''}><span>{uploading?'上传中...':'选择图片'}</span><input ref={coverInputRef} disabled={uploading} type="file" accept=".jpg,.jpeg,.png,.webp,.gif,image/jpeg,image/png,image/webp,image/gif" onClick={e=>{e.currentTarget.value=''}} onChange={e=>void upload(e.currentTarget.files?.[0])}/></label><p>支持 JPG、PNG、WebP、GIF,单图不超过 10MB</p>{notice&&<small className="upload-notice">{notice}</small>}</div></section>
|
||||
<section className="edit-section product-cover-section"><div className="section-head"><h2>产品图片</h2><label className={`gallery-upload-button${uploading?' uploading':''}`}><Plus size={16}/>{uploading?'上传中...':'添加图片'}<input ref={coverInputRef} multiple disabled={uploading} type="file" accept=".jpg,.jpeg,.png,.webp,.gif,image/jpeg,image/png,image/webp,image/gif" onClick={e=>{e.currentTarget.value=''}} onChange={e=>void upload(e.currentTarget.files)}/></label></div><p className="gallery-help">最多 12 张,首张作为产品封面;支持 JPG、PNG、WebP、GIF,单张不超过 10MB。</p>{images.length?<div className="product-gallery-editor">{images.map((image,index)=><article key={image.mediaCode}><div>{index===0&&<span>封面</span>}<img src={assetUrl(image.url)} alt={`产品图片 ${index+1}`}/></div><footer><button type="button" title="向前移动" disabled={index===0} onClick={()=>moveImage(index,-1)}><ArrowUp size={16}/></button><button type="button" title="向后移动" disabled={index===images.length-1} onClick={()=>moveImage(index,1)}><ArrowDown size={16}/></button><button type="button" title="删除图片" onClick={()=>setImages(images.filter((_,position)=>position!==index).map((item,position)=>({...item,sortNo:position})))}><Trash2 size={16}/></button></footer></article>)}</div>:<div className="gallery-empty"><ImageIcon size={36}/><span>暂未上传产品图片</span></div>}</section>
|
||||
<section className="edit-section"><div className="section-head"><h2>产品属性</h2><button onClick={()=>setAttributes([...attributes,{attributeName:'',value:'',unit:'',sortNo:attributes.length}])}><Plus size={16}/>添加属性</button></div>{attributes.map((a,i)=><div className="repeat-row" key={i}><input placeholder="Attribute name" value={a.attributeName} onChange={e=>setAttributes(attributes.map((x,j)=>j===i?{...x,attributeName:e.target.value}:x))}/><input placeholder="Value" value={a.value} onChange={e=>setAttributes(attributes.map((x,j)=>j===i?{...x,value:e.target.value}:x))}/><input placeholder="Unit" value={a.unit||''} onChange={e=>setAttributes(attributes.map((x,j)=>j===i?{...x,unit:e.target.value}:x))}/><button title="删除属性" onClick={()=>setAttributes(attributes.filter((_,j)=>j!==i))}><Trash2 size={17}/></button></div>)}</section>
|
||||
<section className="edit-section product-specifications"><div className="section-head"><h2>产品规格</h2><button onClick={()=>setSpecifications([...specifications,{groupName:'',name:'',value:'',unit:'',sortNo:specifications.length}])}><Plus size={16}/>添加规格</button></div>{specifications.length===0&&<div className="specification-empty">暂无产品规格</div>}{specifications.map((s,i)=><div className="specification-row" key={i}><label><span>规格名称 *</span><input placeholder="例如 Line diameter" value={s.name} onChange={e=>setSpecifications(specifications.map((x,j)=>j===i?{...x,name:e.target.value}:x))}/></label><label className="specification-values"><span>规格值(多个值使用 / 分隔)*</span><input placeholder="例如 2.0mm / 2.4mm / 2.7mm" value={s.value} onChange={e=>setSpecifications(specifications.map((x,j)=>j===i?{...x,value:e.target.value}:x))}/></label><label><span>分组(可选)</span><input placeholder="例如 Basic" value={s.groupName||''} onChange={e=>setSpecifications(specifications.map((x,j)=>j===i?{...x,groupName:e.target.value}:x))}/></label><label><span>单位(可选)</span><input placeholder="例如 mm" value={s.unit||''} onChange={e=>setSpecifications(specifications.map((x,j)=>j===i?{...x,unit:e.target.value}:x))}/></label><button title="删除规格" onClick={()=>setSpecifications(specifications.filter((_,j)=>j!==i))}><Trash2 size={17}/></button></div>)}</section>
|
||||
<section className="edit-section"><h2>产品详情 *</h2><div className="rich-editor"><div className="rich-toolbar"><Tool title="撤销" onClick={()=>editor?.chain().focus().undo().run()}><Undo2/></Tool><Tool title="重做" onClick={()=>editor?.chain().focus().redo().run()}><Redo2/></Tool><Tool title="粗体" active={editor?.isActive('bold')} onClick={()=>editor?.chain().focus().toggleBold().run()}><Bold/></Tool><Tool title="斜体" active={editor?.isActive('italic')} onClick={()=>editor?.chain().focus().toggleItalic().run()}><Italic/></Tool><Tool title="二级标题" active={editor?.isActive('heading',{level:2})} onClick={()=>editor?.chain().focus().toggleHeading({level:2}).run()}><Heading2/></Tool><Tool title="三级标题" active={editor?.isActive('heading',{level:3})} onClick={()=>editor?.chain().focus().toggleHeading({level:3}).run()}><Heading3/></Tool><Tool title="项目列表" onClick={()=>editor?.chain().focus().toggleBulletList().run()}><List/></Tool><Tool title="链接" onClick={addLink}><LinkIcon/></Tool><Tool title="插入图片" onClick={addImage}><ImageIcon/></Tool></div><EditorContent editor={editor}/></div></section>
|
||||
|
||||
@@ -437,6 +437,7 @@ header p {
|
||||
.cover-upload label.uploading span{background:#71808a;cursor:wait}.cover-upload .upload-notice{display:block;color:#176b5b;font-size:12px;text-align:center}.cover-upload input:disabled+span{cursor:wait}
|
||||
.shell > main > header > div > p,.content-page > header > div > p,.category-heading p,.navigation-editor-title p,.navigation-manager > header p,.account-settings > header p,.seo-settings-heading p,.agreement-top p{display:none}
|
||||
.product-cover-section .cover-upload{min-height:140px;grid-template-columns:120px minmax(0,1fr);grid-template-rows:auto auto auto;align-content:center;justify-content:center;column-gap:18px;row-gap:8px;padding:16px 24px}.product-cover-section .cover-upload>svg,.product-cover-section .cover-upload>img{grid-column:1;grid-row:1/-1;justify-self:center}.product-cover-section .cover-upload>img{width:120px;height:120px;object-fit:contain}.product-cover-section .cover-upload label{grid-column:2;grid-row:1;align-self:end}.product-cover-section .cover-upload p{grid-column:2;grid-row:2}.product-cover-section .cover-upload .upload-notice{grid-column:2;grid-row:3}.product-cover-section .cover-upload label,.product-cover-section .cover-upload p,.product-cover-section .cover-upload .upload-notice{justify-self:start;text-align:left}
|
||||
.gallery-upload-button{border:1px solid #d8dee3;border-radius:5px;padding:8px 12px;color:#176b5b;display:inline-flex;align-items:center;gap:6px;cursor:pointer;font-size:13px}.gallery-upload-button.uploading{color:#71808a;cursor:wait}.gallery-upload-button input{display:none}.gallery-help{margin:-8px 0 16px;color:#81908b;font-size:12px}.product-gallery-editor{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:14px}.product-gallery-editor article{border:1px solid #d8dee3;border-radius:5px;overflow:hidden;background:#f8faf9}.product-gallery-editor article>div{position:relative;aspect-ratio:1/1;background:#fff}.product-gallery-editor img{width:100%;height:100%;object-fit:contain}.product-gallery-editor article>div>span{position:absolute;z-index:1;top:7px;left:7px;background:#176b5b;color:#fff;padding:3px 7px;font-size:11px}.product-gallery-editor footer{display:flex;justify-content:center;gap:5px;padding:7px}.product-gallery-editor footer button{width:32px;height:30px;border:1px solid #d8dee3;background:#fff;color:#596873;display:grid;place-items:center;cursor:pointer}.product-gallery-editor footer button:last-child{color:#a43333}.product-gallery-editor footer button:disabled{opacity:.35;cursor:not-allowed}.gallery-empty{min-height:150px;border:1px dashed #bdc8c4;display:grid;place-items:center;align-content:center;gap:8px;color:#81908b;font-size:13px}
|
||||
.specification-row{display:grid;grid-template-columns:minmax(150px,.85fr) minmax(280px,1.65fr) minmax(130px,.7fr) minmax(110px,.55fr) 42px;gap:12px;align-items:end;padding:14px 0;border-top:1px solid #edf0f2}.specification-row label{display:grid;gap:7px;min-width:0}.specification-row label>span{font-size:12px;font-weight:600;color:#53616b}.specification-row input{box-sizing:border-box;border:1px solid #d8dee3;border-radius:5px;padding:10px 12px;font:inherit;width:100%}.specification-row button{height:43px;border:1px solid #ead6d6;background:#fff;color:#a93636;border-radius:5px;display:inline-grid;place-items:center;cursor:pointer}.specification-empty{border:1px dashed #d8dee3;border-radius:5px;padding:26px;text-align:center;color:#81908b;font-size:13px}
|
||||
.pv-product-detail{padding:44px 5%;display:grid;grid-template-columns:minmax(0,1.05fr) minmax(300px,.95fr);gap:34px;align-items:start}.pv-product-image{aspect-ratio:1/1;background:#eef2f0;display:grid;place-items:center;color:#899691;overflow:hidden}.pv-product-image img{width:100%;height:100%;object-fit:contain}.pv-product-detail>div:nth-child(2)>span{font-size:11px;font-weight:800;color:#176b5d}.pv-product-detail h1{font-size:34px;line-height:1.12;margin:12px 0 18px}.pv-product-detail small{display:block;border-block:1px solid #dce2df;padding:10px 0}.pv-product-detail p{line-height:1.65;color:#61706b}.pv-product-detail button{border:0;color:#fff;padding:12px 20px;font-weight:700;margin-top:10px}.pv-product-detail dl{grid-column:1/-1;margin:8px 0 0;border-top:2px solid #203630}.pv-product-detail dl>div{display:flex;justify-content:space-between;padding:10px 0;border-bottom:1px solid #dce2df}.pv-product-detail dt,.pv-product-detail dd{margin:0;font-size:12px}.preview-frame[style*="390px"] .pv-product-detail{grid-template-columns:1fr;padding:28px 20px}.preview-frame[style*="390px"] .pv-product-detail h1{font-size:27px}
|
||||
@media(max-width:900px){.specification-row{grid-template-columns:1fr 1fr}.specification-values{grid-column:1/-1}.specification-row button{grid-column:2;justify-self:end;width:42px}}
|
||||
|
||||
+10
-4
@@ -490,6 +490,9 @@ function Collection({
|
||||
/** B2B 商品详情主体,集中展示主图、核心信息、参数、详情和询盘入口。 */
|
||||
function ProductDetailView({ data: d }: { data: Record<string, any> }) {
|
||||
const [inquiryOpen, setInquiryOpen] = useState(false);
|
||||
const productImages = d.images?.length ? d.images : d.coverMediaUrl ? [{mediaCode:d.coverMediaCode,url:d.coverMediaUrl}] : [];
|
||||
const [selectedImage, setSelectedImage] = useState(0);
|
||||
useEffect(() => setSelectedImage(0), [d.productCode]);
|
||||
useEffect(() => {
|
||||
if (!inquiryOpen) return;
|
||||
const closeOnEscape = (event: KeyboardEvent) => {
|
||||
@@ -505,10 +508,13 @@ function ProductDetailView({ data: d }: { data: Record<string, any> }) {
|
||||
return <article className="detail product-detail">
|
||||
<Crumbs current={String(d.productName || "Product")}/>
|
||||
<section className="product-overview">
|
||||
<div className="product-media">
|
||||
{d.coverMediaUrl
|
||||
? <img src={assetUrl(d.coverMediaUrl)} alt={d.productName || "Product image"}/>
|
||||
: <div className="product-image-placeholder"><ImageIcon size={48}/><span>Product image coming soon</span></div>}
|
||||
<div className="product-gallery">
|
||||
<div className="product-media">
|
||||
{productImages[selectedImage]?.url
|
||||
? <img src={assetUrl(productImages[selectedImage].url)} alt={`${d.productName || "Product"} ${selectedImage + 1}`}/>
|
||||
: <div className="product-image-placeholder"><ImageIcon size={48}/><span>Product image coming soon</span></div>}
|
||||
</div>
|
||||
{productImages.length>1&&<div className="product-thumbnails">{productImages.map((image:any,index:number)=><button type="button" className={`product-thumbnail${index===selectedImage?' active':''}`} key={image.mediaCode||index} onClick={()=>setSelectedImage(index)}><img src={assetUrl(image.url)} alt={`${d.productName || "Product"} thumbnail ${index+1}`}/></button>)}</div>}
|
||||
</div>
|
||||
<div className="product-summary">
|
||||
<p className="eyebrow">PRODUCT</p>
|
||||
|
||||
@@ -287,7 +287,7 @@ nav a:hover {
|
||||
padding-bottom: 32px;
|
||||
}
|
||||
.product-cover { width: 100%; max-height: 560px; object-fit: contain; background: #f4f6f5; margin: 20px 0 35px; }
|
||||
.product-detail{max-width:1220px}.product-detail>.crumbs{margin-bottom:30px}.product-overview{display:grid;grid-template-columns:minmax(0,1.05fr) minmax(380px,.95fr);gap:54px;align-items:start}.product-media{aspect-ratio:1/1;background:#f1f4f2;border:1px solid #e0e6e3;display:grid;place-items:center;overflow:hidden}.product-media>img{width:100%;height:100%;object-fit:contain}.product-image-placeholder{display:grid;place-items:center;gap:14px;color:#899691;text-align:center}.product-image-placeholder span{font-size:13px}.product-summary{padding:18px 0}.product-summary h1{font-size:46px;line-height:1.1;margin:12px 0 22px}.product-summary .lead{border:0;padding:0;margin:22px 0 28px;font-size:17px;line-height:1.75}.product-model{display:inline-flex;gap:10px;align-items:center;border-top:1px solid #d7dfdc;border-bottom:1px solid #d7dfdc;padding:12px 0;width:100%;font-size:13px;color:#687579}.product-model strong{color:#17211f}.product-inquiry-cta{display:inline-flex;align-items:center;justify-content:center;gap:9px;background:#176b5b;color:#fff;border:0;padding:14px 22px;min-width:190px;font-family:inherit;font-size:14px;font-weight:700;cursor:pointer}.product-attributes{margin-top:65px}.product-content{max-width:900px;margin:55px auto 0;line-height:1.75}.product-content pre,.product-content code{font:inherit;white-space:normal}.product-content pre{margin:0}
|
||||
.product-detail{max-width:1220px}.product-detail>.crumbs{margin-bottom:30px}.product-overview{display:grid;grid-template-columns:minmax(0,1.05fr) minmax(380px,.95fr);gap:54px;align-items:start}.product-gallery{min-width:0}.product-media{aspect-ratio:1/1;background:#f1f4f2;border:1px solid #e0e6e3;display:grid;place-items:center;overflow:hidden}.product-media>img{width:100%;height:100%;object-fit:contain}.product-thumbnails{display:grid;grid-template-columns:repeat(auto-fill,minmax(72px,1fr));gap:10px;margin-top:12px}.product-thumbnail{aspect-ratio:1;border:1px solid #d6ddda;background:#fff;padding:4px;cursor:pointer}.product-thumbnail img{width:100%;height:100%;object-fit:contain;display:block}.product-thumbnail.active{border:2px solid var(--green);padding:3px}.product-thumbnail:focus-visible{outline:2px solid var(--green);outline-offset:2px}.product-image-placeholder{display:grid;place-items:center;gap:14px;color:#899691;text-align:center}.product-image-placeholder span{font-size:13px}.product-summary{padding:18px 0}.product-summary h1{font-size:46px;line-height:1.1;margin:12px 0 22px}.product-summary .lead{border:0;padding:0;margin:22px 0 28px;font-size:17px;line-height:1.75}.product-model{display:inline-flex;gap:10px;align-items:center;border-top:1px solid #d7dfdc;border-bottom:1px solid #d7dfdc;padding:12px 0;width:100%;font-size:13px;color:#687579}.product-model strong{color:#17211f}.product-inquiry-cta{display:inline-flex;align-items:center;justify-content:center;gap:9px;background:#176b5b;color:#fff;border:0;padding:14px 22px;min-width:190px;font-family:inherit;font-size:14px;font-weight:700;cursor:pointer}.product-attributes{margin-top:65px}.product-content{max-width:900px;margin:55px auto 0;line-height:1.75}.product-content pre,.product-content code{font:inherit;white-space:normal}.product-content pre{margin:0}
|
||||
.modal-open{overflow:hidden}.inquiry-modal-backdrop{position:fixed;inset:0;z-index:1000;background:#101a18a8;display:grid;place-items:center;padding:24px}.inquiry-modal{position:relative;width:min(860px,100%);max-height:calc(100vh - 48px);overflow:auto;background:#fff;box-shadow:0 18px 60px #07100e40}.inquiry-modal-close{position:absolute;z-index:2;top:18px;right:18px;width:42px;height:42px;border:1px solid #d5ddda;background:#fff;color:#17211f;display:grid;place-items:center;cursor:pointer}.inquiry-modal .inquiry-box{margin:0;border-top:0;padding:42px}.inquiry-modal .inquiry-box h2{padding-right:50px}
|
||||
.content {
|
||||
font-size: 17px;
|
||||
@@ -450,7 +450,7 @@ footer small {
|
||||
.detail h1 {
|
||||
font-size: 42px;
|
||||
}
|
||||
.product-overview{grid-template-columns:1fr;gap:24px}.product-summary{padding:0}.product-summary h1{font-size:36px}.product-inquiry-cta{width:100%;box-sizing:border-box}.product-attributes{margin-top:45px}.product-content{margin-top:40px}
|
||||
.product-overview{grid-template-columns:1fr;gap:24px}.product-thumbnails{display:flex;overflow-x:auto}.product-thumbnail{width:72px;min-width:72px}.product-summary{padding:0}.product-summary h1{font-size:36px}.product-inquiry-cta{width:100%;box-sizing:border-box}.product-attributes{margin-top:45px}.product-content{margin-top:40px}
|
||||
footer {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user