主要更新: - 更新所有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>
112 lines
3.7 KiB
JavaScript
112 lines
3.7 KiB
JavaScript
// 验证课程作业图片数据匹配情况
|
||
const fs = require('fs');
|
||
const path = require('path');
|
||
|
||
// 读取文旅_作业海报.json
|
||
const postersPath = path.join(__dirname, '网页未导入数据/文旅产业/文旅_作业海报.json');
|
||
const posters = JSON.parse(fs.readFileSync(postersPath, 'utf-8'));
|
||
|
||
// 创建课程名称到图片URL的映射
|
||
const posterMap = new Map();
|
||
posters.forEach(item => {
|
||
posterMap.set(item['课程名称'], item['图片url']);
|
||
});
|
||
|
||
console.log(`文旅_作业海报.json 共有 ${posters.length} 条数据\n`);
|
||
|
||
// 读取mockData.js并提取homework数据
|
||
const mockDataPath = path.join(__dirname, 'src/data/mockData.js');
|
||
const mockDataContent = fs.readFileSync(mockDataPath, 'utf-8');
|
||
|
||
// 提取homework部分 (使用正则匹配)
|
||
const homeworkMatch = mockDataContent.match(/homework:\s*\[([\s\S]*?)\n\s*\],\s*\/\//);
|
||
if (!homeworkMatch) {
|
||
console.error('无法找到homework数据');
|
||
process.exit(1);
|
||
}
|
||
|
||
// 统计信息
|
||
let totalCourses = 0;
|
||
let coursesWithImages = 0;
|
||
let coursesWithoutImages = 0;
|
||
let coursesNotInPosterJson = [];
|
||
let coursesWithWrongImages = [];
|
||
|
||
// 简单的课程名称提取 (从imageUrl或name字段)
|
||
const courseNamePattern = /name:\s*"([^"]+)"/g;
|
||
const imageUrlPattern = /imageUrl:\s*"([^"]+)"/g;
|
||
|
||
let match;
|
||
const coursesData = [];
|
||
|
||
// 提取所有课程名称和imageUrl
|
||
let nameMatches = [...mockDataContent.matchAll(courseNamePattern)];
|
||
let imageMatches = [...mockDataContent.matchAll(imageUrlPattern)];
|
||
|
||
console.log('开始验证课程作业图片数据...\n');
|
||
console.log('='* 60);
|
||
|
||
// 遍历homework部分,找到所有课程
|
||
const homeworkPart = homeworkMatch[0];
|
||
const courseItems = [...homeworkPart.matchAll(/\{\s*id:\s*\d+,\s*name:\s*"([^"]+)"[^}]*imageUrl:\s*"([^"]+)"/g)];
|
||
|
||
courseItems.forEach(item => {
|
||
const courseName = item[1];
|
||
const imageUrl = item[2];
|
||
totalCourses++;
|
||
|
||
if (imageUrl && imageUrl !== '') {
|
||
coursesWithImages++;
|
||
|
||
// 检查该课程是否在poster json中
|
||
const expectedUrl = posterMap.get(courseName);
|
||
|
||
if (!expectedUrl) {
|
||
coursesNotInPosterJson.push(courseName);
|
||
console.log(`⚠️ 课程 "${courseName}" 在文旅_作业海报.json中找不到对应数据`);
|
||
} else if (expectedUrl !== imageUrl) {
|
||
coursesWithWrongImages.push({
|
||
name: courseName,
|
||
current: imageUrl,
|
||
expected: expectedUrl
|
||
});
|
||
console.log(`❌ 课程 "${courseName}" 图片URL不匹配`);
|
||
console.log(` 当前: ${imageUrl}`);
|
||
console.log(` 应为: ${expectedUrl}\n`);
|
||
} else {
|
||
console.log(`✅ 课程 "${courseName}" 图片URL正确`);
|
||
}
|
||
} else {
|
||
coursesWithoutImages++;
|
||
console.log(`⚠️ 课程 "${courseName}" 没有设置imageUrl`);
|
||
}
|
||
});
|
||
|
||
console.log('\n' + '='.repeat(60));
|
||
console.log('\n📊 验证结果统计:\n');
|
||
console.log(`总课程数: ${totalCourses}`);
|
||
console.log(`已设置图片: ${coursesWithImages}`);
|
||
console.log(`未设置图片: ${coursesWithoutImages}`);
|
||
console.log(`图片URL错误: ${coursesWithWrongImages.length}`);
|
||
console.log(`不在poster json中: ${coursesNotInPosterJson.length}`);
|
||
|
||
if (coursesWithWrongImages.length > 0) {
|
||
console.log('\n❌ 需要修正的课程:');
|
||
coursesWithWrongImages.forEach(course => {
|
||
console.log(` - ${course.name}`);
|
||
});
|
||
}
|
||
|
||
if (coursesNotInPosterJson.length > 0) {
|
||
console.log('\n⚠️ 不在文旅_作业海报.json中的课程:');
|
||
coursesNotInPosterJson.forEach(name => {
|
||
console.log(` - ${name}`);
|
||
});
|
||
}
|
||
|
||
if (coursesWithWrongImages.length === 0 && coursesNotInPosterJson.length === 0 && coursesWithoutImages === 0) {
|
||
console.log('\n✅ 所有课程图片数据都正确匹配!');
|
||
} else {
|
||
console.log('\n⚠️ 发现数据不匹配,需要修复。');
|
||
}
|