功能迭代
This commit is contained in:
1 parent
8e03c99cab
commit
9e87a4002a
23 files changed
+553
-38
No files matched your search
@@ -25,8 +25,8 @@ public class AdminContentFacade {
|
|||||||
return service.detail(request.siteCode(), request.contentCode(), request.contentType().name());
|
return service.detail(request.siteCode(), request.contentCode(), request.contentType().name());
|
||||||
}
|
}
|
||||||
/** 查询内容列表。 */ public ContentListAdminRes list(ContentListAdminReq request) {
|
/** 查询内容列表。 */ public ContentListAdminRes list(ContentListAdminReq request) {
|
||||||
return new ContentListAdminRes(service.list(request.siteCode(), request.contentType().name(),
|
return service.list(request.siteCode(), request.contentType().name(), request.primaryCategoryCode(),
|
||||||
request.primaryCategoryCode(), request.status()));
|
request.status(), request.pageNo(), request.pageSize());
|
||||||
}
|
}
|
||||||
/** 删除内容。 */ public CommonAdminRes delete(ContentOperationAdminReq request) { service.delete(request.siteCode(), request.contentCode(), request.contentType().name()); return CommonAdminRes.success(); }
|
/** 删除内容。 */ public CommonAdminRes delete(ContentOperationAdminReq request) { service.delete(request.siteCode(), request.contentCode(), request.contentType().name()); return CommonAdminRes.success(); }
|
||||||
/** 变更内容发布状态。 */ public CommonAdminRes changeStatus(ContentStatusAdminReq request) { service.changeStatus(request); return CommonAdminRes.success(); }
|
/** 变更内容发布状态。 */ public CommonAdminRes changeStatus(ContentStatusAdminReq request) { service.changeStatus(request); return CommonAdminRes.success(); }
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ public class AdminProductFacade {
|
|||||||
/** 保存产品。 */ public ProductSaveAdminRes save(SaveProductAdminReq request) { return new ProductSaveAdminRes(service.save(request), "SUCCESS", "操作成功"); }
|
/** 保存产品。 */ public ProductSaveAdminRes save(SaveProductAdminReq request) { return new ProductSaveAdminRes(service.save(request), "SUCCESS", "操作成功"); }
|
||||||
/** 查询产品编辑详情。 */ public ProductDetailAdminRes detail(ProductDetailAdminReq request) { return service.detail(request.siteCode(), request.productCode()); }
|
/** 查询产品编辑详情。 */ public ProductDetailAdminRes detail(ProductDetailAdminReq request) { return service.detail(request.siteCode(), request.productCode()); }
|
||||||
/** 查询产品列表。 */ public ProductListAdminRes list(ProductListAdminReq request) {
|
/** 查询产品列表。 */ public ProductListAdminRes list(ProductListAdminReq request) {
|
||||||
return new ProductListAdminRes(service.list(request.siteCode(), request.primaryCategoryCode(), request.status()));
|
return service.list(request.siteCode(), request.primaryCategoryCode(), request.status(),
|
||||||
|
request.pageNo(), request.pageSize());
|
||||||
}
|
}
|
||||||
/** 删除产品。 */ public CommonAdminRes delete(ProductOperationAdminReq request) { service.delete(request.siteCode(), request.productCode()); return CommonAdminRes.success(); }
|
/** 删除产品。 */ public CommonAdminRes delete(ProductOperationAdminReq request) { service.delete(request.siteCode(), request.productCode()); return CommonAdminRes.success(); }
|
||||||
/** 变更产品发布状态。 */ public CommonAdminRes changeStatus(ProductStatusAdminReq request) { service.changeStatus(request); return CommonAdminRes.success(); }
|
/** 变更产品发布状态。 */ public CommonAdminRes changeStatus(ProductStatusAdminReq request) { service.changeStatus(request); return CommonAdminRes.success(); }
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.shoplix.admin.modules.content.req;
|
|||||||
import com.shoplix.modules.content.enums.ContentTypeEnum;
|
import com.shoplix.modules.content.enums.ContentTypeEnum;
|
||||||
import com.shoplix.modules.common.enums.PublishStatusEnum;
|
import com.shoplix.modules.common.enums.PublishStatusEnum;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.Max;
|
||||||
|
import jakarta.validation.constraints.Min;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import jakarta.validation.constraints.Size;
|
import jakarta.validation.constraints.Size;
|
||||||
|
|
||||||
@@ -11,6 +13,8 @@ public record ContentListAdminReq(
|
|||||||
/** 所属站点业务编号。 */ @NotBlank String siteCode,
|
/** 所属站点业务编号。 */ @NotBlank String siteCode,
|
||||||
/** 内容类型。 */ @NotNull ContentTypeEnum contentType,
|
/** 内容类型。 */ @NotNull ContentTypeEnum contentType,
|
||||||
/** 内容分类业务编号,为空时查询全部分类。 */ @Size(max = 16) String primaryCategoryCode,
|
/** 内容分类业务编号,为空时查询全部分类。 */ @Size(max = 16) String primaryCategoryCode,
|
||||||
/** 发布状态,为空时查询全部状态。 */ PublishStatusEnum status) {
|
/** 发布状态,为空时查询全部状态。 */ PublishStatusEnum status,
|
||||||
|
/** 页码,从 1 开始;兼容旧调用,为空时使用第 1 页。 */ @Min(1) Integer pageNo,
|
||||||
|
/** 每页数量;兼容旧调用,为空时使用 20 条。 */ @Min(1) @Max(100) Integer pageSize) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2,7 +2,12 @@ package com.shoplix.admin.modules.content.res;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/** 运营后台内容列表响应。 */
|
/** 运营后台内容分页响应。 */
|
||||||
public record ContentListAdminRes(List<ContentItemAdminRes> items) {
|
public record ContentListAdminRes(
|
||||||
|
/** 当前页内容。 */ List<ContentItemAdminRes> items,
|
||||||
|
/** 符合条件的内容总数。 */ long total,
|
||||||
|
/** 当前页码。 */ int pageNo,
|
||||||
|
/** 每页数量。 */ int pageSize,
|
||||||
|
/** 总页数。 */ int totalPages) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,12 +1,16 @@
|
|||||||
package com.shoplix.admin.modules.product.req;
|
package com.shoplix.admin.modules.product.req;
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.Max;
|
||||||
|
import jakarta.validation.constraints.Min;
|
||||||
import jakarta.validation.constraints.Size;
|
import jakarta.validation.constraints.Size;
|
||||||
|
|
||||||
/** 运营后台产品列表请求。 */
|
/** 运营后台产品列表请求。 */
|
||||||
public record ProductListAdminReq(
|
public record ProductListAdminReq(
|
||||||
/** 所属站点业务编号。 */ @NotBlank String siteCode,
|
/** 所属站点业务编号。 */ @NotBlank String siteCode,
|
||||||
/** 产品分类业务编号,为空时查询全部分类。 */ @Size(max = 16) String primaryCategoryCode,
|
/** 产品分类业务编号,为空时查询全部分类。 */ @Size(max = 16) String primaryCategoryCode,
|
||||||
/** 发布状态,为空时查询全部状态。 */ com.shoplix.modules.common.enums.PublishStatusEnum status) {
|
/** 发布状态,为空时查询全部状态。 */ com.shoplix.modules.common.enums.PublishStatusEnum status,
|
||||||
|
/** 页码,从 1 开始;兼容旧调用,为空时使用第 1 页。 */ @Min(1) Integer pageNo,
|
||||||
|
/** 每页数量;兼容旧调用,为空时使用 20 条。 */ @Min(1) @Max(100) Integer pageSize) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2,7 +2,12 @@ package com.shoplix.admin.modules.product.res;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/** 运营后台产品列表响应。 */
|
/** 运营后台产品分页响应。 */
|
||||||
public record ProductListAdminRes(List<ProductItemAdminRes> items) {
|
public record ProductListAdminRes(
|
||||||
|
/** 当前页产品。 */ List<ProductItemAdminRes> items,
|
||||||
|
/** 符合条件的产品总数。 */ long total,
|
||||||
|
/** 当前页码。 */ int pageNo,
|
||||||
|
/** 每页数量。 */ int pageSize,
|
||||||
|
/** 总页数。 */ int totalPages) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,14 +72,15 @@ public class AdminContentService {
|
|||||||
entity.getSortNo(), entity.getStatus(), entity.getPublishTime());
|
entity.getSortNo(), entity.getStatus(), entity.getPublishTime());
|
||||||
}
|
}
|
||||||
/** 查询指定类型内容。 */
|
/** 查询指定类型内容。 */
|
||||||
public List<ContentItemAdminRes> list(String siteCode, String type, String primaryCategoryCode,
|
public com.shoplix.admin.modules.content.res.ContentListAdminRes list(
|
||||||
PublishStatusEnum status) {
|
String siteCode, String type, String primaryCategoryCode, PublishStatusEnum status,
|
||||||
|
Integer requestedPageNo, Integer requestedPageSize) {
|
||||||
Map<String, ContentCategoryEntity> categoryMap = categoryRepository.list(siteCode, type, false).stream()
|
Map<String, ContentCategoryEntity> categoryMap = categoryRepository.list(siteCode, type, false).stream()
|
||||||
.collect(Collectors.toMap(ContentCategoryEntity::getCategoryCode, Function.identity()));
|
.collect(Collectors.toMap(ContentCategoryEntity::getCategoryCode, Function.identity()));
|
||||||
Map<String, String> mediaUrlMap = mediaRepository.list(siteCode, null).stream()
|
Map<String, String> mediaUrlMap = mediaRepository.list(siteCode, null).stream()
|
||||||
.collect(Collectors.toMap(media -> media.getMediaCode(), media -> media.getRelativeUrl(),
|
.collect(Collectors.toMap(media -> media.getMediaCode(), media -> media.getRelativeUrl(),
|
||||||
(first, ignored) -> first));
|
(first, ignored) -> first));
|
||||||
return repository.list(siteCode, type).stream()
|
List<ContentItemAdminRes> filteredItems = repository.list(siteCode, type).stream()
|
||||||
.filter(item -> primaryCategoryCode == null || primaryCategoryCode.isBlank()
|
.filter(item -> primaryCategoryCode == null || primaryCategoryCode.isBlank()
|
||||||
|| primaryCategoryCode.equals(item.getPrimaryCategoryCode()))
|
|| primaryCategoryCode.equals(item.getPrimaryCategoryCode()))
|
||||||
.filter(item -> status == null || status.name().equals(item.getStatus()))
|
.filter(item -> status == null || status.name().equals(item.getStatus()))
|
||||||
@@ -91,6 +92,14 @@ public class AdminContentService {
|
|||||||
mediaUrlMap.get(item.getCoverMediaCode()),
|
mediaUrlMap.get(item.getCoverMediaCode()),
|
||||||
item.getStatus(), item.getFeaturedFlag() != null && item.getFeaturedFlag() == 1,
|
item.getStatus(), item.getFeaturedFlag() != null && item.getFeaturedFlag() == 1,
|
||||||
item.getPublishTime())).toList();
|
item.getPublishTime())).toList();
|
||||||
|
int pageNo = requestedPageNo == null ? 1 : requestedPageNo;
|
||||||
|
int pageSize = requestedPageSize == null ? 20 : requestedPageSize;
|
||||||
|
int total = filteredItems.size();
|
||||||
|
int totalPages = total == 0 ? 0 : (total + pageSize - 1) / pageSize;
|
||||||
|
int fromIndex = Math.min((pageNo - 1) * pageSize, total);
|
||||||
|
int toIndex = Math.min(fromIndex + pageSize, total);
|
||||||
|
return new com.shoplix.admin.modules.content.res.ContentListAdminRes(
|
||||||
|
filteredItems.subList(fromIndex, toIndex), total, pageNo, pageSize, totalPages);
|
||||||
}
|
}
|
||||||
/** 逻辑删除指定类型内容。 */
|
/** 逻辑删除指定类型内容。 */
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|||||||
@@ -152,13 +152,14 @@ public class AdminProductService {
|
|||||||
return new ProductDetailAdminRes(item.getProductCode(), item.getPrimaryCategoryCode(), item.getProductName(), item.getSlug(), item.getModel(), item.getSummary(), item.getProductContent(), item.getContentTemplateCode(), item.getTemplatePosition(), item.getCoverMediaCode(), mediaUrl, images, 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.getContentTemplateCode(), item.getTemplatePosition(), item.getCoverMediaCode(), mediaUrl, images, item.getFeaturedFlag() == 1, item.getInquiryEnabled() == 1, item.getSortNo(), item.getStatus(), attributes, specifications);
|
||||||
}
|
}
|
||||||
/** 查询后台产品列表。 */
|
/** 查询后台产品列表。 */
|
||||||
public List<ProductItemAdminRes> list(String siteCode, String primaryCategoryCode, PublishStatusEnum status) {
|
public ProductListAdminRes list(String siteCode, String primaryCategoryCode, PublishStatusEnum status,
|
||||||
|
Integer requestedPageNo, Integer requestedPageSize) {
|
||||||
Map<String, ProductCategoryEntity> categoryMap = categoryRepository.list(siteCode, false).stream()
|
Map<String, ProductCategoryEntity> categoryMap = categoryRepository.list(siteCode, false).stream()
|
||||||
.collect(Collectors.toMap(ProductCategoryEntity::getCategoryCode, Function.identity()));
|
.collect(Collectors.toMap(ProductCategoryEntity::getCategoryCode, Function.identity()));
|
||||||
Map<String, String> mediaUrlMap = mediaRepository.list(siteCode, null).stream()
|
Map<String, String> mediaUrlMap = mediaRepository.list(siteCode, null).stream()
|
||||||
.collect(Collectors.toMap(media -> media.getMediaCode(), media -> media.getRelativeUrl(),
|
.collect(Collectors.toMap(media -> media.getMediaCode(), media -> media.getRelativeUrl(),
|
||||||
(first, ignored) -> first));
|
(first, ignored) -> first));
|
||||||
return repository.list(siteCode).stream()
|
List<ProductItemAdminRes> filteredItems = repository.list(siteCode).stream()
|
||||||
.filter(item -> primaryCategoryCode == null || primaryCategoryCode.isBlank()
|
.filter(item -> primaryCategoryCode == null || primaryCategoryCode.isBlank()
|
||||||
|| primaryCategoryCode.equals(item.getPrimaryCategoryCode()))
|
|| primaryCategoryCode.equals(item.getPrimaryCategoryCode()))
|
||||||
.filter(item -> status == null || status.name().equals(item.getStatus()))
|
.filter(item -> status == null || status.name().equals(item.getStatus()))
|
||||||
@@ -170,6 +171,13 @@ public class AdminProductService {
|
|||||||
mediaUrlMap.get(item.getCoverMediaCode()),
|
mediaUrlMap.get(item.getCoverMediaCode()),
|
||||||
item.getStatus(), item.getFeaturedFlag() == 1, item.getInquiryEnabled() == 1,
|
item.getStatus(), item.getFeaturedFlag() == 1, item.getInquiryEnabled() == 1,
|
||||||
item.getPublishTime())).toList();
|
item.getPublishTime())).toList();
|
||||||
|
int pageNo = requestedPageNo == null ? 1 : requestedPageNo;
|
||||||
|
int pageSize = requestedPageSize == null ? 20 : requestedPageSize;
|
||||||
|
int total = filteredItems.size();
|
||||||
|
int totalPages = total == 0 ? 0 : (total + pageSize - 1) / pageSize;
|
||||||
|
int fromIndex = Math.min((pageNo - 1) * pageSize, total);
|
||||||
|
int toIndex = Math.min(fromIndex + pageSize, total);
|
||||||
|
return new ProductListAdminRes(filteredItems.subList(fromIndex, toIndex), total, pageNo, pageSize, totalPages);
|
||||||
}
|
}
|
||||||
/** 逻辑删除产品。 */
|
/** 逻辑删除产品。 */
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 398 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 137 KiB |
@@ -0,0 +1,102 @@
|
|||||||
|
"""为三款产品准备无中文的产品图与英文规格图。"""
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
from PIL import Image, ImageDraw, ImageFont, ImageOps
|
||||||
|
|
||||||
|
|
||||||
|
SOURCE_ROOT = Path(r"C:\Users\29506\Desktop\cy\鸿遇工贸\产品图片")
|
||||||
|
OUTPUT_ROOT = Path(r"E:\work\shangyuan\shoplix\output\product-import")
|
||||||
|
FONT_REGULAR = Path(r"C:\Windows\Fonts\arial.ttf")
|
||||||
|
FONT_BOLD = Path(r"C:\Windows\Fonts\arialbd.ttf")
|
||||||
|
|
||||||
|
PRODUCTS = {
|
||||||
|
"HY-001": {
|
||||||
|
"folder": "Protective Cover Trimmer Head - White HY-001",
|
||||||
|
"name": "Protective Cover Trimmer Head - White",
|
||||||
|
"files": [
|
||||||
|
"O1CN01D8S3e9G83iC2XrKe_!!2217056636432-0-cib.jpg_.webp",
|
||||||
|
"O1CN01OEkLBL7Ic8J2R3rs_!!2217056636432-0-cib.jpg_.webp",
|
||||||
|
"O1CN01spYFDTqxaDF2R3rs_!!2217056636432-0-cib.jpg_.webp",
|
||||||
|
"O1CN01t8mmPN9FSiF2R3rs_!!2217056636432-0-cib.jpg_.webp",
|
||||||
|
],
|
||||||
|
"specs": [("Material", "Metal + aluminum"), ("Dimensions", "80.5 × 80.5 × 23 mm"),
|
||||||
|
("Net weight", "200 g"), ("Application", "Grass trimming")],
|
||||||
|
},
|
||||||
|
"HY-012": {
|
||||||
|
"folder": "Large Aluminum Cylinder Trimmer Head HY-012",
|
||||||
|
"name": "Large Aluminum Cylinder Trimmer Head",
|
||||||
|
"files": [
|
||||||
|
"O1CN01TZ4um7NgP8B1chua_!!2217056636432-0-cib.jpg_.webp",
|
||||||
|
"O1CN01vpinbZvGDlK1chua_!!2217056636432-0-cib.jpg_.webp",
|
||||||
|
"O1CN01zCrsDO1J0OE1chua_!!2217056636432-0-cib.jpg_.webp",
|
||||||
|
],
|
||||||
|
"specs": [("Material", "Aluminum alloy"), ("Dimensions", "45 × 45 × 55 mm"),
|
||||||
|
("Net weight", "400 g"), ("Application", "Grass trimming")],
|
||||||
|
},
|
||||||
|
"HY-032": {
|
||||||
|
"folder": "European-Type Trimmer Head - Orange HY-032",
|
||||||
|
"name": "European-Type Trimmer Head - Orange",
|
||||||
|
"files": [
|
||||||
|
"O1CN01unDmzQcaXFC2b8G8_!!2217056636432-0-cib.jpg_.webp",
|
||||||
|
"O1CN01UyV2HS9YFAC2b8G8_!!2217056636432-0-cib.jpg_.webp",
|
||||||
|
"O1CN01wsHSM4JvXdD2b8G8_!!2217056636432-0-cib.jpg_.webp",
|
||||||
|
],
|
||||||
|
"specs": [("Material", "Engineering plastic + metal"), ("Dimensions", "145 × 145 × 75 mm"),
|
||||||
|
("Net weight", "485 g"), ("Application", "Grass trimming")],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def font(size: int, bold: bool = False) -> ImageFont.FreeTypeFont:
|
||||||
|
"""加载用于英文详情图的系统字体。"""
|
||||||
|
return ImageFont.truetype(str(FONT_BOLD if bold else FONT_REGULAR), size)
|
||||||
|
|
||||||
|
|
||||||
|
def save_clean_image(source: Path, target: Path) -> None:
|
||||||
|
"""将无中文的原图统一转为高质量 JPEG。"""
|
||||||
|
image = Image.open(source).convert("RGB")
|
||||||
|
image.save(target, "JPEG", quality=92, optimize=True)
|
||||||
|
|
||||||
|
|
||||||
|
def create_specification_card(model: str, config: dict, product_image: Path, target: Path) -> None:
|
||||||
|
"""基于实拍图生成全英文规格详情图。"""
|
||||||
|
canvas = Image.new("RGB", (1200, 1200), "#f5f7f6")
|
||||||
|
draw = ImageDraw.Draw(canvas)
|
||||||
|
draw.rectangle((0, 0, 1200, 165), fill="#176b5b")
|
||||||
|
draw.text((70, 48), config["name"], font=font(44, True), fill="white")
|
||||||
|
draw.text((72, 108), model, font=font(25), fill="#d7eee7")
|
||||||
|
product = Image.open(product_image).convert("RGB")
|
||||||
|
product = ImageOps.contain(product, (540, 650))
|
||||||
|
x = 70 + (540 - product.width) // 2
|
||||||
|
y = 230 + (650 - product.height) // 2
|
||||||
|
canvas.paste(product, (x, y))
|
||||||
|
draw.rounded_rectangle((660, 230, 1130, 910), radius=22, fill="white", outline="#dce4e1", width=2)
|
||||||
|
draw.text((710, 282), "Product specifications", font=font(30, True), fill="#16221f")
|
||||||
|
row_y = 370
|
||||||
|
for label, value in config["specs"]:
|
||||||
|
draw.text((710, row_y), label.upper(), font=font(17, True), fill="#71817c")
|
||||||
|
draw.text((710, row_y + 34), value, font=font(25), fill="#17211f")
|
||||||
|
draw.line((710, row_y + 86, 1080, row_y + 86), fill="#e5eae8", width=2)
|
||||||
|
row_y += 125
|
||||||
|
draw.text((70, 1030), "OEM & wholesale inquiries are welcome", font=font(30, True), fill="#176b5b")
|
||||||
|
draw.text((70, 1082), "Confirm machine compatibility before ordering.", font=font(23), fill="#64736e")
|
||||||
|
canvas.save(target, "JPEG", quality=93, optimize=True)
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
"""输出三款产品的清洁图库和英文规格图。"""
|
||||||
|
OUTPUT_ROOT.mkdir(parents=True, exist_ok=True)
|
||||||
|
for model, config in PRODUCTS.items():
|
||||||
|
product_dir = OUTPUT_ROOT / model
|
||||||
|
product_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
source_dir = SOURCE_ROOT / config["folder"]
|
||||||
|
prepared = []
|
||||||
|
for index, filename in enumerate(config["files"], start=1):
|
||||||
|
target = product_dir / f"{model.lower()}-{index}.jpg"
|
||||||
|
save_clean_image(source_dir / filename, target)
|
||||||
|
prepared.append(target)
|
||||||
|
create_specification_card(model, config, prepared[0], product_dir / f"{model.lower()}-specifications-en.jpg")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
"""上传三款产品图片,并更新英文详情与规格属性。"""
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
from html import escape
|
||||||
|
import requests
|
||||||
|
|
||||||
|
|
||||||
|
BASE_URL = "http://127.0.0.1:8081/api/admin/v1"
|
||||||
|
SITE_CODE = "SIT0000000000001"
|
||||||
|
IMAGE_ROOT = Path(r"E:\work\shangyuan\shoplix\output\product-import")
|
||||||
|
|
||||||
|
PRODUCT_DATA = {
|
||||||
|
"HY-001": {
|
||||||
|
"intro": "A durable protective-cover trimmer head supplied with replaceable nylon lines for efficient grass trimming and routine garden maintenance.",
|
||||||
|
"features": ["Metal and aluminum construction", "Compact protective-cover design", "Replaceable nylon trimming lines", "Suitable for garden and landscape maintenance"],
|
||||||
|
"specifications": [("General", "Material", "Metal + aluminum", ""), ("Dimensions", "Size", "80.5 × 80.5 × 23", "mm"), ("Dimensions", "Net weight", "200", "g"), ("Application", "Use", "Grass trimming", "")],
|
||||||
|
},
|
||||||
|
"HY-012": {
|
||||||
|
"intro": "A heavy-duty aluminum cylinder trimmer head designed for reliable line feeding, quick line replacement and demanding garden-tool applications.",
|
||||||
|
"features": ["Thickened aluminum-alloy housing", "Quick and convenient line replacement", "Multiple line outlets for efficient cutting", "OEM and wholesale supply available"],
|
||||||
|
"specifications": [("General", "Material", "Aluminum alloy", ""), ("Dimensions", "Diameter", "45", "mm"), ("Dimensions", "Height", "55", "mm"), ("Dimensions", "Net weight", "400", "g"), ("Application", "Use", "Grass trimming", "")],
|
||||||
|
},
|
||||||
|
"HY-032": {
|
||||||
|
"intro": "A European-style orange trimmer head combining a robust housing, practical line-feeding structure and broad compatibility for grass-cutting equipment.",
|
||||||
|
"features": ["European-style trimmer-head design", "Engineering-plastic and metal construction", "Large 145 mm working diameter", "Suitable for garden and landscape maintenance"],
|
||||||
|
"specifications": [("General", "Material", "Engineering plastic + metal", ""), ("Dimensions", "Length", "145", "mm"), ("Dimensions", "Width", "145", "mm"), ("Dimensions", "Height", "75", "mm"), ("Dimensions", "Net weight", "485", "g"), ("Application", "Use", "Grass trimming", "")],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def login(session: requests.Session) -> None:
|
||||||
|
"""登录运营后台并保持会话。"""
|
||||||
|
response = session.post(f"{BASE_URL}/auth/login", json={"username": "admin", "password": "Shoplix@2026"}, timeout=30)
|
||||||
|
response.raise_for_status()
|
||||||
|
|
||||||
|
|
||||||
|
def find_product(session: requests.Session, model: str) -> dict:
|
||||||
|
"""按型号查找产品并读取完整详情。"""
|
||||||
|
response = session.post(f"{BASE_URL}/products/list", json={"siteCode": SITE_CODE}, timeout=30)
|
||||||
|
response.raise_for_status()
|
||||||
|
item = next((row for row in response.json().get("items", []) if row.get("model") == model), None)
|
||||||
|
if item is None:
|
||||||
|
raise RuntimeError(f"Product not found: {model}")
|
||||||
|
detail = session.post(f"{BASE_URL}/products/detail", json={"siteCode": SITE_CODE, "productCode": item["productCode"]}, timeout=30)
|
||||||
|
detail.raise_for_status()
|
||||||
|
return detail.json()
|
||||||
|
|
||||||
|
|
||||||
|
def find_existing_media(session: requests.Session, filename: str) -> dict | None:
|
||||||
|
"""复用已经上传的同名素材,避免重复写入。"""
|
||||||
|
response = session.post(f"{BASE_URL}/media/page", json={"siteCode": SITE_CODE, "mediaType": "IMAGE", "keyword": filename, "tagName": "", "pageNo": 1, "pageSize": 30}, timeout=30)
|
||||||
|
response.raise_for_status()
|
||||||
|
return next((item for item in response.json().get("items", []) if item.get("originalFileName") == filename), None)
|
||||||
|
|
||||||
|
|
||||||
|
def upload_image(session: requests.Session, path: Path, model: str) -> dict:
|
||||||
|
"""上传单张产品图并返回素材信息。"""
|
||||||
|
existing = find_existing_media(session, path.name)
|
||||||
|
if existing:
|
||||||
|
return existing
|
||||||
|
with path.open("rb") as file_handle:
|
||||||
|
response = session.post(f"{BASE_URL}/media/upload", data={"siteCode": SITE_CODE, "altText": f"{model} product image"}, files={"file": (path.name, file_handle, "image/jpeg")}, timeout=120)
|
||||||
|
response.raise_for_status()
|
||||||
|
return response.json()
|
||||||
|
|
||||||
|
|
||||||
|
def build_content(detail: dict, config: dict, media: list[dict]) -> str:
|
||||||
|
"""生成包含英文卖点和实拍图的产品详情 HTML。"""
|
||||||
|
name = escape(detail["productName"])
|
||||||
|
features = "".join(f"<li>{escape(item)}</li>" for item in config["features"])
|
||||||
|
image_blocks = "".join(
|
||||||
|
f'<figure style="margin:24px 0;text-align:center"><img src="{escape(item["url"])}" alt="{name}" style="max-width:100%;height:auto" /></figure>'
|
||||||
|
for item in media[1:3]
|
||||||
|
)
|
||||||
|
return (
|
||||||
|
f"<h2>{name}</h2><p>{escape(config['intro'])}</p>"
|
||||||
|
f"<h3>Key features</h3><ul>{features}</ul>{image_blocks}"
|
||||||
|
"<h3>OEM & wholesale service</h3><p>Custom packaging, product configuration and bulk-order support are available. Please confirm machine compatibility before ordering.</p>"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def update_product(session: requests.Session, model: str, detail: dict, config: dict, media: list[dict]) -> None:
|
||||||
|
"""保存产品多图、英文详情和英文规格属性。"""
|
||||||
|
specifications = [
|
||||||
|
{"groupName": group, "name": name, "value": value, "unit": unit, "sortNo": index}
|
||||||
|
for index, (group, name, value, unit) in enumerate(config["specifications"], start=1)
|
||||||
|
]
|
||||||
|
attributes = [
|
||||||
|
{"attributeCode": None, "attributeName": name, "value": f"{value}{(' ' + unit) if unit else ''}", "unit": unit, "sortNo": index}
|
||||||
|
for index, (_, name, value, unit) in enumerate(config["specifications"], start=1)
|
||||||
|
]
|
||||||
|
request = {
|
||||||
|
"productCode": detail["productCode"], "siteCode": SITE_CODE,
|
||||||
|
"primaryCategoryCode": detail.get("primaryCategoryCode"), "productName": detail["productName"],
|
||||||
|
"slug": detail["slug"], "model": detail.get("model"), "summary": config["intro"],
|
||||||
|
"productContent": build_content(detail, config, media),
|
||||||
|
"contentTemplateCode": detail.get("contentTemplateCode") or "", "templatePosition": detail.get("templatePosition") or "AFTER",
|
||||||
|
"coverMediaCode": media[0]["mediaCode"],
|
||||||
|
"images": [{"mediaCode": item["mediaCode"], "sortNo": index} for index, item in enumerate(media)],
|
||||||
|
"featured": detail.get("featured", False), "inquiryEnabled": detail.get("inquiryEnabled", True),
|
||||||
|
"sortNo": detail.get("sortNo", 0), "status": detail["status"],
|
||||||
|
"specifications": specifications, "attributes": attributes,
|
||||||
|
}
|
||||||
|
response = session.post(f"{BASE_URL}/products/save", json=request, timeout=60)
|
||||||
|
response.raise_for_status()
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
"""完成三款产品的素材上传和数据更新。"""
|
||||||
|
with requests.Session() as session:
|
||||||
|
login(session)
|
||||||
|
for model, config in PRODUCT_DATA.items():
|
||||||
|
detail = find_product(session, model)
|
||||||
|
media = [upload_image(session, path, model) for path in sorted((IMAGE_ROOT / model).glob("*.jpg"))]
|
||||||
|
update_product(session, model, detail, config, media)
|
||||||
|
print(f"Updated {model}: {len(media)} images")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 211 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 121 KiB |
@@ -0,0 +1,58 @@
|
|||||||
|
1
|
||||||
|
00:00:00,000 --> 00:00:04,840
|
||||||
|
Welcome to Yongkang Hongyu Industry and Trade Co., Ltd.
|
||||||
|
I am the company representative.
|
||||||
|
|
||||||
|
2
|
||||||
|
00:00:04,840 --> 00:00:09,760
|
||||||
|
We specialize in garden tools, trimmer line,
|
||||||
|
trimmer heads and related accessories.
|
||||||
|
|
||||||
|
3
|
||||||
|
00:00:09,760 --> 00:00:12,640
|
||||||
|
Let me show you around our factory.
|
||||||
|
|
||||||
|
4
|
||||||
|
00:00:12,640 --> 00:00:16,000
|
||||||
|
Established in 2020, our factory
|
||||||
|
has a team of 50 employees.
|
||||||
|
|
||||||
|
5
|
||||||
|
00:00:16,000 --> 00:00:21,760
|
||||||
|
Located in Gushan Town, Yongkang,
|
||||||
|
our factory covers 3,800 square meters.
|
||||||
|
|
||||||
|
6
|
||||||
|
00:00:21,760 --> 00:00:28,200
|
||||||
|
Our modern facility produces trimmer heads
|
||||||
|
and a wide range of garden tool accessories.
|
||||||
|
|
||||||
|
7
|
||||||
|
00:00:28,280 --> 00:00:34,560
|
||||||
|
With dedicated equipment and an R&D team, capacity reaches
|
||||||
|
about 20,000 pieces per day and 6 million pieces per year.
|
||||||
|
|
||||||
|
8
|
||||||
|
00:00:34,560 --> 00:00:40,400
|
||||||
|
Our products are exported to Russia, Southeast Asia,
|
||||||
|
Europe and other markets. OEM service is available.
|
||||||
|
|
||||||
|
9
|
||||||
|
00:00:40,400 --> 00:00:45,400
|
||||||
|
From incoming materials to final shipment,
|
||||||
|
every stage is controlled for reliable quality.
|
||||||
|
|
||||||
|
10
|
||||||
|
00:00:45,400 --> 00:00:49,440
|
||||||
|
We provide one-stop ODM service,
|
||||||
|
from product design and R&D to manufacturing.
|
||||||
|
|
||||||
|
11
|
||||||
|
00:00:49,440 --> 00:00:56,400
|
||||||
|
We also manufacture for established brands,
|
||||||
|
earning strong recognition from industry buyers.
|
||||||
|
|
||||||
|
12
|
||||||
|
00:00:56,440 --> 00:01:03,480
|
||||||
|
Interested in our products? Contact us anytime.
|
||||||
|
Yongkang Hongyu looks forward to working with you.
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 49 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 61 KiB |
@@ -0,0 +1,147 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"start": 0.0,
|
||||||
|
"end": 3.2,
|
||||||
|
"text": "\u5927\u5bb6\u597d,\u6b22\u8fce\u6765\u5230\u6cf3\u6c64\u5e02\u7ea2\u57df\u516c\u8d38\u9c7c\u4ef7\u516c\u53f8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 3.2,
|
||||||
|
"end": 4.84,
|
||||||
|
"text": "\u6211\u662f\u516c\u53f8\u8d1f\u8d23\u4eba"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 4.84,
|
||||||
|
"end": 7.48,
|
||||||
|
"text": "\u6211\u662f\u4e3b\u8981\u751f\u4ea7\u5706\u7075\u5de5\u5177"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 7.48,
|
||||||
|
"end": 9.76,
|
||||||
|
"text": "\u989d\u949e\u53ca\u6253\u8349\u5934\u53ca\u914d\u4ef6"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 9.76,
|
||||||
|
"end": 12.64,
|
||||||
|
"text": "\u63a5\u4e0b\u6765\u6211\u5e26\u5927\u5bb6\u53c2\u89c2\u4e00\u4e0b\u6211\u4eec\u5de5\u5382"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 12.64,
|
||||||
|
"end": 14.84,
|
||||||
|
"text": "\u6211\u4eec\u5de5\u5382\u6210\u7acb\u4e8e2020\u5e74"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 14.84,
|
||||||
|
"end": 16.0,
|
||||||
|
"text": "\u5458\u5de5\u670950\u4eba"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 16.0,
|
||||||
|
"end": 19.24,
|
||||||
|
"text": "\u5de5\u5382\u5730\u5740\u4f4d\u4e8e\u6cf3\u5eb7\u5e02\u53e4\u5c71\u9547\u4eba\u6cb3\u5ea62\u53f7"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 19.24,
|
||||||
|
"end": 21.76,
|
||||||
|
"text": "\u5360\u5730\u9762\u79ef\u8fbe\u52303800\u5e73\u65b9"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 21.76,
|
||||||
|
"end": 24.56,
|
||||||
|
"text": "\u62e5\u6709\u73b0\u4ee3\u5316\u5382\u623f\u548c\u5148\u8fdb\u7684\u8bbe\u5907"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 24.56,
|
||||||
|
"end": 28.2,
|
||||||
|
"text": "\u516c\u53f8\u4e3b\u8981\u751f\u4ea7\u6253\u8349\u5934\u53ca\u5706\u7075\u914d\u4ef6\u7b49\u4ea7\u54c1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 28.28,
|
||||||
|
"end": 31.4,
|
||||||
|
"text": "\u5de5\u5382\u62e5\u6709\u4e13\u4e1a\u7684\u751f\u4ea7\u8bbe\u5907\u548c\u7814\u53d1\u56e2\u961f"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 31.4,
|
||||||
|
"end": 32.88,
|
||||||
|
"text": "\u9884\u4ea7\u91cf\u7ea62\u4e07\u4ef6"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 32.88,
|
||||||
|
"end": 34.56,
|
||||||
|
"text": "\u5ef6\u4ea7\u91cf\u7ea6600\u4e07\u4ef6"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 34.56,
|
||||||
|
"end": 36.16,
|
||||||
|
"text": "\u4ea7\u54c1\u8fdc\u6d88\u4fc4\u7f57\u65af"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 36.16,
|
||||||
|
"end": 37.0,
|
||||||
|
"text": "\u4e1c\u5357\u4e9a"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 37.0,
|
||||||
|
"end": 38.48,
|
||||||
|
"text": "\u6b27\u6d32\u56fd\u5bb6\u7ea7\u5730\u533a"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 38.48,
|
||||||
|
"end": 40.4,
|
||||||
|
"text": "OEM\u7b49\u4ee3\u5de5\u670d\u52a1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 40.4,
|
||||||
|
"end": 42.76,
|
||||||
|
"text": "\u5de5\u5382\u4ece\u6765\u6599\u751f\u4ea7\u5230\u51fa\u8d27"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 42.76,
|
||||||
|
"end": 45.4,
|
||||||
|
"text": "\u6bcf\u4e2a\u73af\u8282\u5374\u4fdd\u51fa\u5382\u5546\u54c1\u8d28\u91cf\u8fc7\u786c"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 45.4,
|
||||||
|
"end": 47.2,
|
||||||
|
"text": "\u53ef\u4ee5\u627f\u63a5\u4ece\u8bbe\u8ba1\u7814\u53d1\u5230"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 47.2,
|
||||||
|
"end": 49.44,
|
||||||
|
"text": "\u751f\u4ea7\u5236\u9020\u4e00\u6218\u58ebODM"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 49.44,
|
||||||
|
"end": 50.04,
|
||||||
|
"text": "\u540c\u65f6"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 50.04,
|
||||||
|
"end": 53.4,
|
||||||
|
"text": "\u516c\u53f8\u4e3a\u56fd\u5185\u5916\u77e5\u540d\u54c1\u724c\u63d0\u4f9b\u4ee3\u5de5\u670d\u52a1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 53.4,
|
||||||
|
"end": 56.4,
|
||||||
|
"text": "\u4ea7\u54c1\u8d28\u91cf\u83b7\u5f97\u884c\u4e1a\u4e70\u5bb6\u7684\u9ad8\u5ea6\u8ba4\u53ef"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 56.44,
|
||||||
|
"end": 58.2,
|
||||||
|
"text": "\u5982\u679c\u60a8\u5bf9\u6211\u4eec\u611f\u5174\u8da3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 58.2,
|
||||||
|
"end": 59.88,
|
||||||
|
"text": "\u6b22\u8fce\u968f\u65f6\u8054\u7cfb\u6211\u4eec"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 59.88,
|
||||||
|
"end": 62.2,
|
||||||
|
"text": "\u6c38\u5eb7\u5e02\u7ea2\u57df\u5de5\u8d38\u6709\u9650\u516c\u53f8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start": 62.2,
|
||||||
|
"end": 63.48,
|
||||||
|
"text": "\u671f\u5f85\u4e0e\u60a8\u5408\u4f5c"
|
||||||
|
}
|
||||||
|
]
|
||||||
+56
-15
@@ -222,6 +222,11 @@ function App({
|
|||||||
const [categoryFilter, setCategoryFilter] = useState("");
|
const [categoryFilter, setCategoryFilter] = useState("");
|
||||||
const [statusFilter, setStatusFilter] = useState("");
|
const [statusFilter, setStatusFilter] = useState("");
|
||||||
const [categories, setCategories] = useState<CategoryOption[]>([]);
|
const [categories, setCategories] = useState<CategoryOption[]>([]);
|
||||||
|
const [pageNo, setPageNo] = useState(1);
|
||||||
|
const [pageSize, setPageSize] = useState(20);
|
||||||
|
const [total, setTotal] = useState(0);
|
||||||
|
const [totalPages, setTotalPages] = useState(0);
|
||||||
|
const [previewImage, setPreviewImage] = useState("");
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
const [siteDialogOpen, setSiteDialogOpen] = useState(false);
|
const [siteDialogOpen, setSiteDialogOpen] = useState(false);
|
||||||
@@ -319,6 +324,8 @@ function App({
|
|||||||
siteCode: SITE,
|
siteCode: SITE,
|
||||||
primaryCategoryCode: categoryFilter || null,
|
primaryCategoryCode: categoryFilter || null,
|
||||||
status: statusFilter || null,
|
status: statusFilter || null,
|
||||||
|
pageNo,
|
||||||
|
pageSize,
|
||||||
})
|
})
|
||||||
: section === "pages"
|
: section === "pages"
|
||||||
? await post("/pages/list", { siteCode: SITE })
|
? await post("/pages/list", { siteCode: SITE })
|
||||||
@@ -333,16 +340,22 @@ function App({
|
|||||||
contentType: section,
|
contentType: section,
|
||||||
primaryCategoryCode: categoryFilter || null,
|
primaryCategoryCode: categoryFilter || null,
|
||||||
status: statusFilter || null,
|
status: statusFilter || null,
|
||||||
|
pageNo,
|
||||||
|
pageSize,
|
||||||
});
|
});
|
||||||
setItems(data.items || []);
|
setItems(data.items || []);
|
||||||
|
setTotal(data.total || 0);
|
||||||
|
setTotalPages(data.totalPages || 0);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setError(e instanceof Error ? e.message : "加载失败");
|
setError(e instanceof Error ? e.message : "加载失败");
|
||||||
setItems([]);
|
setItems([]);
|
||||||
|
setTotal(0);
|
||||||
|
setTotalPages(0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/** 加载产品、新闻或案例列表所需的分类筛选项。 */
|
/** 加载产品、新闻或案例列表所需的分类筛选项。 */
|
||||||
const loadCategoryFilters = async () => {
|
const loadCategoryFilters = async () => {
|
||||||
if (!["products", "NEWS", "CASE"].includes(section)) {
|
if (!["products", "NEWS", "CASE", "HELP"].includes(section)) {
|
||||||
setCategories([]);
|
setCategories([]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -361,11 +374,12 @@ function App({
|
|||||||
};
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void load();
|
void load();
|
||||||
}, [section, categoryFilter, statusFilter]);
|
}, [section, categoryFilter, statusFilter, pageNo, pageSize]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setQuery("");
|
setQuery("");
|
||||||
setCategoryFilter("");
|
setCategoryFilter("");
|
||||||
setStatusFilter("");
|
setStatusFilter("");
|
||||||
|
setPageNo(1);
|
||||||
void loadCategoryFilters();
|
void loadCategoryFilters();
|
||||||
}, [section]);
|
}, [section]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -896,13 +910,13 @@ function App({
|
|||||||
placeholder={`搜索${title}名称或路径`}
|
placeholder={`搜索${title}名称或路径`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{["products", "NEWS", "CASE"].includes(section) && (
|
{["products", "NEWS", "CASE", "HELP"].includes(section) && (
|
||||||
<div className="list-filters">
|
<div className="list-filters">
|
||||||
<select
|
<select
|
||||||
aria-label="按分类筛选"
|
aria-label="按分类筛选"
|
||||||
value={categoryFilter}
|
value={categoryFilter}
|
||||||
onChange={(event) =>
|
onChange={(event) =>
|
||||||
setCategoryFilter(event.target.value)
|
(setCategoryFilter(event.target.value), setPageNo(1))
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<option value="">全部分类</option>
|
<option value="">全部分类</option>
|
||||||
@@ -919,7 +933,7 @@ function App({
|
|||||||
aria-label="按上下架状态筛选"
|
aria-label="按上下架状态筛选"
|
||||||
value={statusFilter}
|
value={statusFilter}
|
||||||
onChange={(event) =>
|
onChange={(event) =>
|
||||||
setStatusFilter(event.target.value)
|
(setStatusFilter(event.target.value), setPageNo(1))
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<option value="">全部状态</option>
|
<option value="">全部状态</option>
|
||||||
@@ -936,7 +950,7 @@ function App({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<section
|
<section
|
||||||
className={`table ${section === "inquiries" ? "inquiry-table" : ""} ${section === "products" ? "product-list-table" : ["NEWS", "CASE"].includes(section) ? "content-list-table" : ""}`}
|
className={`table ${section === "inquiries" ? "inquiry-table" : ""} ${section === "products" ? "product-list-table" : ["NEWS", "CASE", "HELP"].includes(section) ? "content-list-table" : ""}`}
|
||||||
>
|
>
|
||||||
<div className="thead">
|
<div className="thead">
|
||||||
{section === "inquiries" ? (
|
{section === "inquiries" ? (
|
||||||
@@ -960,7 +974,7 @@ function App({
|
|||||||
<span>发布时间</span>
|
<span>发布时间</span>
|
||||||
<span>操作</span>
|
<span>操作</span>
|
||||||
</>
|
</>
|
||||||
) : ["NEWS", "CASE"].includes(section) ? (
|
) : ["NEWS", "CASE", "HELP"].includes(section) ? (
|
||||||
<>
|
<>
|
||||||
<span>图片</span>
|
<span>图片</span>
|
||||||
<span>名称</span>
|
<span>名称</span>
|
||||||
@@ -1035,17 +1049,22 @@ function App({
|
|||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{["products", "NEWS", "CASE"].includes(
|
{["products", "NEWS", "CASE", "HELP"].includes(
|
||||||
section,
|
section,
|
||||||
) && (
|
) && (
|
||||||
<span className="list-cover">
|
<span className="list-cover">
|
||||||
{item.coverMediaUrl ? (
|
{item.coverMediaUrl ? (
|
||||||
<img
|
<button
|
||||||
src={assetUrl(item.coverMediaUrl)}
|
type="button"
|
||||||
alt={
|
className="image-preview-trigger"
|
||||||
item.productName || item.title || "封面"
|
onClick={() => setPreviewImage(assetUrl(item.coverMediaUrl!))}
|
||||||
}
|
aria-label="放大查看图片"
|
||||||
/>
|
>
|
||||||
|
<img
|
||||||
|
src={assetUrl(item.coverMediaUrl)}
|
||||||
|
alt={item.productName || item.title || "封面"}
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
) : (
|
) : (
|
||||||
<span className="list-cover-empty">
|
<span className="list-cover-empty">
|
||||||
暂无图片
|
暂无图片
|
||||||
@@ -1069,7 +1088,7 @@ function App({
|
|||||||
{section === "products" && (
|
{section === "products" && (
|
||||||
<code>{item.productCode || "--"}</code>
|
<code>{item.productCode || "--"}</code>
|
||||||
)}
|
)}
|
||||||
{["products", "NEWS", "CASE"].includes(
|
{["products", "NEWS", "CASE", "HELP"].includes(
|
||||||
section,
|
section,
|
||||||
) && (
|
) && (
|
||||||
<span>{item.primaryCategoryName || "未分类"}</span>
|
<span>{item.primaryCategoryName || "未分类"}</span>
|
||||||
@@ -1149,6 +1168,22 @@ function App({
|
|||||||
))
|
))
|
||||||
)}
|
)}
|
||||||
</section>
|
</section>
|
||||||
|
{["products", "NEWS", "CASE", "HELP"].includes(section) && totalPages > 0 && (
|
||||||
|
<nav className="list-pagination" aria-label={`${title}分页`}>
|
||||||
|
<span>共 {total} 条</span>
|
||||||
|
<button type="button" disabled={pageNo <= 1} onClick={() => setPageNo(pageNo - 1)}>上一页</button>
|
||||||
|
<strong>{pageNo} / {totalPages}</strong>
|
||||||
|
<button type="button" disabled={pageNo >= totalPages} onClick={() => setPageNo(pageNo + 1)}>下一页</button>
|
||||||
|
<label>
|
||||||
|
每页
|
||||||
|
<select value={pageSize} onChange={(event) => (setPageSize(Number(event.target.value)), setPageNo(1))}>
|
||||||
|
<option value={10}>10</option>
|
||||||
|
<option value={20}>20</option>
|
||||||
|
<option value={50}>50</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</nav>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
@@ -1257,6 +1292,12 @@ function App({
|
|||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{previewImage && (
|
||||||
|
<div className="image-preview-mask" onClick={() => setPreviewImage("")}>
|
||||||
|
<button type="button" aria-label="关闭图片预览" onClick={() => setPreviewImage("")}><X size={22} /></button>
|
||||||
|
<img src={previewImage} alt="图片放大预览" onClick={(event) => event.stopPropagation()} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{siteDialogOpen && (
|
{siteDialogOpen && (
|
||||||
<div className="mask" onMouseDown={() => setSiteDialogOpen(false)}>
|
<div className="mask" onMouseDown={() => setSiteDialogOpen(false)}>
|
||||||
<section
|
<section
|
||||||
|
|||||||
@@ -460,4 +460,5 @@ header p {
|
|||||||
@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}}
|
@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}}
|
||||||
.template-editor-layout{max-width:1500px;margin:auto;display:grid;gap:20px}.template-editor-tip,.template-selection-note{margin:0;color:#73817d;font-size:13px;line-height:1.6}.template-table .thead,.template-table .row{grid-template-columns:minmax(0,2fr) 130px 90px 180px}.template-table .row-actions{display:flex;justify-content:flex-end;gap:12px}.template-table .row-actions .danger{color:#a93636}.template-table button svg{vertical-align:middle;margin-right:4px}@media(max-width:760px){.template-table .thead{display:none}.template-table .row{grid-template-columns:1fr}.template-table .row-actions{justify-content:flex-start}}
|
.template-editor-layout{max-width:1500px;margin:auto;display:grid;gap:20px}.template-editor-tip,.template-selection-note{margin:0;color:#73817d;font-size:13px;line-height:1.6}.template-table .thead,.template-table .row{grid-template-columns:minmax(0,2fr) 130px 90px 180px}.template-table .row-actions{display:flex;justify-content:flex-end;gap:12px}.template-table .row-actions .danger{color:#a93636}.template-table button svg{vertical-align:middle;margin-right:4px}@media(max-width:760px){.template-table .thead{display:none}.template-table .row{grid-template-columns:1fr}.template-table .row-actions{justify-content:flex-start}}
|
||||||
.media-filters{display:flex;gap:10px}.media-result-summary{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px;color:#66757b;font-size:13px}.media-result-summary label{display:flex;align-items:center;gap:8px}.media-result-summary select{height:34px;border:1px solid #d8dee3;border-radius:4px;background:#fff;padding:0 8px}.media-tag{height:30px;border:1px dashed #b9c7c3;background:#f8faf9;color:#647570;border-radius:4px;padding:0 8px;display:flex;align-items:center;gap:6px;justify-content:center;cursor:pointer;overflow:hidden}.media-tag.assigned{border-style:solid;background:#e9f3ef;color:#176b5b}.media-tag-editor{display:grid;grid-template-columns:minmax(0,1fr) 30px 30px;gap:5px}.media-tag-editor input{min-width:0;border:1px solid #b8c6c2;border-radius:4px;padding:6px 8px}.media-tag-editor button{border:1px solid #d5ddda;background:#fff;border-radius:4px;display:grid;place-items:center;cursor:pointer}.media-pagination{display:flex;align-items:center;justify-content:center;gap:6px;margin-top:20px}.media-pagination button{width:36px;height:36px;border:1px solid #d5ddda;background:#fff;border-radius:4px;display:grid;place-items:center;cursor:pointer}.media-pagination button.active{background:#176b5b;border-color:#176b5b;color:#fff}.media-pagination button:disabled{opacity:.45;cursor:not-allowed}.media-pagination span{margin-left:8px;color:#718087;font-size:13px}@media(max-width:760px){.media-filters{display:grid}.media-result-summary{align-items:flex-start}.media-pagination{flex-wrap:wrap}}
|
.media-filters{display:flex;gap:10px}.media-result-summary{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px;color:#66757b;font-size:13px}.media-result-summary label{display:flex;align-items:center;gap:8px}.media-result-summary select{height:34px;border:1px solid #d8dee3;border-radius:4px;background:#fff;padding:0 8px}.media-tag{height:30px;border:1px dashed #b9c7c3;background:#f8faf9;color:#647570;border-radius:4px;padding:0 8px;display:flex;align-items:center;gap:6px;justify-content:center;cursor:pointer;overflow:hidden}.media-tag.assigned{border-style:solid;background:#e9f3ef;color:#176b5b}.media-tag-editor{display:grid;grid-template-columns:minmax(0,1fr) 30px 30px;gap:5px}.media-tag-editor input{min-width:0;border:1px solid #b8c6c2;border-radius:4px;padding:6px 8px}.media-tag-editor button{border:1px solid #d5ddda;background:#fff;border-radius:4px;display:grid;place-items:center;cursor:pointer}.media-pagination{display:flex;align-items:center;justify-content:center;gap:6px;margin-top:20px}.media-pagination button{width:36px;height:36px;border:1px solid #d5ddda;background:#fff;border-radius:4px;display:grid;place-items:center;cursor:pointer}.media-pagination button.active{background:#176b5b;border-color:#176b5b;color:#fff}.media-pagination button:disabled{opacity:.45;cursor:not-allowed}.media-pagination span{margin-left:8px;color:#718087;font-size:13px}@media(max-width:760px){.media-filters{display:grid}.media-result-summary{align-items:flex-start}.media-pagination{flex-wrap:wrap}}
|
||||||
|
.image-preview-trigger{display:block;width:100%;height:100%;padding:0;border:0;background:transparent;cursor:zoom-in}.image-preview-trigger img{display:block;width:100%;height:100%;object-fit:cover}.image-preview-mask{position:fixed;inset:0;z-index:3000;display:grid;place-items:center;padding:48px;background:rgba(10,18,24,.84)}.image-preview-mask>button{position:absolute;top:20px;right:24px;width:40px;height:40px;border:0;border-radius:50%;display:grid;place-items:center;background:#fff;color:#17242d;cursor:pointer}.image-preview-mask>img{max-width:min(94vw,1400px);max-height:90vh;object-fit:contain;border-radius:6px;box-shadow:0 18px 60px rgba(0,0,0,.45)}.list-pagination{display:flex;align-items:center;justify-content:flex-end;gap:10px;margin:18px 0 4px;color:#66757b;font-size:13px}.list-pagination button,.list-pagination select{height:34px;border:1px solid #d5ddda;border-radius:4px;background:#fff;padding:0 12px}.list-pagination button{cursor:pointer}.list-pagination button:disabled{opacity:.45;cursor:not-allowed}.list-pagination label{display:flex;align-items:center;gap:6px}
|
||||||
.dashboard-page{padding:34px 38px 48px;max-width:1600px;margin:0 auto}.dashboard-header{display:flex;align-items:flex-start;justify-content:space-between;margin-bottom:26px}.dashboard-header h1{font-size:30px;margin:0 0 7px;letter-spacing:0}.dashboard-header p{margin:0;color:#76827f}.dashboard-updated{display:flex;align-items:center;gap:12px;color:#7b8784;font-size:13px}.dashboard-updated button{width:38px;height:38px;border:1px solid #d9e0dd;background:#fff;display:grid;place-items:center;color:#176b5b}.spin{animation:dashboard-spin 1s linear infinite}@keyframes dashboard-spin{to{transform:rotate(360deg)}}.dashboard-inline-error{padding:10px 14px;margin-bottom:18px;background:#fff3f1;color:#a43d31;border-left:3px solid #c95043}.dashboard-kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));border:1px solid #dfe5e2;background:#fff;margin-bottom:20px}.dashboard-metric{min-width:0;height:132px;border:0;border-right:1px solid #e5e9e7;background:#fff;padding:24px;display:flex;align-items:flex-start;gap:16px;text-align:left;color:#182522}.dashboard-metric:last-child{border-right:0}.dashboard-metric:not(:disabled){cursor:pointer}.dashboard-metric:not(:disabled):hover{background:#f7faf9}.dashboard-metric>span:nth-child(2){display:grid;gap:4px}.dashboard-metric small{color:#74817d;font-size:12px}.dashboard-metric strong{font-size:29px;letter-spacing:0}.dashboard-metric em{font-style:normal;color:#697672;font-size:12px}.dashboard-metric>svg{margin-left:auto;color:#176b5b}.metric-icon{width:38px;height:38px;display:grid;place-items:center;background:#e9f3ef;color:#176b5b}.metric-icon svg{width:19px}.dashboard-grid{display:grid;gap:20px;margin-bottom:20px}.dashboard-primary-grid{grid-template-columns:minmax(0,1.7fr) minmax(320px,.8fr)}.dashboard-secondary-grid{grid-template-columns:minmax(0,1.35fr) minmax(250px,.7fr) minmax(0,1.15fr)}.dashboard-panel{background:#fff;border:1px solid #dfe5e2;padding:24px;min-width:0}.dashboard-panel-title{height:30px;display:flex;align-items:start;justify-content:space-between}.dashboard-panel-title h2{font-size:17px;margin:0;letter-spacing:0}.dashboard-panel-title>span,.dashboard-panel-title button{font-size:12px;color:#7b8784}.dashboard-panel-title button{border:0;background:transparent;display:flex;align-items:center;gap:4px;cursor:pointer}.traffic-legend{display:flex;justify-content:flex-end;gap:16px;font-size:11px;color:#77837f}.traffic-legend span{display:flex;align-items:center;gap:5px}.traffic-legend i{width:8px;height:8px}.traffic-legend .pv,.traffic-bars .pv{background:#176b5b}.traffic-legend .uv,.traffic-bars .uv{background:#b9d6cc}.traffic-chart{height:230px;display:flex;align-items:end;gap:9px;border-bottom:1px solid #dfe5e2;padding-top:24px}.traffic-day{height:100%;flex:1;min-width:0;display:grid;grid-template-rows:1fr 22px;gap:8px}.traffic-bars{display:flex;align-items:end;justify-content:center;gap:3px}.traffic-bars i{width:min(12px,40%);min-height:3px}.traffic-day>span{text-align:center;font-size:10px;color:#83908c;white-space:nowrap}.content-stat-list{display:grid;gap:20px;margin-top:22px}.content-stat-list button{border:0;background:transparent;padding:0;text-align:left;cursor:pointer}.content-stat-list button>span{display:flex;justify-content:space-between}.content-stat-list b{font-size:13px}.content-stat-list small{color:#76827f}.content-stat-list i,.device-list i{display:block;height:5px;background:#edf1ef;margin-top:8px}.content-stat-list em,.device-list em{display:block;height:100%;background:#176b5b}.publish-summary{display:flex;gap:8px;align-items:center;margin-top:24px;padding-top:18px;border-top:1px solid #e2e7e5;color:#52615d;font-size:12px}.top-page-list{margin-top:14px}.top-page-list>div{display:grid;grid-template-columns:28px minmax(0,1fr) auto;gap:10px;align-items:center;padding:11px 0;border-bottom:1px solid #edf0ef}.top-page-list>div>b{color:#9aa5a1;font-size:11px}.top-page-list span{min-width:0;display:grid}.top-page-list strong,.top-page-list small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.top-page-list strong{font-size:13px}.top-page-list small{font-size:11px;color:#86918e}.top-page-list em{font-style:normal;font-size:12px;color:#52615d}.device-list{display:grid;gap:20px;margin-top:22px}.device-list>div{display:grid;grid-template-columns:1fr auto;align-items:center}.device-list span{display:flex;gap:7px;align-items:center;font-size:12px}.device-list b{font-size:12px}.device-list i{grid-column:1/-1}.recent-inquiries{margin-top:12px}.recent-inquiries button{width:100%;border:0;border-bottom:1px solid #edf0ef;background:transparent;padding:12px 0;display:flex;justify-content:space-between;gap:12px;text-align:left;cursor:pointer}.recent-inquiries button:hover strong{color:#176b5b}.recent-inquiries span,.recent-inquiries em{display:grid;gap:3px;min-width:0}.recent-inquiries strong{font-size:13px}.recent-inquiries small{font-size:11px;color:#83908c;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.recent-inquiries emLine truncated
|
.dashboard-page{padding:34px 38px 48px;max-width:1600px;margin:0 auto}.dashboard-header{display:flex;align-items:flex-start;justify-content:space-between;margin-bottom:26px}.dashboard-header h1{font-size:30px;margin:0 0 7px;letter-spacing:0}.dashboard-header p{margin:0;color:#76827f}.dashboard-updated{display:flex;align-items:center;gap:12px;color:#7b8784;font-size:13px}.dashboard-updated button{width:38px;height:38px;border:1px solid #d9e0dd;background:#fff;display:grid;place-items:center;color:#176b5b}.spin{animation:dashboard-spin 1s linear infinite}@keyframes dashboard-spin{to{transform:rotate(360deg)}}.dashboard-inline-error{padding:10px 14px;margin-bottom:18px;background:#fff3f1;color:#a43d31;border-left:3px solid #c95043}.dashboard-kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));border:1px solid #dfe5e2;background:#fff;margin-bottom:20px}.dashboard-metric{min-width:0;height:132px;border:0;border-right:1px solid #e5e9e7;background:#fff;padding:24px;display:flex;align-items:flex-start;gap:16px;text-align:left;color:#182522}.dashboard-metric:last-child{border-right:0}.dashboard-metric:not(:disabled){cursor:pointer}.dashboard-metric:not(:disabled):hover{background:#f7faf9}.dashboard-metric>span:nth-child(2){display:grid;gap:4px}.dashboard-metric small{color:#74817d;font-size:12px}.dashboard-metric strong{font-size:29px;letter-spacing:0}.dashboard-metric em{font-style:normal;color:#697672;font-size:12px}.dashboard-metric>svg{margin-left:auto;color:#176b5b}.metric-icon{width:38px;height:38px;display:grid;place-items:center;background:#e9f3ef;color:#176b5b}.metric-icon svg{width:19px}.dashboard-grid{display:grid;gap:20px;margin-bottom:20px}.dashboard-primary-grid{grid-template-columns:minmax(0,1.7fr) minmax(320px,.8fr)}.dashboard-secondary-grid{grid-template-columns:minmax(0,1.35fr) minmax(250px,.7fr) minmax(0,1.15fr)}.dashboard-panel{background:#fff;border:1px solid #dfe5e2;padding:24px;min-width:0}.dashboard-panel-title{height:30px;display:flex;align-items:start;justify-content:space-between}.dashboard-panel-title h2{font-size:17px;margin:0;letter-spacing:0}.dashboard-panel-title>span,.dashboard-panel-title button{font-size:12px;color:#7b8784}.dashboard-panel-title button{border:0;background:transparent;display:flex;align-items:center;gap:4px;cursor:pointer}.traffic-legend{display:flex;justify-content:flex-end;gap:16px;font-size:11px;color:#77837f}.traffic-legend span{display:flex;align-items:center;gap:5px}.traffic-legend i{width:8px;height:8px}.traffic-legend .pv,.traffic-bars .pv{background:#176b5b}.traffic-legend .uv,.traffic-bars .uv{background:#b9d6cc}.traffic-chart{height:230px;display:flex;align-items:end;gap:9px;border-bottom:1px solid #dfe5e2;padding-top:24px}.traffic-day{height:100%;flex:1;min-width:0;display:grid;grid-template-rows:1fr 22px;gap:8px}.traffic-bars{display:flex;align-items:end;justify-content:center;gap:3px}.traffic-bars i{width:min(12px,40%);min-height:3px}.traffic-day>span{text-align:center;font-size:10px;color:#83908c;white-space:nowrap}.content-stat-list{display:grid;gap:20px;margin-top:22px}.content-stat-list button{border:0;background:transparent;padding:0;text-align:left;cursor:pointer}.content-stat-list button>span{display:flex;justify-content:space-between}.content-stat-list b{font-size:13px}.content-stat-list small{color:#76827f}.content-stat-list i,.device-list i{display:block;height:5px;background:#edf1ef;margin-top:8px}.content-stat-list em,.device-list em{display:block;height:100%;background:#176b5b}.publish-summary{display:flex;gap:8px;align-items:center;margin-top:24px;padding-top:18px;border-top:1px solid #e2e7e5;color:#52615d;font-size:12px}.top-page-list{margin-top:14px}.top-page-list>div{display:grid;grid-template-columns:28px minmax(0,1fr) auto;gap:10px;align-items:center;padding:11px 0;border-bottom:1px solid #edf0ef}.top-page-list>div>b{color:#9aa5a1;font-size:11px}.top-page-list span{min-width:0;display:grid}.top-page-list strong,.top-page-list small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.top-page-list strong{font-size:13px}.top-page-list small{font-size:11px;color:#86918e}.top-page-list em{font-style:normal;font-size:12px;color:#52615d}.device-list{display:grid;gap:20px;margin-top:22px}.device-list>div{display:grid;grid-template-columns:1fr auto;align-items:center}.device-list span{display:flex;gap:7px;align-items:center;font-size:12px}.device-list b{font-size:12px}.device-list i{grid-column:1/-1}.recent-inquiries{margin-top:12px}.recent-inquiries button{width:100%;border:0;border-bottom:1px solid #edf0ef;background:transparent;padding:12px 0;display:flex;justify-content:space-between;gap:12px;text-align:left;cursor:pointer}.recent-inquiries button:hover strong{color:#176b5b}.recent-inquiries span,.recent-inquiries em{display:grid;gap:3px;min-width:0}.recent-inquiries strong{font-size:13px}.recent-inquiries small{font-size:11px;color:#83908c;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.recent-inquiries emLine truncated
|
||||||
+18
-9
@@ -118,6 +118,21 @@ function normalizeRichTextHtml(content?: string): string {
|
|||||||
decoded = decoded.replace(/^\s*<pre><code>/i, "").replace(/<\/code><\/pre>(?:<p><\/p>)?\s*$/i, "");
|
decoded = decoded.replace(/^\s*<pre><code>/i, "").replace(/<\/code><\/pre>(?:<p><\/p>)?\s*$/i, "");
|
||||||
return sanitizeRichTextHtml(decoded);
|
return sanitizeRichTextHtml(decoded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 渲染富文本并允许点击其中的图片进行全屏放大。 */
|
||||||
|
function ZoomableRichContent({ content, className = "content" }: { content?: string; className?: string }) {
|
||||||
|
const [zoomUrl, setZoomUrl] = useState("");
|
||||||
|
const openImage = (event: React.MouseEvent<HTMLDivElement>) => {
|
||||||
|
if (event.target instanceof HTMLImageElement) setZoomUrl(event.target.src);
|
||||||
|
};
|
||||||
|
return <>
|
||||||
|
<div className={className} onClick={openImage} dangerouslySetInnerHTML={{ __html: normalizeRichTextHtml(content) }} />
|
||||||
|
{zoomUrl && <div className="product-lightbox" role="presentation" onClick={() => setZoomUrl("")}>
|
||||||
|
<button type="button" aria-label="Close enlarged image" onClick={() => setZoomUrl("")}><X size={22}/></button>
|
||||||
|
<img src={zoomUrl} alt="Enlarged content" onClick={(event) => event.stopPropagation()} />
|
||||||
|
</div>}
|
||||||
|
</>;
|
||||||
|
}
|
||||||
function setMeta(name: string, content?: string) {
|
function setMeta(name: string, content?: string) {
|
||||||
const selector = `meta[name="${name}"]`;
|
const selector = `meta[name="${name}"]`;
|
||||||
let element = document.head.querySelector<HTMLMetaElement>(selector);
|
let element = document.head.querySelector<HTMLMetaElement>(selector);
|
||||||
@@ -514,10 +529,7 @@ function Collection({
|
|||||||
<h1>{d.productName || d.title}</h1>
|
<h1>{d.productName || d.title}</h1>
|
||||||
<p className="lead">{d.summary}</p>
|
<p className="lead">{d.summary}</p>
|
||||||
{d.attributes?.length > 0 && <section className="specs"><h2>Product attributes</h2>{d.attributes.map((a:any,i:number)=><div key={i}><span>{a.name}</span><strong>{a.value} {a.unit}</strong></div>)}</section>}
|
{d.attributes?.length > 0 && <section className="specs"><h2>Product attributes</h2>{d.attributes.map((a:any,i:number)=><div key={i}><span>{a.name}</span><strong>{a.value} {a.unit}</strong></div>)}</section>}
|
||||||
<div
|
<ZoomableRichContent content={d.content} />
|
||||||
className="content"
|
|
||||||
dangerouslySetInnerHTML={{ __html: normalizeRichTextHtml(d.content) }}
|
|
||||||
/>
|
|
||||||
{d.specifications?.length > 0 && (
|
{d.specifications?.length > 0 && (
|
||||||
<section className="specs">
|
<section className="specs">
|
||||||
<h2>Technical specifications</h2>
|
<h2>Technical specifications</h2>
|
||||||
@@ -698,7 +710,7 @@ function ProductDetailView({ data: d, configuration }: { data: Record<string, an
|
|||||||
<button type="button" role="tab" aria-selected={activeProductTab === "SPECIFICATIONS"} className={activeProductTab === "SPECIFICATIONS" ? "active" : ""} onClick={() => setActiveProductTab("SPECIFICATIONS")}>Specifications</button>
|
<button type="button" role="tab" aria-selected={activeProductTab === "SPECIFICATIONS"} className={activeProductTab === "SPECIFICATIONS" ? "active" : ""} onClick={() => setActiveProductTab("SPECIFICATIONS")}>Specifications</button>
|
||||||
</div>
|
</div>
|
||||||
{activeProductTab === "DETAILS" ? (
|
{activeProductTab === "DETAILS" ? (
|
||||||
<div className="content product-content" role="tabpanel" dangerouslySetInnerHTML={{__html:normalizeRichTextHtml(d.content)}}/>
|
<ZoomableRichContent content={d.content} className="content product-content" />
|
||||||
) : (
|
) : (
|
||||||
<div className="product-specification-panel" role="tabpanel">
|
<div className="product-specification-panel" role="tabpanel">
|
||||||
{specifications.length > 0 ? specifications.map((spec:any,index:number)=><div className="product-specification-row" key={`${spec.groupName}-${spec.name}-${index}`}><span>{spec.groupName || "General"}</span><strong>{spec.name}</strong><em>{spec.value} {spec.unit}</em></div>) : <p className="product-tab-empty">Specifications are being prepared.</p>}
|
{specifications.length > 0 ? specifications.map((spec:any,index:number)=><div className="product-specification-row" key={`${spec.groupName}-${spec.name}-${index}`}><span>{spec.groupName || "General"}</span><strong>{spec.name}</strong><em>{spec.value} {spec.unit}</em></div>) : <p className="product-tab-empty">Specifications are being prepared.</p>}
|
||||||
@@ -794,10 +806,7 @@ function ConfiguredPage({ slug }: { slug: string }) {
|
|||||||
<p className="eyebrow">{agreementPage ? "LEGAL INFORMATION" : "COMPANY INFORMATION"}</p>
|
<p className="eyebrow">{agreementPage ? "LEGAL INFORMATION" : "COMPANY INFORMATION"}</p>
|
||||||
<h1>{data.pageName}</h1>
|
<h1>{data.pageName}</h1>
|
||||||
{data.summary && <p className="lead">{data.summary}</p>}
|
{data.summary && <p className="lead">{data.summary}</p>}
|
||||||
<div
|
<ZoomableRichContent content={data.content} />
|
||||||
className="content"
|
|
||||||
dangerouslySetInnerHTML={{ __html: normalizeRichTextHtml(data.content) }}
|
|
||||||
/>
|
|
||||||
</article>
|
</article>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -472,3 +472,4 @@ footer small {
|
|||||||
/* 商详页详情与规格标签 */
|
/* 商详页详情与规格标签 */
|
||||||
.product-tab-list button{font-family:inherit;font-size:17px;font-weight:600}
|
.product-tab-list button{font-family:inherit;font-size:17px;font-weight:600}
|
||||||
@media(max-width:760px){.product-content{margin-top:0}.product-specification-row{grid-template-columns:1fr 1.4fr;gap:8px 16px}.product-specification-row em{grid-column:2}}
|
@media(max-width:760px){.product-content{margin-top:0}.product-specification-row{grid-template-columns:1fr 1.4fr;gap:8px 16px}.product-specification-row em{grid-column:2}}
|
||||||
|
.content img{cursor:zoom-in}
|
||||||
Reference in new issue
Block a user