更新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:
128
frontend_视觉设计/finalCleanIndent.cjs
Normal file
128
frontend_视觉设计/finalCleanIndent.cjs
Normal file
@@ -0,0 +1,128 @@
|
||||
#!/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}_final_clean`;
|
||||
const mockContent = fs.readFileSync('src/mocks/resumeInterviewMock.js', 'utf-8');
|
||||
fs.writeFileSync(backupPath, mockContent);
|
||||
console.log(`✓ Backup created: ${backupPath}`);
|
||||
|
||||
// Function to clean indentation from text
|
||||
function cleanIndentation(text) {
|
||||
const lines = text.split('\n');
|
||||
const cleanedLines = lines.map(line => line.trimStart());
|
||||
return cleanedLines.join('\n');
|
||||
}
|
||||
|
||||
// Read and parse the file structure
|
||||
let processedContent = mockContent;
|
||||
let totalCount = 0;
|
||||
|
||||
// Find all "answer": "..." patterns and clean them
|
||||
// Using a more robust approach by processing character by character
|
||||
let newContent = '';
|
||||
let i = 0;
|
||||
|
||||
while (i < processedContent.length) {
|
||||
// Look for "answer": "
|
||||
if (processedContent.substring(i, i + 10) === '"answer": "') {
|
||||
// Found an answer field
|
||||
newContent += '"answer": "';
|
||||
i += 10;
|
||||
|
||||
// Extract the answer content, handling escapes properly
|
||||
let answerContent = '';
|
||||
let escaped = false;
|
||||
|
||||
while (i < processedContent.length) {
|
||||
const char = processedContent[i];
|
||||
|
||||
if (escaped) {
|
||||
answerContent += char;
|
||||
escaped = false;
|
||||
} else if (char === '\\') {
|
||||
answerContent += char;
|
||||
escaped = true;
|
||||
} else if (char === '"') {
|
||||
// End of answer content
|
||||
break;
|
||||
} else {
|
||||
answerContent += char;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
// Process the answer content
|
||||
// Unescape for processing
|
||||
let unescaped = answerContent
|
||||
.replace(/\\n/g, '\n')
|
||||
.replace(/\\"/g, '"')
|
||||
.replace(/\\\\/g, '\\');
|
||||
|
||||
// Clean indentation
|
||||
let cleaned = cleanIndentation(unescaped);
|
||||
|
||||
// Re-escape
|
||||
let reescaped = cleaned
|
||||
.replace(/\\/g, '\\\\')
|
||||
.replace(/"/g, '\\"')
|
||||
.replace(/\n/g, '\\n');
|
||||
|
||||
newContent += reescaped;
|
||||
totalCount++;
|
||||
|
||||
} else {
|
||||
newContent += processedContent[i];
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
console.log(`\n✅ Processed ${totalCount} answer fields`);
|
||||
|
||||
// Save the file
|
||||
fs.writeFileSync('src/mocks/resumeInterviewMock.js', newContent);
|
||||
|
||||
// Verify syntax
|
||||
const { execSync } = require('child_process');
|
||||
try {
|
||||
execSync('node -c src/mocks/resumeInterviewMock.js', { encoding: 'utf-8' });
|
||||
console.log('✅ Syntax validation passed');
|
||||
|
||||
// Verify the changes
|
||||
console.log('\n📋 Verification of cleaned answers:\n');
|
||||
const verifyContent = fs.readFileSync('src/mocks/resumeInterviewMock.js', 'utf-8');
|
||||
|
||||
// Check a few samples
|
||||
const samplePattern = /"answer":\s*"([^"]*?阶段[^"]{0,300})"/;
|
||||
const sampleMatch = verifyContent.match(samplePattern);
|
||||
|
||||
if (sampleMatch) {
|
||||
const sample = sampleMatch[1].replace(/\\n/g, '\n').substring(0, 400);
|
||||
console.log('Sample answer (should have no leading spaces on each line):');
|
||||
console.log('─'.repeat(60));
|
||||
console.log(sample);
|
||||
console.log('─'.repeat(60));
|
||||
|
||||
// Check if indentation was actually removed
|
||||
const lines = sample.split('\n');
|
||||
let hasIndentation = false;
|
||||
for (const line of lines) {
|
||||
if (line.startsWith(' ') || line.startsWith('\t')) {
|
||||
hasIndentation = true;
|
||||
console.log(`⚠️ Still has indentation: "${line.substring(0, 50)}..."`);
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasIndentation) {
|
||||
console.log('✅ All indentation successfully removed!');
|
||||
}
|
||||
}
|
||||
|
||||
} 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