Files
Agent-n8n/scripts/fix_markdown_paths.py
Yep_Q 67f5dfbe50 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>
2025-09-29 10:02:15 +08:00

136 lines
6.2 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""
修复所有订单班Markdown文件中的图片路径
移除URL编码的子目录直接指向./image/目录
"""
import re
from pathlib import Path
from urllib.parse import unquote
def fix_markdown_image_paths():
"""修复所有Markdown文件中的图片路径"""
base_path = Path("/Users/xiaoqi/Documents/Dev/Project/2025-09-08_n8nDEMO演示/data/订单班文档资料")
# 所有订单班
order_classes = [
"文旅", "财经商贸", "食品", "智能开发", "智能制造",
"视觉设计", "交通物流", "土木", "大健康", "能源",
"化工", "环保"
]
print("=" * 60)
print("修复Markdown文件中的图片路径")
print("=" * 60)
for order_class in order_classes:
order_dir = base_path / order_class
if not order_dir.exists():
continue
notion_dir = order_dir / "notion文稿"
if not notion_dir.exists():
continue
# 查找所有MD文件
md_files = list(notion_dir.glob("*.md"))
if not md_files:
continue
print(f"\n处理 {order_class}...")
for md_file in md_files:
try:
content = md_file.read_text(encoding='utf-8')
original_content = content
# 修复图片路径的各种模式
# 1. 移除URL编码的子目录路径
# 匹配 ![xxx](./image/URL编码路径/文件名)
pattern = r'!\[([^\]]*)\]\(./image/[^/\)]+/([^\)]+\.(jpg|jpeg|png|gif))\)'
content = re.sub(pattern, r'![\1](./image/\2)', content, flags=re.IGNORECASE)
# 2. 修复只有文件名的情况
# 获取image目录中的所有图片
image_dir = notion_dir / "image"
if image_dir.exists():
images = list(image_dir.glob("*.jpg"))
# 创建映射:原始文件名(各种形式)到新文件名
name_mapping = {}
# 根据命名规则推断映射
for img in images:
new_name = img.name
# 推断可能的原始名称
if new_name.startswith("图片_"):
# 图片_01.jpg 可能来自各种中文名称
num = new_name.replace("图片_", "").replace(".jpg", "")
# 这些需要根据实际顺序来映射
if order_class == "食品":
# 食品订单班的特定映射
mappings = {
"01": ["一、项目概述1.jpeg"],
"02": ["一、项目概述2.jpeg"],
"03": ["一、项目概述3.jpeg"],
"04": ["七、营销与推广1.jpeg"],
"05": ["七、营销与推广2.jpeg"],
"06": ["三、品牌定位1.jpeg"],
"07": ["三、品牌定位2.jpeg"],
"08": ["九、风险管理与应对1.jpeg"],
"09": ["九、风险管理与应对2.jpeg"],
"10": ["二、市场分析1.jpeg"],
"11": ["二、市场分析2.jpeg"],
"12": ["二、市场分析3.jpeg"],
"13": ["五、选址与装修1.jpeg"],
"14": ["五、选址与装修2.jpeg"],
"15": ["八、财务管理1.jpeg"],
"16": ["八、财务管理2.jpeg"],
"17": ["八、财务管理3.jpeg"],
"18": ["六、人员管理1.jpeg"],
"19": ["六、人员管理2.jpeg"],
"20": ["六、人员管理3.jpeg"],
"21": ["六、人员管理4.jpeg"],
"22": ["四、菜品服务1.jpeg"],
"23": ["四、菜品服务2.jpeg"],
"24": ["四、菜品服务3.jpeg"],
"25": ["四、菜品服务4.jpeg"]
}
if num in mappings:
for old_name in mappings[num]:
name_mapping[old_name] = new_name
# 应用映射
for old_name, new_name in name_mapping.items():
# 处理各种可能的引用格式
# URL编码的文件名
encoded_old = re.escape(old_name.replace(' ', '%20'))
# 替换包含子目录的路径
content = re.sub(
f'!\[([^\]]*)\]\([^\)]*{re.escape(old_name)}\)',
f'![\g<1>](./image/{new_name})',
content
)
# 替换URL编码版本
content = re.sub(
f'!\[([^\]]*)\]\([^\)]*{encoded_old}\)',
f'![\g<1>](./image/{new_name})',
content
)
# 保存修改
if content != original_content:
md_file.write_text(content, encoding='utf-8')
print(f" ✓ 修复: {md_file.name}")
except Exception as e:
print(f" ✗ 失败 {md_file.name}: {e}")
print("\n" + "=" * 60)
print("✅ 路径修复完成!")
if __name__ == "__main__":
fix_markdown_image_paths()