diff --git a/apps/miniapp/pages/index/index.js b/apps/miniapp/pages/index/index.js index e3a34e4..19be8c4 100644 --- a/apps/miniapp/pages/index/index.js +++ b/apps/miniapp/pages/index/index.js @@ -1,8 +1,8 @@ const { brand, trustContent, offerings } = require("../../utils/linjing-data"); const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace"); Page({ - data: { brand, trustContent, offerings, loading: false }, - onLoad() { this.setData({ loading: true }); loadWorkspaceWithFallback().then((workspace) => { this.setData({ brand: workspace.brand, trustContent: workspace.trustContent || trustContent, offerings: workspace.offerings || offerings, loading: false }); wx.setNavigationBarTitle({ title: workspace.brand.name || brand.name }); }); }, + data: { brand, trustContent, offerings, modules: [], theme: {}, loading: false }, + onLoad() { this.setData({ loading: true }); loadWorkspaceWithFallback().then((workspace) => { this.setData({ brand: workspace.brand, trustContent: workspace.trustContent || trustContent, offerings: workspace.offerings || offerings, modules: workspace.modules || [], theme: workspace.theme || {}, loading: false }); wx.setNavigationBarTitle({ title: workspace.brand.name || brand.name }); }); }, selectOffering(e) { wx.navigateTo({ url: "/pages/offering/detail?id=" + e.currentTarget.dataset.id }); }, goWorks() { wx.switchTab({ url: "/pages/services/index" }); }, goInquiry() { wx.navigateTo({ url: "/pages/inquiry/index" }); }, diff --git a/apps/miniapp/pages/services/index.js b/apps/miniapp/pages/services/index.js index 96fb0f4..5389f6b 100644 --- a/apps/miniapp/pages/services/index.js +++ b/apps/miniapp/pages/services/index.js @@ -1,8 +1,8 @@ const { offerings } = require("../../utils/linjing-data"); const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace"); Page({ - data: { loading: false, error: "", offerings, filtered: offerings, category: "全部" }, - onLoad() { loadWorkspaceWithFallback().then((workspace) => { const items = workspace.offerings || offerings; this.setData({ offerings: items, filtered: items }); }); }, + data: { loading: false, error: "", offerings, filtered: offerings, modules: [], theme: {}, category: "全部" }, + onLoad() { loadWorkspaceWithFallback().then((workspace) => { const items = workspace.offerings || offerings; this.setData({ offerings: items, filtered: items, modules: workspace.modules || [], theme: workspace.theme || {} }); }); }, switchCategory(e) { const category = e.currentTarget.dataset.category; const items = this.data.offerings || offerings; this.setData({ category, filtered: category === "全部" ? items : items.filter((item) => item.category === category) }); }, open(e) { wx.navigateTo({ url: "/pages/offering/detail?id=" + e.currentTarget.dataset.id }); }, }); diff --git a/apps/miniapp/utils/module-registry.js b/apps/miniapp/utils/module-registry.js index 4aea266..dfb6747 100644 --- a/apps/miniapp/utils/module-registry.js +++ b/apps/miniapp/utils/module-registry.js @@ -16,8 +16,10 @@ const FALLBACK_THEME = { }; 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") }; + const aliases = { identity: "brand-hero", trust: "trust-proof", offering: "offering-list", inquiry: "inquiry", contact: "founder-card" }; + const type = aliases[module.type] || module.type; + const known = Object.values(CORE_MODULES).find((entry) => entry.key === type); + return { ...module, type, variant: module.variant || (known ? known.variants[0] : "default"), supported: Boolean(known || type === "custom") }; } function resolveRuntime(workspace) { diff --git a/docs/template-runtime-progress.md b/docs/template-runtime-progress.md index e62c97f..edc227f 100644 --- a/docs/template-runtime-progress.md +++ b/docs/template-runtime-progress.md @@ -32,6 +32,7 @@ - [ ] Phase 2:标准模块库。 - [x] 建立小程序核心模块注册表、变体清单和未知模块降级策略。 +- [x] 兼容旧模板模块 key,并将运行时模块状态注入首页和案例列表页面。 - [x] 更新基础 Design Tokens 到林境门作视觉基线,后续主题通过 Runtime Workspace 覆盖。 - [ ] Phase 3:模板中心、安装快照、升级和回滚。 - [ ] Phase 4:Capability Plugin。