Files
teach_sys_Demo/verify_homework_images.cjs
KQL 1b964b3886 chore: 更新数据文件和组件优化
主要更新内容:
- 优化UI组件(视频播放器、HR访问模态框、岗位信息展示等)
- 更新数据文件(简历、岗位、项目案例等)
- 添加新的图片资源(面试状态图标等)
- 新增AgentPage等页面组件
- 清理旧的备份文件,提升代码库整洁度
- 优化岗位等级和面试状态的数据结构

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-15 15:55:25 +08:00

112 lines
3.7 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 验证课程作业图片数据匹配情况
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⚠ 发现数据不匹配,需要修复。');
}