diff --git a/site/src/main/java/com/shoplix/site/facade/SiteContentFacade.java b/site/src/main/java/com/shoplix/site/facade/SiteContentFacade.java index e02ecb3..02d0786 100644 --- a/site/src/main/java/com/shoplix/site/facade/SiteContentFacade.java +++ b/site/src/main/java/com/shoplix/site/facade/SiteContentFacade.java @@ -12,7 +12,9 @@ import org.springframework.stereotype.Component; public class SiteContentFacade { private final SiteContentService service; /** 注入内容业务。 */ public SiteContentFacade(SiteContentService service) { this.service = service; } - /** 查询内容列表。 */ public ContentListSiteRes list(ContentListSiteReq req) { return service.list(req.contentType().name(), req.categoryCode()); } + /** 查询内容列表。 */ public ContentListSiteRes list(ContentListSiteReq req) { + return service.list(req.contentType().name(), req.categoryCode(), req.pageNo(), req.pageSize()); + } /** 查询内容详情。 */ public ContentDetailSiteRes detail(ContentDetailSiteReq req) { return service.detail(req.contentType().name(), req.slug()); } } diff --git a/site/src/main/java/com/shoplix/site/facade/SiteProductFacade.java b/site/src/main/java/com/shoplix/site/facade/SiteProductFacade.java index 9eae217..e196d4f 100644 --- a/site/src/main/java/com/shoplix/site/facade/SiteProductFacade.java +++ b/site/src/main/java/com/shoplix/site/facade/SiteProductFacade.java @@ -13,7 +13,9 @@ import org.springframework.stereotype.Component; public class SiteProductFacade { private final SiteProductService service; /** 注入产品业务。 */ public SiteProductFacade(SiteProductService service) { this.service = service; } - /** 查询产品列表。 */ public ProductListSiteRes list(ProductListSiteReq req) { return service.list(req.categoryCode()); } + /** 查询产品列表。 */ public ProductListSiteRes list(ProductListSiteReq req) { + return service.list(req.categoryCode(), req.pageNo(), req.pageSize()); + } /** 查询产品分类列表。 */ public ProductCategoryListSiteRes categories() { return service.categories(); } /** 查询产品详情。 */ public ProductDetailSiteRes detail(SlugDetailSiteReq req) { return service.detail(req.slug()); } } diff --git a/site/src/main/java/com/shoplix/site/modules/content/req/ContentListSiteReq.java b/site/src/main/java/com/shoplix/site/modules/content/req/ContentListSiteReq.java index 86166ba..ae2e66a 100644 --- a/site/src/main/java/com/shoplix/site/modules/content/req/ContentListSiteReq.java +++ b/site/src/main/java/com/shoplix/site/modules/content/req/ContentListSiteReq.java @@ -1,12 +1,16 @@ package com.shoplix.site.modules.content.req; import com.shoplix.modules.content.enums.ContentTypeEnum; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; /** 前台站内容列表请求。 */ public record ContentListSiteReq( /** 内容类型。 */ @NotNull ContentTypeEnum contentType, - /** 分类业务编号,为空时查询全部分类。 */ @Size(max = 16) String categoryCode) { + /** 分类业务编号,为空时查询全部分类。 */ @Size(max = 16) String categoryCode, + /** 页码,从 1 开始;为空时使用第 1 页。 */ @Min(1) Integer pageNo, + /** 每页数量;为空时使用 12 条。 */ @Min(1) @Max(100) Integer pageSize) { } diff --git a/site/src/main/java/com/shoplix/site/modules/content/res/ContentListSiteRes.java b/site/src/main/java/com/shoplix/site/modules/content/res/ContentListSiteRes.java index b3da1c1..111d119 100644 --- a/site/src/main/java/com/shoplix/site/modules/content/res/ContentListSiteRes.java +++ b/site/src/main/java/com/shoplix/site/modules/content/res/ContentListSiteRes.java @@ -3,6 +3,11 @@ package com.shoplix.site.modules.content.res; import java.util.List; /** 前台站内容列表响应。 */ -public record ContentListSiteRes(List items) { +public record ContentListSiteRes( + /** 当前页内容。 */ List items, + /** 内容总数。 */ long total, + /** 当前页码。 */ int pageNo, + /** 每页数量。 */ int pageSize, + /** 总页数。 */ int totalPages) { } diff --git a/site/src/main/java/com/shoplix/site/modules/product/req/ProductListSiteReq.java b/site/src/main/java/com/shoplix/site/modules/product/req/ProductListSiteReq.java index 0965a93..66b94a4 100644 --- a/site/src/main/java/com/shoplix/site/modules/product/req/ProductListSiteReq.java +++ b/site/src/main/java/com/shoplix/site/modules/product/req/ProductListSiteReq.java @@ -1,8 +1,13 @@ package com.shoplix.site.modules.product.req; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; import jakarta.validation.constraints.Size; /** 前台站产品列表请求。 */ -public record ProductListSiteReq(@Size(max = 16) String categoryCode) { +public record ProductListSiteReq( + /** 产品分类业务编号,为空时查询全部分类。 */ @Size(max = 16) String categoryCode, + /** 页码,从 1 开始;为空时使用第 1 页。 */ @Min(1) Integer pageNo, + /** 每页数量;为空时使用 12 条。 */ @Min(1) @Max(100) Integer pageSize) { } diff --git a/site/src/main/java/com/shoplix/site/modules/product/res/ProductListSiteRes.java b/site/src/main/java/com/shoplix/site/modules/product/res/ProductListSiteRes.java index 3512171..7b701eb 100644 --- a/site/src/main/java/com/shoplix/site/modules/product/res/ProductListSiteRes.java +++ b/site/src/main/java/com/shoplix/site/modules/product/res/ProductListSiteRes.java @@ -3,6 +3,11 @@ package com.shoplix.site.modules.product.res; import java.util.List; /** 前台站产品列表响应。 */ -public record ProductListSiteRes(List items) { +public record ProductListSiteRes( + /** 当前页产品。 */ List items, + /** 产品总数。 */ long total, + /** 当前页码。 */ int pageNo, + /** 每页数量。 */ int pageSize, + /** 总页数。 */ int totalPages) { } diff --git a/site/src/main/java/com/shoplix/site/service/SiteContentService.java b/site/src/main/java/com/shoplix/site/service/SiteContentService.java index 2432185..0983190 100644 --- a/site/src/main/java/com/shoplix/site/service/SiteContentService.java +++ b/site/src/main/java/com/shoplix/site/service/SiteContentService.java @@ -20,11 +20,17 @@ public class SiteContentService { this.repository = repository; this.mediaRepository = mediaRepository; } /** 查询当前站点指定类型已发布内容。 */ - public ContentListSiteRes list(String type, String categoryCode) { - List items = repository.listPublished(SiteContextHolder.getRequired().siteCode(), type, categoryCode).stream() + public ContentListSiteRes list(String type, String categoryCode, Integer requestedPageNo, Integer requestedPageSize) { + List contents = repository.listPublished(SiteContextHolder.getRequired().siteCode(), type, categoryCode); + int pageNo = requestedPageNo == null ? 1 : requestedPageNo; + int pageSize = requestedPageSize == null ? 12 : requestedPageSize; + int totalPages = contents.isEmpty() ? 0 : (contents.size() + pageSize - 1) / pageSize; + int fromIndex = Math.min((pageNo - 1) * pageSize, contents.size()); + int toIndex = Math.min(fromIndex + pageSize, contents.size()); + List items = contents.subList(fromIndex, toIndex).stream() .map(item -> new ContentItemSiteRes(item.getContentCode(), item.getContentType(), item.getTitle(), item.getSlug(), item.getSummary(), item.getCoverMediaCode(), resolveMediaUrl(item), item.getPublishTime())).toList(); - return new ContentListSiteRes(items); + return new ContentListSiteRes(items, contents.size(), pageNo, pageSize, totalPages); } /** 查询当前站点指定类型内容详情。 */ public ContentDetailSiteRes detail(String type, String slug) { diff --git a/site/src/main/java/com/shoplix/site/service/SiteProductService.java b/site/src/main/java/com/shoplix/site/service/SiteProductService.java index 886ff2e..33c3577 100644 --- a/site/src/main/java/com/shoplix/site/service/SiteProductService.java +++ b/site/src/main/java/com/shoplix/site/service/SiteProductService.java @@ -46,16 +46,21 @@ public class SiteProductService { this.templateRepository = templateRepository; } /** 查询当前站点已发布产品。 */ - public ProductListSiteRes list(String categoryCode) { + public ProductListSiteRes list(String categoryCode, Integer requestedPageNo, Integer requestedPageSize) { String siteCode = SiteContextHolder.getRequired().siteCode(); List products = categoryCode == null || categoryCode.isBlank() ? repository.listPublished(siteCode, null) : repository.listPublishedByCategories(siteCode, resolveCategoryCodes(siteCode, categoryCode)); - List items = products.stream() + int pageNo = requestedPageNo == null ? 1 : requestedPageNo; + int pageSize = requestedPageSize == null ? 12 : requestedPageSize; + int totalPages = products.isEmpty() ? 0 : (products.size() + pageSize - 1) / pageSize; + int fromIndex = Math.min((pageNo - 1) * pageSize, products.size()); + int toIndex = Math.min(fromIndex + pageSize, products.size()); + List items = products.subList(fromIndex, toIndex).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(); - return new ProductListSiteRes(items); + return new ProductListSiteRes(items, products.size(), pageNo, pageSize, totalPages); } /** 查询当前站点已发布产品分类。 */ diff --git a/site/src/test/java/com/shoplix/site/facade/SiteContentFacadeTest.java b/site/src/test/java/com/shoplix/site/facade/SiteContentFacadeTest.java index 0cd84fc..3117cf5 100644 --- a/site/src/test/java/com/shoplix/site/facade/SiteContentFacadeTest.java +++ b/site/src/test/java/com/shoplix/site/facade/SiteContentFacadeTest.java @@ -23,13 +23,13 @@ class SiteContentFacadeTest { /** 内容列表查询应将类型和分类编号完整传递给业务服务。 */ @Test void passesCategoryCodeToContentService() { - ContentListSiteRes expected = new ContentListSiteRes(List.of()); - when(service.list("NEWS", "CCT0000000000001")).thenReturn(expected); + ContentListSiteRes expected = new ContentListSiteRes(List.of(), 0, 1, 12, 0); + when(service.list("NEWS", "CCT0000000000001", 1, 12)).thenReturn(expected); SiteContentFacade facade = new SiteContentFacade(service); - ContentListSiteRes actual = facade.list(new ContentListSiteReq(ContentTypeEnum.NEWS, "CCT0000000000001")); + ContentListSiteRes actual = facade.list(new ContentListSiteReq(ContentTypeEnum.NEWS, "CCT0000000000001", 1, 12)); assertSame(expected, actual); - verify(service).list("NEWS", "CCT0000000000001"); + verify(service).list("NEWS", "CCT0000000000001", 1, 12); } } diff --git a/site/src/test/java/com/shoplix/site/service/SiteProductServiceTest.java b/site/src/test/java/com/shoplix/site/service/SiteProductServiceTest.java index 5f90959..b231a6a 100644 --- a/site/src/test/java/com/shoplix/site/service/SiteProductServiceTest.java +++ b/site/src/test/java/com/shoplix/site/service/SiteProductServiceTest.java @@ -72,7 +72,7 @@ class SiteProductServiceTest { when(productRepository.listPublished(SITE_CODE, null)).thenReturn(List.of(product)); when(mediaRepository.find(SITE_CODE, "MED001")).thenReturn(Optional.of(media)); - var response = service.list(null); + var response = service.list(null, 1, 12); assertThat(response.items()).singleElement() .extracting(item -> item.coverMediaUrl()) @@ -91,7 +91,7 @@ class SiteProductServiceTest { argThat(codes -> codes.containsAll(List.of("CAT001", "CAT002", "CAT003"))))) .thenReturn(List.of()); - service.list("CAT001"); + service.list("CAT001", 1, 12); org.mockito.Mockito.verify(productRepository).listPublishedByCategories( org.mockito.ArgumentMatchers.eq(SITE_CODE), diff --git a/tmp/admin-cookie-1688.txt b/tmp/admin-cookie-1688.txt deleted file mode 100644 index 8237139..0000000 --- a/tmp/admin-cookie-1688.txt +++ /dev/null @@ -1,5 +0,0 @@ -# Netscape HTTP Cookie File -# https://curl.se/docs/http-cookies.html -# This file was generated by libcurl! Edit at your own risk. - -#HttpOnly_localhost FALSE / FALSE 1798635247 JSESSIONID 4A716E18A919595B44857D86E4405795 diff --git a/tmp/admin-cookie-merge.txt b/tmp/admin-cookie-merge.txt deleted file mode 100644 index f2af4a5..0000000 --- a/tmp/admin-cookie-merge.txt +++ /dev/null @@ -1,5 +0,0 @@ -# Netscape HTTP Cookie File -# https://curl.se/docs/http-cookies.html -# This file was generated by libcurl! Edit at your own risk. - -#HttpOnly_localhost FALSE / FALSE 1798637756 JSESSIONID BC5A5CE6FA39A57BF6703B6FDF64BA53 diff --git a/tmp/admin-cookie.txt b/tmp/admin-cookie.txt deleted file mode 100644 index e9aee68..0000000 --- a/tmp/admin-cookie.txt +++ /dev/null @@ -1,5 +0,0 @@ -# Netscape HTTP Cookie File -# https://curl.se/docs/http-cookies.html -# This file was generated by libcurl! Edit at your own risk. - -#HttpOnly_localhost FALSE / FALSE 1798630810 JSESSIONID 2CDAD74E39F8A0ACF8A2173966647DC8 diff --git a/tmp/merge-nylon-brush-wheel.ps1 b/tmp/merge-nylon-brush-wheel.ps1 deleted file mode 100644 index 20d1756..0000000 --- a/tmp/merge-nylon-brush-wheel.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -# 合并尼龙刷轮的三个套件型号,并删除重复产品记录。 -$login = @{ username = 'admin'; password = 'Shoplix@2026' } | ConvertTo-Json -Invoke-RestMethod -Method Post -Uri 'http://localhost:8081/api/admin/v1/auth/login' -ContentType 'application/json' -Body $login -SessionVariable adminSession | Out-Null - -$productContent = @' -

Nylon Brush Wheel Kit Overview

-

This nylon brush wheel kit is available with three adapter and fixing kit options: HY-047, HY-048 and HY-049. It is designed for garden maintenance, brush cutter accessory sourcing and replacement-part distribution.

-

Available Kit Options

-
  • HY-047: Nylon brush wheel with 8-piece adapter kit.
  • HY-048: Nylon brush wheel with 4-piece fixing kit.
  • HY-049: Nylon brush wheel with Stihl-style 4-piece kit.
-

Ordering Information

-

Please confirm the required kit option, machine compatibility, mounting dimensions, quantity, packaging and branding requirements before ordering. OEM and wholesale inquiries are welcome.

-'@ - -$saveBody = @{ - productCode = 'PRD0089E12MHRYF4' - siteCode = 'SIT0000000000001' - primaryCategoryCode = 'PCT0089DGXVJZDVK' - productName = 'Nylon Brush Wheel Kit' - slug = 'nylon-brush-wheel-kit' - model = 'HY-047 / HY-048 / HY-049' - summary = 'Nylon brush wheel supplied with three adapter and fixing kit options for garden maintenance and brush cutter accessory sourcing.' - productContent = $productContent - contentTemplateCode = '' - templatePosition = 'AFTER' - coverMediaCode = 'MED0089DZO2RZW1S' - images = @( - @{ mediaCode = 'MED0089DZO2RZW1S'; sortNo = 0 }, - @{ mediaCode = 'MED0089DZO5MDQ80'; sortNo = 1 }, - @{ mediaCode = 'MED0089DZO8EW54W'; sortNo = 2 } - ) - featured = $false - inquiryEnabled = $true - sortNo = 47 - status = 'PUBLISHED' - attributes = @( - @{ attributeCode = 'PAT0083ZKZ1VM3UO'; attributeName = 'Model'; value = 'HY-047 / HY-048 / HY-049'; unit = ''; sortNo = 1 }, - @{ attributeCode = 'PAT0089C84SCSJY8'; attributeName = 'Product Type'; value = 'Nylon Brush Wheel Kit'; unit = ''; sortNo = 2 }, - @{ attributeCode = 'PAT0089C84W1RNCW'; attributeName = 'Color'; value = 'Orange'; unit = ''; sortNo = 3 }, - @{ attributeCode = 'PAT0083ZKZ1XHJ40'; attributeName = 'Material'; value = 'Nylon / Metal'; unit = ''; sortNo = 4 }, - @{ attributeCode = $null; attributeName = 'Kit Options'; value = '8-Piece Adapter Kit; 4-Piece Fixing Kit; Stihl-Style 4-Piece Kit'; unit = ''; sortNo = 5 } - ) - specifications = @( - @{ groupName = 'Kit Options'; name = 'HY-047'; value = '8-Piece Adapter Kit'; unit = ''; sortNo = 1 }, - @{ groupName = 'Kit Options'; name = 'HY-048'; value = '4-Piece Fixing Kit'; unit = ''; sortNo = 2 }, - @{ groupName = 'Kit Options'; name = 'HY-049'; value = 'Stihl-Style 4-Piece Kit'; unit = ''; sortNo = 3 }, - @{ groupName = 'Material'; name = 'Primary Material'; value = 'Nylon / Metal'; unit = ''; sortNo = 4 }, - @{ groupName = 'Appearance'; name = 'Color'; value = 'Orange'; unit = ''; sortNo = 5 } - ) -} | ConvertTo-Json -Depth 10 - -$saved = Invoke-RestMethod -Method Post -Uri 'http://localhost:8081/api/admin/v1/products/save' -ContentType 'application/json' -Body $saveBody -WebSession $adminSession -if ($saved.productCode -ne 'PRD0089E12MHRYF4') { - throw '合并后的产品保存失败,未删除原产品。' -} -foreach ($productCode in @('PRD0089E13JUANLS', 'PRD0089E14JAZ9C0')) { - $deleteBody = @{ siteCode = 'SIT0000000000001'; productCode = $productCode } | ConvertTo-Json - Invoke-RestMethod -Method Post -Uri 'http://localhost:8081/api/admin/v1/products/delete' -ContentType 'application/json' -Body $deleteBody -WebSession $adminSession | Out-Null -} -Write-Output $saved.productCode diff --git a/tmp/publish-localized-decorations.ps1 b/tmp/publish-localized-decorations.ps1 deleted file mode 100644 index 9100bd5..0000000 --- a/tmp/publish-localized-decorations.ps1 +++ /dev/null @@ -1,87 +0,0 @@ -# 将厂家英文素材发布到首页和关于我们页面。 -$loginBody = @{ username = 'admin'; password = 'Shoplix@2026' } | ConvertTo-Json -Invoke-RestMethod -Method Post -Uri 'http://localhost:8081/api/admin/v1/auth/login' -ContentType 'application/json' -Body $loginBody -SessionVariable adminSession | Out-Null - -function New-Section { - param( - [string]$Id, - [string]$Type, - [string]$Title, - [string]$Subtitle = '', - [string]$ImageUrl = '', - [string]$VideoUrl = '', - [string]$Background = '#ffffff', - [string]$TextColor = '#17211f', - [string]$ButtonText = '', - [string]$ButtonUrl = '', - [string]$SourceType = '', - [int]$Limit = 3, - [string]$HeroHeight = '80' - ) - return [ordered]@{ - id = $Id; type = $Type; title = $Title; subtitle = $Subtitle - imageUrl = $ImageUrl; imageUrls = @(); videoUrl = $VideoUrl; heroHeight = $HeroHeight - buttonText = $ButtonText; buttonUrl = $ButtonUrl; sourceType = $SourceType; limit = $Limit - visible = $true; background = $Background; textColor = $TextColor - showProductInformation = $true; productInformationTitle = 'Product information'; productInformationLimit = 8 - } -} - -function Save-And-Publish { - param([string]$PageType, [object]$Schema) - $schemaJson = $Schema | ConvertTo-Json -Depth 12 -Compress - $saveBody = @{ siteCode = 'SIT0000000000001'; pageType = $PageType; schema = $schemaJson } | ConvertTo-Json -Compress - Invoke-RestMethod -Method Post -Uri 'http://localhost:8081/api/admin/v1/decorations/save' -ContentType 'application/json' -Body $saveBody -WebSession $adminSession | Out-Null - $publishBody = @{ siteCode = 'SIT0000000000001'; pageType = $PageType } | ConvertTo-Json -Compress - Invoke-RestMethod -Method Post -Uri 'http://localhost:8081/api/admin/v1/decorations/publish' -ContentType 'application/json' -Body $publishBody -WebSession $adminSession | Out-Null -} - -$heroUrl = 'https://oss-api.steliro.com/shoplix-test/media/SIT0000000000001/2026/11/37af4f25c31f462b8429884af30d14d3.jpg' -$factoryUrl = 'https://oss-api.steliro.com/shoplix-test/media/SIT0000000000001/2026/11/7a75f01f4f6048bf9666fd9b48b60f72.jpg' -$marketsUrl = 'https://oss-api.steliro.com/shoplix-test/media/SIT0000000000001/2026/11/1200c08946744254a4c1577bcadd691b.jpg' -$strengthsUrl = 'https://oss-api.steliro.com/shoplix-test/media/SIT0000000000001/2026/11/7416eaa60400423db8b2700ec4f40650.jpg' -$workflowUrl = 'https://oss-api.steliro.com/shoplix-test/media/SIT0000000000001/2026/11/bf41428561e24bb2834b4aa6a8879f35.jpg' -$aboutUrl = 'https://oss-api.steliro.com/shoplix-test/media/SIT0000000000001/2026/11/ce6c0f6323244fde8ad2cb4c7067007b.jpg' -$videoUrl = 'https://oss-api.steliro.com/shoplix-test/media/SIT0000000000001/2026/11/ef0ffeeb4c79420ea80927f78f7af840.mp4' - -$homeDetailBody = @{ siteCode = 'SIT0000000000001'; pageType = 'HOME' } | ConvertTo-Json -$homeDetail = Invoke-RestMethod -Method Post -Uri 'http://localhost:8081/api/admin/v1/decorations/detail' -ContentType 'application/json' -Body $homeDetailBody -WebSession $adminSession -$homeSchema = $homeDetail.schema | ConvertFrom-Json -$homeSchema.sections = @($homeSchema.sections | Where-Object { $_.id -notin @('factory-home-en', 'strengths-home-en', 'workflow-home-en') }) -$hero = $homeSchema.sections | Where-Object { $_.type -eq 'HERO' } | Select-Object -First 1 -$hero.imageUrl = $heroUrl -$hero.imageUrls = @($heroUrl) -$hero.title = 'Reliable Trimmer Heads for Global Buyers' -$hero.subtitle = 'Factory-direct garden tool parts, flexible OEM/ODM service and dependable quality for wholesalers, distributors and brands.' -$hero.buttonText = 'Explore Products' - -$productIndex = [Array]::IndexOf($homeSchema.sections, ($homeSchema.sections | Where-Object { $_.type -eq 'PRODUCTS' } | Select-Object -First 1)) -$beforeProducts = @($homeSchema.sections[0..$productIndex]) -$afterProducts = @($homeSchema.sections[($productIndex + 1)..($homeSchema.sections.Count - 1)]) -$homeSchema.sections = @( - $beforeProducts - (New-Section -Id 'strengths-home-en' -Type 'RICH_TEXT' -Title 'Manufacturing Strength for Stable Supply' -Subtitle 'Focused production experience, a skilled team and scalable daily capacity support repeat orders and long-term sourcing programs.' -ImageUrl $strengthsUrl -Background '#f2f7f5') - (New-Section -Id 'factory-home-en' -Type 'RICH_TEXT' -Title 'Inside Our Production & Warehousing' -Subtitle 'From precision machining and material preparation to finished goods storage, our facilities support an organized and traceable workflow.' -ImageUrl $factoryUrl) - (New-Section -Id 'workflow-home-en' -Type 'RICH_TEXT' -Title 'A Clear OEM & ODM Workflow' -Subtitle 'We coordinate requirement review, sample development, materials, production, quality inspection and export packing.' -ImageUrl $workflowUrl -Background '#f7f9f8') - $afterProducts -) -Save-And-Publish -PageType 'HOME' -Schema $homeSchema - -$about = [ordered]@{ - global = [ordered]@{ primaryColor = '#176b5d'; backgroundColor = '#ffffff'; textColor = '#17211f'; fontFamily = 'Inter'; contentWidth = 1200 } - sections = @( - (New-Section -Id 'about-header' -Type 'HEADER' -Title 'TRIMMER HEAD SOURCING') - (New-Section -Id 'about-hero' -Type 'HERO' -Title 'A Specialized Partner for Garden Tool Components' -Subtitle 'Yongkang Hongyu combines product development, manufacturing and export support for trimmer heads, trimmer line and related accessories.' -ImageUrl $aboutUrl -ButtonText 'Request a Quote' -ButtonUrl '/contact-us' -Background '#17342e' -TextColor '#ffffff' -HeroHeight '50') - (New-Section -Id 'about-company' -Type 'RICH_TEXT' -Title 'Built for Consistent B2B Supply' -Subtitle 'Our team manages machining, assembly, warehousing and final inspection to support consistent OEM and wholesale orders for buyers across multiple regions.' -ImageUrl $aboutUrl -Background '#f4f7f6') - (New-Section -Id 'about-factory' -Type 'RICH_TEXT' -Title 'Manufacturing & Warehousing' -Subtitle 'Dedicated production areas and organized storage help us maintain stable lead times, product consistency and order traceability.' -ImageUrl $factoryUrl) - (New-Section -Id 'about-strengths' -Type 'RICH_TEXT' -Title 'Capabilities at a Glance' -Subtitle 'Focused industry experience, extensive product options, a skilled production team and scalable daily output.' -ImageUrl $strengthsUrl -Background '#f2f7f5') - (New-Section -Id 'about-workflow' -Type 'RICH_TEXT' -Title 'OEM & ODM from Requirement to Shipment' -Subtitle 'A practical six-step workflow keeps custom projects clear and manageable from initial review through export packing.' -ImageUrl $workflowUrl) - (New-Section -Id 'about-video' -Type 'VIDEO' -Title 'Take a Short Tour of Our Factory' -Subtitle 'Meet our team and learn about our production, capacity and quality approach through an English-narrated factory introduction.' -VideoUrl $videoUrl -Background '#edf5f2') - (New-Section -Id 'about-markets' -Type 'RICH_TEXT' -Title 'Supporting Buyers in Global Markets' -Subtitle 'We work with distributors, wholesalers and garden tool brands across Europe, Asia, the Americas and other international markets.' -ImageUrl $marketsUrl) - (New-Section -Id 'about-inquiry' -Type 'INQUIRY' -Title 'Discuss Your Garden Tool Parts Project' -Subtitle 'Tell us your target models, quantities, market requirements or customization needs. Our team will respond with product and sourcing guidance.' -Background '#e7efec') - (New-Section -Id 'about-footer' -Type 'FOOTER' -Title 'TRIMMER HEAD SOURCING' -Subtitle 'Garden Tool Parts & Accessories' -Background '#101a25' -TextColor '#ffffff') - ) -} -Save-And-Publish -PageType 'ABOUT_US' -Schema $about - -Write-Output 'HOME_AND_ABOUT_PUBLISHED' diff --git a/web-site/src/main.tsx b/web-site/src/main.tsx index 4ffc5b1..aa546e8 100644 --- a/web-site/src/main.tsx +++ b/web-site/src/main.tsx @@ -376,7 +376,7 @@ function LiveHeader({ section, style }: { section: DecorationSection; style: Rea } function LiveCollection({section}:{section:DecorationSection}) { const [items,setItems]=useState([]); - useEffect(()=>{const path=section.type==="PRODUCTS"?"/products/list":"/contents/list";const body=section.type==="PRODUCTS"?{}:{contentType:section.sourceType||"CASE"};post(path,body).then(data=>setItems((data.items||[]).slice(0,section.limit||3))).catch(()=>setItems([]))},[section.type,section.sourceType,section.limit]); + useEffect(()=>{const path=section.type==="PRODUCTS"?"/products/list":"/contents/list";const body=section.type==="PRODUCTS"?{pageNo:1,pageSize:section.limit||3}:{contentType:section.sourceType||"CASE",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(); return

FEATURED

{section.title}

; } @@ -496,6 +496,8 @@ function Collection({ const productCategories = useProductCategoryTree(); const [data, setData] = useState>([]); const [error, setError] = useState(""); + const [pageNo, setPageNo] = useState(() => Math.max(1, Number(new URLSearchParams(location.search).get("page")) || 1)); + const [totalPages, setTotalPages] = useState(0); useEffect(() => { const run = async () => { try { @@ -509,16 +511,19 @@ function Collection({ } else { const x = await post( type === "products" ? "/products/list" : "/contents/list", - type === "products" ? { categoryCode } : { contentType: type, categoryCode }, + type === "products" + ? { categoryCode, pageNo, pageSize: 12 } + : { contentType: type, categoryCode, pageNo, pageSize: 12 }, ); setData(x.items || []); + setTotalPages(x.totalPages || 0); } } catch (e) { setError(e instanceof Error ? e.message : "Unable to load"); } }; void run(); - }, [type, slug, categoryCode]); + }, [type, slug, categoryCode, pageNo]); if (error) return ; if (slug && !Array.isArray(data)) { const d = data as Record; @@ -608,6 +613,13 @@ function Collection({ ))} + {totalPages > 1 && ( + + )} ); } @@ -630,8 +642,8 @@ function SearchResults({ query }: { query: string }) { if (!keyword) { setResults([]); setLoading(false); return; } setLoading(true); Promise.all([ - post("/products/list", {}).then((data) => ({ items: data.items || [], base: "products", label: "Product" })), - ...(["NEWS", "CASE", "HELP"] as ContentType[]).map((contentType) => post("/contents/list", { contentType }).then((data) => ({ items: data.items || [], base: contentType.toLowerCase(), label: contentType === "CASE" ? "Case" : contentType.charAt(0) + contentType.slice(1).toLowerCase() }))), + post("/products/list", { pageNo: 1, pageSize: 100 }).then((data) => ({ items: data.items || [], base: "products", label: "Product" })), + ...(["NEWS", "CASE", "HELP"] as ContentType[]).map((contentType) => post("/contents/list", { contentType, pageNo: 1, pageSize: 100 }).then((data) => ({ items: data.items || [], base: contentType.toLowerCase(), label: contentType === "CASE" ? "Case" : contentType.charAt(0) + contentType.slice(1).toLowerCase() }))), ]).then((groups) => { 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))); diff --git a/web-site/src/styles.css b/web-site/src/styles.css index d7849e2..93ebbea 100644 --- a/web-site/src/styles.css +++ b/web-site/src/styles.css @@ -528,6 +528,35 @@ nav a:hover { .collection-layout .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } + +.site-pagination { + align-items: center; + display: flex; + gap: 18px; + justify-content: center; + margin: 42px 0 0; +} + +.site-pagination button { + background: #0d6d5e; + border: 1px solid #0d6d5e; + color: #fff; + cursor: pointer; + min-width: 104px; + padding: 11px 18px; +} + +.site-pagination button:disabled { + background: #edf1ef; + border-color: #d9e0dd; + color: #8c9893; + cursor: not-allowed; +} + +.site-pagination span { + color: #53615c; + font-size: 14px; +} .category-sidebar { position: sticky; top: 106px;