Files
ALL-teach_sys/frontend_财经商贸/updateExpertSupportData.js
KQL 38350dca36 更新12个教务系统并优化项目大小
主要更新:
- 更新所有12个产业的教务系统数据和功能
- 删除所有 node_modules 文件夹(节省3.7GB)
- 删除所有 .yoyo 缓存文件夹(节省1.2GB)
- 删除所有 dist 构建文件(节省55MB)

项目优化:
- 项目大小从 8.1GB 减少到 3.2GB(节省60%空间)
- 保留完整的源代码和配置文件
- .gitignore 已配置,防止再次提交大文件

启动脚本:
- start-industry.sh/bat/ps1 脚本会自动检测并安装依赖
- 首次启动时自动运行 npm install
- 支持单个或批量启动产业系统

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-17 14:36:25 +08:00

175 lines
5.8 KiB
JavaScript
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.

import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// 读取财经商贸问答内容数据
const financeQAData = JSON.parse(
fs.readFileSync(path.join(__dirname, '网页未导入数据/财经商贸产业/财经商贸问答内容.json'), 'utf-8')
);
// 转换数据格式
const conversations = financeQAData.map((item, index) => {
const messages = [];
// 添加流程1用户问题
if (item["问题_流程1"]) {
messages.push({
type: "user",
content: item["问题_流程1"],
time: item["流程1_时间"]
});
}
// 添加流程2助手回答
if (item["回答_流程2"]) {
const isAIAnswer = item["问答类型"] === "智能客服";
messages.push({
type: "assistant",
content: item["回答_流程2"],
mentor: isAIAnswer ? "多多畅职机器人" : item["查询导师名称"] + "老师",
time: item["流程2_时间"],
mentorAvatar: isAIAnswer
? "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_icon/recuWmDuekBTlr.png"
: getMentorAvatar(item["查询导师名称"])
});
}
// 添加流程3用户问题
if (item["问题_流程3"]) {
messages.push({
type: "user",
content: item["问题_流程3"],
time: item["流程3_时间"]
});
}
// 添加流程4助手回答
if (item["回答_流程4"]) {
const isAIAnswer = item["问答类型"] === "智能客服";
messages.push({
type: "assistant",
content: item["回答_流程4"],
mentor: isAIAnswer ? "多多畅职机器人" : item["查询导师名称"] + "老师",
time: item["流程4_时间"],
mentorAvatar: isAIAnswer
? "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_icon/recuWmDuekBTlr.png"
: getMentorAvatar(item["查询导师名称"])
});
}
// 添加流程5用户问题
if (item["问题_流程5"]) {
messages.push({
type: "user",
content: item["问题_流程5"],
time: item["流程5_时间"]
});
}
// 添加流程6助手回答
if (item["回答_流程6"]) {
const isAIAnswer = item["问答类型"] === "智能客服";
messages.push({
type: "assistant",
content: item["回答_流程6"],
mentor: isAIAnswer ? "多多畅职机器人" : item["查询导师名称"] + "老师",
time: item["流程6_时间"],
mentorAvatar: isAIAnswer
? "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_icon/recuWmDuekBTlr.png"
: getMentorAvatar(item["查询导师名称"])
});
}
// 过滤掉空内容的消息
const validMessages = messages.filter(msg => msg.content);
// 按时间排序消息(确保对话的时间顺序正确)
validMessages.sort((a, b) => {
const timeA = new Date(a.time.replace(/\//g, '-'));
const timeB = new Date(b.time.replace(/\//g, '-'));
return timeA - timeB;
});
// 从第一条消息时间提取年月
const firstTime = validMessages[0]?.time || "2024/1/1 00:00";
const [datePart] = firstTime.split(' ');
const [year, month] = datePart.split('/');
const dateStr = `${year}${month}`;
return {
id: index + 1,
title: item["问题标题"],
status: "finish",
date: dateStr,
type: item["问题类型"],
messages: validMessages
};
});
// 导师头像映射使用真实的导师头像URL
function getMentorAvatar(mentorName) {
const mentorAvatars = {
"刘红梅": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_teacher-avatar/recuW7dxJ5wnh1.png",
"朱琳琳": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_teacher-avatar/recuW7dxJ5J6yn.png",
"马国栋": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_teacher-avatar/recuW7dxJ5fgO2.jpeg",
"徐明辉": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_teacher-avatar/recuW7dxJ5j6oq.png",
"李奇": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_teacher-avatar/recuUpJBMNLZL5.png" // 李奇是AI答疑保持原头像
};
return mentorAvatars[mentorName] || "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/teach_sys_teacher-avatar/recuUpJBMNLZL5.png";
}
// 构建完整的数据结构
const expertSupportData = {
conversations: conversations
};
// 备份原文件
const backupPath = path.join(__dirname, 'src/data', `expertSupportData.js.backup_${new Date().toISOString().replace(/[:.]/g, '-')}`);
fs.copyFileSync(
path.join(__dirname, 'src/data/expertSupportData.js'),
backupPath
);
console.log(`备份已创建: ${backupPath}`);
// 生成新的文件内容
const fileContent = `// 从财经商贸问答内容.json转换的专家支持中心数据
const expertSupportData = ${JSON.stringify(expertSupportData, null, 2)};
export default expertSupportData;`;
// 写入文件
fs.writeFileSync(
path.join(__dirname, 'src/data/expertSupportData.js'),
fileContent,
'utf-8'
);
console.log(`成功更新专家支持中心数据,共 ${conversations.length} 个对话`);
// 统计信息
const typeStats = {};
conversations.forEach(conv => {
typeStats[conv.type] = (typeStats[conv.type] || 0) + 1;
});
console.log('\n问题类型统计');
Object.entries(typeStats).forEach(([type, count]) => {
console.log(` ${type}: ${count}`);
});
// 统计导师参与情况
const mentorStats = {};
financeQAData.forEach(item => {
if (item["查询导师名称"]) {
mentorStats[item["查询导师名称"]] = (mentorStats[item["查询导师名称"]] || 0) + 1;
}
});
console.log('\n导师参与统计');
Object.entries(mentorStats).forEach(([mentor, count]) => {
console.log(` ${mentor}: ${count} 个对话`);
});