feat: 实现多订单班支持系统
主要功能: - 修改RequirementModal支持12个订单班选择 - 添加OrderClassIconMap图标映射组件 - Store中添加selectedOrderClass状态管理 - WorkflowPage支持传递orderClass参数 - web_result添加URL参数切换功能 - 创建order-class-handler.js动态处理页面主题 技术改进: - 创建软链接关联订单班数据目录 - 生成wenlu.json和food.json数据结构 - 删除重复的web_result目录 - 添加测试页面test-order-class.html 影响范围: - 展会策划系统现支持12个订单班 - 结果展示页面自动适配不同订单班主题 - 用户可选择不同行业生成对应方案 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
142
scripts/convert_food_to_json.py
Normal file
142
scripts/convert_food_to_json.py
Normal file
@@ -0,0 +1,142 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
将食品订单班的Markdown文档转换为JSON格式
|
||||
"""
|
||||
|
||||
import json
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
def parse_markdown_to_json():
|
||||
"""解析Markdown文档并转换为JSON"""
|
||||
|
||||
# 路径设置
|
||||
base_path = Path("/Users/xiaoqi/Documents/Dev/Project/2025-09-08_n8nDEMO演示")
|
||||
md_file = base_path / "data/订单班文档资料/食品/notion文稿/中高端个性化轻食店铺经营方案 278d463fce51805081f7cfdc7280f4a4.md"
|
||||
|
||||
# 读取Markdown文件
|
||||
with open(md_file, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# 数据结构
|
||||
data = {
|
||||
"title": "中高端个性化轻食店铺经营方案",
|
||||
"category": "食品",
|
||||
"description": "一个针对年轻消费群体的中高端轻食品牌经营方案",
|
||||
"sections": [],
|
||||
"images": []
|
||||
}
|
||||
|
||||
# 提取所有图片
|
||||
images = re.findall(r'!\[([^\]]*)\]\(([^)]+)\)', content)
|
||||
for alt, path in images:
|
||||
# 清理路径
|
||||
clean_path = path.replace('./image/', '')
|
||||
data["images"].append({
|
||||
"alt": alt,
|
||||
"src": f"images/food/{clean_path}"
|
||||
})
|
||||
|
||||
# 按章节解析内容
|
||||
sections_pattern = r'^# ([^#\n]+)\n((?:(?!^#).*\n?)*)'
|
||||
sections = re.findall(sections_pattern, content, re.MULTILINE)
|
||||
|
||||
for section_title, section_content in sections:
|
||||
if section_title.strip() == "中高端个性化轻食店铺经营方案":
|
||||
continue
|
||||
|
||||
section_data = {
|
||||
"title": section_title.strip(),
|
||||
"content": [],
|
||||
"subsections": []
|
||||
}
|
||||
|
||||
# 解析二级标题
|
||||
subsections_pattern = r'^## ([^#\n]+)\n((?:(?!^##).*\n?)*)'
|
||||
subsections = re.findall(subsections_pattern, section_content, re.MULTILINE)
|
||||
|
||||
for subsection_title, subsection_content in subsections:
|
||||
subsection_data = {
|
||||
"title": subsection_title.strip(),
|
||||
"content": []
|
||||
}
|
||||
|
||||
# 清理内容
|
||||
lines = subsection_content.strip().split('\n')
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
if line and not line.startswith('!['):
|
||||
# 处理列表项
|
||||
if line.startswith('- '):
|
||||
subsection_data["content"].append({
|
||||
"type": "list-item",
|
||||
"text": line[2:].strip()
|
||||
})
|
||||
elif line.startswith('**') and line.endswith('**'):
|
||||
subsection_data["content"].append({
|
||||
"type": "bold",
|
||||
"text": line[2:-2].strip()
|
||||
})
|
||||
else:
|
||||
subsection_data["content"].append({
|
||||
"type": "text",
|
||||
"text": line
|
||||
})
|
||||
|
||||
section_data["subsections"].append(subsection_data)
|
||||
|
||||
# 如果没有二级标题,直接解析内容
|
||||
if not subsections:
|
||||
lines = section_content.strip().split('\n')
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
if line and not line.startswith('![') and not line.startswith('##'):
|
||||
section_data["content"].append({
|
||||
"type": "text",
|
||||
"text": line
|
||||
})
|
||||
|
||||
data["sections"].append(section_data)
|
||||
|
||||
# 添加关键指标
|
||||
data["highlights"] = {
|
||||
"target": "年轻白领、健身爱好者、追求品质生活的群体",
|
||||
"investment": "50-100万元",
|
||||
"location": "商业区、写字楼密集区",
|
||||
"features": [
|
||||
"健康营养的轻食产品",
|
||||
"个性化定制服务",
|
||||
"舒适的就餐环境",
|
||||
"线上线下融合运营"
|
||||
],
|
||||
"advantages": [
|
||||
"市场需求旺盛",
|
||||
"毛利率较高",
|
||||
"品牌差异化明显",
|
||||
"复购率高"
|
||||
]
|
||||
}
|
||||
|
||||
return data
|
||||
|
||||
def main():
|
||||
"""主函数"""
|
||||
print("开始转换食品订单班数据...")
|
||||
|
||||
# 转换数据
|
||||
data = parse_markdown_to_json()
|
||||
|
||||
# 保存JSON文件
|
||||
output_dir = Path("/Users/xiaoqi/Documents/Dev/Project/2025-09-08_n8nDEMO演示/web_frontend/data")
|
||||
output_dir.mkdir(exist_ok=True)
|
||||
|
||||
output_file = output_dir / "food_order_data.json"
|
||||
with open(output_file, 'w', encoding='utf-8') as f:
|
||||
json.dump(data, f, ensure_ascii=False, indent=2)
|
||||
|
||||
print(f"✅ 数据已保存到: {output_file}")
|
||||
print(f" - 章节数: {len(data['sections'])}")
|
||||
print(f" - 图片数: {len(data['images'])}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user