diff --git a/apps/miniapp/styles/tokens.wxss b/apps/miniapp/styles/tokens.wxss index 5ab962f..2660ce4 100644 --- a/apps/miniapp/styles/tokens.wxss +++ b/apps/miniapp/styles/tokens.wxss @@ -1,14 +1,15 @@ /* 个人品牌 Design Tokens;行业模板只提供内容,不覆盖这些基础视觉变量。 */ page { - --brand-color-bg: #fbf7f1; + --brand-color-bg: #f7f5f1; --brand-color-surface: #ffffff; - --brand-color-subtle: #f4ebd9; - --brand-color-primary: #b54a2c; - --brand-color-primary-dark: #913a23; - --brand-color-text: #2b2b2b; - --brand-color-muted: #7a4a2b; - --brand-color-accent: #e8a75f; + --brand-color-subtle: #f7f5f1; + --brand-color-primary: #8a6846; + --brand-color-primary-dark: #202221; + --brand-color-text: #252525; + --brand-color-muted: #77736b; + --brand-color-accent: #d9c8b2; + --brand-color-border: #e6ded5; --brand-radius-card: 16rpx; - --brand-radius-control: 12rpx; + --brand-radius-control: 8rpx; --brand-space-page: 32rpx; } diff --git a/apps/miniapp/utils/module-registry.js b/apps/miniapp/utils/module-registry.js new file mode 100644 index 0000000..4aea266 --- /dev/null +++ b/apps/miniapp/utils/module-registry.js @@ -0,0 +1,28 @@ +const CORE_MODULES = { + brandHero: { key: "brand-hero", variants: ["architectural", "portrait", "editorial"] }, + founderCard: { key: "founder-card", variants: ["compact", "contact"] }, + trustProof: { key: "trust-proof", variants: ["stats", "manifesto", "timeline"] }, + offeringList: { key: "offering-list", variants: ["image-first", "editorial", "square-card"] }, + offeringDetail: { key: "offering-detail", variants: ["project-case", "product-spec", "service-process"] }, + inquiry: { key: "inquiry", variants: ["standard", "project-brief", "booking"] }, + records: { key: "records", variants: ["timeline", "list"] }, + profile: { key: "profile", variants: ["contact", "editorial"] }, +}; + +const FALLBACK_THEME = { + colors: { background: "#F7F5F1", surface: "#FFFFFF", foreground: "#252525", muted: "#77736B", accent: "#8A6846", dark: "#202221", border: "#E6DED5" }, + radius: { card: "16rpx", control: "8rpx" }, + spacing: { page: "32rpx", section: "28rpx" }, +}; + +function resolveModule(module) { + const known = Object.values(CORE_MODULES).find((entry) => entry.key === module.type); + return { ...module, variant: module.variant || (known ? known.variants[0] : "default"), supported: Boolean(known || module.type === "custom") }; +} + +function resolveRuntime(workspace) { + const modules = Array.isArray(workspace && workspace.modules) ? workspace.modules : []; + return { theme: workspace && workspace.theme ? workspace.theme : FALLBACK_THEME, modules: modules.map(resolveModule), capabilities: workspace && Array.isArray(workspace.capabilities) ? workspace.capabilities : [] }; +} + +module.exports = { CORE_MODULES, FALLBACK_THEME, resolveRuntime }; diff --git a/apps/miniapp/utils/runtime-workspace.js b/apps/miniapp/utils/runtime-workspace.js index cbf0087..11b2032 100644 --- a/apps/miniapp/utils/runtime-workspace.js +++ b/apps/miniapp/utils/runtime-workspace.js @@ -1,5 +1,6 @@ const { request } = require("./request"); const fallback = require("./linjing-data"); +const { resolveRuntime } = require("./module-registry"); function toOffering(item) { const config = item && item.config && typeof item.config === "object" ? item.config : {}; @@ -21,7 +22,7 @@ function loadWorkspace() { const offerings = Array.isArray(workspace && workspace.offerings) ? workspace.offerings.map(toOffering) : fallback.offerings; - return { ...workspace, brand, offerings, trustContent: fallback.trustContent }; + return { ...workspace, ...resolveRuntime(workspace), brand, offerings, trustContent: fallback.trustContent }; }); } @@ -31,8 +32,9 @@ function loadWorkspaceWithFallback() { brand: fallback.brand, offerings: fallback.offerings, trustContent: fallback.trustContent, - modules: [], capabilities: [], + theme: resolveRuntime({}).theme, + modules: [], })); } diff --git a/docs/template-runtime-progress.md b/docs/template-runtime-progress.md index cbc25c6..e62c97f 100644 --- a/docs/template-runtime-progress.md +++ b/docs/template-runtime-progress.md @@ -31,6 +31,8 @@ ### 后续阶段 - [ ] Phase 2:标准模块库。 +- [x] 建立小程序核心模块注册表、变体清单和未知模块降级策略。 +- [x] 更新基础 Design Tokens 到林境门作视觉基线,后续主题通过 Runtime Workspace 覆盖。 - [ ] Phase 3:模板中心、安装快照、升级和回滚。 - [ ] Phase 4:Capability Plugin。 - [ ] Phase 5:林境门作与第二行业双模板验证。