功能迭代
This commit is contained in:
1 parent
9df10ca806
commit
5fc7d4564c
11 files changed
+227
-11
No files matched your search
+3
@@ -5,6 +5,8 @@ import jakarta.validation.constraints.NotBlank;
|
|||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import jakarta.validation.constraints.Size;
|
import jakarta.validation.constraints.Size;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/** 后台保存产品公共内容模板请求。 */
|
/** 后台保存产品公共内容模板请求。 */
|
||||||
public record SaveProductTemplateAdminReq(
|
public record SaveProductTemplateAdminReq(
|
||||||
/** 模板业务编号,新增时为空。 */ @Size(max = 16) String templateCode,
|
/** 模板业务编号,新增时为空。 */ @Size(max = 16) String templateCode,
|
||||||
@@ -12,6 +14,7 @@ public record SaveProductTemplateAdminReq(
|
|||||||
/** 模板名称。 */ @NotBlank @Size(max = 100) String templateName,
|
/** 模板名称。 */ @NotBlank @Size(max = 100) String templateName,
|
||||||
/** 模板用途说明。 */ @Size(max = 500) String description,
|
/** 模板用途说明。 */ @Size(max = 500) String description,
|
||||||
/** 模板英文富文本内容。 */ @NotBlank String templateContent,
|
/** 模板英文富文本内容。 */ @NotBlank String templateContent,
|
||||||
|
/** 关联推荐产品业务编号,最多选择 12 个。 */ @Size(max = 12) List<@Size(max = 16) String> relatedProductCodes,
|
||||||
/** 发布状态。 */ @NotNull PublishStatusEnum status,
|
/** 发布状态。 */ @NotNull PublishStatusEnum status,
|
||||||
/** 模板排序值。 */ @NotNull Integer sortNo) {
|
/** 模板排序值。 */ @NotNull Integer sortNo) {
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,14 @@
|
|||||||
package com.shoplix.admin.modules.product.res;
|
package com.shoplix.admin.modules.product.res;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/** 后台产品公共内容模板响应。 */
|
/** 后台产品公共内容模板响应。 */
|
||||||
public record ProductTemplateAdminRes(
|
public record ProductTemplateAdminRes(
|
||||||
/** 模板业务编号。 */ String templateCode,
|
/** 模板业务编号。 */ String templateCode,
|
||||||
/** 模板名称。 */ String templateName,
|
/** 模板名称。 */ String templateName,
|
||||||
/** 模板用途说明。 */ String description,
|
/** 模板用途说明。 */ String description,
|
||||||
/** 模板英文富文本内容。 */ String templateContent,
|
/** 模板英文富文本内容。 */ String templateContent,
|
||||||
|
/** 关联推荐产品业务编号。 */ List<String> relatedProductCodes,
|
||||||
/** 发布状态。 */ String status,
|
/** 发布状态。 */ String status,
|
||||||
/** 模板排序值。 */ Integer sortNo,
|
/** 模板排序值。 */ Integer sortNo,
|
||||||
/** 更新时间毫秒时间戳。 */ Long updateTime) {
|
/** 更新时间毫秒时间戳。 */ Long updateTime) {
|
||||||
|
|||||||
@@ -245,6 +245,14 @@ public class AdminProductService {
|
|||||||
entity.setTemplateName(request.templateName().trim());
|
entity.setTemplateName(request.templateName().trim());
|
||||||
entity.setDescription(request.description());
|
entity.setDescription(request.description());
|
||||||
entity.setTemplateContent(request.templateContent());
|
entity.setTemplateContent(request.templateContent());
|
||||||
|
List<String> relatedProductCodes = request.relatedProductCodes() == null ? List.of()
|
||||||
|
: request.relatedProductCodes().stream().filter(code -> code != null && !code.isBlank()).distinct().toList();
|
||||||
|
for (String productCode : relatedProductCodes) {
|
||||||
|
if (repository.findByCode(request.siteCode(), productCode).isEmpty()) {
|
||||||
|
throw templateException("PRODUCT_TEMPLATE_RELATED_PRODUCT_NOT_FOUND", ProductTemplateMessageKeys.UNAVAILABLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
entity.setRelatedProductCodes(String.join(",", relatedProductCodes));
|
||||||
entity.setStatus(request.status().name());
|
entity.setStatus(request.status().name());
|
||||||
entity.setSortNo(request.sortNo());
|
entity.setSortNo(request.sortNo());
|
||||||
entity.setUpdateTime(System.currentTimeMillis());
|
entity.setUpdateTime(System.currentTimeMillis());
|
||||||
@@ -283,7 +291,14 @@ public class AdminProductService {
|
|||||||
/** 转换产品公共内容模板响应。 */
|
/** 转换产品公共内容模板响应。 */
|
||||||
private ProductTemplateAdminRes toTemplateResponse(ProductContentTemplateEntity entity) {
|
private ProductTemplateAdminRes toTemplateResponse(ProductContentTemplateEntity entity) {
|
||||||
return new ProductTemplateAdminRes(entity.getTemplateCode(), entity.getTemplateName(), entity.getDescription(),
|
return new ProductTemplateAdminRes(entity.getTemplateCode(), entity.getTemplateName(), entity.getDescription(),
|
||||||
entity.getTemplateContent(), entity.getStatus(), entity.getSortNo(), entity.getUpdateTime());
|
entity.getTemplateContent(), splitProductCodes(entity.getRelatedProductCodes()), entity.getStatus(),
|
||||||
|
entity.getSortNo(), entity.getUpdateTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 拆分模板关联产品业务编号。 */
|
||||||
|
private List<String> splitProductCodes(String value) {
|
||||||
|
return value == null || value.isBlank() ? List.of()
|
||||||
|
: java.util.Arrays.stream(value.split(",")).map(String::trim).filter(code -> !code.isBlank()).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 创建已完成多语言解析的产品模板业务异常。 */
|
/** 创建已完成多语言解析的产品模板业务异常。 */
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE product_content_template
|
||||||
|
ADD COLUMN related_product_codes VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '关联推荐产品业务编号列表,多个编号使用英文逗号分隔' AFTER template_content;
|
||||||
+1
@@ -15,6 +15,7 @@ public class ProductContentTemplateEntity {
|
|||||||
/** 模板名称。 */ private String templateName;
|
/** 模板名称。 */ private String templateName;
|
||||||
/** 模板用途说明。 */ private String description;
|
/** 模板用途说明。 */ private String description;
|
||||||
/** 模板英文富文本内容。 */ private String templateContent;
|
/** 模板英文富文本内容。 */ private String templateContent;
|
||||||
|
/** 关联推荐产品业务编号列表,多个编号使用英文逗号分隔。 */ private String relatedProductCodes;
|
||||||
/** 发布状态:DRAFT草稿,PUBLISHED已发布,OFFLINE已下线。 */ private String status;
|
/** 发布状态:DRAFT草稿,PUBLISHED已发布,OFFLINE已下线。 */ private String status;
|
||||||
/** 模板排序值。 */ private Integer sortNo;
|
/** 模板排序值。 */ private Integer sortNo;
|
||||||
/** 逻辑删除状态:0未删除,1已删除。 */ private Integer deleted;
|
/** 逻辑删除状态:0未删除,1已删除。 */ private Integer deleted;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public record ProductDetailSiteRes(
|
|||||||
/** 产品图片列表。 */ List<ProductImageSiteRes> images,
|
/** 产品图片列表。 */ List<ProductImageSiteRes> images,
|
||||||
/** 是否允许提交产品询盘。 */ Boolean inquiryEnabled,
|
/** 是否允许提交产品询盘。 */ Boolean inquiryEnabled,
|
||||||
/** 产品属性列表。 */ List<ProductAttributeSiteRes> attributes,
|
/** 产品属性列表。 */ List<ProductAttributeSiteRes> attributes,
|
||||||
/** 产品规格列表。 */ List<ProductSpecificationSiteRes> specifications) {
|
/** 产品规格列表。 */ List<ProductSpecificationSiteRes> specifications,
|
||||||
|
/** 关联推荐产品列表。 */ List<ProductItemSiteRes> relatedProducts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +139,43 @@ public class SiteProductService {
|
|||||||
primaryCategory == null ? null : primaryCategory.getSlug(), categoryBreadcrumbs(siteCode, primaryCategory),
|
primaryCategory == null ? null : primaryCategory.getSlug(), categoryBreadcrumbs(siteCode, primaryCategory),
|
||||||
item.getSummary(), resolveProductContent(item),
|
item.getSummary(), resolveProductContent(item),
|
||||||
item.getCoverMediaCode(), mediaUrl, images,
|
item.getCoverMediaCode(), mediaUrl, images,
|
||||||
item.getInquiryEnabled() == 1, attributes, specifications);
|
item.getInquiryEnabled() == 1, attributes, specifications, resolveRelatedProducts(siteCode, item));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 优先读取内容模板关联产品,并使用同分类及全站产品补足推荐位。 */
|
||||||
|
private List<ProductItemSiteRes> resolveRelatedProducts(String siteCode, ProductEntity currentProduct) {
|
||||||
|
List<ProductEntity> products = new ArrayList<>();
|
||||||
|
Set<String> selectedCodes = new LinkedHashSet<>();
|
||||||
|
selectedCodes.add(currentProduct.getProductCode());
|
||||||
|
relatedProductCodes(siteCode, currentProduct).stream()
|
||||||
|
.map(code -> repository.findByCode(siteCode, code).orElse(null))
|
||||||
|
.forEach(item -> addRecommendedProduct(products, selectedCodes, item));
|
||||||
|
repository.listPublished(siteCode, currentProduct.getPrimaryCategoryCode())
|
||||||
|
.forEach(item -> addRecommendedProduct(products, selectedCodes, item));
|
||||||
|
if (products.size() < 4) {
|
||||||
|
repository.listPublished(siteCode, null)
|
||||||
|
.forEach(item -> addRecommendedProduct(products, selectedCodes, item));
|
||||||
|
}
|
||||||
|
return products.stream().map(item -> new ProductItemSiteRes(item.getProductCode(), item.getProductName(),
|
||||||
|
item.getSlug(), item.getModel(), item.getSummary(), item.getCoverMediaCode(),
|
||||||
|
resolveMediaUrl(siteCode, item.getCoverMediaCode()), item.getInquiryEnabled() == 1)).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 将有效且未重复的已发布产品加入推荐列表。 */
|
||||||
|
private void addRecommendedProduct(List<ProductEntity> products, Set<String> selectedCodes, ProductEntity product) {
|
||||||
|
if (products.size() >= 4 || product == null || !"PUBLISHED".equals(product.getStatus())) return;
|
||||||
|
if (selectedCodes.add(product.getProductCode())) products.add(product);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 读取产品所选模板配置的关联产品编号。 */
|
||||||
|
private List<String> relatedProductCodes(String siteCode, ProductEntity product) {
|
||||||
|
if (product.getContentTemplateCode() == null || product.getContentTemplateCode().isBlank()) return List.of();
|
||||||
|
return templateRepository.findPublished(siteCode, product.getContentTemplateCode())
|
||||||
|
.map(template -> template.getRelatedProductCodes() == null || template.getRelatedProductCodes().isBlank()
|
||||||
|
? List.<String>of()
|
||||||
|
: java.util.Arrays.stream(template.getRelatedProductCodes().split(","))
|
||||||
|
.map(String::trim).filter(code -> !code.isBlank()).toList())
|
||||||
|
.orElse(List.of());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 构建从顶级分类到产品主分类的完整面包屑。 */
|
/** 构建从顶级分类到产品主分类的完整面包屑。 */
|
||||||
|
|||||||
@@ -30,11 +30,20 @@ type ProductTemplate = {
|
|||||||
/** 模板名称。 */ templateName: string;
|
/** 模板名称。 */ templateName: string;
|
||||||
/** 模板用途说明。 */ description: string;
|
/** 模板用途说明。 */ description: string;
|
||||||
/** 模板英文富文本内容。 */ templateContent: string;
|
/** 模板英文富文本内容。 */ templateContent: string;
|
||||||
|
/** 模板关联推荐产品业务编号。 */ relatedProductCodes: string[];
|
||||||
/** 发布状态。 */ status: string;
|
/** 发布状态。 */ status: string;
|
||||||
/** 排序值。 */ sortNo: number;
|
/** 排序值。 */ sortNo: number;
|
||||||
/** 更新时间毫秒时间戳。 */ updateTime?: number;
|
/** 更新时间毫秒时间戳。 */ updateTime?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type ProductOption = {
|
||||||
|
/** 产品业务编号。 */ productCode: string;
|
||||||
|
/** 产品英文名称。 */ productName: string;
|
||||||
|
/** 产品型号。 */ model?: string;
|
||||||
|
/** 产品封面图片地址。 */ coverMediaUrl?: string;
|
||||||
|
/** 发布状态。 */ status: string;
|
||||||
|
};
|
||||||
|
|
||||||
type MediaItem = {
|
type MediaItem = {
|
||||||
/** 素材业务编号。 */ mediaCode: string;
|
/** 素材业务编号。 */ mediaCode: string;
|
||||||
/** 素材访问地址。 */ url: string;
|
/** 素材访问地址。 */ url: string;
|
||||||
@@ -47,6 +56,7 @@ const emptyTemplate: ProductTemplate = {
|
|||||||
templateName: "",
|
templateName: "",
|
||||||
description: "",
|
description: "",
|
||||||
templateContent: "<p></p>",
|
templateContent: "<p></p>",
|
||||||
|
relatedProductCodes: [],
|
||||||
status: "DRAFT",
|
status: "DRAFT",
|
||||||
sortNo: 30,
|
sortNo: 30,
|
||||||
};
|
};
|
||||||
@@ -54,6 +64,7 @@ const emptyTemplate: ProductTemplate = {
|
|||||||
/** 产品公共详情模板列表和编辑页面。 */
|
/** 产品公共详情模板列表和编辑页面。 */
|
||||||
export default function ProductTemplateManager() {
|
export default function ProductTemplateManager() {
|
||||||
const [items, setItems] = useState<ProductTemplate[]>([]);
|
const [items, setItems] = useState<ProductTemplate[]>([]);
|
||||||
|
const [products, setProducts] = useState<ProductOption[]>([]);
|
||||||
const [editing, setEditing] = useState<ProductTemplate | null>(null);
|
const [editing, setEditing] = useState<ProductTemplate | null>(null);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
@@ -72,10 +83,12 @@ export default function ProductTemplateManager() {
|
|||||||
const loadTemplates = async () => {
|
const loadTemplates = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const data = await apiPost("/products/templates/list", {
|
const [data, productData] = await Promise.all([
|
||||||
siteCode: SITE,
|
apiPost("/products/templates/list", { siteCode: SITE }),
|
||||||
});
|
apiPost("/products/list", { siteCode: SITE, pageNo: 1, pageSize: 100 }),
|
||||||
setItems(data.items || []);
|
]);
|
||||||
|
setItems((data.items || []).map((item: ProductTemplate) => ({ ...item, relatedProductCodes: item.relatedProductCodes || [] })));
|
||||||
|
setProducts(productData.items || []);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setNotice(error instanceof Error ? error.message : "模板加载失败");
|
setNotice(error instanceof Error ? error.message : "模板加载失败");
|
||||||
} finally {
|
} finally {
|
||||||
@@ -106,6 +119,7 @@ export default function ProductTemplateManager() {
|
|||||||
templateName: editing.templateName,
|
templateName: editing.templateName,
|
||||||
description: editing.description,
|
description: editing.description,
|
||||||
templateContent: editor.getHTML(),
|
templateContent: editor.getHTML(),
|
||||||
|
relatedProductCodes: editing.relatedProductCodes || [],
|
||||||
status: editing.status,
|
status: editing.status,
|
||||||
sortNo: editing.sortNo,
|
sortNo: editing.sortNo,
|
||||||
});
|
});
|
||||||
@@ -247,6 +261,30 @@ export default function ProductTemplateManager() {
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
<section className="edit-section">
|
||||||
|
<div className="section-head">
|
||||||
|
<h2>关联推荐产品</h2>
|
||||||
|
<span>已选择 {editing.relatedProductCodes?.length || 0} / 12</span>
|
||||||
|
</div>
|
||||||
|
<p className="template-editor-tip">
|
||||||
|
使用该模板的产品详情页底部将统一展示所选产品;未选择时按当前产品分类自动推荐。
|
||||||
|
</p>
|
||||||
|
<div className="template-related-products">
|
||||||
|
{products.filter((product) => product.status === "PUBLISHED").map((product) => {
|
||||||
|
const checked = (editing.relatedProductCodes || []).includes(product.productCode);
|
||||||
|
return <label className={checked ? "selected" : ""} key={product.productCode}>
|
||||||
|
{product.coverMediaUrl ? <img src={assetUrl(product.coverMediaUrl)} alt={product.productName}/> : <span className="product-image-empty"><ImageIcon size={18}/></span>}
|
||||||
|
<span><strong>{product.productName}</strong><small>{product.model || product.productCode}</small></span>
|
||||||
|
<input type="checkbox" checked={checked} disabled={!checked && (editing.relatedProductCodes?.length || 0) >= 12} onChange={() => setEditing({
|
||||||
|
...editing,
|
||||||
|
relatedProductCodes: checked
|
||||||
|
? editing.relatedProductCodes.filter((code) => code !== product.productCode)
|
||||||
|
: [...(editing.relatedProductCodes || []), product.productCode],
|
||||||
|
})}/>
|
||||||
|
</label>;
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
<section className="edit-section">
|
<section className="edit-section">
|
||||||
<div className="section-head">
|
<div className="section-head">
|
||||||
<h2>公共富文本内容</h2>
|
<h2>公共富文本内容</h2>
|
||||||
|
|||||||
@@ -3966,3 +3966,53 @@ header p {
|
|||||||
min-width: 30px;
|
min-width: 30px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.template-related-products {
|
||||||
|
display: grid;
|
||||||
|
gap: 10px;
|
||||||
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
|
max-height: 430px;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.template-related-products label {
|
||||||
|
align-items: center;
|
||||||
|
border: 1px solid #dce4e1;
|
||||||
|
cursor: pointer;
|
||||||
|
display: grid;
|
||||||
|
gap: 10px;
|
||||||
|
grid-template-columns: 54px 1fr auto;
|
||||||
|
padding: 9px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.template-related-products label.selected {
|
||||||
|
background: #edf6f3;
|
||||||
|
border-color: #14735f;
|
||||||
|
}
|
||||||
|
|
||||||
|
.template-related-products img,
|
||||||
|
.template-related-products .product-image-empty {
|
||||||
|
align-items: center;
|
||||||
|
background: #f4f6f5;
|
||||||
|
display: flex;
|
||||||
|
height: 54px;
|
||||||
|
justify-content: center;
|
||||||
|
object-fit: contain;
|
||||||
|
width: 54px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.template-related-products label > span:nth-child(2) {
|
||||||
|
display: grid;
|
||||||
|
gap: 4px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.template-related-products strong,
|
||||||
|
.template-related-products small {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.template-related-products { grid-template-columns: 1fr; }
|
||||||
|
}
|
||||||
+18
-4
@@ -6,6 +6,10 @@ import { initializeAnalytics, routePageCode, trackInquirySubmitted, trackPageLea
|
|||||||
|
|
||||||
const API = import.meta.env.VITE_SITE_API_BASE || "/api/site/v1";
|
const API = import.meta.env.VITE_SITE_API_BASE || "/api/site/v1";
|
||||||
type ContentType = "NEWS" | "CASE" | "HELP";
|
type ContentType = "NEWS" | "CASE" | "HELP";
|
||||||
|
/** 将内容类型映射为前台标准复数路径。 */
|
||||||
|
function contentPath(type: ContentType): string {
|
||||||
|
return type === "CASE" ? "cases" : type.toLowerCase();
|
||||||
|
}
|
||||||
type Item = {
|
type Item = {
|
||||||
productCode?: string;
|
productCode?: string;
|
||||||
contentCode?: string;
|
contentCode?: string;
|
||||||
@@ -403,7 +407,7 @@ function LiveHeader({ section, style }: { section: DecorationSection; style: Rea
|
|||||||
function LiveCollection({section}:{section:DecorationSection}) {
|
function LiveCollection({section}:{section:DecorationSection}) {
|
||||||
const [items,setItems]=useState<Item[]>([]);
|
const [items,setItems]=useState<Item[]>([]);
|
||||||
useEffect(()=>{const path=section.type==="PRODUCTS"?"/products/list":"/contents/list";const body=section.type==="PRODUCTS"?{featured:true,pageNo:1,pageSize:section.limit||3}:{contentType:section.sourceType||"CASE",featured:true,pageNo:1,pageSize:section.limit||3};post(path,body).then(data=>setItems(data.items||[])).catch(()=>setItems([]))},[section.type,section.sourceType,section.limit]);
|
useEffect(()=>{const path=section.type==="PRODUCTS"?"/products/list":"/contents/list";const body=section.type==="PRODUCTS"?{featured:true,pageNo:1,pageSize:section.limit||3}:{contentType:section.sourceType||"CASE",featured:true,pageNo:1,pageSize:section.limit||3};post(path,body).then(data=>setItems(data.items||[])).catch(()=>setItems([]))},[section.type,section.sourceType,section.limit]);
|
||||||
const base=section.type==="PRODUCTS"?"products":(section.sourceType||"CASE").toLowerCase();
|
const base=section.type==="PRODUCTS"?"products":contentPath((section.sourceType||"CASE") as ContentType);
|
||||||
return <section className="live-collection" style={{background:section.background,color:section.textColor}}><p>FEATURED</p><h2>{section.title}</h2><div>{items.map(item=><a href={`/${base}/${item.slug}`} key={item.productCode||item.contentCode}><div>{item.coverMediaUrl&&<img src={assetUrl(item.coverMediaUrl)} alt={item.productName||item.title} loading="lazy"/>}</div><span>{section.type==="PRODUCTS"?"PRODUCT":section.sourceType}</span><h3>{item.productName||item.title}</h3><p>{item.summary}</p></a>)}</div></section>;
|
return <section className="live-collection" style={{background:section.background,color:section.textColor}}><p>FEATURED</p><h2>{section.title}</h2><div>{items.map(item=><a href={`/${base}/${item.slug}`} key={item.productCode||item.contentCode}><div>{item.coverMediaUrl&&<img src={assetUrl(item.coverMediaUrl)} alt={item.productName||item.title} loading="lazy"/>}</div><span>{section.type==="PRODUCTS"?"PRODUCT":section.sourceType}</span><h3>{item.productName||item.title}</h3><p>{item.summary}</p></a>)}</div></section>;
|
||||||
}
|
}
|
||||||
function Header() {
|
function Header() {
|
||||||
@@ -581,7 +585,7 @@ function Collection({
|
|||||||
</article>
|
</article>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const basePath = type === "products" ? "/products" : `/${type.toLowerCase()}`;
|
const basePath = type === "products" ? "/products" : `/${contentPath(type as ContentType)}`;
|
||||||
return (
|
return (
|
||||||
<section className="listing">
|
<section className="listing">
|
||||||
<Crumbs current={title} />
|
<Crumbs current={title} />
|
||||||
@@ -607,7 +611,7 @@ function Collection({
|
|||||||
{(data as Item[]).map((item) => (
|
{(data as Item[]).map((item) => (
|
||||||
<a
|
<a
|
||||||
className="card"
|
className="card"
|
||||||
href={`/${type === "products" ? "products" : type.toLowerCase()}/${item.slug}`}
|
href={`/${type === "products" ? "products" : contentPath(type as ContentType)}/${item.slug}`}
|
||||||
key={item.productCode || item.contentCode}
|
key={item.productCode || item.contentCode}
|
||||||
>
|
>
|
||||||
<div className="thumb">
|
<div className="thumb">
|
||||||
@@ -666,7 +670,7 @@ function SearchResults({ query }: { query: string }) {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
Promise.all([
|
Promise.all([
|
||||||
post("/products/list", { keyword: query.trim(), pageNo: 1, pageSize: 100 }).then((data) => ({ items: data.items || [], base: "products", label: "Product" })),
|
post("/products/list", { keyword: query.trim(), pageNo: 1, pageSize: 100 }).then((data) => ({ items: data.items || [], base: "products", label: "Product" })),
|
||||||
...(["NEWS", "CASE", "HELP"] as ContentType[]).map((contentType) => post("/contents/list", { contentType, keyword: query.trim(), pageNo: 1, pageSize: 100 }).then((data) => ({ items: data.items || [], base: contentType.toLowerCase(), label: contentType === "CASE" ? "Case" : contentType.charAt(0) + contentType.slice(1).toLowerCase() }))),
|
...(["NEWS", "CASE", "HELP"] as ContentType[]).map((contentType) => post("/contents/list", { contentType, keyword: query.trim(), pageNo: 1, pageSize: 100 }).then((data) => ({ items: data.items || [], base: contentPath(contentType), label: contentType === "CASE" ? "Case" : contentType.charAt(0) + contentType.slice(1).toLowerCase() }))),
|
||||||
]).then((groups) => {
|
]).then((groups) => {
|
||||||
const matched = groups.flatMap((group) => group.items.map((item: Item) => ({ item, base: group.base, label: group.label })))
|
const matched = groups.flatMap((group) => group.items.map((item: Item) => ({ item, base: group.base, label: group.label })))
|
||||||
.filter(({ item }) => [item.productName, item.title, item.summary, item.model].some((value) => value?.toLowerCase().includes(keyword)));
|
.filter(({ item }) => [item.productName, item.title, item.summary, item.model].some((value) => value?.toLowerCase().includes(keyword)));
|
||||||
@@ -810,6 +814,16 @@ function ProductDetailView({ data: d, configuration }: { data: Record<string, an
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</section>
|
</section>
|
||||||
|
{(d.relatedProducts || []).length > 0 && <section className="related-products">
|
||||||
|
<p className="eyebrow">YOU MAY ALSO LIKE</p>
|
||||||
|
<h2>Related products</h2>
|
||||||
|
<div>{d.relatedProducts.map((product: Item) => <a href={`/products/${product.slug}`} key={product.productCode}>
|
||||||
|
<figure>{product.coverMediaUrl ? <img src={assetUrl(product.coverMediaUrl)} alt={product.productName} loading="lazy"/> : <ImageIcon size={36}/>}</figure>
|
||||||
|
<small>{product.model || "PRODUCT"}</small>
|
||||||
|
<h3>{product.productName}</h3>
|
||||||
|
<span>View product <ChevronRight size={14}/></span>
|
||||||
|
</a>)}</div>
|
||||||
|
</section>}
|
||||||
{imageZoomOpen && productImages[selectedImage]?.url && <div className="product-lightbox" role="presentation" onClick={() => setImageZoomOpen(false)}><button type="button" aria-label="Close enlarged image" onClick={() => setImageZoomOpen(false)}><X size={22}/></button><img src={assetUrl(productImages[selectedImage].url)} alt={`${d.productName || "Product"} enlarged`} onClick={(event) => event.stopPropagation()}/></div>}
|
{imageZoomOpen && productImages[selectedImage]?.url && <div className="product-lightbox" role="presentation" onClick={() => setImageZoomOpen(false)}><button type="button" aria-label="Close enlarged image" onClick={() => setImageZoomOpen(false)}><X size={22}/></button><img src={assetUrl(productImages[selectedImage].url)} alt={`${d.productName || "Product"} enlarged`} onClick={(event) => event.stopPropagation()}/></div>}
|
||||||
{d.inquiryEnabled && inquiryOpen && (
|
{d.inquiryEnabled && inquiryOpen && (
|
||||||
<div className="inquiry-modal-backdrop" role="presentation" onMouseDown={() => setInquiryOpen(false)}>
|
<div className="inquiry-modal-backdrop" role="presentation" onMouseDown={() => setInquiryOpen(false)}>
|
||||||
|
|||||||
@@ -1507,3 +1507,56 @@ footer small {
|
|||||||
.content img {
|
.content img {
|
||||||
cursor: zoom-in;
|
cursor: zoom-in;
|
||||||
}
|
}
|
||||||
|
.related-products {
|
||||||
|
border-top: 1px solid #dfe6e3;
|
||||||
|
margin-top: 54px;
|
||||||
|
padding-top: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.related-products > h2 {
|
||||||
|
font-family: Georgia, serif;
|
||||||
|
font-size: clamp(30px, 4vw, 46px);
|
||||||
|
margin: 6px 0 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.related-products > div {
|
||||||
|
display: grid;
|
||||||
|
gap: 22px;
|
||||||
|
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
|
||||||
|
.related-products a {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.related-products figure {
|
||||||
|
align-items: center;
|
||||||
|
background: #f3f6f5;
|
||||||
|
display: flex;
|
||||||
|
height: 260px;
|
||||||
|
justify-content: center;
|
||||||
|
margin: 0 0 17px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.related-products img {
|
||||||
|
height: 100%;
|
||||||
|
object-fit: contain;
|
||||||
|
transition: transform .25s ease;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.related-products a:hover img { transform: scale(1.04); }
|
||||||
|
.related-products small { color: #6c7974; }
|
||||||
|
.related-products h3 { font-family: Georgia, serif; font-size: 20px; margin: 8px 0 13px; }
|
||||||
|
.related-products a > span { align-items: center; color: #08715e; display: flex; font-size: 13px; font-weight: 700; gap: 4px; }
|
||||||
|
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.related-products > div { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||||
|
.related-products figure { height: 210px; }
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 560px) {
|
||||||
|
.related-products > div { grid-template-columns: 1fr; }
|
||||||
|
}
|
||||||
Reference in new issue
Block a user