主要内容: - 包含12个产业的完整教务系统前端代码 - 智能启动脚本 (start-industry.sh) - 可视化产业导航页面 (index.html) - 项目文档 (README.md) 优化内容: - 删除所有node_modules和.yoyo文件夹,从7.5GB减少到2.7GB - 添加.gitignore文件避免上传不必要的文件 - 自动依赖管理和智能启动系统 产业列表: 1. 文旅产业 (5150) 2. 智能制造 (5151) 3. 智能开发 (5152) 4. 财经商贸 (5153) 5. 视觉设计 (5154) 6. 交通物流 (5155) 7. 大健康 (5156) 8. 土木水利 (5157) 9. 食品产业 (5158) 10. 化工产业 (5159) 11. 能源产业 (5160) 12. 环保产业 (5161) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
114 lines
4.5 KiB
Python
114 lines
4.5 KiB
Python
#!/usr/bin/env python3
|
|
"""更新专家支持中心的对话数据为视觉设计问答内容"""
|
|
|
|
import json
|
|
import os
|
|
from datetime import datetime
|
|
|
|
def load_visual_qa_data():
|
|
"""加载视觉设计问答内容"""
|
|
file_path = '网页未导入数据/视觉设计产业/视觉设计问答内容.json'
|
|
with open(file_path, 'r', encoding='utf-8') as f:
|
|
return json.load(f)
|
|
|
|
def get_mentor_avatar(mentor_name):
|
|
"""根据导师名称获取头像URL"""
|
|
mentor_avatars = {
|
|
"光年": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_teacher-avatar/recuW7dxJ5AdfT.png",
|
|
"唐振华": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_teacher-avatar/recuW7dxJ5EEac.png",
|
|
"张宏达": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_teacher-avatar/recuW7dxJ5bHYT.png",
|
|
"李奇": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_teacher-avatar/recuUpSO4gUtJz.png",
|
|
"多多畅职机器人": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_icon/recuWmDuekBTlr.png"
|
|
}
|
|
return mentor_avatars.get(mentor_name, mentor_avatars["多多畅职机器人"])
|
|
|
|
def transform_qa_to_conversations(qa_data):
|
|
"""转换问答数据为对话列表格式"""
|
|
conversations = []
|
|
|
|
for idx, qa in enumerate(qa_data):
|
|
# 构建消息列表
|
|
messages = []
|
|
|
|
# 处理最多3轮问答
|
|
for i in range(1, 6, 2): # 1,3,5
|
|
question_key = f"问题_流程{i}"
|
|
question_time_key = f"流程{i}_时间"
|
|
answer_key = f"回答_流程{i+1}"
|
|
answer_time_key = f"流程{i+1}_时间"
|
|
|
|
if qa.get(question_key) and qa.get(question_key).strip():
|
|
# 添加用户问题
|
|
messages.append({
|
|
"type": "user",
|
|
"content": qa[question_key],
|
|
"time": qa.get(question_time_key, "2024/12/1 10:00")
|
|
})
|
|
|
|
# 添加导师/机器人回答
|
|
if qa.get(answer_key) and qa.get(answer_key).strip():
|
|
mentor_name = qa.get("查询导师名称", "").strip()
|
|
if qa["问答类型"] == "智能客服" or not mentor_name:
|
|
mentor_name = "多多畅职机器人"
|
|
|
|
messages.append({
|
|
"type": "assistant",
|
|
"content": qa[answer_key],
|
|
"mentor": mentor_name,
|
|
"time": qa.get(answer_time_key, "2024/12/1 10:01"),
|
|
"mentorAvatar": get_mentor_avatar(mentor_name)
|
|
})
|
|
|
|
# 只有有消息的对话才添加
|
|
if messages:
|
|
# 提取日期部分作为显示日期
|
|
first_time = messages[0].get("time", "2024/12/1 10:00")
|
|
date_parts = first_time.split(' ')[0].split('/')
|
|
display_date = f"{date_parts[0]}年{int(date_parts[1])}月"
|
|
|
|
conversations.append({
|
|
"id": idx + 1,
|
|
"title": qa.get("问题标题", "视觉设计咨询"),
|
|
"status": "finish",
|
|
"date": display_date,
|
|
"type": qa.get("问题类型", "常规问题"),
|
|
"messages": messages
|
|
})
|
|
|
|
return conversations
|
|
|
|
def update_expert_support_file():
|
|
"""更新expertSupportData.js文件"""
|
|
# 加载视觉设计问答数据
|
|
qa_data = load_visual_qa_data()
|
|
|
|
# 转换为对话格式
|
|
conversations = transform_qa_to_conversations(qa_data)
|
|
|
|
# 构建完整的数据结构
|
|
expert_support_data = {
|
|
"conversations": conversations
|
|
}
|
|
|
|
# 生成JavaScript内容
|
|
js_content = f"""// 专家支持中心数据 - 视觉设计产业
|
|
const expertSupportData = {json.dumps(expert_support_data, ensure_ascii=False, indent=2)};
|
|
|
|
export default expertSupportData;"""
|
|
|
|
# 备份原文件
|
|
backup_time = datetime.now().strftime('%Y%m%d_%H%M%S')
|
|
os.system(f'cp src/data/expertSupportData.js src/data/expertSupportData.js.backup_{backup_time}')
|
|
|
|
# 写入新文件
|
|
with open('src/data/expertSupportData.js', 'w', encoding='utf-8') as f:
|
|
f.write(js_content)
|
|
|
|
print(f"✅ 已更新 expertSupportData.js")
|
|
print(f" - 对话数量: {len(conversations)}")
|
|
print(f" - 备份文件: expertSupportData.js.backup_{backup_time}")
|
|
|
|
if __name__ == "__main__":
|
|
print("🚀 开始更新专家支持中心数据...")
|
|
update_expert_support_file()
|
|
print("🎉 更新完成!") |