87 lines
2.5 KiB
Python
87 lines
2.5 KiB
Python
|
|
#!/usr/bin/env python3
|
|||
|
|
# -*- coding: utf-8 -*-
|
|||
|
|
"""
|
|||
|
|
更新文旅订单班相关路径引用脚本
|
|||
|
|
"""
|
|||
|
|
import os
|
|||
|
|
import re
|
|||
|
|
|
|||
|
|
BASE_DIR = "/Users/xiaoqi/Documents/Dev/Project/2025-09-08_n8nDEMO演示/web_frontend/exhibition-demo/src"
|
|||
|
|
|
|||
|
|
# 需要更新的文件
|
|||
|
|
FILES_TO_UPDATE = [
|
|||
|
|
"data/terminalSimulations/wenlu.ts",
|
|||
|
|
"pages/WorkflowPageV4.tsx"
|
|||
|
|
]
|
|||
|
|
|
|||
|
|
# 路径替换规则
|
|||
|
|
PATH_REPLACEMENTS = {
|
|||
|
|
"/data/会展策划/image/": "/data/订单班文档资料/文旅/notion文稿/image/"
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
def update_file(file_path):
|
|||
|
|
"""更新单个文件中的路径引用"""
|
|||
|
|
full_path = os.path.join(BASE_DIR, file_path)
|
|||
|
|
|
|||
|
|
if not os.path.exists(full_path):
|
|||
|
|
print(f"⚠️ 文件不存在: {file_path}")
|
|||
|
|
return False
|
|||
|
|
|
|||
|
|
print(f"\n📝 处理文件: {file_path}")
|
|||
|
|
|
|||
|
|
# 读取文件
|
|||
|
|
with open(full_path, 'r', encoding='utf-8') as f:
|
|||
|
|
content = f.read()
|
|||
|
|
|
|||
|
|
original_content = content
|
|||
|
|
updated_count = 0
|
|||
|
|
|
|||
|
|
# 替换路径
|
|||
|
|
for old_path, new_path in PATH_REPLACEMENTS.items():
|
|||
|
|
if old_path in content:
|
|||
|
|
count = content.count(old_path)
|
|||
|
|
content = content.replace(old_path, new_path)
|
|||
|
|
updated_count += count
|
|||
|
|
print(f" ✅ 替换 {count} 处: {old_path} -> {new_path}")
|
|||
|
|
|
|||
|
|
# 写回文件
|
|||
|
|
if content != original_content:
|
|||
|
|
with open(full_path, 'w', encoding='utf-8') as f:
|
|||
|
|
f.write(content)
|
|||
|
|
print(f" ✅ 文件已更新,共 {updated_count} 处修改")
|
|||
|
|
return True
|
|||
|
|
else:
|
|||
|
|
print(f" ℹ️ 无需更新")
|
|||
|
|
return False
|
|||
|
|
|
|||
|
|
def main():
|
|||
|
|
print("=" * 70)
|
|||
|
|
print("🚀 文旅订单班路径更新脚本")
|
|||
|
|
print("=" * 70)
|
|||
|
|
|
|||
|
|
updated_files = []
|
|||
|
|
|
|||
|
|
for file_path in FILES_TO_UPDATE:
|
|||
|
|
if update_file(file_path):
|
|||
|
|
updated_files.append(file_path)
|
|||
|
|
|
|||
|
|
print("\n" + "=" * 70)
|
|||
|
|
print(f"✅ 完成!共更新 {len(updated_files)} 个文件")
|
|||
|
|
print("=" * 70)
|
|||
|
|
|
|||
|
|
if updated_files:
|
|||
|
|
print("\n更新的文件:")
|
|||
|
|
for f in updated_files:
|
|||
|
|
print(f" - {f}")
|
|||
|
|
|
|||
|
|
print("\n⚠️ 提示: 请手动删除以下旧文件夹:")
|
|||
|
|
print(" 1. /web_frontend/exhibition-demo/public/data/会展策划")
|
|||
|
|
print(" 2. /web_frontend/exhibition-demo/public/data/Agent_prompt")
|
|||
|
|
print(" 3. /web_frontend/exhibition-demo/public/data/agent头像")
|
|||
|
|
print(" 4. /web_frontend/data/会展策划 notion文稿")
|
|||
|
|
print(" 5. /web_frontend/data/Agent_prompt")
|
|||
|
|
print(" 6. /web_frontend/data/agent头像")
|
|||
|
|
|
|||
|
|
if __name__ == "__main__":
|
|||
|
|
main()
|