feat: 收口多品牌与模板构建基础

This commit is contained in:
que01 committed 2026-09-25 02:55:46 +08:00
1 parent 0425a1c672
commit 77224ea51f
317 files changed
+11290 -1158

No files matched your search

@@ -0,0 +1,28 @@
{
"templateKey": "acheng-campus-food",
"viewport": { "width": 375, "height": 812 },
"states": {
"home": {
"page": "pages/index/index",
"anchors": ["acheng-home", "brand-card", "今日菜单", "现做现吃"]
},
"offerings": {
"page": "pages/services/index",
"anchors": ["acheng-offerings", "今日菜单", "团体活动"]
},
"detail": { "page": "pages/offering/detail", "anchors": ["inquire"] },
"inquiry": { "page": "pages/inquiry/index", "anchors": ["提交"] },
"success": {
"page": "pages/inquiry-success/index",
"anchors": ["presentation.title"]
},
"records": {
"page": "pages/records/index",
"anchors": ["presentation.title"]
},
"profile": {
"page": "pages/bookings/index",
"anchors": ["acheng-profile", "出摊与配送"]
}
}
}
+20 -5
View File
@@ -6,11 +6,26 @@
"page": "pages/index/index",
"anchors": ["founder-card", "brand-hero", "trust-proof", "offering-list"]
},
"offerings": { "page": "pages/services/index", "anchors": ["作品与系统", "查看详情"] },
"detail": { "page": "pages/offering/detail", "anchors": ["预约测量"] },
"offerings": {
"page": "pages/services/index",
"anchors": ["presentation.title", "presentation.detailAction", "presentation.inquiryAction"]
},
"detail": {
"page": "pages/offering/detail",
"anchors": ["presentation.craftsTitle", "presentation.inquiryAction"]
},
"inquiry": { "page": "pages/inquiry/index", "anchors": ["提交"] },
"success": { "page": "pages/inquiry-success/index", "anchors": ["已收到", "查看"] },
"records": { "page": "pages/records/index", "anchors": ["咨询记录", "咨询"] },
"profile": { "page": "pages/bookings/index", "anchors": ["直派服务区域与履约说明", "一门一档"] }
"success": {
"page": "pages/inquiry-success/index",
"anchors": ["presentation.title", "presentation.recordsAction"]
},
"records": {
"page": "pages/records/index",
"anchors": ["presentation.title", "presentation.createAction"]
},
"profile": {
"page": "pages/bookings/index",
"anchors": ["presentation.coverageTitle", "presentation.warrantyTitle"]
}
}
}
+26 -6
View File
@@ -4,13 +4,33 @@
"states": {
"home": {
"page": "pages/index/index",
"anchors": ["founder-card", "brand-hero", "trust-proof", "trust-manifesto", "offering-list"]
"anchors": [
"linjing-home",
"presentation.founderBadge",
"presentation.manifestoEyebrow",
"presentation.flowTitle"
]
},
"offerings": {
"page": "pages/services/index",
"anchors": ["presentation.title", "presentation.detailAction", "presentation.inquiryAction"]
},
"detail": {
"page": "pages/offering/detail",
"anchors": ["presentation.craftsTitle", "presentation.inquiryAction"]
},
"offerings": { "page": "pages/services/index", "anchors": ["作品与系统", "查看详情"] },
"detail": { "page": "pages/offering/detail", "anchors": ["预约测量"] },
"inquiry": { "page": "pages/inquiry/index", "anchors": ["提交"] },
"success": { "page": "pages/inquiry-success/index", "anchors": ["已收到", "查看"] },
"records-empty": { "page": "pages/records/index", "anchors": ["咨询记录", "咨询"] },
"profile": { "page": "pages/bookings/index", "anchors": ["直派服务区域与履约说明", "一门一档"] }
"success": {
"page": "pages/inquiry-success/index",
"anchors": ["presentation.title", "presentation.recordsAction"]
},
"records-empty": {
"page": "pages/records/index",
"anchors": ["presentation.title", "presentation.createAction"]
},
"profile": {
"page": "pages/bookings/index",
"anchors": ["presentation.coverageTitle", "presentation.warrantyTitle"]
}
}
}
-16
View File
@@ -1,16 +0,0 @@
{
"templateKey": "personal+minimal-neutral",
"viewport": { "width": 375, "height": 812 },
"states": {
"home": {
"page": "pages/index/index",
"anchors": ["brand-hero", "founder-card", "offering-list", "trust-proof"]
},
"offerings": { "page": "pages/services/index", "anchors": ["作品与系统", "查看详情"] },
"detail": { "page": "pages/offering/detail", "anchors": ["预约测量"] },
"inquiry": { "page": "pages/inquiry/index", "anchors": ["提交"] },
"success": { "page": "pages/inquiry-success/index", "anchors": ["已收到", "查看"] },
"records-empty": { "page": "pages/records/index", "anchors": ["咨询记录", "咨询"] },
"profile": { "page": "pages/bookings/index", "anchors": ["直派服务区域与履约说明", "一门一档"] }
}
}
-23
View File
@@ -1,23 +0,0 @@
{
"templateKey": "personal+minimal-neutral",
"version": "1.0.0",
"pages": ["home", "offerings", "detail", "inquiry", "success", "records", "profile"],
"layout": {
"home": ["brand-hero", "founder-card", "offering-list", "trust-proof"],
"offerings": ["offering-list"],
"detail": ["offering-detail"],
"profile": ["profile"]
},
"requiredModules": [
"brand-hero",
"founder-card",
"trust-proof",
"offering-list",
"offering-detail",
"inquiry-form",
"records",
"profile",
"success-summary"
],
"visualAnchors": { "home": ["brand-hero", "founder-card", "offering-list", "trust-proof"] }
}
@@ -0,0 +1,45 @@
const assert = require("node:assert/strict");
const fs = require("node:fs");
const path = require("node:path");
const test = require("node:test");
const vm = require("node:vm");
const source = fs.readFileSync(path.join(__dirname, "../utils/runtime-workspace.js"), "utf8");
function loadWithResponse(response) {
const module = { exports: {} };
const storage = {
getStorageSync() {
throw new Error("不应读取旧缓存");
},
setStorageSync() {
throw new Error("不应缓存公开内容");
},
};
vm.runInNewContext(source, {
module,
wx: storage,
require(id) {
if (id === "./request") return { request: () => Promise.resolve(response) };
if (id === "./module-registry") return { resolveRuntime: () => ({}) };
throw new Error(`意外依赖:${id}`);
},
});
return module.exports.loadWorkspaceWithFallback();
}
test("未发布品牌不会使用旧 workspace 缓存", async () => {
await assert.rejects(
loadWithResponse({ publication: { status: "unpublished" }, brand: null }),
/品牌尚未发布/,
);
});
test("已发布 workspace 正常返回", async () => {
const workspace = await loadWithResponse({
publication: { status: "published" },
brand: { name: "测试品牌" },
offerings: [],
});
assert.equal(workspace.brand.name, "测试品牌");
});
+33 -1
View File
@@ -3,6 +3,8 @@ const path = require("node:path");
const root = path.resolve(__dirname, "..");
const requestSource = fs.readFileSync(path.join(root, "utils/request.js"), "utf8");
const configSource = fs.readFileSync(path.join(root, "utils/config.js"), "utf8");
const moduleRegistrySource = fs.readFileSync(path.join(root, "utils/module-registry.js"), "utf8");
const runtimeRequestSource = fs.readFileSync(path.join(root, "utils/request.js"), "utf8");
if (
!requestSource.includes('path.startsWith("/public/")') ||
!requestSource.includes("brandSlug") ||
@@ -11,7 +13,37 @@ if (
console.error("miniapp: public requests must carry the configured brand slug");
process.exit(1);
}
const fixtureFiles = ["linjing-door.json", "minimal-neutral.json", "doors-industry.json"];
if (!moduleRegistrySource.includes("Object.values(manifest?.pages || {})")) {
console.error("miniapp: visual page renderers must resolve from the manifest");
process.exit(1);
}
if (
!runtimeRequestSource.includes('path.startsWith("/customer/session/wechat")') ||
!runtimeRequestSource.includes('"customerToken:" + config.brandSlug')
) {
console.error("miniapp: customer sessions must be brand-scoped");
process.exit(1);
}
const productionRoots = ["components/modules", "components/templates", "pages"];
const productionSources = [];
function collectSources(directory) {
const current = path.join(root, directory);
for (const item of fs.readdirSync(current, { withFileTypes: true })) {
const itemPath = path.join(current, item.name);
if (item.isDirectory()) collectSources(path.relative(root, itemPath));
else if (itemPath.endsWith(".js") || itemPath.endsWith(".wxml"))
productionSources.push({ file: itemPath, content: fs.readFileSync(itemPath, "utf8") });
}
}
productionRoots.forEach(collectSources);
for (const term of ["林境门", "亲自主理量房", "拒绝流水线拼装", "linjingInquiryRecords"]) {
const leak = productionSources.find(({ content }) => content.includes(term));
if (leak) {
console.error(`miniapp: static business term ${term} leaked into ${leak.file}`);
process.exit(1);
}
}
const fixtureFiles = ["linjing-door.json", "doors-industry.json"];
const fixtures = fixtureFiles.map((file) =>
JSON.parse(fs.readFileSync(path.join(__dirname, "fixtures", file), "utf8")),
);
@@ -3,8 +3,8 @@ const path = require("node:path");
const root = path.resolve(__dirname, "..");
const fixtureFiles = [
"linjing-door-visual.json",
"minimal-neutral-visual.json",
"doors-visual.json",
"acheng-campus-food-visual.json",
];
const fixtures = fixtureFiles.map((file) =>
JSON.parse(fs.readFileSync(path.join(__dirname, "fixtures", file), "utf8")),
@@ -22,8 +22,10 @@ for (const fixture of fixtures) {
.map((match) => match[1])
.filter((name) => name.includes("-"));
for (const ref of componentRefs) {
const candidate = path.join(root, "components/modules", ref, `${ref}.wxml`);
if (fs.existsSync(candidate)) content += fs.readFileSync(candidate, "utf8");
for (const componentRoot of ["components/modules", "components/templates"]) {
const candidate = path.join(root, componentRoot, ref, `${ref}.wxml`);
if (fs.existsSync(candidate)) content += fs.readFileSync(candidate, "utf8");
}
}
for (const anchor of definition.anchors)
if (!content.includes(anchor)) failures.push(`${state}: missing anchor ${anchor}`);