chore: 统一小程序代码格式
This commit is contained in:
1 parent
11dc293349
commit
1a2f179e15
48 files changed
+1701
-66
No files matched your search
@@ -3,30 +3,60 @@ const CORE_MODULES = {
|
||||
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"] },
|
||||
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" },
|
||||
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 aliases = { identity: "brand-hero", trust: "trust-proof", offering: "offering-list", inquiry: "inquiry", contact: "founder-card" };
|
||||
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") };
|
||||
return {
|
||||
...module,
|
||||
type,
|
||||
variant: module.variant || (known ? known.variants[0] : "default"),
|
||||
supported: Boolean(known || type === "custom"),
|
||||
};
|
||||
}
|
||||
|
||||
function resolveRuntime(workspace) {
|
||||
const modules = Array.isArray(workspace && workspace.modules) ? workspace.modules : [];
|
||||
const resolved = modules.map(resolveModule);
|
||||
const home = workspace && workspace.layout && Array.isArray(workspace.layout.home) ? workspace.layout.home : resolved.map((item) => item.type);
|
||||
return { theme: workspace && workspace.theme ? workspace.theme : FALLBACK_THEME, modules: resolved, layout: { home: home.filter((key) => resolved.some((item) => item.type === key)) }, capabilities: workspace && Array.isArray(workspace.capabilities) ? workspace.capabilities : [] };
|
||||
const home =
|
||||
workspace && workspace.layout && Array.isArray(workspace.layout.home)
|
||||
? workspace.layout.home
|
||||
: resolved.map((item) => item.type);
|
||||
return {
|
||||
theme: workspace && workspace.theme ? workspace.theme : FALLBACK_THEME,
|
||||
modules: resolved,
|
||||
layout: { home: home.filter((key) => resolved.some((item) => item.type === key)) },
|
||||
capabilities: workspace && Array.isArray(workspace.capabilities) ? workspace.capabilities : [],
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = { CORE_MODULES, FALLBACK_THEME, resolveRuntime };
|
||||
Reference in new issue
Block a user