39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
|
|
const fs = require('fs');
|
||
|
|
const path = require('path');
|
||
|
|
|
||
|
|
// 读取mockData.js
|
||
|
|
const mockDataPath = path.join(__dirname, 'src/data/mockData.js');
|
||
|
|
const content = fs.readFileSync(mockDataPath, 'utf-8');
|
||
|
|
|
||
|
|
// 提取垂直能力课部分
|
||
|
|
const verticalMatch = content.match(/name:\s*"垂直能力课"[\s\S]*?units:\s*\[([\s\S]*?)\]\s*,\s*\/\/ 保留原始list/);
|
||
|
|
|
||
|
|
if (verticalMatch) {
|
||
|
|
const unitsContent = verticalMatch[1];
|
||
|
|
|
||
|
|
// 提取所有unit名称
|
||
|
|
const unitNames = [...unitsContent.matchAll(/name:\s*"([^"]+)",\s*courses:/g)].map(m => m[1]);
|
||
|
|
|
||
|
|
console.log('垂直能力课的units数量:', unitNames.length);
|
||
|
|
console.log('\nunits列表:');
|
||
|
|
unitNames.forEach((name, index) => {
|
||
|
|
console.log(` ${index + 1}. ${name}`);
|
||
|
|
});
|
||
|
|
|
||
|
|
// 统计每个unit的课程数
|
||
|
|
console.log('\n每个unit的课程数:');
|
||
|
|
const unitBlocks = unitsContent.split(/\},\s*\{/).filter(Boolean);
|
||
|
|
|
||
|
|
unitNames.forEach((name, index) => {
|
||
|
|
const unitPattern = new RegExp(`name:\\s*"${name.replace(/[()]/g, '\\$&')}"[\\s\\S]*?courses:\\s*\\[([\\s\\S]*?)\\]`, 'g');
|
||
|
|
const match = unitPattern.exec(unitsContent);
|
||
|
|
if (match) {
|
||
|
|
const coursesContent = match[1];
|
||
|
|
const courseCount = (coursesContent.match(/\{[^}]*id:\s*\d+/g) || []).length;
|
||
|
|
console.log(` ${name}: ${courseCount}个课程`);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
} else {
|
||
|
|
console.log('未找到垂直能力课的units结构');
|
||
|
|
}
|