Files
ALL-teach_sys/frontend_环保/convertEnvQA.js
KQL cd2e307402 初始化12个产业教务系统项目
主要内容:
- 包含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>
2025-09-24 14:14:14 +08:00

88 lines
3.0 KiB
JavaScript
Raw 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.

import fs from 'fs';
// 读取环保问答内容数据
const envQAData = JSON.parse(fs.readFileSync('./网页未导入数据/环保产业/环保问答内容.json', 'utf8'));
// 导师头像映射
const mentorAvatars = {
"何晓凯": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_teacher-avatar/recuW70q6gekXc.png",
"赵雅芳": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_teacher-avatar/recuW7dxJ547VI.png",
"丁增辉": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_teacher-avatar/recuW7dxJ5I7zh.png",
"": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_icon/recuWmDuekBTlr.png" // 多多畅职机器人头像
};
// 转换数据格式
const conversations = [];
envQAData.forEach((qa, index) => {
const conversation = {
id: index + 1,
title: qa["问题标题AI"],
status: "finish",
date: qa["流程1_时间"] ? qa["流程1_时间"].split('/').slice(0, 2).join('年') + '月' : "2024年",
type: qa["问答类型"],
messages: []
};
// 处理流程1-6的问答
for (let i = 1; i <= 6; i += 2) {
const questionKey = `问题_流程${i}`;
const questionTimeKey = `流程${i}_时间`;
const answerKey = `回答_流程${i+1}`;
const answerTimeKey = `流程${i+1}_时间`;
const question = qa[questionKey];
const questionTime = qa[questionTimeKey];
const answer = qa[answerKey];
const answerTime = qa[answerTimeKey];
if (question && question.trim() !== '') {
// 添加用户问题
conversation.messages.push({
type: "user",
content: question,
time: questionTime || `2024/${index + 1}/${10 + i} 12:00`
});
// 添加回答
if (answer && answer.trim() !== '') {
const mentorName = qa["查询导师名称"] || "";
const displayName = mentorName ? mentorName + "老师" : "多多畅职机器人";
conversation.messages.push({
type: "assistant",
content: answer,
mentor: displayName,
time: answerTime || `2024/${index + 1}/${10 + i} 12:01`,
mentorAvatar: mentorAvatars[mentorName] || mentorAvatars[""]
});
}
}
}
if (conversation.messages.length > 0) {
conversations.push(conversation);
}
});
// 构建完整的expertSupportData结构
const expertSupportData = {
conversations: conversations
};
// 输出转换后的数据
console.log('转换完成!共生成', conversations.length, '个对话');
console.log('每个对话的消息数量:');
conversations.forEach((conv, i) => {
console.log(` 对话${i + 1} [${conv.title}]${conv.messages.length}条消息`);
});
// 保存到文件
const outputPath = './src/data/expertSupportData.js';
const fileContent = `// 从环保问答内容.json转换的专家支持中心数据
const expertSupportData = ${JSON.stringify(expertSupportData, null, 2)};
export default expertSupportData;`;
fs.writeFileSync(outputPath, fileContent, 'utf8');
console.log('\n数据已保存到:', outputPath);