refactor: 退役运行时视觉模块并泛化模板门禁
This commit is contained in:
1 parent
25d1fe983c
commit
e2e2340bfe
56 files changed
+290
-1037
No files matched your search
@@ -0,0 +1,45 @@
|
|||||||
|
# 执行记录
|
||||||
|
|
||||||
|
## 当前状态
|
||||||
|
|
||||||
|
在核查阿成、林境实际模板引用后,确认旧 BrandModule 启停/排序不会影响构建产物。该链路与已采用的模板包渲染架构冲突,任务按运行时视觉模块退役处理。
|
||||||
|
|
||||||
|
## 决策边界
|
||||||
|
|
||||||
|
- 退役视觉模块,不退役业务内容和 capability。
|
||||||
|
- BrandModule 是模板安装时生成、发布时打包、Admin 可开关排序的旧视觉模型;确认没有内容外键后删除。
|
||||||
|
- BrandFieldDefinition、TrustContent、Offering、InquiryForm、CapabilityInstallation 保持。
|
||||||
|
- 模板包声明的 pages 和视觉资源仍是小程序页面结构的来源。
|
||||||
|
|
||||||
|
## 验证记录
|
||||||
|
|
||||||
|
- 当前模板实际引用:阿成使用自有首页/列表/主理人组件,以及咨询、详情、记录、成功流程;林境使用自有页面和组件。
|
||||||
|
- runtime-tab-bar 已无文件和业务引用。
|
||||||
|
- brand-hero、founder-card、trust-proof、offering-list、trust-manifesto 在模板生产代码中零引用。
|
||||||
|
|
||||||
|
## 进度
|
||||||
|
|
||||||
|
- [x] 删除未使用小程序视觉组件和 registry。
|
||||||
|
- [x] 移除 BrandModule API/Admin/发布快照链路。
|
||||||
|
- [x] 生成并验证删除 BrandModule 的 Prisma migration。
|
||||||
|
- [x] 更新文档、任务状态并运行验证。
|
||||||
|
|
||||||
|
## 模板规模化门禁
|
||||||
|
|
||||||
|
`apps/miniapp/test/validate-visual-fixture.cjs` 不再读取固定的视觉 fixture,也不再检查阿成或林境的行业文案。测试会自动发现所有 `packages/template-*/template.json`,逐个调用 template compiler,并验证:
|
||||||
|
|
||||||
|
- manifest 声明的页面和编译产物完整;
|
||||||
|
- `app.json` 页面、原生 tabBar、图标资源一致;
|
||||||
|
- 页面 `usingComponents` 与相对 `require()` 可解析;
|
||||||
|
- 当前模板产物不引用其他模板的专属组件。
|
||||||
|
|
||||||
|
因此新增第 3 个或第 200 个模板时,不需要修改测试脚本;模板自身的 manifest 和产物就是测试输入。旧 `apps/miniapp/test/fixtures/*-visual.json` 仅保留为历史素材,不再作为通用门禁。
|
||||||
|
|
||||||
|
## 最后验证
|
||||||
|
|
||||||
|
- `pnpm --filter @personal-brand/miniapp test:visual-fixture`:2 个模板自动发现并通过(阿成 9 页面 / 5 tab,林境 7 页面 / 3 tab)。
|
||||||
|
- `pnpm --filter @personal-brand/miniapp test:fixture`:通过。
|
||||||
|
- `pnpm typecheck`:通过。
|
||||||
|
- `pnpm lint`:通过。
|
||||||
|
- `pnpm test:template-compiler`:5 项通过。
|
||||||
|
- `pnpm validate:templates`:2 个模板包通过。
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# 运行时视觉模块退役
|
||||||
|
|
||||||
|
## 目标
|
||||||
|
|
||||||
|
让小程序运行时只承担数据访问、通用流程和无行业绑定的 UI;模板视觉由模板包拥有。移除旧页面模块(BrandModule)配置链路和没有模板引用的视觉模块组件,避免后台提供不会影响成品的开关。
|
||||||
|
|
||||||
|
## 保留
|
||||||
|
|
||||||
|
- 品牌、信任内容、业务提供项、咨询表单、提交记录、能力安装与工作流。
|
||||||
|
- 模板包自己的页面、组件、图标和样式。
|
||||||
|
- 仍被模板引用的详情、咨询、记录、成功流程组件,以及通用表单控件。
|
||||||
|
- Admin 的模板目录与模板安装管理。
|
||||||
|
|
||||||
|
## 删除
|
||||||
|
|
||||||
|
- runtime-tab-bar 和零引用的品牌视觉模块组件。
|
||||||
|
- BrandModule 数据模型、Admin 开关/排序、public workspace modules 输出和客户端动态模块 registry。
|
||||||
|
- 将 industry template 的语义区块复制为可开关视觉模块的逻辑。
|
||||||
|
|
||||||
|
## 验收
|
||||||
|
|
||||||
|
所有 `packages/template-*/template.json` 自动发现并逐个编译;编译产物不含退役模块;每个模板声明的页面、原生 tabBar、图标和依赖均可解析;API integration、Admin/API types、Prisma migration、miniapp workspace 测试通过;保留的数据与能力行为不变。验收不依赖固定模板数量、模板 key、行业文案或历史视觉 fixture。
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
id,task,status,acceptance_criteria,validation_command,completed_at,retry_count,notes
|
||||||
|
1,删除未使用的小程序视觉组件和动态模块 registry,DONE,没有模板引用的视觉组件与运行时分发代码已删除,pnpm --filter @personal-brand/miniapp test:fixture,2026-09-26,0,fixture 通过
|
||||||
|
2,移除 BrandModule API/Admin/发布快照链路,DONE,后台没有无效页面模块操作且 public workspace 不返回模块渲染指令,pnpm --filter @personal-brand/api test,2026-09-26,0,API 集成测试通过
|
||||||
|
3,移除 Prisma BrandModule 模型并更新模板服务/seed,DONE,数据库迁移和生成客户端一致,pnpm --filter @personal-brand/api exec prisma validate --schema prisma/schema.prisma,2026-09-26,0,迁移和 Prisma validate 通过
|
||||||
|
4,更新契约测试文档并执行全量验证,DONE,模板编译、API 测试、miniapp 测试和类型检查通过,pnpm typecheck && pnpm lint && pnpm test:template-compiler && pnpm validate:templates,2026-09-26,0,新增通用模板产物门禁;2 个模板自动发现并通过
|
||||||
|
@@ -22,8 +22,7 @@ export function OverviewPage() {
|
|||||||
const error = results.find((result) => result.isError)?.error;
|
const error = results.find((result) => result.isError)?.error;
|
||||||
const retry = () => results.forEach((result) => void result.refetch());
|
const retry = () => results.forEach((result) => void result.refetch());
|
||||||
const brand = results[0].data;
|
const brand = results[0].data;
|
||||||
const workspace = results[1].data as
|
const workspace = results[1].data as { inquiryForm?: { isEnabled?: boolean } } | undefined;
|
||||||
{ inquiryForm?: { isEnabled?: boolean }; modules?: Array<{ isEnabled?: boolean }> } | undefined;
|
|
||||||
const trust = results[2].data;
|
const trust = results[2].data;
|
||||||
const offerings = results[3].data as Array<{ isEnabled?: boolean }> | undefined;
|
const offerings = results[3].data as Array<{ isEnabled?: boolean }> | undefined;
|
||||||
const submissions = results[4].data;
|
const submissions = results[4].data;
|
||||||
@@ -75,15 +74,6 @@ export function OverviewPage() {
|
|||||||
<Statistic title="咨询提交" value={submissions?.length ?? 0} suffix="条" />
|
<Statistic title="咨询提交" value={submissions?.length ?? 0} suffix="条" />
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
<Col xs={24} sm={12} lg={6}>
|
|
||||||
<Card>
|
|
||||||
<Statistic
|
|
||||||
title="工作空间模块"
|
|
||||||
value={workspace?.modules?.filter((item) => item.isEnabled).length ?? 0}
|
|
||||||
suffix="个启用"
|
|
||||||
/>
|
|
||||||
</Card>
|
|
||||||
</Col>
|
|
||||||
</Row>
|
</Row>
|
||||||
<Row gutter={[16, 16]}>
|
<Row gutter={[16, 16]}>
|
||||||
<Col xs={24} lg={12}>
|
<Col xs={24} lg={12}>
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import { createApiClient } from "../../lib/api.js";
|
|||||||
import { ApiClientError } from "@personal-brand/api-client";
|
import { ApiClientError } from "@personal-brand/api-client";
|
||||||
import type {
|
import type {
|
||||||
BrandFieldDefinition,
|
BrandFieldDefinition,
|
||||||
BrandModule,
|
|
||||||
BrandTemplateKey,
|
BrandTemplateKey,
|
||||||
InquiryForm,
|
InquiryForm,
|
||||||
} from "@personal-brand/api-client";
|
} from "@personal-brand/api-client";
|
||||||
@@ -134,11 +133,6 @@ export function WorkspacePage() {
|
|||||||
void queryClient.invalidateQueries({ queryKey: ["admin-workspace"] });
|
void queryClient.invalidateQueries({ queryKey: ["admin-workspace"] });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const updateModule = useMutation({
|
|
||||||
mutationFn: ({ id, body }: { id: string; body: Partial<BrandModule> }) =>
|
|
||||||
client.updateAdminModule(id, body),
|
|
||||||
onSuccess: () => void queryClient.invalidateQueries({ queryKey: ["admin-workspace"] }),
|
|
||||||
});
|
|
||||||
const createField = useMutation({
|
const createField = useMutation({
|
||||||
mutationFn: (values: Omit<BrandFieldDefinition, "id" | "source">) =>
|
mutationFn: (values: Omit<BrandFieldDefinition, "id" | "source">) =>
|
||||||
client.createAdminField(values),
|
client.createAdminField(values),
|
||||||
@@ -242,7 +236,7 @@ export function WorkspacePage() {
|
|||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const { modules, fields, installations } = query.data;
|
const { fields, installations } = query.data;
|
||||||
return (
|
return (
|
||||||
<Space direction="vertical" size="large" style={{ width: "100%" }}>
|
<Space direction="vertical" size="large" style={{ width: "100%" }}>
|
||||||
<AdminPageHeader
|
<AdminPageHeader
|
||||||
@@ -478,13 +472,7 @@ export function WorkspacePage() {
|
|||||||
<Typography.Text strong>
|
<Typography.Text strong>
|
||||||
{combinationPreview.data.industry.name} × {combinationPreview.data.visual.name}
|
{combinationPreview.data.industry.name} × {combinationPreview.data.visual.name}
|
||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
<Space wrap>
|
<Space wrap></Space>
|
||||||
{combinationPreview.data.runtime.modules.map((item) => (
|
|
||||||
<Tag key={item.key}>
|
|
||||||
{item.title} · {item.variant}
|
|
||||||
</Tag>
|
|
||||||
))}
|
|
||||||
</Space>
|
|
||||||
<Typography.Text type="secondary">
|
<Typography.Text type="secondary">
|
||||||
能力:
|
能力:
|
||||||
{combinationPreview.data.runtime.capabilities.map((item) => item.key).join("、") ||
|
{combinationPreview.data.runtime.capabilities.map((item) => item.key).join("、") ||
|
||||||
@@ -565,52 +553,6 @@ export function WorkspacePage() {
|
|||||||
<MutationError error={createForm.error} />
|
<MutationError error={createForm.error} />
|
||||||
<MutationError error={updateForm.error} />
|
<MutationError error={updateForm.error} />
|
||||||
</Card>
|
</Card>
|
||||||
<Card title="页面模块">
|
|
||||||
<Table
|
|
||||||
rowKey="id"
|
|
||||||
dataSource={modules}
|
|
||||||
columns={[
|
|
||||||
{ title: "模块", dataIndex: "title" },
|
|
||||||
{ title: "类型", dataIndex: "type", render: (value) => <Tag>{value}</Tag> },
|
|
||||||
{ title: "来源", dataIndex: "source" },
|
|
||||||
{
|
|
||||||
title: "状态",
|
|
||||||
dataIndex: "isEnabled",
|
|
||||||
render: (value, item: BrandModule) => (
|
|
||||||
<Select
|
|
||||||
size="small"
|
|
||||||
value={Boolean(value)}
|
|
||||||
onChange={(next) =>
|
|
||||||
updateModule.mutate({ id: item.id, body: { isEnabled: Boolean(next) } })
|
|
||||||
}
|
|
||||||
options={[
|
|
||||||
{ value: true, label: "启用" },
|
|
||||||
{ value: false, label: "停用" },
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "排序",
|
|
||||||
dataIndex: "sortOrder",
|
|
||||||
render: (value, item: BrandModule) => (
|
|
||||||
<Input
|
|
||||||
size="small"
|
|
||||||
type="number"
|
|
||||||
defaultValue={Number(value)}
|
|
||||||
onBlur={(event) =>
|
|
||||||
updateModule.mutate({
|
|
||||||
id: item.id,
|
|
||||||
body: { sortOrder: Number(event.target.value) },
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
<MutationError error={updateModule.error} />
|
|
||||||
</Card>
|
|
||||||
<Card
|
<Card
|
||||||
title="自定义字段"
|
title="自定义字段"
|
||||||
extra={
|
extra={
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
DROP TABLE "BrandModule";
|
||||||
@@ -54,7 +54,6 @@ model BrandProfile {
|
|||||||
tags Tag[]
|
tags Tag[]
|
||||||
trustContents TrustContent[]
|
trustContents TrustContent[]
|
||||||
templateInstallations BrandTemplateInstallation[]
|
templateInstallations BrandTemplateInstallation[]
|
||||||
modules BrandModule[]
|
|
||||||
fieldDefinitions BrandFieldDefinition[]
|
fieldDefinitions BrandFieldDefinition[]
|
||||||
offerings Offering[]
|
offerings Offering[]
|
||||||
inquiryForms InquiryForm[]
|
inquiryForms InquiryForm[]
|
||||||
@@ -123,21 +122,6 @@ model BrandTemplateInstallation {
|
|||||||
@@index([brandId])
|
@@index([brandId])
|
||||||
}
|
}
|
||||||
|
|
||||||
model BrandModule {
|
|
||||||
id String @id @default(uuid())
|
|
||||||
brandId String
|
|
||||||
brand BrandProfile @relation(fields: [brandId], references: [id], onDelete: Cascade)
|
|
||||||
type String
|
|
||||||
title String
|
|
||||||
isEnabled Boolean @default(true)
|
|
||||||
sortOrder Int @default(0)
|
|
||||||
source String @default("core")
|
|
||||||
config Json?
|
|
||||||
createdAt DateTime @default(now())
|
|
||||||
updatedAt DateTime @updatedAt
|
|
||||||
@@index([brandId, isEnabled, sortOrder])
|
|
||||||
}
|
|
||||||
|
|
||||||
model BrandFieldDefinition {
|
model BrandFieldDefinition {
|
||||||
id String @id @default(uuid())
|
id String @id @default(uuid())
|
||||||
brandId String
|
brandId String
|
||||||
|
|||||||
@@ -702,26 +702,6 @@ async function ensureRuntimeContent(brandId: string, template: RuntimeSeedTempla
|
|||||||
data: { isEnabled: false },
|
data: { isEnabled: false },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const moduleDefinitions = [
|
|
||||||
["founder-card", "主理人介绍"],
|
|
||||||
["brand-hero", "品牌首屏"],
|
|
||||||
["trust-proof", "信任与案例"],
|
|
||||||
["offering-list", "业务提供项"],
|
|
||||||
["inquiry", "咨询入口"],
|
|
||||||
] as const;
|
|
||||||
for (const [sortOrder, [type, title]] of moduleDefinitions.entries()) {
|
|
||||||
const existing = await prisma.brandModule.findFirst({ where: { brandId, type } });
|
|
||||||
if (existing) {
|
|
||||||
await prisma.brandModule.update({
|
|
||||||
where: { id: existing.id },
|
|
||||||
data: { isEnabled: true, sortOrder, title },
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await prisma.brandModule.create({
|
|
||||||
data: { brandId, type, title, sortOrder, source: "seed", isEnabled: true },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const incompleteOfferings = await prisma.offering.findMany({
|
const incompleteOfferings = await prisma.offering.findMany({
|
||||||
where: { brandId, isEnabled: true, coverUrl: null },
|
where: { brandId, isEnabled: true, coverUrl: null },
|
||||||
select: { id: true, name: true },
|
select: { id: true, name: true },
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export class AdminMembershipGuard implements CanActivate {
|
|||||||
if (request.url.startsWith("/admin/session/login")) return Promise.resolve(true);
|
if (request.url.startsWith("/admin/session/login")) return Promise.resolve(true);
|
||||||
if (!request.url.startsWith("/admin/")) return Promise.resolve(true);
|
if (!request.url.startsWith("/admin/")) return Promise.resolve(true);
|
||||||
if (
|
if (
|
||||||
/^\/admin\/workspace\/(install|capabilities(?:\/|$)|template(?:\/|$)|modules(?:\/|$)|fields(?:\/|$))/.test(
|
/^\/admin\/workspace\/(install|capabilities(?:\/|$)|template(?:\/|$)|fields(?:\/|$))/.test(
|
||||||
request.url,
|
request.url,
|
||||||
) ||
|
) ||
|
||||||
/^\/admin\/config\/visual-template(?:\/|$)/.test(request.url)
|
/^\/admin\/config\/visual-template(?:\/|$)/.test(request.url)
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import {
|
|||||||
InstallTemplateDto,
|
InstallTemplateDto,
|
||||||
CreateOfferingDto,
|
CreateOfferingDto,
|
||||||
UpdateOfferingDto,
|
UpdateOfferingDto,
|
||||||
UpdateModuleDto,
|
|
||||||
CreateFieldDefinitionDto,
|
CreateFieldDefinitionDto,
|
||||||
UpdateFieldDefinitionDto,
|
UpdateFieldDefinitionDto,
|
||||||
CreateInquiryFormDto,
|
CreateInquiryFormDto,
|
||||||
@@ -158,10 +157,9 @@ class AdminWorkspaceController {
|
|||||||
@Get()
|
@Get()
|
||||||
async get(@Req() request: FastifyRequest): Promise<unknown> {
|
async get(@Req() request: FastifyRequest): Promise<unknown> {
|
||||||
const brandId = this.requireAdmin(request).brandId;
|
const brandId = this.requireAdmin(request).brandId;
|
||||||
const [brand, installations, modules, fields, offerings, forms] = await Promise.all([
|
const [brand, installations, fields, offerings, forms] = await Promise.all([
|
||||||
this.prisma.brandProfile.findUnique({ where: { id: brandId } }),
|
this.prisma.brandProfile.findUnique({ where: { id: brandId } }),
|
||||||
this.prisma.brandTemplateInstallation.findMany({ where: { brandId } }),
|
this.prisma.brandTemplateInstallation.findMany({ where: { brandId } }),
|
||||||
this.prisma.brandModule.findMany({ where: { brandId }, orderBy: { sortOrder: "asc" } }),
|
|
||||||
this.prisma.brandFieldDefinition.findMany({
|
this.prisma.brandFieldDefinition.findMany({
|
||||||
where: { brandId },
|
where: { brandId },
|
||||||
orderBy: { sortOrder: "asc" },
|
orderBy: { sortOrder: "asc" },
|
||||||
@@ -178,7 +176,6 @@ class AdminWorkspaceController {
|
|||||||
return {
|
return {
|
||||||
brand,
|
brand,
|
||||||
installations,
|
installations,
|
||||||
modules,
|
|
||||||
fields,
|
fields,
|
||||||
offerings,
|
offerings,
|
||||||
forms,
|
forms,
|
||||||
@@ -378,27 +375,6 @@ class AdminWorkspaceController {
|
|||||||
return this.templateWorkspace.rollback(this.requireAdmin(request).brandId);
|
return this.templateWorkspace.rollback(this.requireAdmin(request).brandId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Patch("modules/:id")
|
|
||||||
async updateModule(
|
|
||||||
@Req() request: FastifyRequest,
|
|
||||||
@Param("id") id: string,
|
|
||||||
@Body() body: UpdateModuleDto,
|
|
||||||
): Promise<unknown> {
|
|
||||||
const brandId = this.requireAdmin(request).brandId;
|
|
||||||
const item = await this.prisma.brandModule.findFirst({
|
|
||||||
where: { id, brandId },
|
|
||||||
});
|
|
||||||
if (!item) throw new BadRequestException("品牌模块不存在");
|
|
||||||
const { config, ...fields } = body;
|
|
||||||
return this.prisma.brandModule.update({
|
|
||||||
where: { id },
|
|
||||||
data: {
|
|
||||||
...fields,
|
|
||||||
...(config === undefined ? {} : { config: config as Prisma.InputJsonValue }),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Post("fields")
|
@Post("fields")
|
||||||
createField(
|
createField(
|
||||||
@Req() request: FastifyRequest,
|
@Req() request: FastifyRequest,
|
||||||
|
|||||||
@@ -157,13 +157,6 @@ export class UpdateOfferingDto {
|
|||||||
@IsOptional() cta?: { type: string; label: string; config?: Record<string, unknown> };
|
@IsOptional() cta?: { type: string; label: string; config?: Record<string, unknown> };
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UpdateModuleDto {
|
|
||||||
@IsOptional() @IsString() title?: string;
|
|
||||||
@IsOptional() @IsBoolean() isEnabled?: boolean;
|
|
||||||
@IsOptional() @IsInt() @Min(0) @Max(9999) sortOrder?: number;
|
|
||||||
@IsOptional() config?: Record<string, unknown>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class CreateFieldDefinitionDto {
|
export class CreateFieldDefinitionDto {
|
||||||
@IsIn(["profile", "service", "inquiry"]) scope!: string;
|
@IsIn(["profile", "service", "inquiry"]) scope!: string;
|
||||||
@IsString() @Matches(/^[a-z][a-z0-9_]*$/) key!: string;
|
@IsString() @Matches(/^[a-z][a-z0-9_]*$/) key!: string;
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ export interface BrandReleaseSnapshot {
|
|||||||
templatePackageManifest?: ReturnType<typeof getTemplatePackageManifestForVisualKey> | null;
|
templatePackageManifest?: ReturnType<typeof getTemplatePackageManifestForVisualKey> | null;
|
||||||
brand: Record<string, unknown> | null;
|
brand: Record<string, unknown> | null;
|
||||||
installation: Record<string, unknown> | null;
|
installation: Record<string, unknown> | null;
|
||||||
modules: unknown[];
|
|
||||||
fields: unknown[];
|
fields: unknown[];
|
||||||
offerings: unknown[];
|
offerings: unknown[];
|
||||||
forms: unknown[];
|
forms: unknown[];
|
||||||
@@ -31,14 +30,13 @@ export async function buildBrandReleaseSnapshot(
|
|||||||
database: Prisma.TransactionClient,
|
database: Prisma.TransactionClient,
|
||||||
brandId: string,
|
brandId: string,
|
||||||
): Promise<BrandReleaseSnapshot> {
|
): Promise<BrandReleaseSnapshot> {
|
||||||
const [brand, installation, modules, fields, offerings, forms, trustContents, capabilities] =
|
const [brand, installation, fields, offerings, forms, trustContents, capabilities] =
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
database.brandProfile.findUnique({ where: { id: brandId } }),
|
database.brandProfile.findUnique({ where: { id: brandId } }),
|
||||||
database.brandTemplateInstallation.findFirst({
|
database.brandTemplateInstallation.findFirst({
|
||||||
where: { brandId },
|
where: { brandId },
|
||||||
orderBy: { updatedAt: "desc" },
|
orderBy: { updatedAt: "desc" },
|
||||||
}),
|
}),
|
||||||
database.brandModule.findMany({ where: { brandId }, orderBy: { sortOrder: "asc" } }),
|
|
||||||
database.brandFieldDefinition.findMany({ where: { brandId }, orderBy: { sortOrder: "asc" } }),
|
database.brandFieldDefinition.findMany({ where: { brandId }, orderBy: { sortOrder: "asc" } }),
|
||||||
database.offering.findMany({ where: { brandId }, orderBy: { sortOrder: "asc" } }),
|
database.offering.findMany({ where: { brandId }, orderBy: { sortOrder: "asc" } }),
|
||||||
database.inquiryForm.findMany({ where: { brandId }, orderBy: { updatedAt: "desc" } }),
|
database.inquiryForm.findMany({ where: { brandId }, orderBy: { updatedAt: "desc" } }),
|
||||||
@@ -66,7 +64,6 @@ export async function buildBrandReleaseSnapshot(
|
|||||||
templatePackageManifest: getTemplatePackageManifestForVisualKey(visualKey) ?? null,
|
templatePackageManifest: getTemplatePackageManifestForVisualKey(visualKey) ?? null,
|
||||||
brand: brand ? jsonObject(brand) : null,
|
brand: brand ? jsonObject(brand) : null,
|
||||||
installation: installation ? jsonObject(installation) : null,
|
installation: installation ? jsonObject(installation) : null,
|
||||||
modules: modules.map((item) => jsonObject(item)),
|
|
||||||
fields: fields.map((item) => jsonObject(item)),
|
fields: fields.map((item) => jsonObject(item)),
|
||||||
offerings: offerings.map((item) => jsonObject(item)),
|
offerings: offerings.map((item) => jsonObject(item)),
|
||||||
forms: forms.map((item) => jsonObject(item)),
|
forms: forms.map((item) => jsonObject(item)),
|
||||||
|
|||||||
@@ -12,12 +12,7 @@ import {
|
|||||||
getDefaultVisualTemplateKey,
|
getDefaultVisualTemplateKey,
|
||||||
getTemplatePackageManifestForVisualKey,
|
getTemplatePackageManifestForVisualKey,
|
||||||
} from "@personal-brand/config";
|
} from "@personal-brand/config";
|
||||||
import type {
|
import type { RuntimeInquiryField, RuntimeOffering, RuntimeWorkspace } from "@personal-brand/types";
|
||||||
RuntimeInquiryField,
|
|
||||||
RuntimeOffering,
|
|
||||||
RuntimeWorkspace,
|
|
||||||
RuntimeModule,
|
|
||||||
} from "@personal-brand/types";
|
|
||||||
|
|
||||||
@Controller("public/workspace")
|
@Controller("public/workspace")
|
||||||
export class PublicWorkspaceController {
|
export class PublicWorkspaceController {
|
||||||
@@ -42,7 +37,6 @@ export class PublicWorkspaceController {
|
|||||||
brand: null,
|
brand: null,
|
||||||
template: null,
|
template: null,
|
||||||
visualTemplate: null,
|
visualTemplate: null,
|
||||||
modules: [],
|
|
||||||
offerings: [],
|
offerings: [],
|
||||||
inquiryForms: [],
|
inquiryForms: [],
|
||||||
capabilities: [],
|
capabilities: [],
|
||||||
@@ -53,9 +47,6 @@ export class PublicWorkspaceController {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
const brandData = this.jsonObject(releaseSnapshot.brand);
|
const brandData = this.jsonObject(releaseSnapshot.brand);
|
||||||
const modulesData = this.jsonArray(releaseSnapshot.modules).filter(
|
|
||||||
(item) => this.jsonObject(item).isEnabled === true,
|
|
||||||
) as Array<Record<string, unknown>>;
|
|
||||||
const offeringsData = this.jsonArray(releaseSnapshot.offerings).filter(
|
const offeringsData = this.jsonArray(releaseSnapshot.offerings).filter(
|
||||||
(item) => this.jsonObject(item).isEnabled === true,
|
(item) => this.jsonObject(item).isEnabled === true,
|
||||||
) as Array<Record<string, unknown>>;
|
) as Array<Record<string, unknown>>;
|
||||||
@@ -120,17 +111,6 @@ export class PublicWorkspaceController {
|
|||||||
...brandData,
|
...brandData,
|
||||||
...brandConfig,
|
...brandConfig,
|
||||||
};
|
};
|
||||||
const runtimeModules: RuntimeModule[] = modulesData.map((item) => ({
|
|
||||||
key: this.string(item.type, "custom"),
|
|
||||||
type: this.moduleType(this.string(item.type, "custom")),
|
|
||||||
version: "1.0.0",
|
|
||||||
propsSchema: `module.${this.string(item.type, "custom")}.v1`,
|
|
||||||
dataSource: this.string(item.type, "custom"),
|
|
||||||
config: this.jsonObject(item.config),
|
|
||||||
source:
|
|
||||||
item.source === "custom" ? "custom" : item.source === "template" ? "template" : "core",
|
|
||||||
schemaVersion: "1.0",
|
|
||||||
}));
|
|
||||||
const runtimeOfferings: RuntimeOffering[] = offeringsData.map((raw) => {
|
const runtimeOfferings: RuntimeOffering[] = offeringsData.map((raw) => {
|
||||||
const item = raw;
|
const item = raw;
|
||||||
const config = this.jsonObject(item.config);
|
const config = this.jsonObject(item.config);
|
||||||
@@ -282,7 +262,6 @@ export class PublicWorkspaceController {
|
|||||||
page: templatePackageManifest.entrypoints[tab.page] ?? tab.page,
|
page: templatePackageManifest.entrypoints[tab.page] ?? tab.page,
|
||||||
})) ?? [],
|
})) ?? [],
|
||||||
},
|
},
|
||||||
modules: runtimeModules,
|
|
||||||
offerings: runtimeOfferings,
|
offerings: runtimeOfferings,
|
||||||
inquiryForms: formsData.map((raw) => {
|
inquiryForms: formsData.map((raw) => {
|
||||||
const form = this.jsonObject(raw);
|
const form = this.jsonObject(raw);
|
||||||
@@ -355,32 +334,6 @@ export class PublicWorkspaceController {
|
|||||||
private jsonArray(value: unknown): Prisma.JsonValue[] {
|
private jsonArray(value: unknown): Prisma.JsonValue[] {
|
||||||
return Array.isArray(value) ? (value as Prisma.JsonValue[]) : [];
|
return Array.isArray(value) ? (value as Prisma.JsonValue[]) : [];
|
||||||
}
|
}
|
||||||
private moduleType(value: string): RuntimeModule["type"] {
|
|
||||||
const aliases: Record<string, RuntimeModule["type"]> = {
|
|
||||||
identity: "brand-hero",
|
|
||||||
trust: "trust-proof",
|
|
||||||
offering: "offering-list",
|
|
||||||
contact: "founder-card",
|
|
||||||
};
|
|
||||||
const known: RuntimeModule["type"][] = [
|
|
||||||
"brand-hero",
|
|
||||||
"founder-card",
|
|
||||||
"trust-proof",
|
|
||||||
"offering-list",
|
|
||||||
"offering-detail",
|
|
||||||
"gallery",
|
|
||||||
"timeline",
|
|
||||||
"faq",
|
|
||||||
"contact",
|
|
||||||
"inquiry",
|
|
||||||
"records",
|
|
||||||
"custom",
|
|
||||||
];
|
|
||||||
const type = aliases[value] ?? value;
|
|
||||||
return (
|
|
||||||
known.includes(type as RuntimeModule["type"]) ? type : "custom"
|
|
||||||
) as RuntimeModule["type"];
|
|
||||||
}
|
|
||||||
private sectionType(value: unknown): RuntimeOffering["sections"][number]["type"] {
|
private sectionType(value: unknown): RuntimeOffering["sections"][number]["type"] {
|
||||||
const known = ["text", "image-list", "timeline", "faq", "specification"] as const;
|
const known = ["text", "image-list", "timeline", "faq", "specification"] as const;
|
||||||
return known.includes(value as (typeof known)[number])
|
return known.includes(value as (typeof known)[number])
|
||||||
|
|||||||
@@ -94,12 +94,6 @@ export class PublicTemplateController {
|
|||||||
visual: visualTemplate,
|
visual: visualTemplate,
|
||||||
runtime: {
|
runtime: {
|
||||||
schemaVersion: "1.0.0",
|
schemaVersion: "1.0.0",
|
||||||
modules: industryTemplate.modules.map((module) => ({
|
|
||||||
key: module.key,
|
|
||||||
type: module.type,
|
|
||||||
title: module.title,
|
|
||||||
variant: visualTemplate.variants[module.type] ?? "default",
|
|
||||||
})),
|
|
||||||
capabilities: resolveCapabilities(industryTemplate.capabilities),
|
capabilities: resolveCapabilities(industryTemplate.capabilities),
|
||||||
theme: visualTemplate.theme,
|
theme: visualTemplate.theme,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -85,15 +85,6 @@ export class TemplateWorkspaceService {
|
|||||||
configSnapshot: templatePackageSnapshot as unknown as Prisma.InputJsonValue,
|
configSnapshot: templatePackageSnapshot as unknown as Prisma.InputJsonValue,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await tx.brandModule.createMany({
|
|
||||||
data: template.modules.map(({ type, title }, sortOrder) => ({
|
|
||||||
brandId,
|
|
||||||
type,
|
|
||||||
title,
|
|
||||||
sortOrder,
|
|
||||||
source: "template",
|
|
||||||
})),
|
|
||||||
});
|
|
||||||
await tx.brandFieldDefinition.createMany({
|
await tx.brandFieldDefinition.createMany({
|
||||||
data: template.fields.map(({ scope, key, label, type, required }, sortOrder) => ({
|
data: template.fields.map(({ scope, key, label, type, required }, sortOrder) => ({
|
||||||
brandId,
|
brandId,
|
||||||
@@ -118,20 +109,13 @@ export class TemplateWorkspaceService {
|
|||||||
const installation = await this.installation(brandId);
|
const installation = await this.installation(brandId);
|
||||||
const template = getBrandTemplate(installation.templateKey);
|
const template = getBrandTemplate(installation.templateKey);
|
||||||
if (!template) throw new BadRequestException("已安装模板不存在");
|
if (!template) throw new BadRequestException("已安装模板不存在");
|
||||||
const [modules, fields] = await Promise.all([
|
const fields = await this.prisma.brandFieldDefinition.findMany({ where: { brandId } });
|
||||||
this.prisma.brandModule.findMany({ where: { brandId } }),
|
|
||||||
this.prisma.brandFieldDefinition.findMany({ where: { brandId } }),
|
|
||||||
]);
|
|
||||||
return {
|
return {
|
||||||
currentVersion: installation.templateVersion,
|
currentVersion: installation.templateVersion,
|
||||||
latestVersion: template.version,
|
latestVersion: template.version,
|
||||||
canUpgrade: installation.templateVersion !== template.version,
|
canUpgrade: installation.templateVersion !== template.version,
|
||||||
canRollback:
|
canRollback:
|
||||||
Array.isArray(installation.previousSnapshots) && installation.previousSnapshots.length > 0,
|
Array.isArray(installation.previousSnapshots) && installation.previousSnapshots.length > 0,
|
||||||
missingModules: template.modules.filter(
|
|
||||||
(item) =>
|
|
||||||
!modules.some((current) => current.type === item.type && current.source === "template"),
|
|
||||||
),
|
|
||||||
missingFields: template.fields.filter(
|
missingFields: template.fields.filter(
|
||||||
(item) =>
|
(item) =>
|
||||||
!fields.some((current) => current.scope === item.scope && current.key === item.key),
|
!fields.some((current) => current.scope === item.scope && current.key === item.key),
|
||||||
@@ -145,27 +129,11 @@ export class TemplateWorkspaceService {
|
|||||||
if (installation.templateVersion === template.version)
|
if (installation.templateVersion === template.version)
|
||||||
throw new BadRequestException("当前模板已经是最新版本");
|
throw new BadRequestException("当前模板已经是最新版本");
|
||||||
return this.prisma.$transaction(async (tx) => {
|
return this.prisma.$transaction(async (tx) => {
|
||||||
const [modules, fields] = await Promise.all([
|
const fields = await tx.brandFieldDefinition.findMany({ where: { brandId } });
|
||||||
tx.brandModule.findMany({ where: { brandId } }),
|
|
||||||
tx.brandFieldDefinition.findMany({ where: { brandId } }),
|
|
||||||
]);
|
|
||||||
const addedModules = template.modules.filter(
|
|
||||||
(item) =>
|
|
||||||
!modules.some((current) => current.type === item.type && current.source === "template"),
|
|
||||||
);
|
|
||||||
const addedFields = template.fields.filter(
|
const addedFields = template.fields.filter(
|
||||||
(item) =>
|
(item) =>
|
||||||
!fields.some((current) => current.scope === item.scope && current.key === item.key),
|
!fields.some((current) => current.scope === item.scope && current.key === item.key),
|
||||||
);
|
);
|
||||||
await tx.brandModule.createMany({
|
|
||||||
data: addedModules.map(({ type, title }, index) => ({
|
|
||||||
brandId,
|
|
||||||
type,
|
|
||||||
title,
|
|
||||||
sortOrder: modules.length + index,
|
|
||||||
source: "template",
|
|
||||||
})),
|
|
||||||
});
|
|
||||||
await tx.brandFieldDefinition.createMany({
|
await tx.brandFieldDefinition.createMany({
|
||||||
data: addedFields.map(({ scope, key, label, type, required }, index) => ({
|
data: addedFields.map(({ scope, key, label, type, required }, index) => ({
|
||||||
brandId,
|
brandId,
|
||||||
@@ -189,7 +157,7 @@ export class TemplateWorkspaceService {
|
|||||||
previousSnapshots: [...history, installation.configSnapshot],
|
previousSnapshots: [...history, installation.configSnapshot],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return { installation: updated, addedModules, addedFields };
|
return { installation: updated, addedFields };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
async rollback(brandId: string) {
|
async rollback(brandId: string) {
|
||||||
|
|||||||
@@ -320,7 +320,6 @@ test("health and public content are available without authentication", async ()
|
|||||||
const runtime = JSON.parse(workspace.body);
|
const runtime = JSON.parse(workspace.body);
|
||||||
assert.equal(runtime.schemaVersion, "1.0.0");
|
assert.equal(runtime.schemaVersion, "1.0.0");
|
||||||
assert.ok(Array.isArray(runtime.navigation.tabs));
|
assert.ok(Array.isArray(runtime.navigation.tabs));
|
||||||
assert.ok(Array.isArray(runtime.modules));
|
|
||||||
assert.ok(Array.isArray(runtime.offerings));
|
assert.ok(Array.isArray(runtime.offerings));
|
||||||
assert.ok(Array.isArray(runtime.inquiryForms));
|
assert.ok(Array.isArray(runtime.inquiryForms));
|
||||||
assert.ok(Array.isArray(runtime.capabilities));
|
assert.ok(Array.isArray(runtime.capabilities));
|
||||||
@@ -675,7 +674,6 @@ test("admin can install doors industry template through the shared runtime contr
|
|||||||
await prisma.inquirySubmission.deleteMany({ where: { brandId } });
|
await prisma.inquirySubmission.deleteMany({ where: { brandId } });
|
||||||
await prisma.inquiryForm.deleteMany({ where: { brandId } });
|
await prisma.inquiryForm.deleteMany({ where: { brandId } });
|
||||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
||||||
await prisma.brandModule.deleteMany({ where: { brandId } });
|
|
||||||
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
||||||
const login = await request("/admin/session/login", {
|
const login = await request("/admin/session/login", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -702,7 +700,6 @@ test("admin can install doors industry template through the shared runtime contr
|
|||||||
assert.equal(JSON.parse(samplePreview.body).templateKey, "doors");
|
assert.equal(JSON.parse(samplePreview.body).templateKey, "doors");
|
||||||
} finally {
|
} finally {
|
||||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
||||||
await prisma.brandModule.deleteMany({ where: { brandId } });
|
|
||||||
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -770,7 +767,6 @@ test("admin can install a template and public workspace exposes enabled configur
|
|||||||
await prisma.inquirySubmission.deleteMany({ where: { brandId } });
|
await prisma.inquirySubmission.deleteMany({ where: { brandId } });
|
||||||
await prisma.inquiryForm.deleteMany({ where: { brandId } });
|
await prisma.inquiryForm.deleteMany({ where: { brandId } });
|
||||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
||||||
await prisma.brandModule.deleteMany({ where: { brandId } });
|
|
||||||
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
||||||
const login = await request("/admin/session/login", {
|
const login = await request("/admin/session/login", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -839,14 +835,13 @@ test("admin can install a template and public workspace exposes enabled configur
|
|||||||
const workspaceBody = JSON.parse(publicWorkspace.body);
|
const workspaceBody = JSON.parse(publicWorkspace.body);
|
||||||
assert.equal(workspaceBody.contractVersion, "1.0");
|
assert.equal(workspaceBody.contractVersion, "1.0");
|
||||||
assert.equal(workspaceBody.template.key, "food");
|
assert.equal(workspaceBody.template.key, "food");
|
||||||
assert.ok(workspaceBody.modules.length > 0);
|
|
||||||
assert.equal("templateContent" in workspaceBody, false);
|
assert.equal("templateContent" in workspaceBody, false);
|
||||||
assert.equal("runtimeModules" in workspaceBody, false);
|
assert.equal("runtimeModules" in workspaceBody, false);
|
||||||
assert.equal("runtimeCapabilities" in workspaceBody, false);
|
assert.equal("runtimeCapabilities" in workspaceBody, false);
|
||||||
assert.equal("fields" in workspaceBody, false);
|
assert.equal("fields" in workspaceBody, false);
|
||||||
assert.equal("trustContent" in workspaceBody, false);
|
assert.equal("trustContent" in workspaceBody, false);
|
||||||
assert.equal("inquiryForm" in workspaceBody, false);
|
assert.equal("inquiryForm" in workspaceBody, false);
|
||||||
assert.equal(workspaceBody.modules[0].schemaVersion, "1.0");
|
assert.equal("modules" in workspaceBody, false);
|
||||||
assert.ok(workspaceBody.inquiryForms.length > 0);
|
assert.ok(workspaceBody.inquiryForms.length > 0);
|
||||||
const conflict = await request("/admin/workspace/install", {
|
const conflict = await request("/admin/workspace/install", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -856,14 +851,12 @@ test("admin can install a template and public workspace exposes enabled configur
|
|||||||
assert.equal(conflict.statusCode, 400);
|
assert.equal(conflict.statusCode, 400);
|
||||||
} finally {
|
} finally {
|
||||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
||||||
await prisma.brandModule.deleteMany({ where: { brandId } });
|
|
||||||
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test("admin can customize workspace modules and fields with brand isolation", async () => {
|
test("admin can customize workspace fields with brand isolation", async () => {
|
||||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
||||||
await prisma.brandModule.deleteMany({ where: { brandId } });
|
|
||||||
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
||||||
const login = await request("/admin/session/login", {
|
const login = await request("/admin/session/login", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -879,19 +872,12 @@ test("admin can customize workspace modules and fields with brand isolation", as
|
|||||||
const workspace = await request("/admin/workspace", {
|
const workspace = await request("/admin/workspace", {
|
||||||
headers: { authorization: `Bearer ${token}` },
|
headers: { authorization: `Bearer ${token}` },
|
||||||
});
|
});
|
||||||
const moduleId = JSON.parse(workspace.body).modules[0].id;
|
|
||||||
const invalidField = await request("/admin/workspace/fields", {
|
const invalidField = await request("/admin/workspace/fields", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { authorization: `Bearer ${token}` },
|
headers: { authorization: `Bearer ${token}` },
|
||||||
payload: { scope: "unknown", key: "Bad-Key", label: "非法字段", type: "text" },
|
payload: { scope: "unknown", key: "Bad-Key", label: "非法字段", type: "text" },
|
||||||
});
|
});
|
||||||
assert.equal(invalidField.statusCode, 400);
|
assert.equal(invalidField.statusCode, 400);
|
||||||
const updatedModule = await request(`/admin/workspace/modules/${moduleId}`, {
|
|
||||||
method: "PATCH",
|
|
||||||
headers: { authorization: `Bearer ${token}` },
|
|
||||||
payload: { title: "我的品牌介绍", isEnabled: false },
|
|
||||||
});
|
|
||||||
assert.equal(updatedModule.statusCode, 200);
|
|
||||||
const createdField = await request("/admin/workspace/fields", {
|
const createdField = await request("/admin/workspace/fields", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { authorization: `Bearer ${token}` },
|
headers: { authorization: `Bearer ${token}` },
|
||||||
@@ -919,7 +905,6 @@ test("admin can customize workspace modules and fields with brand isolation", as
|
|||||||
assert.equal(deletedField.statusCode, 200);
|
assert.equal(deletedField.statusCode, 200);
|
||||||
} finally {
|
} finally {
|
||||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
||||||
await prisma.brandModule.deleteMany({ where: { brandId } });
|
|
||||||
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 62 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 114 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 61 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 67 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 65 KiB |
@@ -1,8 +0,0 @@
|
|||||||
Component({
|
|
||||||
properties: { hero: { type: Object, value: {} }, variant: { type: String, value: "default" } },
|
|
||||||
methods: {
|
|
||||||
explore() {
|
|
||||||
this.triggerEvent("explore");
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{ "component": true }
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<view class="hero"><image class="hero-image" src="{{hero.image}}" mode="aspectFill"/><view class="hero-shade"/><view class="hero-copy"><text class="eyebrow">{{hero.eyebrow}}</text><text class="hero-title">{{hero.title}}</text><text class="hero-slogan">{{hero.slogan}}</text><button class="hero-button" bindtap="explore">{{hero.cta}}</button></view></view>
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
.hero {
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
margin-top: 22rpx;
|
|
||||||
height: 560rpx;
|
|
||||||
border-radius: 16rpx;
|
|
||||||
background: #202221;
|
|
||||||
}
|
|
||||||
.hero-image {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
.hero-shade {
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
background: linear-gradient(180deg, transparent 30%, rgba(32, 34, 33, 0.9));
|
|
||||||
}
|
|
||||||
.hero-copy {
|
|
||||||
position: absolute;
|
|
||||||
left: 28rpx;
|
|
||||||
right: 28rpx;
|
|
||||||
bottom: 28rpx;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
.eyebrow {
|
|
||||||
display: block;
|
|
||||||
color: #d9c8b2;
|
|
||||||
font-size: 20rpx;
|
|
||||||
letter-spacing: 3rpx;
|
|
||||||
}
|
|
||||||
.hero-title {
|
|
||||||
display: block;
|
|
||||||
margin-top: 14rpx;
|
|
||||||
font: 40rpx serif;
|
|
||||||
}
|
|
||||||
.hero-slogan {
|
|
||||||
display: block;
|
|
||||||
margin-top: 10rpx;
|
|
||||||
color: #ddd5cb;
|
|
||||||
font-size: 23rpx;
|
|
||||||
}
|
|
||||||
.hero-button {
|
|
||||||
margin: 24rpx 0 0 0;
|
|
||||||
padding: 0 22rpx;
|
|
||||||
border: 1rpx solid #d9c8b2;
|
|
||||||
border-radius: 0;
|
|
||||||
background: transparent;
|
|
||||||
color: #fff;
|
|
||||||
font-size: 24rpx;
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
Component({
|
|
||||||
properties: {
|
|
||||||
brand: { type: Object, value: {} },
|
|
||||||
presentation: { type: Object, value: {} },
|
|
||||||
variant: { type: String, value: "default" },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{ "component": true }
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<view class="founder"><image wx:if="{{brand.avatarUrl}}" class="avatar" src="{{brand.avatarUrl}}"/><view wx:else class="avatar avatar-placeholder">{{brand.founder}}</view><view><text class="founder-name">{{brand.founder}}</text><text class="founder-title">{{brand.title}}</text><text class="quote">“{{brand.slogan}}”</text></view><text wx:if="{{presentation.founderBadge}}" class="badge">{{presentation.founderBadge}}</text></view>
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
.founder {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 18rpx;
|
|
||||||
padding: 24rpx;
|
|
||||||
background: #fff;
|
|
||||||
border-radius: 16rpx;
|
|
||||||
}
|
|
||||||
.avatar {
|
|
||||||
width: 88rpx;
|
|
||||||
height: 88rpx;
|
|
||||||
border-radius: 50%;
|
|
||||||
object-fit: cover;
|
|
||||||
}
|
|
||||||
.avatar-placeholder {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
overflow: hidden;
|
|
||||||
background: #eee;
|
|
||||||
color: #777;
|
|
||||||
font-size: 24rpx;
|
|
||||||
}
|
|
||||||
.founder-name {
|
|
||||||
display: block;
|
|
||||||
font: 34rpx serif;
|
|
||||||
}
|
|
||||||
.founder-title {
|
|
||||||
display: block;
|
|
||||||
margin-top: 6rpx;
|
|
||||||
color: #77736b;
|
|
||||||
font-size: 22rpx;
|
|
||||||
}
|
|
||||||
.quote {
|
|
||||||
display: block;
|
|
||||||
margin-top: 8rpx;
|
|
||||||
color: #8a6846;
|
|
||||||
font-size: 22rpx;
|
|
||||||
}
|
|
||||||
.badge {
|
|
||||||
margin-left: auto;
|
|
||||||
padding: 8rpx 12rpx;
|
|
||||||
border: 1rpx solid #d9c8b2;
|
|
||||||
color: #8a6846;
|
|
||||||
font-size: 20rpx;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
Component({
|
|
||||||
properties: {
|
|
||||||
offerings: { type: Array, value: [] },
|
|
||||||
presentation: { type: Object, value: {} },
|
|
||||||
variant: { type: String, value: "default" },
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
open(e) {
|
|
||||||
this.triggerEvent("open", { id: e.currentTarget.dataset.id });
|
|
||||||
},
|
|
||||||
more() {
|
|
||||||
this.triggerEvent("more");
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{ "component": true }
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<view class="section"><view class="section-head"><view><text class="eyebrow dark">{{presentation.worksEyebrow}}</text><text class="section-title">{{presentation.worksTitle}}</text></view><text class="more" bindtap="more">{{presentation.worksAction}}</text></view><view wx:for="{{offerings}}" wx:key="id" class="work-card" data-id="{{item.id}}" bindtap="open"><image src="{{item.image}}" mode="aspectFill"/><view class="work-info"><text class="work-category">{{item.category}} · {{item.area}}</text><text class="work-name">{{item.name}}</text><text class="work-desc">{{item.series}} · {{item.keywords[0]}} · {{item.keywords[1]}}</text></view></view></view>
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
.section {
|
|
||||||
margin-top: 22rpx;
|
|
||||||
padding: 28rpx;
|
|
||||||
background: #fff;
|
|
||||||
}
|
|
||||||
.section-head {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
.eyebrow {
|
|
||||||
display: block;
|
|
||||||
color: #8a6846;
|
|
||||||
font-size: 20rpx;
|
|
||||||
letter-spacing: 3rpx;
|
|
||||||
}
|
|
||||||
.section-title {
|
|
||||||
display: block;
|
|
||||||
margin-top: 10rpx;
|
|
||||||
font: 40rpx serif;
|
|
||||||
}
|
|
||||||
.more {
|
|
||||||
color: #8a6846;
|
|
||||||
font-size: 22rpx;
|
|
||||||
}
|
|
||||||
.work-card {
|
|
||||||
margin-top: 22rpx;
|
|
||||||
overflow: hidden;
|
|
||||||
border: 1rpx solid #e6ded5;
|
|
||||||
}
|
|
||||||
.work-card image {
|
|
||||||
width: 100%;
|
|
||||||
height: 300rpx;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
.work-info {
|
|
||||||
padding: 18rpx;
|
|
||||||
}
|
|
||||||
.work-category {
|
|
||||||
display: block;
|
|
||||||
color: #8a6846;
|
|
||||||
font-size: 21rpx;
|
|
||||||
}
|
|
||||||
.work-name {
|
|
||||||
display: block;
|
|
||||||
margin-top: 8rpx;
|
|
||||||
font: 30rpx serif;
|
|
||||||
}
|
|
||||||
.work-desc {
|
|
||||||
display: block;
|
|
||||||
margin-top: 8rpx;
|
|
||||||
color: #77736b;
|
|
||||||
font-size: 22rpx;
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
Component({
|
|
||||||
properties: {
|
|
||||||
brand: { type: Object, value: {} },
|
|
||||||
presentation: { type: Object, value: {} },
|
|
||||||
recordsCount: { type: Number, value: 0 },
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
call() {
|
|
||||||
this.triggerEvent("call");
|
|
||||||
},
|
|
||||||
copy() {
|
|
||||||
this.triggerEvent("copy");
|
|
||||||
},
|
|
||||||
records() {
|
|
||||||
this.triggerEvent("records");
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{ "component": true }
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<view class="profile"><view class="contact-card"><view class="identity"><image wx:if="{{brand.avatarUrl}}" class="avatar" src="{{brand.avatarUrl}}" mode="aspectFill"/><view wx:else class="avatar">{{brand.founder}}</view><view><text class="founder">{{brand.founder}}</text><text class="role">{{brand.title}}</text></view></view><view class="line"><text>{{presentation.phoneLabel || '联系电话'}}</text><view><text>{{brand.phone}}</text><button bindtap="call">{{presentation.callAction || '呼叫'}}</button></view></view><view class="line"><text>{{presentation.wechatLabel || '微信'}}</text><view><text>{{brand.wechat}}</text><button bindtap="copy">{{presentation.copyAction || '复制'}}</button></view></view><view class="line"><text>{{presentation.addressLabel || '工作地址'}}</text><text>{{brand.studioAddress}}</text></view></view><view class="entry" bindtap="records"><text>{{presentation.recordsTitle || '我的咨询记录'}}</text><text>{{recordsCount}} {{presentation.recordsCountUnit || '条记录'}} ›</text></view></view>
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
.profile {
|
|
||||||
margin-top: 22rpx;
|
|
||||||
}
|
|
||||||
.contact-card {
|
|
||||||
padding: 34rpx 30rpx;
|
|
||||||
background: #202221;
|
|
||||||
color: #fff;
|
|
||||||
border-radius: 18rpx;
|
|
||||||
}
|
|
||||||
.identity {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 20rpx;
|
|
||||||
}
|
|
||||||
.avatar {
|
|
||||||
width: 88rpx;
|
|
||||||
height: 88rpx;
|
|
||||||
border: 2rpx solid #8a6846;
|
|
||||||
border-radius: 50%;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
color: #d9c8b2;
|
|
||||||
font: 42rpx serif;
|
|
||||||
}
|
|
||||||
.founder {
|
|
||||||
display: block;
|
|
||||||
font: 34rpx serif;
|
|
||||||
}
|
|
||||||
.role {
|
|
||||||
display: block;
|
|
||||||
margin-top: 8rpx;
|
|
||||||
color: #d9c8b2;
|
|
||||||
font-size: 22rpx;
|
|
||||||
}
|
|
||||||
.line {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
margin-top: 22rpx;
|
|
||||||
padding-top: 18rpx;
|
|
||||||
border-top: 1rpx solid rgba(255, 255, 255, 0.12);
|
|
||||||
color: #aaa;
|
|
||||||
font-size: 23rpx;
|
|
||||||
}
|
|
||||||
.line > view {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 10rpx;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
.line button {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0 14rpx;
|
|
||||||
background: rgba(255, 255, 255, 0.1);
|
|
||||||
color: #d9c8b2;
|
|
||||||
font-size: 21rpx;
|
|
||||||
}
|
|
||||||
.entry {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
margin-top: 20rpx;
|
|
||||||
padding: 28rpx;
|
|
||||||
background: #fff;
|
|
||||||
border: 1rpx solid #e6ded5;
|
|
||||||
border-radius: 16rpx;
|
|
||||||
font-size: 26rpx;
|
|
||||||
}
|
|
||||||
.entry text:last-child {
|
|
||||||
color: #8a6846;
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
Component({
|
|
||||||
properties: {
|
|
||||||
content: { type: Object, value: {} },
|
|
||||||
presentation: { type: Object, value: {} },
|
|
||||||
variant: { type: String, value: "default" },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{ "component": true }
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<view class="trust"><text class="eyebrow">{{presentation.manifestoEyebrow}}</text><text class="section-title light">{{presentation.manifestoTitle}}</text><view wx:for="{{content.pillars}}" wx:key="title"><text class="work-name light">{{item.title}}</text><text class="body light-body">{{item.desc}}</text></view></view>
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
.trust {
|
|
||||||
margin-top: 22rpx;
|
|
||||||
padding: 32rpx;
|
|
||||||
background: #202221;
|
|
||||||
color: #fff;
|
|
||||||
border-radius: 16rpx;
|
|
||||||
}
|
|
||||||
.eyebrow {
|
|
||||||
display: block;
|
|
||||||
color: #d9c8b2;
|
|
||||||
font-size: 20rpx;
|
|
||||||
letter-spacing: 3rpx;
|
|
||||||
}
|
|
||||||
.section-title {
|
|
||||||
display: block;
|
|
||||||
margin-top: 12rpx;
|
|
||||||
font: 42rpx serif;
|
|
||||||
}
|
|
||||||
.light {
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
.work-name {
|
|
||||||
display: block;
|
|
||||||
margin-top: 24rpx;
|
|
||||||
font: 29rpx serif;
|
|
||||||
}
|
|
||||||
.body {
|
|
||||||
display: block;
|
|
||||||
margin-top: 8rpx;
|
|
||||||
color: #77736b;
|
|
||||||
font-size: 24rpx;
|
|
||||||
line-height: 1.7;
|
|
||||||
}
|
|
||||||
.light-body {
|
|
||||||
color: #c8c5bf;
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
Component({
|
|
||||||
properties: {
|
|
||||||
content: { type: Object, value: {} },
|
|
||||||
presentation: { type: Object, value: {} },
|
|
||||||
variant: { type: String, value: "default" },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{ "component": true }
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<view class="trust-section">
|
|
||||||
<view class="trust-head"><text class="eyebrow">{{presentation.proofEyebrow || '信任凭证'}}</text></view>
|
|
||||||
<view class="stats">
|
|
||||||
<view wx:for="{{content.stats}}" wx:key="value" class="stat-card"><text class="stat-value">{{item.value}}</text><text class="stat-label">{{item.label}}</text><text class="stat-sub">{{item.sub}}</text></view>
|
|
||||||
</view>
|
|
||||||
<view class="manifesto">
|
|
||||||
<view class="manifesto-head"><text>{{presentation.manifestoEyebrow}}</text><text>{{presentation.manifestoTitle}}</text></view>
|
|
||||||
<view wx:for="{{content.pillars}}" wx:key="title" class="pillar"><view class="pillar-icon">{{item.icon === 'tree' ? '木' : item.icon === 'ruler' ? '尺' : '盾'}}</view><view><text class="pillar-title">{{item.title}}</text><text class="pillar-desc">{{item.desc}}</text></view></view>
|
|
||||||
</view>
|
|
||||||
<view class="flow-card"><text class="flow-eyebrow">{{presentation.flowEyebrow}}</text><text class="flow-title">{{presentation.flowTitle}}</text><view class="flow-grid"><view wx:for="{{content.serviceFlow}}" wx:key="step" class="flow-item"><text class="flow-step">{{item.step}}</text><text class="flow-name">{{item.name}}</text><text class="flow-desc">{{item.desc}}</text></view></view></view>
|
|
||||||
</view>
|
|
||||||
@@ -1,159 +0,0 @@
|
|||||||
.trust-section {
|
|
||||||
padding: 0 40rpx 42rpx;
|
|
||||||
}
|
|
||||||
.trust-head {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
margin-bottom: 20rpx;
|
|
||||||
}
|
|
||||||
.eyebrow {
|
|
||||||
display: block;
|
|
||||||
color: #8a6846;
|
|
||||||
font-size: 20rpx;
|
|
||||||
letter-spacing: 3rpx;
|
|
||||||
}
|
|
||||||
.trust-link {
|
|
||||||
color: #8a6846;
|
|
||||||
font-size: 21rpx;
|
|
||||||
}
|
|
||||||
.stats {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 1fr 1fr;
|
|
||||||
gap: 16rpx;
|
|
||||||
margin-bottom: 18rpx;
|
|
||||||
}
|
|
||||||
.stat-card {
|
|
||||||
padding: 22rpx;
|
|
||||||
background: #fff;
|
|
||||||
border: 1rpx solid #e6ded5;
|
|
||||||
border-radius: 16rpx;
|
|
||||||
}
|
|
||||||
.stat-value {
|
|
||||||
display: block;
|
|
||||||
color: #8a6846;
|
|
||||||
font: 38rpx serif;
|
|
||||||
}
|
|
||||||
.stat-label {
|
|
||||||
display: block;
|
|
||||||
font-size: 22rpx;
|
|
||||||
margin-top: 4rpx;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
.stat-sub {
|
|
||||||
display: block;
|
|
||||||
margin-top: 6rpx;
|
|
||||||
color: #77736b;
|
|
||||||
font-size: 18rpx;
|
|
||||||
line-height: 1.5;
|
|
||||||
}
|
|
||||||
.manifesto {
|
|
||||||
padding: 28rpx;
|
|
||||||
border-radius: 20rpx;
|
|
||||||
background: #202221;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
.manifesto-head {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
padding-bottom: 18rpx;
|
|
||||||
margin-bottom: 20rpx;
|
|
||||||
border-bottom: 1rpx solid rgba(255, 255, 255, 0.12);
|
|
||||||
color: #d9c8b2;
|
|
||||||
font-size: 20rpx;
|
|
||||||
}
|
|
||||||
.manifesto-head text:last-child {
|
|
||||||
color: rgba(255, 255, 255, 0.5);
|
|
||||||
font-size: 18rpx;
|
|
||||||
}
|
|
||||||
.pillar {
|
|
||||||
display: flex;
|
|
||||||
gap: 16rpx;
|
|
||||||
margin-top: 20rpx;
|
|
||||||
}
|
|
||||||
.pillar-icon {
|
|
||||||
width: 44rpx;
|
|
||||||
height: 44rpx;
|
|
||||||
flex: 0 0 44rpx;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
border-radius: 8rpx;
|
|
||||||
background: rgba(138, 104, 70, 0.3);
|
|
||||||
color: #d9c8b2;
|
|
||||||
font-size: 18rpx;
|
|
||||||
}
|
|
||||||
.pillar-title,
|
|
||||||
.pillar-desc {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
.pillar-title {
|
|
||||||
font-size: 22rpx;
|
|
||||||
}
|
|
||||||
.pillar-desc {
|
|
||||||
margin-top: 5rpx;
|
|
||||||
color: rgba(255, 255, 255, 0.62);
|
|
||||||
font-size: 18rpx;
|
|
||||||
line-height: 1.55;
|
|
||||||
}
|
|
||||||
.flow-card {
|
|
||||||
margin-top: 22rpx;
|
|
||||||
padding: 32rpx 24rpx;
|
|
||||||
border: 1rpx solid #e6ded5;
|
|
||||||
border-radius: 20rpx;
|
|
||||||
background: #efece6;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
.flow-eyebrow,
|
|
||||||
.flow-title,
|
|
||||||
.flow-sub {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
.flow-eyebrow {
|
|
||||||
color: #8a6846;
|
|
||||||
font-size: 18rpx;
|
|
||||||
letter-spacing: 2rpx;
|
|
||||||
}
|
|
||||||
.flow-title {
|
|
||||||
margin-top: 6rpx;
|
|
||||||
font: 30rpx serif;
|
|
||||||
}
|
|
||||||
.flow-sub {
|
|
||||||
margin-top: 8rpx;
|
|
||||||
color: #77736b;
|
|
||||||
font-size: 18rpx;
|
|
||||||
}
|
|
||||||
.flow-grid {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 1fr 1fr;
|
|
||||||
gap: 16rpx;
|
|
||||||
margin-top: 26rpx;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
.flow-item {
|
|
||||||
padding: 18rpx;
|
|
||||||
border: 1rpx solid #e6ded5;
|
|
||||||
border-radius: 14rpx;
|
|
||||||
background: #fff;
|
|
||||||
}
|
|
||||||
.flow-step,
|
|
||||||
.flow-name,
|
|
||||||
.flow-desc {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
.flow-step {
|
|
||||||
color: #8a6846;
|
|
||||||
font-size: 18rpx;
|
|
||||||
font-weight: 700;
|
|
||||||
}
|
|
||||||
.flow-name {
|
|
||||||
margin-top: 5rpx;
|
|
||||||
font-size: 21rpx;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
.flow-desc {
|
|
||||||
margin-top: 6rpx;
|
|
||||||
color: #77736b;
|
|
||||||
font-size: 17rpx;
|
|
||||||
line-height: 1.5;
|
|
||||||
}
|
|
||||||
@@ -21,7 +21,6 @@ function loadWithResponse(response) {
|
|||||||
wx: storage,
|
wx: storage,
|
||||||
require(id) {
|
require(id) {
|
||||||
if (id === "./request") return { request: () => Promise.resolve(response) };
|
if (id === "./request") return { request: () => Promise.resolve(response) };
|
||||||
if (id === "./module-registry") return { resolveRuntime: () => ({}) };
|
|
||||||
throw new Error(`意外依赖:${id}`);
|
throw new Error(`意外依赖:${id}`);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -44,17 +43,21 @@ test("已发布 workspace 正常返回", async () => {
|
|||||||
assert.equal(workspace.brand.name, "测试品牌");
|
assert.equal(workspace.brand.name, "测试品牌");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("运行时只消费 canonical workspace 字段", async () => {
|
test("运行时保留模板业务数据,不再解释视觉模块", async () => {
|
||||||
const workspace = await loadWithResponse({
|
const workspace = await loadWithResponse({
|
||||||
publication: { status: "published" },
|
publication: { status: "published" },
|
||||||
brand: { name: "测试品牌" },
|
brand: { name: "测试品牌" },
|
||||||
offerings: [],
|
offerings: [],
|
||||||
trustPresentation: { bio: "品牌介绍" },
|
trustPresentation: { bio: "品牌介绍" },
|
||||||
inquiryForms: [],
|
inquiryForms: [],
|
||||||
|
modules: [{ key: "brand-hero" }],
|
||||||
|
visualTemplateManifest: { pages: [] },
|
||||||
});
|
});
|
||||||
assert.deepEqual(workspace.trustContent, { bio: "品牌介绍" });
|
assert.deepEqual(workspace.trustContent, { bio: "品牌介绍" });
|
||||||
assert.equal(workspace.fields, undefined);
|
assert.equal(workspace.fields, undefined);
|
||||||
assert.equal(workspace.inquiryForm, undefined);
|
assert.equal(workspace.inquiryForm, undefined);
|
||||||
|
assert.equal(workspace.modules[0].key, "brand-hero");
|
||||||
|
assert.deepEqual(workspace.visualTemplateManifest, { pages: [] });
|
||||||
});
|
});
|
||||||
|
|
||||||
test("模板声明的业务提供项展示字段会保留在小程序 view model", async () => {
|
test("模板声明的业务提供项展示字段会保留在小程序 view model", async () => {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ const { execFileSync } = require("node:child_process");
|
|||||||
const root = path.resolve(__dirname, "..");
|
const root = path.resolve(__dirname, "..");
|
||||||
const requestSource = fs.readFileSync(path.join(root, "utils/request.js"), "utf8");
|
const requestSource = fs.readFileSync(path.join(root, "utils/request.js"), "utf8");
|
||||||
const configSource = fs.readFileSync(path.join(root, "utils/config.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");
|
const runtimeRequestSource = fs.readFileSync(path.join(root, "utils/request.js"), "utf8");
|
||||||
if (
|
if (
|
||||||
!requestSource.includes('path.startsWith("/public/")') ||
|
!requestSource.includes('path.startsWith("/public/")') ||
|
||||||
@@ -15,10 +14,6 @@ if (
|
|||||||
console.error("miniapp: public requests must carry the configured brand slug");
|
console.error("miniapp: public requests must carry the configured brand slug");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
if (!moduleRegistrySource.includes("manifest.pages")) {
|
|
||||||
console.error("miniapp: visual page renderers must resolve from the manifest");
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
if (
|
if (
|
||||||
!runtimeRequestSource.includes('path.startsWith("/customer/session/wechat")') ||
|
!runtimeRequestSource.includes('path.startsWith("/customer/session/wechat")') ||
|
||||||
!runtimeRequestSource.includes('"customerToken:" + config.brandSlug')
|
!runtimeRequestSource.includes('"customerToken:" + config.brandSlug')
|
||||||
@@ -66,17 +61,6 @@ if (!doorsContent.offerings.every((item) => item.kind === "product" || item.kind
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
for (const fixture of fixtures) {
|
for (const fixture of fixtures) {
|
||||||
const modules = fixture.requiredModules.map((key) => path.join(root, "components/modules", key));
|
|
||||||
const missing = modules.filter(
|
|
||||||
(directory) =>
|
|
||||||
![".js", ".json", ".wxml", ".wxss"].every((extension) =>
|
|
||||||
fs.existsSync(path.join(directory, `${path.basename(directory)}${extension}`)),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
if (missing.length) {
|
|
||||||
console.error(`${fixture.templateKey}: missing module files: ${missing.join(", ")}`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
const pageMap = {
|
const pageMap = {
|
||||||
home: "pages/index/index",
|
home: "pages/index/index",
|
||||||
offerings: "pages/services/index",
|
offerings: "pages/services/index",
|
||||||
@@ -108,27 +92,8 @@ for (const fixture of fixtures) {
|
|||||||
console.error(`${fixture.templateKey}: missing page manifests: ${missingPages.join(", ")}`);
|
console.error(`${fixture.templateKey}: missing page manifests: ${missingPages.join(", ")}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
if (!fixture.layout?.home?.length) {
|
|
||||||
console.error(`${fixture.templateKey}: missing home layout`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
fixture.requiredCapabilities &&
|
|
||||||
fixture.requiredCapabilities.includes("inquiry") &&
|
|
||||||
!fixture.requiredModules.includes("inquiry-form")
|
|
||||||
) {
|
|
||||||
console.error(`${fixture.templateKey}: inquiry capability requires inquiry-form module`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
fixture.visualAnchors?.home &&
|
|
||||||
JSON.stringify(fixture.layout.home) !== JSON.stringify(fixture.visualAnchors.home)
|
|
||||||
) {
|
|
||||||
console.error(`${fixture.templateKey}: home layout does not match visual anchors`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
console.log(
|
console.log(
|
||||||
`Fixture ${fixture.templateKey}@${fixture.version} passed: ${fixture.requiredModules.length} modules.`,
|
`Fixture ${fixture.templateKey}@${fixture.version} passed: ${fixture.pages.length} pages.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
console.log(
|
console.log(
|
||||||
|
|||||||
@@ -1,40 +1,194 @@
|
|||||||
const fs = require("node:fs");
|
const fs = require("node:fs");
|
||||||
const path = require("node:path");
|
const path = require("node:path");
|
||||||
const root = path.resolve(__dirname, "..");
|
const os = require("node:os");
|
||||||
const fixtureFiles = [
|
const { execFileSync } = require("node:child_process");
|
||||||
"linjing-door-visual.json",
|
|
||||||
"doors-visual.json",
|
const workspaceRoot = path.resolve(__dirname, "../../..");
|
||||||
"acheng-campus-food-visual.json",
|
const packagesRoot = path.join(workspaceRoot, "packages");
|
||||||
];
|
const compiler = path.join(packagesRoot, "template-compiler/src/cli.mjs");
|
||||||
const fixtures = fixtureFiles.map((file) =>
|
const pageExtensions = [".js", ".json", ".wxml", ".wxss"];
|
||||||
JSON.parse(fs.readFileSync(path.join(__dirname, "fixtures", file), "utf8")),
|
|
||||||
);
|
function readJson(filePath) {
|
||||||
for (const fixture of fixtures) {
|
return JSON.parse(fs.readFileSync(filePath, "utf8"));
|
||||||
const failures = [];
|
}
|
||||||
for (const [state, definition] of Object.entries(fixture.states)) {
|
|
||||||
const wxmlPath = path.join(root, `${definition.page}.wxml`);
|
function listTemplatePackages() {
|
||||||
if (!fs.existsSync(wxmlPath)) {
|
return fs
|
||||||
failures.push(`${state}: missing ${definition.page}.wxml`);
|
.readdirSync(packagesRoot, { withFileTypes: true })
|
||||||
continue;
|
.filter((entry) => entry.isDirectory() && entry.name.startsWith("template-"))
|
||||||
}
|
.map((entry) => path.join(packagesRoot, entry.name))
|
||||||
let content = fs.readFileSync(wxmlPath, "utf8");
|
.filter((directory) => fs.existsSync(path.join(directory, "template.json")))
|
||||||
const componentRefs = [...content.matchAll(/<([a-z][a-z0-9-]*)\s/g)]
|
.sort();
|
||||||
.map((match) => match[1])
|
}
|
||||||
.filter((name) => name.includes("-"));
|
|
||||||
for (const ref of componentRefs) {
|
function resolveComponent(output, fromFile, reference) {
|
||||||
for (const componentRoot of ["components/modules", "components/templates"]) {
|
const base = reference.startsWith("/")
|
||||||
const candidate = path.join(root, componentRoot, ref, `${ref}.wxml`);
|
? path.join(output, reference)
|
||||||
if (fs.existsSync(candidate)) content += fs.readFileSync(candidate, "utf8");
|
: reference.startsWith(".")
|
||||||
}
|
? path.resolve(path.dirname(path.join(output, fromFile)), reference)
|
||||||
}
|
: path.join(output, "miniprogram_npm", reference);
|
||||||
for (const anchor of definition.anchors)
|
return [".json", ".js", ".wxml"].every((extension) => fs.existsSync(base + extension));
|
||||||
if (!content.includes(anchor)) failures.push(`${state}: missing anchor ${anchor}`);
|
}
|
||||||
}
|
|
||||||
if (failures.length) {
|
function resolveRequire(output, fromFile, reference) {
|
||||||
console.error(failures.join("\n"));
|
const base = path.resolve(path.dirname(path.join(output, fromFile)), reference);
|
||||||
process.exit(1);
|
return [base, base + ".js", path.join(base, "index.js")].some(
|
||||||
}
|
(candidate) => fs.existsSync(candidate) && fs.statSync(candidate).isFile(),
|
||||||
console.log(
|
|
||||||
`Visual fixture ${fixture.templateKey} passed: ${Object.keys(fixture.states).length} states at ${fixture.viewport.width}x${fixture.viewport.height}.`,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function listFiles(directory, base = directory, files = []) {
|
||||||
|
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
||||||
|
if (entry.name === "node_modules" || entry.name === "miniprogram_npm") continue;
|
||||||
|
const absolutePath = path.join(directory, entry.name);
|
||||||
|
if (entry.isDirectory()) listFiles(absolutePath, base, files);
|
||||||
|
else files.push(path.relative(base, absolutePath).split(path.sep).join("/"));
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
|
function templateComponentNames(directory) {
|
||||||
|
const componentRoot = path.join(directory, "miniapp/components/templates");
|
||||||
|
if (!fs.existsSync(componentRoot)) return [];
|
||||||
|
return fs
|
||||||
|
.readdirSync(componentRoot, { withFileTypes: true })
|
||||||
|
.filter((entry) => entry.isDirectory())
|
||||||
|
.map((entry) => entry.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateManifestOutput(manifest, output, otherComponentNames) {
|
||||||
|
const failures = [];
|
||||||
|
const appPath = path.join(output, "app.json");
|
||||||
|
if (!fs.existsSync(appPath)) return ["missing generated app.json"];
|
||||||
|
const app = readJson(appPath);
|
||||||
|
const entrypointPages = Object.values(manifest.entrypoints || {});
|
||||||
|
const declaredPages = [...new Set([...(manifest.pages || []), ...entrypointPages])];
|
||||||
|
|
||||||
|
for (const page of declaredPages) {
|
||||||
|
for (const extension of pageExtensions) {
|
||||||
|
if (!fs.existsSync(path.join(output, page + extension)))
|
||||||
|
failures.push(`declared page ${page} is missing ${extension}`);
|
||||||
|
}
|
||||||
|
if (!app.pages.includes(page)) failures.push(`declared page ${page} is absent from app.json`);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const page of app.pages || []) {
|
||||||
|
for (const extension of pageExtensions) {
|
||||||
|
if (!fs.existsSync(path.join(output, page + extension)))
|
||||||
|
failures.push(`app page ${page} is missing ${extension}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const tabs = app.tabBar?.list || [];
|
||||||
|
if (tabs.length !== manifest.navigation.length)
|
||||||
|
failures.push(
|
||||||
|
`app.json tabBar has ${tabs.length} entries, manifest declares ${manifest.navigation.length}`,
|
||||||
|
);
|
||||||
|
for (const tab of tabs) {
|
||||||
|
if (!app.pages.includes(tab.pagePath))
|
||||||
|
failures.push(`tabBar page is absent from app.json: ${tab.pagePath}`);
|
||||||
|
for (const icon of [tab.iconPath, tab.selectedIconPath]) {
|
||||||
|
if (icon && !fs.existsSync(path.join(output, icon)))
|
||||||
|
failures.push(`tabBar icon is missing: ${icon}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const file of listFiles(output)) {
|
||||||
|
if (!/\.(js|json|wxml)$/.test(file)) continue;
|
||||||
|
const source = fs.readFileSync(path.join(output, file), "utf8");
|
||||||
|
if (file.endsWith(".json") && (file.startsWith("pages/") || file.startsWith("components/"))) {
|
||||||
|
let definition;
|
||||||
|
try {
|
||||||
|
definition = JSON.parse(source);
|
||||||
|
} catch (error) {
|
||||||
|
failures.push(`${file}: invalid JSON (${error.message})`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (const [name, reference] of Object.entries(definition.usingComponents || {})) {
|
||||||
|
if (reference.startsWith("plugin://")) continue;
|
||||||
|
if (
|
||||||
|
reference.startsWith("/miniprogram_npm/") &&
|
||||||
|
!fs.existsSync(path.join(output, "miniprogram_npm"))
|
||||||
|
)
|
||||||
|
continue;
|
||||||
|
if (!resolveComponent(output, file, reference))
|
||||||
|
failures.push(`${file}: component ${name} cannot be resolved (${reference})`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (file.endsWith(".js")) {
|
||||||
|
for (const match of source.matchAll(/require\(\s*["'](\.{1,2}\/[^"']+)["']\s*\)/g)) {
|
||||||
|
if (!resolveRequire(output, file, match[1]))
|
||||||
|
failures.push(`${file}: require("${match[1]}") cannot be resolved`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (file.startsWith("pages/") || file.startsWith("components/")) {
|
||||||
|
for (const componentName of otherComponentNames) {
|
||||||
|
if (source.includes(componentName))
|
||||||
|
failures.push(`${file}: references another template component ${componentName}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return failures;
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateTemplate(directory) {
|
||||||
|
const manifest = readJson(path.join(directory, "template.json"));
|
||||||
|
const output = fs.mkdtempSync(path.join(os.tmpdir(), "personal-brand-template-"));
|
||||||
|
try {
|
||||||
|
let compilerOutput = "";
|
||||||
|
try {
|
||||||
|
compilerOutput = execFileSync(
|
||||||
|
process.execPath,
|
||||||
|
[compiler, "--template", manifest.packageKey, "--out", output],
|
||||||
|
{ cwd: workspaceRoot, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] },
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
const details = [error.stdout, error.stderr].filter(Boolean).join("\n").trim();
|
||||||
|
return [`compiler failed${details ? `: ${details}` : ""}`];
|
||||||
|
}
|
||||||
|
const otherComponentNames = listTemplatePackages()
|
||||||
|
.filter((candidate) => path.resolve(candidate) !== path.resolve(directory))
|
||||||
|
.flatMap(templateComponentNames);
|
||||||
|
const failures = validateManifestOutput(manifest, output, otherComponentNames);
|
||||||
|
if (failures.length) return failures;
|
||||||
|
return {
|
||||||
|
compilerOutput: compilerOutput.trim(),
|
||||||
|
pageCount: readJson(path.join(output, "app.json")).pages.length,
|
||||||
|
tabCount: manifest.navigation.length,
|
||||||
|
};
|
||||||
|
} finally {
|
||||||
|
fs.rmSync(output, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const templateDirectories = listTemplatePackages();
|
||||||
|
if (!templateDirectories.length) {
|
||||||
|
console.error("No template packages found under packages/template-*");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const failures = [];
|
||||||
|
for (const directory of templateDirectories) {
|
||||||
|
const manifestPath = path.join(directory, "template.json");
|
||||||
|
let manifest;
|
||||||
|
try {
|
||||||
|
manifest = readJson(manifestPath);
|
||||||
|
} catch (error) {
|
||||||
|
failures.push(`${path.basename(directory)}: invalid template.json (${error.message})`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const result = validateTemplate(directory);
|
||||||
|
if (Array.isArray(result)) {
|
||||||
|
failures.push(`${manifest.packageKey}:\n ${result.join("\n ")}`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
console.log(
|
||||||
|
`Template ${manifest.packageKey}@${manifest.version} passed: ${result.pageCount} pages, ${result.tabCount} tabs.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (failures.length) {
|
||||||
|
console.error(failures.join("\n"));
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
console.log(`Validated ${templateDirectories.length} template packages.`);
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
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 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"),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const MANIFEST_TYPE_ALIASES = {
|
|
||||||
"brand-identity": "founder-card",
|
|
||||||
hero: "brand-hero",
|
|
||||||
trust: "trust-proof",
|
|
||||||
"inquiry-form": "inquiry",
|
|
||||||
"success-summary": "success-summary",
|
|
||||||
"records-list": "records",
|
|
||||||
};
|
|
||||||
|
|
||||||
function resolveManifest(workspace) {
|
|
||||||
const manifest = workspace && workspace.visualTemplateManifest;
|
|
||||||
if (!manifest || !Array.isArray(manifest.pages)) return null;
|
|
||||||
const pages = {};
|
|
||||||
for (const page of manifest.pages) {
|
|
||||||
pages[page.key] = {
|
|
||||||
...page,
|
|
||||||
modules: (page.modules || []).map((module) => ({
|
|
||||||
...module,
|
|
||||||
type: MANIFEST_TYPE_ALIASES[module.type] || module.type,
|
|
||||||
variant: module.variant || "default",
|
|
||||||
})),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return { ...manifest, pages };
|
|
||||||
}
|
|
||||||
|
|
||||||
function resolveRuntime(workspace) {
|
|
||||||
const modules = Array.isArray(workspace && workspace.modules) ? workspace.modules : [];
|
|
||||||
const manifest = resolveManifest(workspace);
|
|
||||||
const manifestHome = manifest && manifest.pages.home?.modules;
|
|
||||||
const manifestModules = manifestHome || [];
|
|
||||||
const resolved = modules.map(resolveModule);
|
|
||||||
const resolvedTypes = new Set(resolved.map((item) => item.type));
|
|
||||||
for (const module of manifestModules) {
|
|
||||||
if (!resolvedTypes.has(module.type)) {
|
|
||||||
resolved.push(resolveModule(module));
|
|
||||||
resolvedTypes.add(module.type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const home = manifestHome?.length
|
|
||||||
? manifestHome.map((item) => item.type)
|
|
||||||
: workspace && workspace.layout && Array.isArray(workspace.layout.home)
|
|
||||||
? workspace.layout.home
|
|
||||||
: resolved.map((item) => item.type);
|
|
||||||
const moduleVariants = {};
|
|
||||||
for (const item of manifestHome || []) moduleVariants[item.type] = item.variant;
|
|
||||||
const navigation = Array.isArray(manifest?.navigation)
|
|
||||||
? manifest.navigation.map((item) => ({
|
|
||||||
...item,
|
|
||||||
page:
|
|
||||||
typeof item.page === "string" && manifest.entrypoints?.[item.page]
|
|
||||||
? manifest.entrypoints[item.page]
|
|
||||||
: item.page,
|
|
||||||
}))
|
|
||||||
: Array.isArray(workspace?.navigation)
|
|
||||||
? workspace.navigation
|
|
||||||
: [];
|
|
||||||
return {
|
|
||||||
theme: manifest?.tokens || (workspace && workspace.theme ? workspace.theme : FALLBACK_THEME),
|
|
||||||
modules: resolved,
|
|
||||||
layout: { home: home.filter((key) => resolved.some((item) => item.type === key)) },
|
|
||||||
moduleVariants,
|
|
||||||
navigation,
|
|
||||||
visualManifest: manifest,
|
|
||||||
capabilities: workspace && Array.isArray(workspace.capabilities) ? workspace.capabilities : [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { CORE_MODULES, FALLBACK_THEME, resolveManifest, resolveRuntime };
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
const { request } = require("./request");
|
const { request } = require("./request");
|
||||||
const { resolveRuntime } = require("./module-registry");
|
|
||||||
|
|
||||||
function toOffering(item) {
|
function toOffering(item) {
|
||||||
const presentation =
|
const presentation =
|
||||||
@@ -36,7 +35,6 @@ function normalizeWorkspace(workspace) {
|
|||||||
: {};
|
: {};
|
||||||
return {
|
return {
|
||||||
...workspace,
|
...workspace,
|
||||||
...resolveRuntime(workspace),
|
|
||||||
brand,
|
brand,
|
||||||
offerings,
|
offerings,
|
||||||
trustContent,
|
trustContent,
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
```text
|
```text
|
||||||
BrandProfile
|
BrandProfile
|
||||||
├── BrandTemplateInstallation
|
├── BrandTemplateInstallation
|
||||||
├── BrandModule
|
|
||||||
├── BrandFieldDefinition
|
├── BrandFieldDefinition
|
||||||
├── Offering
|
├── Offering
|
||||||
├── InquiryForm
|
├── InquiryForm
|
||||||
@@ -20,10 +19,6 @@ BrandProfile
|
|||||||
|
|
||||||
记录品牌安装的模板、版本和应用状态。模板安装采用复制快照,品牌配置不运行时继承模板。
|
记录品牌安装的模板、版本和应用状态。模板安装采用复制快照,品牌配置不运行时继承模板。
|
||||||
|
|
||||||
### BrandModule
|
|
||||||
|
|
||||||
记录品牌公开页面模块:类型、标题、启用状态、排序、配置和来源。模块类型包括 `text`、`image-list`、`timeline`、`faq`、`services`、`inquiry`、`trust-content`。
|
|
||||||
|
|
||||||
### BrandFieldDefinition
|
### BrandFieldDefinition
|
||||||
|
|
||||||
记录字段所属对象、字段类型、校验、显示条件、排序、来源和覆盖状态。核心字段不能删除;模板字段可被品牌覆盖;自定义字段由品牌管理。
|
记录字段所属对象、字段类型、校验、显示条件、排序、来源和覆盖状态。核心字段不能删除;模板字段可被品牌覆盖;自定义字段由品牌管理。
|
||||||
@@ -44,7 +39,7 @@ BrandProfile
|
|||||||
|
|
||||||
## 迁移顺序
|
## 迁移顺序
|
||||||
|
|
||||||
1. 新增模板安装、模块、字段、Offering、表单定义和提交快照表;
|
1. 新增模板安装、字段、Offering、表单定义和提交快照表;
|
||||||
2. 为现有品牌安装 `personal` 或 `food` 模板快照;
|
2. 为现有品牌安装 `personal` 或 `food` 模板快照;
|
||||||
3. 将现有 `Service` 映射为 `Offering(kind = "service")`;
|
3. 将现有 `Service` 映射为 `Offering(kind = "service")`;
|
||||||
4. 保持旧预约接口继续工作;
|
4. 保持旧预约接口继续工作;
|
||||||
@@ -56,5 +51,6 @@ BrandProfile
|
|||||||
- 购物车、库存、支付和物流;
|
- 购物车、库存、支付和物流;
|
||||||
- 多模板同时作为完整主模板运行;
|
- 多模板同时作为完整主模板运行;
|
||||||
- 任意 JSON 页面搭建器;
|
- 任意 JSON 页面搭建器;
|
||||||
|
- 通过数据库模块开关重排模板视觉页面;
|
||||||
- 破坏性删除 `Service` 或 `Booking`;
|
- 破坏性删除 `Service` 或 `Booking`;
|
||||||
- 复杂规则表达式引擎。
|
- 复杂规则表达式引擎。
|
||||||
@@ -7,7 +7,6 @@ import type {
|
|||||||
BrandTemplateKey,
|
BrandTemplateKey,
|
||||||
RuntimeCapability,
|
RuntimeCapability,
|
||||||
RuntimeInquiryForm,
|
RuntimeInquiryForm,
|
||||||
RuntimeModule,
|
|
||||||
RuntimeOffering,
|
RuntimeOffering,
|
||||||
ThemeManifest,
|
ThemeManifest,
|
||||||
} from "@personal-brand/types";
|
} from "@personal-brand/types";
|
||||||
@@ -219,15 +218,6 @@ export interface OfferingCta {
|
|||||||
label: string;
|
label: string;
|
||||||
config?: Record<string, unknown>;
|
config?: Record<string, unknown>;
|
||||||
}
|
}
|
||||||
export interface BrandModule {
|
|
||||||
id: string;
|
|
||||||
type: string;
|
|
||||||
title: string;
|
|
||||||
isEnabled: boolean;
|
|
||||||
sortOrder: number;
|
|
||||||
source: string;
|
|
||||||
config?: Record<string, unknown> | null;
|
|
||||||
}
|
|
||||||
export interface BrandFieldDefinition {
|
export interface BrandFieldDefinition {
|
||||||
id: string;
|
id: string;
|
||||||
scope: string;
|
scope: string;
|
||||||
@@ -325,7 +315,6 @@ export interface PublicWorkspace {
|
|||||||
capabilities: string[];
|
capabilities: string[];
|
||||||
};
|
};
|
||||||
capabilities: RuntimeCapability[];
|
capabilities: RuntimeCapability[];
|
||||||
modules: RuntimeModule[];
|
|
||||||
offerings: RuntimeOffering[];
|
offerings: RuntimeOffering[];
|
||||||
inquiryForms: RuntimeInquiryForm[];
|
inquiryForms: RuntimeInquiryForm[];
|
||||||
navigation: { tabs: Array<{ key: string; label: string; page: string }> };
|
navigation: { tabs: Array<{ key: string; label: string; page: string }> };
|
||||||
@@ -624,7 +613,6 @@ export class ApiClient {
|
|||||||
};
|
};
|
||||||
runtime: {
|
runtime: {
|
||||||
schemaVersion: string;
|
schemaVersion: string;
|
||||||
modules: Array<{ key: string; type: string; title: string; variant: string }>;
|
|
||||||
capabilities: Array<{ key: string; version: string }>;
|
capabilities: Array<{ key: string; version: string }>;
|
||||||
theme: unknown;
|
theme: unknown;
|
||||||
};
|
};
|
||||||
@@ -649,7 +637,6 @@ export class ApiClient {
|
|||||||
variants: Record<string, string>;
|
variants: Record<string, string>;
|
||||||
} | null;
|
} | null;
|
||||||
installations: Array<{ id: string; templateKey: BrandTemplateKey; templateVersion: string }>;
|
installations: Array<{ id: string; templateKey: BrandTemplateKey; templateVersion: string }>;
|
||||||
modules: BrandModule[];
|
|
||||||
fields: BrandFieldDefinition[];
|
fields: BrandFieldDefinition[];
|
||||||
offerings: Offering[];
|
offerings: Offering[];
|
||||||
forms: unknown[];
|
forms: unknown[];
|
||||||
@@ -734,12 +721,6 @@ export class ApiClient {
|
|||||||
rollbackAdminTemplate(): Promise<unknown> {
|
rollbackAdminTemplate(): Promise<unknown> {
|
||||||
return this.request("/admin/workspace/template/rollback", { method: "POST" });
|
return this.request("/admin/workspace/template/rollback", { method: "POST" });
|
||||||
}
|
}
|
||||||
updateAdminModule(id: string, body: Partial<BrandModule>): Promise<BrandModule> {
|
|
||||||
return this.request(`/admin/workspace/modules/${encodeURIComponent(id)}`, {
|
|
||||||
method: "PATCH",
|
|
||||||
body,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
createAdminField(
|
createAdminField(
|
||||||
body: Omit<BrandFieldDefinition, "id" | "source">,
|
body: Omit<BrandFieldDefinition, "id" | "source">,
|
||||||
): Promise<BrandFieldDefinition> {
|
): Promise<BrandFieldDefinition> {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ Page({
|
|||||||
trustContent: [],
|
trustContent: [],
|
||||||
records: [],
|
records: [],
|
||||||
error: "",
|
error: "",
|
||||||
navigation: [],
|
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
loadWorkspaceWithFallback()
|
loadWorkspaceWithFallback()
|
||||||
@@ -15,7 +14,6 @@ Page({
|
|||||||
brand: workspace.brand || {},
|
brand: workspace.brand || {},
|
||||||
trustContent: workspace.trustPresentation || {},
|
trustContent: workspace.trustPresentation || {},
|
||||||
records: [],
|
records: [],
|
||||||
navigation: workspace.navigation || [],
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.catch((error) => this.setData({ error: error.message }));
|
.catch((error) => this.setData({ error: error.message }));
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
"navigationBarTextStyle": "black",
|
"navigationBarTextStyle": "black",
|
||||||
"usingComponents": {
|
"usingComponents": {
|
||||||
"t-icon": "/miniprogram_npm/tdesign-miniprogram/icon/icon",
|
"t-icon": "/miniprogram_npm/tdesign-miniprogram/icon/icon",
|
||||||
"profile-module": "/components/modules/profile/profile",
|
|
||||||
"acheng-profile": "/components/templates/acheng-profile/acheng-profile"
|
"acheng-profile": "/components/templates/acheng-profile/acheng-profile"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,8 +6,6 @@ Page({
|
|||||||
error: "",
|
error: "",
|
||||||
offerings: [],
|
offerings: [],
|
||||||
filtered: [],
|
filtered: [],
|
||||||
modules: [],
|
|
||||||
theme: {},
|
|
||||||
brand: {},
|
brand: {},
|
||||||
presentation: {},
|
presentation: {},
|
||||||
category: "all",
|
category: "all",
|
||||||
@@ -39,13 +37,10 @@ Page({
|
|||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
modules: workspace.modules || [],
|
|
||||||
theme: workspace.theme || {},
|
|
||||||
brand: workspace.brand || {},
|
brand: workspace.brand || {},
|
||||||
presentation: workspace.brand?.visualPresentation?.offerings || {},
|
presentation: workspace.brand?.visualPresentation?.offerings || {},
|
||||||
brand: workspace.brand || {},
|
brand: workspace.brand || {},
|
||||||
loadedBrandSlug: config.brandSlug,
|
loadedBrandSlug: config.brandSlug,
|
||||||
navigation: workspace.navigation || [],
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((error) => this.setData({ error: error.message }));
|
.catch((error) => this.setData({ error: error.message }));
|
||||||
|
|||||||
@@ -1,76 +1,17 @@
|
|||||||
export type ManifestCategory = "industry" | "visual" | "hybrid";
|
export type ManifestCategory = "industry" | "visual" | "hybrid";
|
||||||
|
|
||||||
export type WorkspaceModuleType =
|
|
||||||
| "brand-hero"
|
|
||||||
| "founder-card"
|
|
||||||
| "trust-proof"
|
|
||||||
| "offering-list"
|
|
||||||
| "offering-detail"
|
|
||||||
| "gallery"
|
|
||||||
| "timeline"
|
|
||||||
| "faq"
|
|
||||||
| "contact"
|
|
||||||
| "inquiry"
|
|
||||||
| "records"
|
|
||||||
| "custom";
|
|
||||||
|
|
||||||
export interface ThemeManifest {
|
export interface ThemeManifest {
|
||||||
colors: Record<string, string>;
|
colors: Record<string, string>;
|
||||||
typography?: Record<string, string>;
|
typography?: Record<string, string>;
|
||||||
spacing?: Record<string, string>;
|
spacing?: Record<string, string>;
|
||||||
radius?: Record<string, string>;
|
radius?: Record<string, string>;
|
||||||
}
|
}
|
||||||
export interface LayoutManifest {
|
|
||||||
home: string[];
|
|
||||||
offerings: string[];
|
|
||||||
detail: string[];
|
|
||||||
profile: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TemplateManifest {
|
|
||||||
templateKey: string;
|
|
||||||
version: string;
|
|
||||||
category: ManifestCategory;
|
|
||||||
displayName: string;
|
|
||||||
requiredModules: readonly string[];
|
|
||||||
optionalModules: string[];
|
|
||||||
offeringSchema: string;
|
|
||||||
inquirySchemas: string[];
|
|
||||||
requiredCapabilities: string[];
|
|
||||||
optionalCapabilities: string[];
|
|
||||||
theme: ThemeManifest;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ModuleManifest {
|
|
||||||
key: string;
|
|
||||||
version: string;
|
|
||||||
type: WorkspaceModuleType;
|
|
||||||
propsSchema: string;
|
|
||||||
dataSource?: string;
|
|
||||||
variant?: string;
|
|
||||||
visibilityRules?: VisibilityRule[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface VisibilityRule {
|
export interface VisibilityRule {
|
||||||
field: string;
|
field: string;
|
||||||
operator: "equals" | "not-equals" | "exists" | "in";
|
operator: "equals" | "not-equals" | "exists" | "in";
|
||||||
value?: string | number | boolean | string[];
|
value?: string | number | boolean | string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CapabilityManifest {
|
|
||||||
key: string;
|
|
||||||
version: string;
|
|
||||||
permissions: string[];
|
|
||||||
apiContract: string;
|
|
||||||
requiredModules: string[];
|
|
||||||
supportedWorkflows: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RuntimeModule extends ModuleManifest {
|
|
||||||
config: Record<string, unknown>;
|
|
||||||
source: "core" | "template" | "custom";
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RuntimeOffering {
|
export interface RuntimeOffering {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -157,7 +98,6 @@ export interface RuntimeWorkspace {
|
|||||||
navigation: {
|
navigation: {
|
||||||
tabs: Array<{ key: string; label: string; page: string }>;
|
tabs: Array<{ key: string; label: string; page: string }>;
|
||||||
};
|
};
|
||||||
modules: RuntimeModule[];
|
|
||||||
offerings: RuntimeOffering[];
|
offerings: RuntimeOffering[];
|
||||||
inquiryForms: RuntimeInquiryForm[];
|
inquiryForms: RuntimeInquiryForm[];
|
||||||
trustPresentation: TrustPresentation;
|
trustPresentation: TrustPresentation;
|
||||||
@@ -169,10 +109,15 @@ export interface RuntimeWorkspace {
|
|||||||
}
|
}
|
||||||
>;
|
>;
|
||||||
theme: ThemeManifest;
|
theme: ThemeManifest;
|
||||||
layout?: LayoutManifest;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function validateTemplateManifest(manifest: TemplateManifest): string[] {
|
export function validateTemplateManifest(manifest: {
|
||||||
|
templateKey: string;
|
||||||
|
version: string;
|
||||||
|
displayName: string;
|
||||||
|
offeringSchema: string;
|
||||||
|
theme: ThemeManifest;
|
||||||
|
}): string[] {
|
||||||
const errors: string[] = [];
|
const errors: string[] = [];
|
||||||
if (!manifest.templateKey.trim()) errors.push("templateKey is required");
|
if (!manifest.templateKey.trim()) errors.push("templateKey is required");
|
||||||
if (!manifest.version.trim()) errors.push("version is required");
|
if (!manifest.version.trim()) errors.push("version is required");
|
||||||
|
|||||||
Reference in new issue
Block a user