Repository navigation
feat(storefront): serve landing product cards from the runtime catalog - #12
Merged
Merged
Conversation
Add GET /api/subscription/public/catalog (60s in-memory cache, priced module gate) exposing a trimmed StorefrontCatalogItem DTO with display_metadata carried on SubscriptionPlan; include listed plans and preview drafts, never cost fields. Validate display_metadata on the admin plan write path and invalidate the catalog cache with plan writes. Render the custom home page plan/pack/zone cards at runtime from the catalog via a shadow-root portal (LandingStorefront) instead of static HTML; purchases route to /checkout?product_id=..., preview or disabled items render a disabled button. Drop the staged purchase-catalog.json reader and cover the catalog contract with Go and web tests.
YunfanGoForIt
force-pushed
the
feat/storefront-catalog-20261021
branch
from
October 20, 2026 18:50
5323037 to
681afb0
Compare
Author
|
维护者评审通过(2026-10-21):公共目录 DTO 裁剪合规(成本/渠道字段不出边界)、preview 预告机制与 checkout 闸门正交、rebase 后 CI 5/5 绿。AI 辅助实现,维护者已核对。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
本 PR 由 AI 助手(Kimi Code)在维护者指挥下生成并验证,提交者
yunfan并非仓库历史核心开发者。描述为人工要求下的结构化整理。📝 变更描述 / Description
把词来首页(自定义 HomePageContent)的套餐 / 流量包 / 大肥鱼专区商品卡从「静态 HTML 烘焙」迁移到「运行时读取 DB 商品目录」。
后端
GET /api/subscription/public/catalog:复用 pricing 模块开关(HeaderNavModuleAuth("pricing"),默认匿名可达),返回精简StorefrontCatalogItemDTO(product_id/title/subtitle/price_amount/currency/duration/total_amount/category/sort_order/model_scope/enabled/preview/display_metadata),不含任何成本字段;进程内缓存 60s,与GetPricing同款 mutex+时间戳模式。listed = true或display_metadata.preview = true(坏 JSON 不提升草稿)。SubscriptionPlan新增display_metadata列(text);admin 写入路径校验其为 ≤16KiB 的 JSON 对象;InvalidateSubscriptionPlanCache级联失效目录缓存。前端(web/)
src/features/storefront/:LandingStorefront组件在自定义首页的 shadow root 中找到[data-storefront="plans|packs|zones"]挂载点,用 React Query(staleTime 60s)拉目录并createPortal渲染三类卡片(class 与 home.html 静态样式同名)。enabled && !preview:可购买 →<a href="/checkout?product_id=...">;preview/禁用 → disabled 按钮(文案取display_metadata.button_label,缺省 t('Not on sale yet'))。/branding/*.webp)。RichContent移到包裹 div,使 portal 内购买锚点的点击能冒泡到既有登录拦截逻辑。features/payment-display/lib/purchase-catalog.ts(读取已退役的/purchase-catalog.json)。配套运维改动(landing-page.json 退役静态商品段、迁移脚本、staging 清理)在姊妹仓库 iflink-token-platform 的同名分支 PR。
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
feat/storefront-catalog-20261021(draft)✅ 提交前检查项 / Checklist
📸 运行证明 / Proof of Work
新增 Go 测试
controller/subscription_storefront_catalog_test.go4 个用例:匿名可达且成本字段不泄露;preview 草稿收录 / 未 listed 且无 preview 排除 / 坏 metadata 排除;缓存 60s 内直写不可见、Invalidate 后可见;admin 写入拒绝坏 metadata。CI postgres-accounting 矩阵正则已追加TestStorefrontCatalog。新增 web 测试:
storefront-catalog.test.ts(6 个:防御解析、可购买判定、mount 分配、价格/有效期格式化、图片路径 sanitize)与landing-storefront.test.tsx(3 个:portal 渲染、购买锚点冒泡、preview 禁用态)。