feat: 新增独立工坊宣传模板及配置导入验证

This commit is contained in:
que01 committed 2026-10-15 17:44:52 +08:00
1 parent bf4bbf81c7
commit 04e42b3a80
43 files changed
+5726 -13

No files matched your search

File diff suppressed because it is too large. Load diff
+19 -3
View File
@@ -1,12 +1,15 @@
import type { BrandTemplateKey } from "./template-keys.js";
import { getDefaultVisualTemplateKey } from "./visual-templates.js";
import { templatePackageRegistry } from "./template-packages.js";
export interface TemplateSampleContent {
templateKey: BrandTemplateKey;
brandConfig?: Record<string, unknown>;
inquiryFormName: string;
offerings: Array<{
kind: "service" | "product" | "package" | "subscription";
name: string;
coverUrl?: string;
summary: string;
categoryKey: string;
}>;
@@ -136,9 +139,22 @@ export const templateSampleContent = {
doors: doorsSampleContent,
} as const;
export function getTemplateSampleContent(templateKey: string): TemplateSampleContent | undefined {
const packageSample = templatePackageRegistry.find((item) =>
item.supportedIndustryTemplates.includes(templateKey),
export function getTemplateSampleContent(
templateKey: string,
visualTemplateKey?: string,
): TemplateSampleContent | undefined {
const selected = visualTemplateKey
? templatePackageRegistry.find(
(item) =>
item.packageKey === visualTemplateKey &&
item.supportedIndustryTemplates.includes(templateKey),
)
: undefined;
if (selected) return selected.sampleContent?.[templateKey];
const packageSample = templatePackageRegistry.find(
(item) =>
item.packageKey === getDefaultVisualTemplateKey(templateKey) &&
item.supportedIndustryTemplates.includes(templateKey),
)?.sampleContent?.[templateKey];
return packageSample ?? templateSampleContent[templateKey as keyof typeof templateSampleContent];
}
+18
View File
@@ -38,6 +38,24 @@ export const visualTemplates: Record<VisualTemplateKey, VisualTemplateDefinition
profile: ["profile"],
},
},
"atelier-solopreneur": {
key: "atelier-solopreneur",
version: "1.0.0",
name: "独立工坊 · 品牌小程序",
description: "展示品牌小程序服务、试点案例与合作流程,承接需求咨询。",
supportedIndustryTemplates: ["personal"],
variants: { hero: "editorial", offeringList: "service-system", detail: "project-case" },
theme: {
colors: { background: "#fbf9f5", foreground: "#1b1c1a", accent: "#183329", dark: "#183329" },
radius: { card: "28rpx" },
},
layout: {
home: ["brand-hero", "offering-list"],
offerings: ["offering-list"],
detail: ["offering-detail"],
profile: ["profile"],
},
},
};
export function listVisualTemplateKeys(): VisualTemplateKey[] {
@@ -0,0 +1,31 @@
# 独立工坊 · 品牌小程序
`atelier-solopreneur@1.0.0` 是用于宣传个人品牌小程序构建服务的独立模板,适配 `personal` 行业。视觉参考为用户提供的 Stitch 首页、服务、咨询和意向单设计;保留暖白、森林绿、编辑式排版。
## 内容与使用
- 首页:价值定位、差异化卡片、试点案例、目标客户和咨询入口。
- 服务:交付体系、协作流程、信任基础与合作边界。
- 咨询:主理人、微信复制、FAQ 和咨询记录。
- 共享详情、意向表单、成功页和记录页复用 Runtime 能力。
在品牌配置中选择本模板,再从后台显式导入示例。`template.json.sampleContent.personal` 是唯一示例来源,不需要改 Prisma seed。导入不会覆盖已有配置和启用表单。信任内容需确认并发布,品牌基本资料与联系方式需填写真实信息。
所有展示文案和列表由 manifest 提供后台编辑绑定。保存形成草稿,公开内容只在发布后更新。咨询需微信客户会话;H5 无微信登录时显示失败并保留输入,不伪造提交成功。
```sh
TEMPLATE_KEY=atelier-solopreneur pnpm --filter @personal-brand/taro dev:h5
TEMPLATE_KEY=atelier-solopreneur pnpm --filter @personal-brand/taro build:h5
TEMPLATE_KEY=atelier-solopreneur pnpm --filter @personal-brand/taro build:weapp
pnpm template:dev atelier-solopreneur --brand atelier-studio
```
生产小程序构建需提供真实 `BRAND_SLUG`、`API_BASE_URL` 和 `WEAPP_APP_ID`。开发产物默认 `touristappid`,不代表已上线。
## 资源与边界
案例封面采用项目已有示例照片,用于表达场景;不是实际客户合作背书,正式使用可替换为真实模板截图。头像与微信号不虚构默认值。未采用 Stitch 的外链 CDN、Google Fonts 或样例联系方式。
咨询字段共 5 项:称呼 / 品牌名称、主营领域、需求现状、预期排期、联系方式。表单选项使用共享 Inquiry 的可选 chips 样式,默认行为不变。
验收状态见 `docs/atelier-template-acceptance.md`。H5 验收不替代微信开发者工具、真机登录、合法域名和安全区验证。
@@ -0,0 +1,11 @@
{
"tabBar": {
"color": "#686763",
"selectedColor": "#183329",
"backgroundColor": "#fbf9f5",
"borderStyle": "white"
},
"window": {
"navigationBarBackgroundColor": "#fbf9f5"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 804 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 803 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1016 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 787 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 815 B

@@ -0,0 +1,53 @@
const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
const { openPage } = require("../../utils/navigation");
Page({
data: {
brand: {},
presentation: {},
config: {},
offerings: [],
error: "",
loading: true,
opened: -1,
},
onLoad() {
this.reload();
},
reload() {
this.setData({ loading: true, error: "" });
loadWorkspaceWithFallback()
.then((workspace) => {
const brand = workspace.brand || {};
this.setData({
brand,
presentation: brand.visualPresentation?.profile || {},
config: brand.atelier || {},
offerings: workspace.offerings || [],
loading: false,
});
})
.catch((error) => this.setData({ error: error.message, loading: false }));
},
inquiry() {
openPage("/pages/inquiry/index");
},
services() {
openPage("/pages/services/index");
},
contact() {
openPage("/pages/bookings/index");
},
records() {
openPage("/pages/records/index");
},
detail(event) {
openPage("/pages/offering/detail?id=" + encodeURIComponent(event.currentTarget.dataset.id));
},
toggle(event) {
const index = Number(event.currentTarget.dataset.index);
this.setData({ opened: this.data.opened === index ? -1 : index });
},
copy() {
if (this.data.brand.contactWechat) wx.setClipboardData({ data: this.data.brand.contactWechat });
},
});
@@ -0,0 +1 @@
{ "navigationBarTitleText": "咨询", "usingComponents": {} }
@@ -0,0 +1 @@
<view class="page"><view wx:if="{{loading}}">正在加载…</view><view wx:elif="{{error}}">{{error}}<button bindtap="reload">重试</button></view><block wx:else><view class="intro"><text class="eyebrow">{{presentation.eyebrow}}</text><text class="title">{{presentation.title}}</text><text class="body">{{presentation.subtitle}}</text></view><view class="card"><view class="identity"><image wx:if="{{brand.avatarUrl}}" src="{{brand.avatarUrl}}" mode="aspectFill"/><view><text class="card-title">{{brand.founder}}</text><text class="caption">{{brand.title}}</text></view></view><text class="body">{{brand.description}}</text><button bindtap="inquiry">{{presentation.inquiryAction}} · {{presentation.timeHint}}</button><view class="wechat"><text class="caption">{{presentation.wechatLabel}}</text><text>{{brand.contactWechat || presentation.contactHint}}</text><button disabled="{{!brand.contactWechat}}" bindtap="copy">{{presentation.copyAction}}</button></view><text class="caption">{{presentation.promise}}</text><button bindtap="records">{{presentation.recordsAction}}</button></view><view class="intro"><text class="title">{{presentation.faqTitle}}</text><text class="body">{{presentation.faqSubtitle}}</text></view><view wx:for="{{config.faqs}}" wx:key="index" class="card"><view bindtap="toggle" data-index="{{index}}"><text class="card-title">{{index+1}} · {{item.title}} {{opened===index ? "−" : "+"}}</text></view><text wx:if="{{opened===index}}" class="body">{{item.description}}</text></view><view class="footer"><text>{{presentation.footerQuote}}</text><text class="caption">{{presentation.footerNote}}</text></view></block></view>
@@ -0,0 +1,149 @@
page {
background: #fbf9f5;
color: #1b1c1a;
font-size: 28rpx;
line-height: 1.7;
}
text {
display: block;
}
.page {
padding: 40rpx;
}
.intro {
margin-bottom: 36rpx;
}
.eyebrow {
display: inline-block;
background: #eaf0e9;
color: #183329;
border-radius: 99rpx;
padding: 4rpx 16rpx;
font-size: 21rpx;
}
.title {
font-size: 46rpx;
font-weight: 600;
line-height: 1.45;
white-space: pre-line;
margin: 22rpx 0;
}
.body {
font-size: 26rpx;
color: #555953;
line-height: 1.8;
white-space: pre-line;
}
.heading {
display: flex;
justify-content: space-between;
align-items: center;
margin: 60rpx 0 24rpx;
font-size: 30rpx;
}
.heading > text:last-child,
.caption {
font-size: 21rpx;
color: #777971;
}
.card,
.case {
background: white;
border: 1rpx solid #efede7;
border-radius: 28rpx;
padding: 30rpx;
margin-bottom: 24rpx;
}
.card-title {
font-size: 30rpx;
font-weight: 600;
margin-bottom: 12rpx;
}
.tag {
font-size: 20rpx;
color: #8d7956;
text-align: right;
}
.actions,
.cases {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20rpx;
}
.badges {
display: flex;
flex-wrap: wrap;
gap: 16rpx;
font-size: 21rpx;
margin-top: 24rpx;
}
.audiences {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 16rpx;
}
.audiences .card {
padding: 18rpx 8rpx;
text-align: center;
font-size: 24rpx;
}
.case {
padding: 18rpx;
min-width: 0;
}
.case image {
width: 100%;
height: 200rpx;
border-radius: 16rpx;
}
.cta {
background: #183329;
color: white;
padding: 30rpx;
border-radius: 28rpx;
margin: 50rpx 0;
}
.cta .body {
color: #c5d1c6;
}
.identity {
display: flex;
align-items: center;
gap: 24rpx;
margin-bottom: 24rpx;
}
.identity image {
width: 96rpx;
height: 96rpx;
border-radius: 50%;
}
.wechat {
background: #f5f3ed;
padding: 24rpx;
border-radius: 20rpx;
margin: 20rpx 0;
}
.footer {
text-align: center;
margin: 70rpx 0;
}
button {
display: flex;
align-items: center;
justify-content: center;
min-height: 88rpx;
background: #183329;
color: white;
border: 0;
border-radius: 24rpx;
padding: 12rpx 20rpx;
font-size: 25rpx;
margin: 20rpx 0;
}
button::after {
border: 0;
}
.cta button {
background: white;
color: #183329;
}
@@ -0,0 +1,53 @@
const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
const { openPage } = require("../../utils/navigation");
Page({
data: {
brand: {},
presentation: {},
config: {},
offerings: [],
error: "",
loading: true,
opened: -1,
},
onLoad() {
this.reload();
},
reload() {
this.setData({ loading: true, error: "" });
loadWorkspaceWithFallback()
.then((workspace) => {
const brand = workspace.brand || {};
this.setData({
brand,
presentation: brand.visualPresentation?.home || {},
config: brand.atelier || {},
offerings: workspace.offerings || [],
loading: false,
});
})
.catch((error) => this.setData({ error: error.message, loading: false }));
},
inquiry() {
openPage("/pages/inquiry/index");
},
services() {
openPage("/pages/services/index");
},
contact() {
openPage("/pages/bookings/index");
},
records() {
openPage("/pages/records/index");
},
detail(event) {
openPage("/pages/offering/detail?id=" + encodeURIComponent(event.currentTarget.dataset.id));
},
toggle(event) {
const index = Number(event.currentTarget.dataset.index);
this.setData({ opened: this.data.opened === index ? -1 : index });
},
copy() {
if (this.data.brand.contactWechat) wx.setClipboardData({ data: this.data.brand.contactWechat });
},
});
@@ -0,0 +1 @@
{ "navigationBarTitleText": "首页", "usingComponents": {} }
@@ -0,0 +1 @@
<view class="page"><view wx:if="{{loading}}">正在加载…</view><view wx:elif="{{error}}">{{error}}<button bindtap="reload">重试</button></view><block wx:else><view class="intro"><text class="eyebrow">{{presentation.eyebrow}}</text><text class="title">{{presentation.title}}</text><text class="body">{{presentation.subtitle}}</text></view><view class="actions"><button bindtap="inquiry">{{presentation.primaryAction}}</button><button bindtap="services">{{presentation.secondaryAction}}</button></view><view class="badges"><text wx:for="{{config.badges}}" wx:key="index">✓ {{item.title}}</text></view><view class="heading"><text>{{presentation.featuresTitle}}</text><text>{{presentation.featuresEnglish}}</text></view><view wx:for="{{config.features}}" wx:key="index" class="card"><text class="tag">{{item.tag}}</text><text class="card-title">{{item.title}}</text><text class="body">{{item.description}}</text></view><view class="heading"><view>{{presentation.casesTitle}}<text class="caption">{{presentation.casesSubtitle}}</text></view><text>{{presentation.caseAction}}</text></view><view class="cases"><view wx:for="{{offerings}}" wx:key="id" class="case" bindtap="detail" data-id="{{item.id}}"><image wx:if="{{item.coverUrl}}" src="{{item.coverUrl}}" mode="aspectFill"/><text class="card-title">{{item.name}}</text><text class="caption">{{item.summary}}</text></view></view><view class="heading"><text>{{presentation.audienceTitle}}</text><text>{{presentation.audienceEnglish}}</text></view><view class="audiences"><view wx:for="{{config.audiences}}" wx:key="index" class="card"><text>{{item.symbol}}</text><text>{{item.title}}</text><text class="caption">{{item.description}}</text></view></view><view class="cta"><text class="card-title">{{presentation.ctaTitle}}</text><text class="body">{{presentation.ctaSubtitle}}</text><button bindtap="contact">{{presentation.ctaAction}}</button></view></block></view>
@@ -0,0 +1,149 @@
page {
background: #fbf9f5;
color: #1b1c1a;
font-size: 28rpx;
line-height: 1.7;
}
text {
display: block;
}
.page {
padding: 40rpx;
}
.intro {
margin-bottom: 36rpx;
}
.eyebrow {
display: inline-block;
background: #eaf0e9;
color: #183329;
border-radius: 99rpx;
padding: 4rpx 16rpx;
font-size: 21rpx;
}
.title {
font-size: 46rpx;
font-weight: 600;
line-height: 1.45;
white-space: pre-line;
margin: 22rpx 0;
}
.body {
font-size: 26rpx;
color: #555953;
line-height: 1.8;
white-space: pre-line;
}
.heading {
display: flex;
justify-content: space-between;
align-items: center;
margin: 60rpx 0 24rpx;
font-size: 30rpx;
}
.heading > text:last-child,
.caption {
font-size: 21rpx;
color: #777971;
}
.card,
.case {
background: white;
border: 1rpx solid #efede7;
border-radius: 28rpx;
padding: 30rpx;
margin-bottom: 24rpx;
}
.card-title {
font-size: 30rpx;
font-weight: 600;
margin-bottom: 12rpx;
}
.tag {
font-size: 20rpx;
color: #8d7956;
text-align: right;
}
.actions,
.cases {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20rpx;
}
.badges {
display: flex;
flex-wrap: wrap;
gap: 16rpx;
font-size: 21rpx;
margin-top: 24rpx;
}
.audiences {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 16rpx;
}
.audiences .card {
padding: 18rpx 8rpx;
text-align: center;
font-size: 24rpx;
}
.case {
padding: 18rpx;
min-width: 0;
}
.case image {
width: 100%;
height: 200rpx;
border-radius: 16rpx;
}
.cta {
background: #183329;
color: white;
padding: 30rpx;
border-radius: 28rpx;
margin: 50rpx 0;
}
.cta .body {
color: #c5d1c6;
}
.identity {
display: flex;
align-items: center;
gap: 24rpx;
margin-bottom: 24rpx;
}
.identity image {
width: 96rpx;
height: 96rpx;
border-radius: 50%;
}
.wechat {
background: #f5f3ed;
padding: 24rpx;
border-radius: 20rpx;
margin: 20rpx 0;
}
.footer {
text-align: center;
margin: 70rpx 0;
}
button {
display: flex;
align-items: center;
justify-content: center;
min-height: 88rpx;
background: #183329;
color: white;
border: 0;
border-radius: 24rpx;
padding: 12rpx 20rpx;
font-size: 25rpx;
margin: 20rpx 0;
}
button::after {
border: 0;
}
.cta button {
background: white;
color: #183329;
}
@@ -0,0 +1,54 @@
const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
const { openPage } = require("../../utils/navigation");
Page({
data: {
brand: {},
presentation: {},
config: {},
offerings: [],
error: "",
loading: true,
opened: -1,
},
onLoad() {
this.reload();
},
reload() {
this.setData({ loading: true, error: "" });
loadWorkspaceWithFallback()
.then((workspace) => {
const brand = workspace.brand || {};
this.setData({
brand,
presentation: brand.visualPresentation?.offerings || {},
config: brand.atelier || {},
offerings: workspace.offerings || [],
trustItems: workspace.trustItems || [],
loading: false,
});
})
.catch((error) => this.setData({ error: error.message, loading: false }));
},
inquiry() {
openPage("/pages/inquiry/index");
},
services() {
openPage("/pages/services/index");
},
contact() {
openPage("/pages/bookings/index");
},
records() {
openPage("/pages/records/index");
},
detail(event) {
openPage("/pages/offering/detail?id=" + encodeURIComponent(event.currentTarget.dataset.id));
},
toggle(event) {
const index = Number(event.currentTarget.dataset.index);
this.setData({ opened: this.data.opened === index ? -1 : index });
},
copy() {
if (this.data.brand.contactWechat) wx.setClipboardData({ data: this.data.brand.contactWechat });
},
});
@@ -0,0 +1 @@
{ "navigationBarTitleText": "服务", "usingComponents": {} }
@@ -0,0 +1 @@
<view class="page"><view wx:if="{{loading}}">正在加载…</view><view wx:elif="{{error}}">{{error}}<button bindtap="reload">重试</button></view><block wx:else><view class="intro"><text class="eyebrow">{{presentation.eyebrow}}</text><text class="title">{{presentation.title}}</text><text class="body">{{presentation.subtitle}}</text></view><view class="heading"><text>{{presentation.deliverablesTitle}}</text><text>{{presentation.deliverablesEnglish}}</text></view><view wx:for="{{config.deliverables}}" wx:key="index" class="card"><text class="tag">{{item.tag}}</text><text class="card-title">{{index+1}} · {{item.title}}</text><text class="body">{{item.description}}</text></view><view class="heading"><text>{{presentation.processTitle}}</text><text>{{presentation.processEnglish}}</text></view><view wx:for="{{config.process}}" wx:key="index" class="card"><text class="tag">{{item.tag}}</text><text class="card-title">{{index+1}} · {{item.title}}</text><text class="body">{{item.description}}</text></view><view class="heading"><text>{{presentation.proofTitle}}</text><text>{{presentation.proofEnglish}}</text></view><view wx:for="{{config.proofs}}" wx:key="index" class="card"><text class="tag">{{item.tag}}</text><text class="card-title">{{index+1}} · {{item.title}}</text><text class="body">{{item.description}}</text></view><view wx:for="{{trustItems}}" wx:key="id" class="card"><text class="card-title">{{item.title}}</text><text class="caption">{{item.summary}}</text><text class="body">{{item.content}}</text></view><view class="cta"><text class="card-title">{{presentation.ctaTitle}}</text><text class="body">{{presentation.ctaSubtitle}}</text><button bindtap="contact">{{presentation.ctaAction}}</button></view></block></view>
@@ -0,0 +1,149 @@
page {
background: #fbf9f5;
color: #1b1c1a;
font-size: 28rpx;
line-height: 1.7;
}
text {
display: block;
}
.page {
padding: 40rpx;
}
.intro {
margin-bottom: 36rpx;
}
.eyebrow {
display: inline-block;
background: #eaf0e9;
color: #183329;
border-radius: 99rpx;
padding: 4rpx 16rpx;
font-size: 21rpx;
}
.title {
font-size: 46rpx;
font-weight: 600;
line-height: 1.45;
white-space: pre-line;
margin: 22rpx 0;
}
.body {
font-size: 26rpx;
color: #555953;
line-height: 1.8;
white-space: pre-line;
}
.heading {
display: flex;
justify-content: space-between;
align-items: center;
margin: 60rpx 0 24rpx;
font-size: 30rpx;
}
.heading > text:last-child,
.caption {
font-size: 21rpx;
color: #777971;
}
.card,
.case {
background: white;
border: 1rpx solid #efede7;
border-radius: 28rpx;
padding: 30rpx;
margin-bottom: 24rpx;
}
.card-title {
font-size: 30rpx;
font-weight: 600;
margin-bottom: 12rpx;
}
.tag {
font-size: 20rpx;
color: #8d7956;
text-align: right;
}
.actions,
.cases {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20rpx;
}
.badges {
display: flex;
flex-wrap: wrap;
gap: 16rpx;
font-size: 21rpx;
margin-top: 24rpx;
}
.audiences {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 16rpx;
}
.audiences .card {
padding: 18rpx 8rpx;
text-align: center;
font-size: 24rpx;
}
.case {
padding: 18rpx;
min-width: 0;
}
.case image {
width: 100%;
height: 200rpx;
border-radius: 16rpx;
}
.cta {
background: #183329;
color: white;
padding: 30rpx;
border-radius: 28rpx;
margin: 50rpx 0;
}
.cta .body {
color: #c5d1c6;
}
.identity {
display: flex;
align-items: center;
gap: 24rpx;
margin-bottom: 24rpx;
}
.identity image {
width: 96rpx;
height: 96rpx;
border-radius: 50%;
}
.wechat {
background: #f5f3ed;
padding: 24rpx;
border-radius: 20rpx;
margin: 20rpx 0;
}
.footer {
text-align: center;
margin: 70rpx 0;
}
button {
display: flex;
align-items: center;
justify-content: center;
min-height: 88rpx;
background: #183329;
color: white;
border: 0;
border-radius: 24rpx;
padding: 12rpx 20rpx;
font-size: 25rpx;
margin: 20rpx 0;
}
button::after {
border: 0;
}
.cta button {
background: white;
color: #183329;
}
@@ -0,0 +1,24 @@
{
"name": "@personal-brand/template-atelier-solopreneur",
"version": "1.0.0",
"private": true,
"type": "module",
"files": [
"template.json",
"miniapp",
"README.md",
"taro"
],
"dependencies": {
"@tarojs/components": "4.3.0",
"@tarojs/taro": "4.3.0",
"react": "18.3.1",
"@personal-brand/types": "workspace:*",
"@tarojs/plugin-platform-weapp": "4.3.0",
"@tarojs/plugin-platform-h5": "4.3.0",
"react-dom": "18.3.1"
},
"devDependencies": {
"@types/react": "18.3.18"
}
}
@@ -0,0 +1,395 @@
import { useState, cloneElement, isValidElement, type ReactNode } from "react";
import { View, Text, Image, Button } from "@tarojs/components";
import Taro from "@tarojs/taro";
import type { RuntimeWorkspace } from "@personal-brand/types";
import type { TemplateProps } from "../../../apps/taro/src/runtime/template";
import { navigate } from "../../../apps/taro/src/runtime/navigation";
import { object, rows, text, presentation, offering } from "../../../apps/taro/src/runtime/content";
import { inquiryPluginState } from "../../../apps/taro/src/runtime/plugins";
import "./style.css";
type Props = { workspace: RuntimeWorkspace };
function InquiryAction({ workspace, label }: Props & { label: string }) {
const state = inquiryPluginState(workspace);
return (
<Button disabled={!state.enabled} onClick={() => navigate("inquiry")}>
{state.enabled ? label : state.disabledHint || "咨询暂不可用"}
</Button>
);
}
function Home({ workspace }: Props) {
const p = presentation(workspace, "home");
const config = object(workspace.brand.atelier);
return (
<View className="atelier-page">
<View className="atelier-intro" data-editor-target="atelier.home.intro">
<Text className="atelier-eyebrow">{p.eyebrow}</Text>
<Text className="atelier-title">{p.title}</Text>
<Text className="atelier-body">{p.subtitle}</Text>
<View className="atelier-actions">
<InquiryAction workspace={workspace} label={p.primaryAction} />
<Button className="atelier-secondary" onClick={() => navigate("offerings")}>
{p.secondaryAction}
</Button>
</View>
</View>
<View className="atelier-badges" data-editor-target="atelier.home.badges">
{rows(config.badges).map((item, index) => (
<Text key={index}>✓ {item.title}</Text>
))}
</View>
<View className="atelier-heading" data-editor-target="atelier.home.featuresHeading">
<Text>{p.featuresTitle}</Text>
<Text>{p.featuresEnglish}</Text>
</View>
<View className="atelier-stack" data-editor-target="atelier.home.features">
{rows(config.features).map((item, index) => (
<View className="atelier-card" key={index}>
<View className="atelier-card-top">
<Text className="atelier-number">{String(index + 1).padStart(2, "0")}</Text>
<Text className="atelier-tag">{item.tag}</Text>
</View>
<Text className="atelier-card-title">{item.title}</Text>
<Text className="atelier-body">{item.description}</Text>
</View>
))}
</View>
<View className="atelier-heading" data-editor-target="atelier.home.casesHeading">
<View>
<Text>{p.casesTitle}</Text>
<Text className="atelier-caption">{p.casesSubtitle}</Text>
</View>
<Text>{p.caseAction}</Text>
</View>
<View className="atelier-cases">
{workspace.offerings.map((item) => (
<View
className="atelier-case"
key={item.id}
data-editor-target="atelier.home.case"
data-editor-record-id={item.id}
onClick={() => navigate("detail", { id: item.id })}
>
{item.coverUrl ? (
<Image src={item.coverUrl} mode="aspectFill" />
) : (
<View className="atelier-case-placeholder">
<Text>↗</Text>
</View>
)}
<View className="atelier-case-copy">
<Text className="atelier-card-title">{item.name}</Text>
<Text className="atelier-caption">{item.summary}</Text>
<Text className="atelier-case-arrow">→</Text>
</View>
</View>
))}
</View>
<View className="atelier-heading" data-editor-target="atelier.home.audienceHeading">
<Text>{p.audienceTitle}</Text>
<Text>{p.audienceEnglish}</Text>
</View>
<View className="atelier-audiences" data-editor-target="atelier.home.audiences">
{rows(config.audiences).map((item, index) => (
<View className="atelier-audience" key={index}>
<Text className="atelier-symbol">{item.symbol}</Text>
<Text>{item.title}</Text>
<Text className="atelier-caption">{item.description}</Text>
</View>
))}
</View>
<View className="atelier-cta" data-editor-target="atelier.home.cta">
<View>
<Text className="atelier-card-title">{p.ctaTitle}</Text>
<Text className="atelier-caption">{p.ctaSubtitle}</Text>
</View>
<Button onClick={() => navigate("profile")}>{p.ctaAction}</Button>
</View>
</View>
);
}
function Services({ workspace }: Props) {
const p = presentation(workspace, "offerings");
const config = object(workspace.brand.atelier);
return (
<View className="atelier-page">
<View className="atelier-intro" data-editor-target="atelier.offerings.intro">
<Text className="atelier-eyebrow">{p.eyebrow}</Text>
<Text className="atelier-title">{p.title}</Text>
<Text className="atelier-body">{p.subtitle}</Text>
</View>
<View className="atelier-heading" data-editor-target="atelier.offerings.deliverablesHeading">
<Text>{p.deliverablesTitle}</Text>
<Text>{p.deliverablesEnglish}</Text>
</View>
<View className="atelier-stack" data-editor-target="atelier.offerings.deliverables">
{rows(config.deliverables).map((item, index) => (
<View className="atelier-card atelier-deliverable" key={index}>
<Text className="atelier-number">{String(index + 1).padStart(2, "0")}</Text>
<View>
<View className="atelier-card-top">
<Text className="atelier-card-title">{item.title}</Text>
<Text className="atelier-tag">{item.tag}</Text>
</View>
<Text className="atelier-body">{item.description}</Text>
</View>
</View>
))}
</View>
<View className="atelier-heading" data-editor-target="atelier.offerings.processHeading">
<Text>{p.processTitle}</Text>
<Text>{p.processEnglish}</Text>
</View>
<View className="atelier-process" data-editor-target="atelier.offerings.process">
{rows(config.process).map((item, index) => (
<View className="atelier-step" key={index}>
<Text className="atelier-step-dot">{index + 1}</Text>
<View>
<Text className="atelier-card-title">{item.title}</Text>
<Text className="atelier-body">{item.description}</Text>
</View>
</View>
))}
</View>
<View className="atelier-heading" data-editor-target="atelier.offerings.proofHeading">
<Text>{p.proofTitle}</Text>
<Text>{p.proofEnglish}</Text>
</View>
<View className="atelier-proof" data-editor-target="atelier.offerings.proofs">
{rows(config.proofs).map((item, index) => (
<View className="atelier-proof-item" key={index}>
<Text>◇</Text>
<View>
<Text className="atelier-card-title">{item.title}</Text>
<Text className="atelier-body">{item.description}</Text>
</View>
</View>
))}
</View>
{workspace.trustItems.map((item) => (
<View
className="atelier-card atelier-trust"
key={item.id}
data-editor-target={`trust:${item.type}`}
data-editor-record-id={item.id}
>
<Text className="atelier-card-title">{item.title}</Text>
<Text className="atelier-caption">{item.summary}</Text>
<Text className="atelier-body">{item.content}</Text>
</View>
))}
<View className="atelier-cta atelier-cta-large" data-editor-target="atelier.offerings.cta">
<Text className="atelier-card-title">{p.ctaTitle}</Text>
<Text className="atelier-body">{p.ctaSubtitle}</Text>
<InquiryAction workspace={workspace} label={p.ctaAction} />
</View>
</View>
);
}
function Profile({ workspace }: Props) {
const [opened, setOpened] = useState<number | null>(null);
const b = workspace.brand;
const p = presentation(workspace, "profile");
const config = object(b.atelier);
async function copyWechat() {
try {
await Taro.setClipboardData({ data: text(b.contactWechat) });
} catch {
void Taro.showToast({ title: "复制失败,请重试", icon: "none" });
}
}
return (
<View className="atelier-page">
<View className="atelier-intro" data-editor-target="atelier.profile.intro">
<Text className="atelier-eyebrow">{p.eyebrow}</Text>
<Text className="atelier-title">{p.title}</Text>
<Text className="atelier-body">{p.subtitle}</Text>
</View>
<View className="atelier-card">
<View data-editor-target="atelier.profile.identity">
<View className="atelier-identity">
{text(b.avatarUrl) && <Image src={text(b.avatarUrl)} mode="aspectFill" />}
<View>
<Text className="atelier-card-title">{text(b.founder)}</Text>
<Text className="atelier-caption">{text(b.title)}</Text>
</View>
</View>
<Text className="atelier-body atelier-bio">{text(b.description)}</Text>
</View>
<View data-editor-target="atelier.profile.contact">
<InquiryAction workspace={workspace} label={`${p.inquiryAction} ${p.timeHint}`} />
<View className="atelier-wechat">
<View>
<Text className="atelier-caption">{p.wechatLabel}</Text>
<Text>{text(b.contactWechat) || p.contactHint}</Text>
</View>
<Button
className="atelier-copy"
disabled={!text(b.contactWechat)}
onClick={() => void copyWechat()}
>
{p.copyAction}
</Button>
</View>
<Text className="atelier-contact-note">✓ {p.promise}</Text>
<Button className="atelier-records" onClick={() => navigate("records")}>
{p.recordsAction}
</Button>
</View>
</View>
<View className="atelier-faq-heading" data-editor-target="atelier.profile.faqHeading">
<Text className="atelier-title">{p.faqTitle}</Text>
<Text className="atelier-body">{p.faqSubtitle}</Text>
</View>
<View className="atelier-stack" data-editor-target="atelier.profile.faqs">
{rows(config.faqs).map((item, index) => (
<View className="atelier-card atelier-faq" key={index}>
<Button
className="atelier-question"
onClick={() => setOpened(opened === index ? null : index)}
aria-expanded={opened === index}
>
<Text className="atelier-number">{String(index + 1).padStart(2, "0")}</Text>
<Text>{item.title}</Text>
<Text>{opened === index ? "−" : "+"}</Text>
</Button>
{opened === index && (
<Text className="atelier-body atelier-answer">{item.description}</Text>
)}
</View>
))}
</View>
<View className="atelier-footer" data-editor-target="atelier.profile.footer">
<Text>{p.footerQuote}</Text>
<Text className="atelier-caption">{p.footerNote}</Text>
</View>
</View>
);
}
function Detail({ workspace, id }: Props & { id?: string }) {
const found = workspace.offerings.find((item) => item.id === id);
const p = presentation(workspace, "detail");
if (!found)
return (
<View className="runtime-state">
未找到该案例<Button onClick={() => navigate("home")}>返回首页</Button>
</View>
);
const item = offering(found);
return (
<View className="atelier-page">
<View
data-editor-target="atelier-solopreneur.detail.projectDetail"
data-editor-record-id={item.id}
>
{item.image && (
<Image className="atelier-detail-image" src={item.image} mode="aspectFill" />
)}
<Text className="atelier-title">{item.name}</Text>
<Text className="atelier-body">{item.desc}</Text>
</View>
<View
data-editor-target="atelier-solopreneur.detail.projectDetail"
data-editor-record-id={item.id}
>
<View className="atelier-card">
<Text>
<Text data-editor-target="atelier-solopreneur.detail.detailCopy">{p.priceLabel}</Text>:
{item.priceRange}
</Text>
<Text>
<Text data-editor-target="atelier-solopreneur.detail.detailCopy">{p.spaceLabel}</Text>:
{text(item.presentation.spaceType)}
</Text>
<Text>
{item.category} {item.area} {item.series}
</Text>
<Text>{item.keywords.join(" · ")}</Text>
</View>
<Text className="atelier-heading">
<Text data-editor-target="atelier-solopreneur.detail.detailCopy">
{p.backgroundTitle}
</Text>
</Text>
<Text className="atelier-body">{item.details.background}</Text>
<Text className="atelier-heading">
<Text data-editor-target="atelier-solopreneur.detail.detailCopy">{p.conceptTitle}</Text>
</Text>
<Text className="atelier-body">{item.details.designConcept}</Text>
<Text className="atelier-heading">
<Text data-editor-target="atelier-solopreneur.detail.detailCopy">{p.craftsTitle}</Text>
</Text>
{item.details.crafts.map((line, index) => (
<Text className="atelier-body" key={index}>
{line}
</Text>
))}
<Text className="atelier-heading">
<Text data-editor-target="atelier-solopreneur.detail.detailCopy">{p.materialsTitle}</Text>
</Text>
{item.details.materialsList.map((row, index) => (
<Text className="atelier-body" key={index}>
{row.name} {row.spec}
</Text>
))}
</View>
<View
className="atelier-detail-action"
data-editor-target="atelier-solopreneur.detail.action"
>
<InquiryAction workspace={workspace} label={p.inquiryAction} />
<Text className="atelier-caption">{p.inquiryHint}</Text>
</View>
</View>
);
}
const formTargets: Record<string, string> = {
inquiry: "atelier.inquiry.intro",
success: "atelier.success.copy",
records: "atelier.records.copy",
};
export function TemplatePage({ workspace, page, children, offeringId }: TemplateProps) {
if (page === "home")
return (
<View className="atelier">
<Home workspace={workspace} />
</View>
);
if (page === "offerings" || page === "service")
return (
<View className="atelier">
<Services workspace={workspace} />
</View>
);
if (page === "profile")
return (
<View className="atelier">
<Profile workspace={workspace} />
</View>
);
if (page === "detail")
return (
<View className="atelier">
<Detail workspace={workspace} id={offeringId} />
</View>
);
const p = presentation(workspace, "inquiry");
const privacy = (
<View className="atelier-privacy" data-editor-target="atelier.inquiry.privacy">
<Text data-editor-target="atelier.inquiry.intro">{p.note}</Text>
<Text className="atelier-card-title">{p.privacyTitle}</Text>
<Text className="atelier-body">{p.privacyNote}</Text>
<Text className="atelier-caption">{p.followupHint}</Text>
</View>
);
const content =
page === "inquiry" &&
isValidElement<{ choiceStyle?: string; beforeSubmit?: ReactNode }>(children)
? cloneElement(children, { choiceStyle: "chips", beforeSubmit: privacy })
: children;
return (
<View className="atelier atelier-forms">
<View data-editor-target={formTargets[page]}>{content}</View>
</View>
);
}
@@ -0,0 +1,450 @@
.atelier {
--brand-button-height: 96px;
color: #1b1c1a;
background: #fbf9f5;
min-height: 100vh;
font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
font-size: 28px;
line-height: 1.65;
}
.atelier-page {
padding: 48px 40px 72px;
}
.atelier text {
display: block;
}
.atelier button {
background: #183329;
color: #fff;
border-radius: 24px;
font-size: 26px;
padding: 16px 22px;
}
.atelier-intro {
margin-bottom: 36px;
}
.atelier-eyebrow {
display: inline-block !important;
background: #eaf0e9;
color: #183329;
border-radius: 100px;
padding: 4px 16px;
font-size: 21px;
letter-spacing: 1px;
}
.atelier-title {
font-family: "Songti SC", "Noto Serif CJK SC", serif;
font-size: 46px;
font-weight: 600;
line-height: 1.45;
white-space: pre-line;
margin: 22px 0 16px;
}
.atelier-body {
font-size: 26px;
color: #555953;
line-height: 1.8;
white-space: pre-line;
}
.atelier-actions {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
margin-top: 36px;
}
.atelier .atelier-secondary {
background: #fff;
color: #183329;
border: 1px solid #ebe8e3;
}
.atelier-badges {
display: flex;
flex-wrap: wrap;
gap: 12px 24px;
font-size: 21px;
color: #555953;
min-height: 40px;
}
.atelier-heading {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin: 64px 0 24px;
font-size: 30px;
font-weight: 600;
}
.atelier-heading > text:last-child {
font-size: 19px;
font-weight: 400;
color: #777971;
letter-spacing: 1px;
}
.atelier-stack {
display: flex;
flex-direction: column;
gap: 24px;
min-height: 32px;
}
.atelier-card {
background: #fff;
padding: 32px;
border-radius: 30px;
border: 1px solid #f0eeea;
}
.atelier-card-top {
display: flex;
justify-content: space-between;
align-items: center;
gap: 12px;
margin-bottom: 16px;
}
.atelier-number {
font-family: Georgia, serif;
font-size: 30px;
font-style: italic;
color: #8d7956;
flex-shrink: 0;
}
.atelier-tag {
color: #555953;
background: #f3f3ee;
border-radius: 8px;
padding: 3px 10px;
font-size: 19px;
white-space: nowrap;
}
.atelier-card-title {
font-size: 30px;
font-weight: 600;
line-height: 1.6;
margin-bottom: 10px;
}
.atelier-caption {
color: #777971;
font-size: 21px;
font-weight: 400;
line-height: 1.7;
}
.atelier-cases {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
}
.atelier-case {
min-width: 0;
border-radius: 24px;
background: #fff;
border: 1px solid #efede7;
overflow: hidden;
}
.atelier-case image,
.atelier-case-placeholder {
width: 100%;
height: 200px;
}
.atelier-case-placeholder {
background: linear-gradient(135deg, #e1e9dd, #f1e4cd);
display: flex;
align-items: center;
justify-content: center;
font:
72px Georgia,
serif;
color: #183329;
}
.atelier-case-copy {
padding: 20px;
}
.atelier-case .atelier-card-title {
font-size: 27px;
}
.atelier-case-arrow {
color: #8d7956;
margin-top: 12px;
text-align: right;
}
.atelier-audiences {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 16px;
min-height: 40px;
}
.atelier-audience {
text-align: center;
background: #fff;
border-radius: 24px;
padding: 22px 8px;
font-size: 25px;
}
.atelier-symbol {
font-size: 36px;
color: #183329;
}
.atelier-cta {
display: flex;
align-items: center;
gap: 20px;
justify-content: space-between;
background: #183329;
color: #fff;
border-radius: 28px;
padding: 30px;
margin-top: 56px;
}
.atelier-cta > view {
flex: 1;
}
.atelier-cta .atelier-caption,
.atelier-cta .atelier-body {
color: #c5d1c6;
}
.atelier-cta button {
--brand-button-height: 72px;
width: auto;
background: #fff;
color: #183329;
flex-shrink: 0;
font-size: 23px;
}
.atelier-cta-large {
display: block;
}
.atelier-cta-large button {
margin-top: 24px;
width: 100%;
background: #fcdfb1;
}
.atelier-deliverable {
display: grid;
grid-template-columns: 42px 1fr;
gap: 22px;
}
.atelier-deliverable .atelier-card-top {
align-items: start;
margin-bottom: 8px;
}
.atelier-deliverable .atelier-card-title {
font-size: 29px;
}
.atelier-process {
padding-left: 12px;
min-height: 40px;
}
.atelier-step {
display: grid;
grid-template-columns: 38px 1fr;
gap: 20px;
position: relative;
padding-bottom: 36px;
}
.atelier-step:not(:last-child)::before {
content: "";
position: absolute;
top: 34px;
bottom: 0;
left: 16px;
border-left: 1px solid #deded5;
}
.atelier-step-dot {
background: #183329;
color: #fff;
width: 34px;
height: 34px;
border-radius: 50%;
font-size: 22px;
text-align: center;
line-height: 34px;
margin-top: 8px;
}
.atelier-proof {
background: #f5f3ed;
padding: 30px;
border-radius: 26px;
min-height: 40px;
}
.atelier-proof-item {
display: grid;
grid-template-columns: 30px 1fr;
gap: 18px;
margin-bottom: 26px;
}
.atelier-proof-item > text {
color: #8d7956;
}
.atelier-proof-item:last-child {
margin-bottom: 0;
}
.atelier-identity {
display: flex;
align-items: center;
gap: 24px;
}
.atelier-identity image {
width: 96px;
height: 96px;
border-radius: 50%;
flex-shrink: 0;
}
.atelier-bio {
margin: 26px 0 32px;
}
.atelier-wechat {
display: flex;
justify-content: space-between;
align-items: center;
gap: 16px;
padding: 24px;
background: #f5f3ed;
border-radius: 22px;
margin-top: 20px;
}
.atelier-wechat > view {
min-width: 0;
overflow-wrap: anywhere;
}
.atelier .atelier-copy {
--brand-button-height: 56px;
width: auto;
padding: 6px 14px;
font-size: 20px;
color: #183329;
background: #e8eae3;
flex-shrink: 0;
}
.atelier-contact-note {
font-size: 20px;
text-align: center;
margin-top: 24px;
color: #777971;
}
.atelier .atelier-records {
--brand-button-height: 60px;
background: transparent;
color: #183329;
font-size: 22px;
margin-top: 12px;
}
.atelier-faq-heading {
margin: 60px 0 30px;
}
.atelier-faq {
padding: 24px;
}
.atelier .atelier-question {
--brand-button-height: 72px;
display: grid;
grid-template-columns: 36px 1fr 22px;
gap: 16px;
background: transparent;
color: #183329;
text-align: left;
padding: 4px;
}
.atelier-question .atelier-number {
font-size: 22px;
}
.atelier-answer {
margin: 24px 0 8px 52px;
}
.atelier-footer {
text-align: center;
margin-top: 90px;
padding: 20px 0;
}
.atelier-footer > text:first-child {
font:
italic 30px/1.6 Georgia,
serif;
margin-bottom: 16px;
}
.atelier-detail-image {
width: 100%;
height: 400px;
border-radius: 28px;
}
.atelier-detail-action {
margin-top: 50px;
}
.atelier-detail-action .atelier-caption {
text-align: center;
margin-top: 16px;
}
.atelier-forms .inquiry-page,
.atelier-forms .success-page,
.atelier-forms .records-page {
background: #fbf9f5;
padding: 40px;
}
.atelier-forms .form-intro {
background: #f2f0e9;
border-radius: 26px;
padding: 30px;
}
.atelier-forms .form-field {
background: #fff;
border-radius: 26px;
padding: 28px;
margin-bottom: 22px;
}
.atelier-forms .field-input {
background: #f5f4ef;
border: 1px solid #efede7;
border-radius: 18px;
}
.atelier-forms .form-title {
color: #183329;
font-family: "Songti SC", serif;
}
.atelier-forms .submit-button {
background: #183329;
}
.atelier-privacy {
padding: 0 40px 60px;
}
.atelier-privacy .atelier-caption {
margin-top: 24px;
}
.atelier-forms .option-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 14px;
}
.atelier-forms .choice {
--brand-button-height: 80px;
color: #555953;
background: #f5f4ef;
border: 1px solid transparent;
font-size: 23px;
padding: 14px 10px;
}
.atelier-forms .choice.selected {
color: #183329;
background: #eaf0e9;
border-color: #183329;
}
.atelier-forms .atelier-privacy {
padding: 28px;
background: #f2f0e9;
border-radius: 24px;
margin: 10px 0 28px;
}
.atelier-trust {
margin-top: 30px;
}
.atelier-forms .inquiry-form {
background: transparent;
padding: 0;
border: 0;
border-radius: 0;
}
.atelier .required {
display: inline;
color: #8d7956;
}
.atelier-forms .field-grid {
gap: 0;
}
.atelier-forms .field-textarea {
min-height: 220px;
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,4 @@
{
"extends": "../../apps/taro/tsconfig.json",
"include": ["taro"]
}
+1
View File
@@ -122,6 +122,7 @@ export type TemplateTrustContentType = {
};
export type TemplateSampleContent = {
brandConfig?: Record<string, unknown>;
templateKey: string;
inquiryFormName: string;
offerings: Array<Record<string, unknown>>;