更新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>
This commit is contained in:
107
frontend_视觉设计/optimizeIndentation.cjs
Normal file
107
frontend_视觉设计/optimizeIndentation.cjs
Normal file
@@ -0,0 +1,107 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
// Create backup
|
||||
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, -5);
|
||||
const backupPath = `src/mocks/resumeInterviewMock.js.backup_${timestamp}_optimize_indent`;
|
||||
const mockContent = fs.readFileSync('src/mocks/resumeInterviewMock.js', 'utf-8');
|
||||
fs.writeFileSync(backupPath, mockContent);
|
||||
console.log(`✓ Backup created: ${backupPath}`);
|
||||
|
||||
// Function to optimize answer indentation
|
||||
function optimizeIndentation(answer) {
|
||||
// Split by newlines
|
||||
const lines = answer.split('\\n');
|
||||
const cleanedLines = [];
|
||||
|
||||
for (let line of lines) {
|
||||
let cleanedLine = line;
|
||||
|
||||
// Check if this is a list item or numbered item
|
||||
const hasListMarker = /^\s*[-•·*]/.test(line);
|
||||
const hasNumberedList = /^\s*\d+\./.test(line);
|
||||
|
||||
if (hasListMarker || hasNumberedList) {
|
||||
// For top-level list items, remove all indentation
|
||||
if (/^\s{0,4}[-•·*\d]/.test(line)) {
|
||||
cleanedLine = line.trimStart();
|
||||
} else {
|
||||
// For nested list items (more than 4 spaces), keep minimal indentation (2 spaces)
|
||||
cleanedLine = ' ' + line.trimStart();
|
||||
}
|
||||
} else if (line.trim()) {
|
||||
// For non-list content, check if it's continuation of a list item
|
||||
const leadingSpaces = line.match(/^(\s*)/)[1].length;
|
||||
if (leadingSpaces >= 4) {
|
||||
// This seems to be nested content, reduce to 2 spaces
|
||||
cleanedLine = ' ' + line.trimStart();
|
||||
} else {
|
||||
// Regular content, no indentation
|
||||
cleanedLine = line.trimStart();
|
||||
}
|
||||
}
|
||||
|
||||
cleanedLines.push(cleanedLine);
|
||||
}
|
||||
|
||||
return cleanedLines.join('\\n');
|
||||
}
|
||||
|
||||
// Process the file
|
||||
let updatedContent = mockContent;
|
||||
let count = 0;
|
||||
|
||||
// Pattern to match answer fields
|
||||
const answerRegex = /"answer":\s*"((?:[^"\\]|\\.)*)"/g;
|
||||
|
||||
updatedContent = updatedContent.replace(answerRegex, (match, answerContent) => {
|
||||
// Unescape the answer content for processing
|
||||
let unescaped = answerContent
|
||||
.replace(/\\n/g, '\n')
|
||||
.replace(/\\"/g, '"')
|
||||
.replace(/\\\\/g, '\\');
|
||||
|
||||
// Optimize indentation
|
||||
let cleaned = optimizeIndentation(unescaped);
|
||||
|
||||
// Re-escape for JSON
|
||||
let escaped = cleaned
|
||||
.replace(/\\/g, '\\\\')
|
||||
.replace(/"/g, '\\"')
|
||||
.replace(/\n/g, '\\n');
|
||||
|
||||
count++;
|
||||
return `"answer": "${escaped}"`;
|
||||
});
|
||||
|
||||
console.log(`\n✅ Optimized indentation in ${count} answer fields`);
|
||||
|
||||
// Save the file
|
||||
fs.writeFileSync('src/mocks/resumeInterviewMock.js', updatedContent);
|
||||
|
||||
// Verify syntax
|
||||
const { execSync } = require('child_process');
|
||||
try {
|
||||
execSync('node -c src/mocks/resumeInterviewMock.js', { encoding: 'utf-8' });
|
||||
console.log('✅ Syntax validation passed');
|
||||
|
||||
// Show samples of the optimized content
|
||||
console.log('\n📋 Sample of optimized answers:');
|
||||
console.log('(Note: Nested items now have minimal 2-space indentation)\n');
|
||||
const matches = updatedContent.matchAll(/"answer":\s*"([^"]{0,400})/g);
|
||||
let samples = 0;
|
||||
for (const match of matches) {
|
||||
if (samples >= 2) break;
|
||||
console.log(`Sample ${samples + 1}:`);
|
||||
const formatted = match[1].replace(/\\n/g, '\n').substring(0, 350);
|
||||
console.log(formatted);
|
||||
console.log('\n' + '-'.repeat(50) + '\n');
|
||||
samples++;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ Syntax error detected, restoring backup...');
|
||||
fs.writeFileSync('src/mocks/resumeInterviewMock.js', mockContent);
|
||||
console.log('Backup restored');
|
||||
console.error('Error:', error.message);
|
||||
}
|
||||
Reference in New Issue
Block a user