duqing2026 commited on
Commit
65e17dc
·
0 Parent(s):

init: b2b-case-study-studio

Browse files
Files changed (5) hide show
  1. Dockerfile +13 -0
  2. README.md +35 -0
  3. app.py +27 -0
  4. requirements.txt +1 -0
  5. templates/index.html +434 -0
Dockerfile ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ ENV PYTHONDONTWRITEBYTECODE=1
4
+ ENV PYTHONUNBUFFERED=1
5
+
6
+ WORKDIR /app
7
+ COPY requirements.txt /app/requirements.txt
8
+ RUN pip install --no-cache-dir -r requirements.txt
9
+
10
+ COPY . /app
11
+
12
+ EXPOSE 7860
13
+ CMD ["python", "app.py"]
README.md ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: B2B 案例研究工坊
3
+ emoji: 📈
4
+ colorFrom: indigo
5
+ colorTo: violet
6
+ sdk: docker
7
+ app_port: 7860
8
+ short_description: 生成高转化率的 B2B 案例研究页面,支持代码/图片/JSON 导出。
9
+ ---
10
+
11
+ # B2B 案例研究工坊 (B2B Case Study Studio)
12
+
13
+ 一个用于快速构建高转化率“客户成功案例 / 案例研究”页面的可视化工具。面向 SaaS/B2B 团队与代理商,支持结构化编辑(挑战、方案、结果、KPI、证言),多主题预览,并一键导出 HTML 代码嵌入官网或落地页。还支持图片与配置(JSON)导出,便于复用与团队协作。
14
+
15
+ ## 功能特点
16
+ - 可视化编辑:公司信息、背景挑战、解决方案、结果收益、KPI 指标、客户证言
17
+ - 多主题布局:经典、极简、主视觉高亮
18
+ - 一键导出:HTML 代码、PNG 图片、JSON 配置
19
+ - 本地持久化:自动保存到浏览器 LocalStorage
20
+ - 纯前端运行:无外部 API 依赖,中文界面
21
+ - Hugging Face 兼容:Docker 部署,端口 7860
22
+
23
+ ## 使用方法
24
+ 1. 左侧填写公司与案例内容;添加/编辑 KPI 与证言
25
+ 2. 选择主题,右侧实时预览完整案例页
26
+ 3. 点击“导出 HTML 代码”,复制到你的站点(需引入 Tailwind CSS)
27
+ 4. 可导出 PNG 图片用于营销素材;导出/导入 JSON 便于协作
28
+
29
+ ## 技术栈
30
+ - Backend: Flask
31
+ - Frontend: 原生 HTML/CSS/JS + Vue 3
32
+ - Deploy: Docker(Hugging Face Spaces)
33
+
34
+ ## 许可证
35
+ MIT
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, render_template, send_from_directory
2
+ import os
3
+
4
+ app = Flask(__name__, static_folder='static', template_folder='templates')
5
+
6
+ @app.route('/')
7
+ def index():
8
+ return render_template('index.html')
9
+
10
+ @app.route('/health')
11
+ def health():
12
+ return "OK", 200
13
+
14
+ @app.route('/static/<path:path>')
15
+ def send_static(path):
16
+ return send_from_directory('static', path)
17
+
18
+ @app.errorhandler(404)
19
+ def page_not_found(e):
20
+ return render_template('index.html'), 404
21
+
22
+ @app.errorhandler(500)
23
+ def internal_server_error(e):
24
+ return "Internal Server Error: " + str(e), 500
25
+
26
+ if __name__ == '__main__':
27
+ app.run(host='0.0.0.0', port=7860, debug=False)
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ Flask==2.3.3
templates/index.html ADDED
@@ -0,0 +1,434 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>B2B 案例研究工坊</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
9
+ <script src="https://html2canvas.hertzen.com/dist/html2canvas.min.js"></script>
10
+ <style>
11
+ body { font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif; }
12
+ [v-cloak] { display: none; }
13
+ </style>
14
+ </head>
15
+ <body class="bg-gray-50 h-screen overflow-hidden">
16
+ <div id="app" v-cloak class="h-full flex flex-col">
17
+ <!-- 顶部栏 -->
18
+ <header class="bg-white border-b border-gray-200 px-6 py-3 flex justify-between items-center">
19
+ <div class="flex items-center gap-3">
20
+ <div class="bg-indigo-600 text-white p-2 rounded-lg">
21
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
22
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 7h18M3 12h18M3 17h18" />
23
+ </svg>
24
+ </div>
25
+ <h1 class="text-lg font-bold text-gray-800">B2B 案例研究工坊</h1>
26
+ <span class="ml-2 text-xs text-gray-500">用于生成高转化率的案例研究页面</span>
27
+ </div>
28
+ <div class="flex gap-2">
29
+ <button @click="showCodeModal = true" class="px-4 py-2 text-sm border border-gray-200 rounded-md hover:bg-gray-50">
30
+ 导出 HTML 代码
31
+ </button>
32
+ <button @click="exportJSON" class="px-4 py-2 text-sm border border-gray-200 rounded-md hover:bg-gray-50">
33
+ 导出配置 JSON
34
+ </button>
35
+ <label class="px-4 py-2 text-sm border border-gray-200 rounded-md hover:bg-gray-50 cursor-pointer">
36
+ 导入配置 JSON
37
+ <input type="file" class="hidden" @change="importJSON" accept=".json">
38
+ </label>
39
+ <button @click="exportImage" class="px-4 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700">
40
+ 导出图片
41
+ </button>
42
+ </div>
43
+ </header>
44
+
45
+ <div class="flex flex-1 overflow-hidden">
46
+ <!-- 左侧编辑器 -->
47
+ <aside class="w-[420px] bg-white border-r border-gray-200 overflow-y-auto">
48
+ <div class="p-5 space-y-6">
49
+ <section>
50
+ <h3 class="text-xs font-bold text-gray-400 uppercase tracking-wider mb-3">公司信息</h3>
51
+ <div class="space-y-3">
52
+ <div>
53
+ <label class="block text-sm text-gray-600 mb-1">公司名称</label>
54
+ <input v-model="form.company.name" type="text" class="w-full border rounded px-3 py-2 text-sm" placeholder="如:某某科技(Demo)">
55
+ </div>
56
+ <div class="grid grid-cols-2 gap-3">
57
+ <div>
58
+ <label class="block text-sm text-gray-600 mb-1">行业</label>
59
+ <input v-model="form.company.industry" type="text" class="w-full border rounded px-3 py-2 text-sm" placeholder="AI / SaaS / 电商">
60
+ </div>
61
+ <div>
62
+ <label class="block text-sm text-gray-600 mb-1">地区</label>
63
+ <input v-model="form.company.region" type="text" class="w-full border rounded px-3 py-2 text-sm" placeholder="中国 / 美国 / 欧洲">
64
+ </div>
65
+ </div>
66
+ <div>
67
+ <label class="block text-sm text-gray-600 mb-1">Logo 链接(可选)</label>
68
+ <input v-model="form.company.logo" type="text" class="w-full border rounded px-3 py-2 text-sm" placeholder="https://.../logo.png">
69
+ </div>
70
+ </div>
71
+ </section>
72
+
73
+ <section>
74
+ <h3 class="text-xs font-bold text-gray-400 uppercase tracking-wider mb-3">案例内容</h3>
75
+ <div class="space-y-3">
76
+ <div>
77
+ <label class="block text-sm text-gray-600 mb-1">背景与挑战</label>
78
+ <textarea v-model="form.story.challenge" rows="3" class="w-full border rounded px-3 py-2 text-sm resize-none" placeholder="是什么业务背景?遇到什么问题?"></textarea>
79
+ </div>
80
+ <div>
81
+ <label class="block text-sm text-gray-600 mb-1">解决方案</label>
82
+ <textarea v-model="form.story.solution" rows="3" class="w-full border rounded px-3 py-2 text-sm resize-none" placeholder="给出了怎样的方案?包含哪些关键策略/功能?"></textarea>
83
+ </div>
84
+ <div>
85
+ <label class="block text-sm text-gray-600 mb-1">结果与收益</label>
86
+ <textarea v-model="form.story.results" rows="3" class="w-full border rounded px-3 py-2 text-sm resize-none" placeholder="带来了哪些量化或质化结果?"></textarea>
87
+ </div>
88
+ </div>
89
+ </section>
90
+
91
+ <section>
92
+ <div class="flex justify-between items-center mb-3">
93
+ <h3 class="text-xs font-bold text-gray-400 uppercase tracking-wider">关键指标(KPI)</h3>
94
+ <button @click="addKpi" class="text-xs text-indigo-600">添加</button>
95
+ </div>
96
+ <div class="space-y-3">
97
+ <div v-for="(k, i) in form.kpis" :key="i" class="grid grid-cols-3 gap-2">
98
+ <input v-model="k.name" type="text" class="border rounded px-2 py-1 text-sm" placeholder="如:转化率">
99
+ <input v-model="k.value" type="text" class="border rounded px-2 py-1 text-sm" placeholder="如:+38%">
100
+ <input v-model="k.delta" type="text" class="border rounded px-2 py-1 text-sm" placeholder="如:同比 +12%">
101
+ </div>
102
+ </div>
103
+ </section>
104
+
105
+ <section>
106
+ <h3 class="text-xs font-bold text-gray-400 uppercase tracking-wider mb-3">客户证言</h3>
107
+ <div class="space-y-3">
108
+ <textarea v-model="form.quote.text" rows="2" class="w-full border rounded px-3 py-2 text-sm resize-none" placeholder="输入客户评价(短句)"></textarea>
109
+ <div class="grid grid-cols-2 gap-3">
110
+ <input v-model="form.quote.author" type="text" class="border rounded px-3 py-2 text-sm" placeholder="姓名">
111
+ <input v-model="form.quote.title" type="text" class="border rounded px-3 py-2 text-sm" placeholder="职位/公司">
112
+ </div>
113
+ </div>
114
+ </section>
115
+
116
+ <section>
117
+ <h3 class="text-xs font-bold text-gray-400 uppercase tracking-wider mb-3">布局与主题</h3>
118
+ <div class="grid grid-cols-3 gap-2">
119
+ <button v-for="t in themes" :key="t.id"
120
+ @click="config.theme = t.id"
121
+ :class="['h-9 rounded border text-xs', config.theme === t.id ? 'ring-2 ring-indigo-500' : '']">
122
+ [[ t.name ]]
123
+ </button>
124
+ </div>
125
+ <div class="mt-3">
126
+ <label class="block text-sm text-gray-600 mb-1">CTA 文案</label>
127
+ <input v-model="config.ctaText" type="text" class="w-full border rounded px-3 py-2 text-sm" placeholder="如:预约演示 / 联系我们 / 立即试用">
128
+ </div>
129
+ </section>
130
+ </div>
131
+ </aside>
132
+
133
+ <!-- 右侧预览 -->
134
+ <main class="flex-1 bg-gray-100 overflow-auto p-8">
135
+ <div id="capture-area" class="max-w-6xl mx-auto">
136
+ <!-- 主题:经典 -->
137
+ <section v-if="config.theme === 'classic'" class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
138
+ <div class="px-8 pt-8">
139
+ <div class="flex items-center gap-4">
140
+ <img v-if="form.company.logo" :src="form.company.logo" alt="logo" class="w-10 h-10 rounded">
141
+ <div>
142
+ <h2 class="text-2xl font-bold">[[ form.company.name ]] 案例研究</h2>
143
+ <p class="text-gray-500 text-sm">行业:[[ form.company.industry ]] · 地区:[[ form.company.region ]]</p>
144
+ </div>
145
+ </div>
146
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mt-6">
147
+ <div class="md:col-span-2">
148
+ <h3 class="text-lg font-semibold mb-2">背景与挑战</h3>
149
+ <p class="text-gray-700 leading-7">[[ form.story.challenge ]]</p>
150
+ <h3 class="text-lg font-semibold mt-5 mb-2">解决方案</h3>
151
+ <p class="text-gray-700 leading-7">[[ form.story.solution ]]</p>
152
+ <h3 class="text-lg font-semibold mt-5 mb-2">结果与收益</h3>
153
+ <p class="text-gray-700 leading-7">[[ form.story.results ]]</p>
154
+ </div>
155
+ <div class="space-y-3">
156
+ <div v-for="(k, i) in form.kpis" :key="i" class="bg-indigo-50 border border-indigo-100 rounded-lg p-4">
157
+ <div class="text-xs text-indigo-600 font-medium">[[ k.name ]]</div>
158
+ <div class="text-2xl font-bold text-indigo-700 mt-1">[[ k.value ]]</div>
159
+ <div class="text-xs text-indigo-500 mt-1">[[ k.delta ]]</div>
160
+ </div>
161
+ </div>
162
+ </div>
163
+ </div>
164
+ <div class="px-8 py-6 bg-gray-50 border-t border-gray-200 flex items-center justify-between">
165
+ <blockquote class="text-gray-700 italic max-w-3xl">“[[ form.quote.text ]]” — [[ form.quote.author ]], [[ form.quote.title ]]</blockquote>
166
+ <a href="#" class="px-5 py-2.5 bg-indigo-600 text-white rounded-md hover:bg-indigo-700">[[ config.ctaText ]]</a>
167
+ </div>
168
+ </section>
169
+
170
+ <!-- 主题:极简 -->
171
+ <section v-if="config.theme === 'minimal'" class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
172
+ <div class="px-8 pt-8">
173
+ <h2 class="text-3xl font-bold tracking-tight">[[ form.company.name ]] · 成功故事</h2>
174
+ <p class="text-gray-500 mt-1">[[ form.company.industry ]] · [[ form.company.region ]]</p>
175
+ <div class="grid md:grid-cols-2 gap-10 mt-8">
176
+ <div class="space-y-6">
177
+ <div>
178
+ <h3 class="text-sm font-semibold text-gray-800 uppercase">挑战</h3>
179
+ <p class="text-gray-700 leading-7 mt-2">[[ form.story.challenge ]]</p>
180
+ </div>
181
+ <div>
182
+ <h3 class="text-sm font-semibold text-gray-800 uppercase">解决方案</h3>
183
+ <p class="text-gray-700 leading-7 mt-2">[[ form.story.solution ]]</p>
184
+ </div>
185
+ <div>
186
+ <h3 class="text-sm font-semibold text-gray-800 uppercase">结果</h3>
187
+ <p class="text-gray-700 leading-7 mt-2">[[ form.story.results ]]</p>
188
+ </div>
189
+ </div>
190
+ <div class="grid sm:grid-cols-2 gap-4">
191
+ <div v-for="(k, i) in form.kpis" :key="i" class="rounded-lg border border-gray-200 p-4">
192
+ <div class="text-xs text-gray-500">[[ k.name ]]</div>
193
+ <div class="text-3xl font-bold mt-1">[[ k.value ]]</div>
194
+ <div class="text-xs text-gray-400 mt-1">[[ k.delta ]]</div>
195
+ </div>
196
+ </div>
197
+ </div>
198
+ </div>
199
+ <div class="px-8 py-6 flex justify-end bg-gray-50 border-t">
200
+ <a href="#" class="px-5 py-2.5 bg-gray-900 text-white rounded-md hover:bg-black">[[ config.ctaText ]]</a>
201
+ </div>
202
+ </section>
203
+
204
+ <!-- 主题:主视觉 + 高亮 -->
205
+ <section v-if="config.theme === 'hero'" class="rounded-xl overflow-hidden">
206
+ <div class="bg-gradient-to-br from-indigo-600 to-violet-600 text-white px-8 py-12">
207
+ <div class="max-w-4xl">
208
+ <h2 class="text-3xl font-extrabold">与 [[ form.company.name ]] 的合作成果</h2>
209
+ <p class="mt-3 opacity-90">[[ form.story.challenge ]]</p>
210
+ <p class="mt-3 opacity-90">[[ form.story.solution ]]</p>
211
+ </div>
212
+ <div class="grid sm:grid-cols-3 gap-4 mt-8">
213
+ <div v-for="(k, i) in form.kpis" :key="i" class="bg-white/10 rounded-lg p-4">
214
+ <div class="text-sm opacity-90">[[ k.name ]]</div>
215
+ <div class="text-3xl font-bold mt-1">[[ k.value ]]</div>
216
+ <div class="text-xs opacity-80 mt-1">[[ k.delta ]]</div>
217
+ </div>
218
+ </div>
219
+ </div>
220
+ <div class="bg-white px-8 py-8">
221
+ <div class="flex items-center justify-between">
222
+ <blockquote class="text-gray-700 italic max-w-2xl">“[[ form.quote.text ]]” — [[ form.quote.author ]], [[ form.quote.title ]]</blockquote>
223
+ <a href="#" class="px-5 py-2.5 bg-indigo-600 text-white rounded-md hover:bg-indigo-700">[[ config.ctaText ]]</a>
224
+ </div>
225
+ <div class="mt-6">
226
+ <h3 class="text-lg font-semibold mb-2">更多成果细节</h3>
227
+ <p class="text-gray-700 leading-7">[[ form.story.results ]]</p>
228
+ </div>
229
+ </div>
230
+ </section>
231
+ </div>
232
+ </main>
233
+ </div>
234
+
235
+ <!-- 代码导出弹窗 -->
236
+ <div v-if="showCodeModal" class="fixed inset-0 bg-black/50 flex items-center justify-center p-4" @click.self="showCodeModal=false">
237
+ <div class="bg-white rounded-xl shadow-2xl w-full max-w-4xl h-[80vh] flex flex-col overflow-hidden">
238
+ <div class="p-4 border-b flex justify-between items-center bg-gray-50">
239
+ <h3 class="font-bold text-gray-800">导出代码(Tailwind CSS)</h3>
240
+ <button @click="showCodeModal=false" class="text-gray-400 hover:text-gray-600">✕</button>
241
+ </div>
242
+ <div class="flex-1 relative">
243
+ <textarea readonly class="w-full h-full p-4 font-mono text-sm text-gray-700 bg-gray-50" :value="generatedCode"></textarea>
244
+ <button @click="copyCode" class="absolute top-4 right-4 bg-indigo-600 text-white px-4 py-2 rounded-lg text-sm">复制</button>
245
+ </div>
246
+ <div class="p-3 border-t bg-gray-50 text-xs text-gray-500">
247
+ 提示:此代码依赖 Tailwind CSS,请在你的项目中引入。
248
+ </div>
249
+ </div>
250
+ </div>
251
+ </div>
252
+
253
+ <script>
254
+ const { createApp, ref, computed, watch, onMounted } = Vue;
255
+ createApp({
256
+ delimiters: ['[[', ']]'],
257
+ setup() {
258
+ const showCodeModal = ref(false);
259
+ const form = ref({
260
+ company: { name: '某某科技(Demo)', industry: 'SaaS', region: '中国', logo: '' },
261
+ story: {
262
+ challenge: '面对线索增长与转化效率低下的问题,销售与市场团队缺乏高质量的案例资产来支撑增长漏斗。',
263
+ solution: '使用我们的“案例研究工坊”,统一结构化收集案例内容,输出高转化率页面,同时支持导出代码嵌入官网与着陆页。',
264
+ results: '在上���后的 30 天内,来自案例页的试用注册提升 38%,商机转化率提升 12%,销售周期缩短 15%。'
265
+ },
266
+ kpis: [
267
+ { name: '注册提升', value: '+38%', delta: '月环比 +12%' },
268
+ { name: '转化率', value: '+12%', delta: '同比 +8%' },
269
+ { name: '销售周期', value: '-15%', delta: '中位数 45→38 天' }
270
+ ],
271
+ quote: { text: '这是一个极具实用价值的工具,让我们的案例页成为增长引擎。', author: '张三', title: '市场总监,某某科技' }
272
+ });
273
+ const themes = [
274
+ { id: 'classic', name: '经典' },
275
+ { id: 'minimal', name: '极简' },
276
+ { id: 'hero', name: '主视觉' }
277
+ ];
278
+ const config = ref({ theme: 'classic', ctaText: '预约演示' });
279
+
280
+ const addKpi = () => {
281
+ form.value.kpis.push({ name: '指标', value: '+0%', delta: '说明' });
282
+ };
283
+
284
+ onMounted(() => {
285
+ const saved = localStorage.getItem('b2b-case-study-data');
286
+ if (saved) {
287
+ try {
288
+ const data = JSON.parse(saved);
289
+ if (data.form) form.value = data.form;
290
+ if (data.config) config.value = data.config;
291
+ } catch (e) {}
292
+ }
293
+ });
294
+ watch([form, config], () => {
295
+ localStorage.setItem('b2b-case-study-data', JSON.stringify({ form: form.value, config: config.value }));
296
+ }, { deep: true });
297
+
298
+ // 代码生成(根据当前主题)
299
+ const generatedCode = computed(() => {
300
+ const f = form.value;
301
+ const c = config.value;
302
+ const kpiHtml = f.kpis.map(k => `
303
+ <div class="rounded-lg border ${c.theme==='classic'?'bg-indigo-50 border-indigo-100':'border-gray-200'} p-4">
304
+ <div class="text-xs ${c.theme==='classic'?'text-indigo-600':'text-gray-500'}">${k.name}</div>
305
+ <div class="text-2xl font-bold ${c.theme==='classic'?'text-indigo-700':'text-gray-900'} mt-1">${k.value}</div>
306
+ <div class="text-xs ${c.theme==='classic'?'text-indigo-500':'text-gray-400'} mt-1">${k.delta}</div>
307
+ </div>
308
+ `).join('');
309
+
310
+ let header = `
311
+ <div class="flex items-center gap-4">
312
+ ${f.company.logo ? `<img src="${f.company.logo}" alt="logo" class="w-10 h-10 rounded">` : ``}
313
+ <div>
314
+ <h2 class="text-2xl font-bold">${f.company.name} 案例研究</h2>
315
+ <p class="text-gray-500 text-sm">行业:${f.company.industry} · 地区:${f.company.region}</p>
316
+ </div>
317
+ </div>
318
+ `;
319
+ let mainClassic = `
320
+ <section class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
321
+ <div class="px-8 pt-8">
322
+ ${header}
323
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mt-6">
324
+ <div class="md:col-span-2">
325
+ <h3 class="text-lg font-semibold mb-2">背景与挑战</h3>
326
+ <p class="text-gray-700 leading-7">${f.story.challenge}</p>
327
+ <h3 class="text-lg font-semibold mt-5 mb-2">解决方案</h3>
328
+ <p class="text-gray-700 leading-7">${f.story.solution}</p>
329
+ <h3 class="text-lg font-semibold mt-5 mb-2">结果与收益</h3>
330
+ <p class="text-gray-700 leading-7">${f.story.results}</p>
331
+ </div>
332
+ <div class="space-y-3">${kpiHtml}</div>
333
+ </div>
334
+ </div>
335
+ <div class="px-8 py-6 bg-gray-50 border-t border-gray-200 flex items-center justify-between">
336
+ <blockquote class="text-gray-700 italic max-w-3xl">“${f.quote.text}” — ${f.quote.author}, ${f.quote.title}</blockquote>
337
+ <a href="#" class="px-5 py-2.5 bg-indigo-600 text-white rounded-md hover:bg-indigo-700">${c.ctaText}</a>
338
+ </div>
339
+ </section>
340
+ `;
341
+ let code = mainClassic;
342
+ if (c.theme === 'minimal') {
343
+ code = `
344
+ <section class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
345
+ <div class="px-8 pt-8">
346
+ <h2 class="text-3xl font-bold tracking-tight">${f.company.name} · 成功故事</h2>
347
+ <p class="text-gray-500 mt-1">${f.company.industry} · ${f.company.region}</p>
348
+ <div class="grid md:grid-cols-2 gap-10 mt-8">
349
+ <div class="space-y-6">
350
+ <div><h3 class="text-sm font-semibold text-gray-800 uppercase">挑战</h3><p class="text-gray-700 leading-7 mt-2">${f.story.challenge}</p></div>
351
+ <div><h3 class="text-sm font-semibold text-gray-800 uppercase">解决方案</h3><p class="text-gray-700 leading-7 mt-2">${f.story.solution}</p></div>
352
+ <div><h3 class="text-sm font-semibold text-gray-800 uppercase">结果</h3><p class="text-gray-700 leading-7 mt-2">${f.story.results}</p></div>
353
+ </div>
354
+ <div class="grid sm:grid-cols-2 gap-4">${kpiHtml}</div>
355
+ </div>
356
+ </div>
357
+ <div class="px-8 py-6 flex justify-end bg-gray-50 border-t">
358
+ <a href="#" class="px-5 py-2.5 bg-gray-900 text-white rounded-md hover:bg-black">${c.ctaText}</a>
359
+ </div>
360
+ </section>
361
+ `;
362
+ }
363
+ if (c.theme === 'hero') {
364
+ code = `
365
+ <section class="rounded-xl overflow-hidden">
366
+ <div class="bg-gradient-to-br from-indigo-600 to-violet-600 text-white px-8 py-12">
367
+ <div class="max-w-4xl">
368
+ <h2 class="text-3xl font-extrabold">与 ${f.company.name} 的合作成果</h2>
369
+ <p class="mt-3 opacity-90">${f.story.challenge}</p>
370
+ <p class="mt-3 opacity-90">${f.story.solution}</p>
371
+ </div>
372
+ <div class="grid sm:grid-cols-3 gap-4 mt-8">
373
+ ${f.kpis.map(k => `
374
+ <div class="bg-white/10 rounded-lg p-4"><div class="text-sm opacity-90">${k.name}</div><div class="text-3xl font-bold mt-1">${k.value}</div><div class="text-xs opacity-80 mt-1">${k.delta}</div></div>
375
+ `).join('')}
376
+ </div>
377
+ </div>
378
+ <div class="bg-white px-8 py-8">
379
+ <div class="flex items-center justify-between">
380
+ <blockquote class="text-gray-700 italic max-w-2xl">“${f.quote.text}” — ${f.quote.author}, ${f.quote.title}</blockquote>
381
+ <a href="#" class="px-5 py-2.5 bg-indigo-600 text-white rounded-md hover:bg-indigo-700">${c.ctaText}</a>
382
+ </div>
383
+ <div class="mt-6">
384
+ <h3 class="text-lg font-semibold mb-2">更多成果细节</h3>
385
+ <p class="text-gray-700 leading-7">${f.story.results}</p>
386
+ </div>
387
+ </div>
388
+ </section>
389
+ `;
390
+ }
391
+ return `<!-- Case Study Section (Tailwind CSS) -->\n${code}`;
392
+ });
393
+
394
+ const copyCode = async () => {
395
+ try { await navigator.clipboard.writeText(generatedCode.value); alert('已复制到剪贴板'); }
396
+ catch { alert('复制失败,请手动复制'); }
397
+ };
398
+ const exportJSON = () => {
399
+ const data = { form: form.value, config: config.value, version: '1.0' };
400
+ const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
401
+ const url = URL.createObjectURL(blob);
402
+ const a = document.createElement('a'); a.href = url; a.download = 'case-study-config.json'; a.click(); URL.revokeObjectURL(url);
403
+ };
404
+ const importJSON = (e) => {
405
+ const file = e.target.files[0]; if (!file) return;
406
+ const reader = new FileReader();
407
+ reader.onload = (ev) => {
408
+ try {
409
+ const data = JSON.parse(ev.target.result);
410
+ if (data.form) form.value = data.form;
411
+ if (data.config) config.value = data.config;
412
+ alert('配置导入成功');
413
+ } catch { alert('无效的 JSON 文件'); }
414
+ };
415
+ reader.readAsText(file); e.target.value = '';
416
+ };
417
+ const exportImage = async () => {
418
+ const el = document.getElementById('capture-area');
419
+ try {
420
+ const canvas = await html2canvas(el, { backgroundColor: null, scale: 2 });
421
+ const link = document.createElement('a'); link.download = 'case-study.png'; link.href = canvas.toDataURL(); link.click();
422
+ } catch { alert('导出失败,请重试'); }
423
+ };
424
+
425
+ return {
426
+ form, config, themes, addKpi,
427
+ showCodeModal, generatedCode, copyCode,
428
+ exportJSON, importJSON, exportImage
429
+ };
430
+ }
431
+ }).mount('#app');
432
+ </script>
433
+ </body>
434
+ </html>