daShangDao_miniProgram/temp_validate.js
2026-06-15 16:37:57 +08:00

57 lines
1.8 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. 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 = 'D:\\project\\zhizhu\\components\\PhotoUploadForm.vue';
const content = fs.readFileSync(path, 'utf8');
const lines = content.split('\n');
console.log('=== Final validation ===\n');
// 检查文件末尾结构
console.log('File ending structure:');
for (let i = lines.length - 30; i < lines.length; i++) {
if (lines[i].includes('</script>') || lines[i].includes('</style>') ||
lines[i].includes('};') || lines[i].includes('},') ||
lines[i].trim() === '}') {
console.log(`Line ${i + 1}: ${lines[i]}`);
}
}
// 精确的括号计数
let braceCount = 0;
let exportStart = -1;
let scriptEnd = -1;
for (let i = 0; i < lines.length; i++) {
if (lines[i].includes('export default {')) {
exportStart = i;
}
if (lines[i].includes('</script>')) {
scriptEnd = i;
break;
}
}
// 从 export default 开始计数
if (exportStart >= 0 && scriptEnd >= 0) {
for (let i = exportStart; i <= scriptEnd; i++) {
const line = lines[i];
// 跳过 importexport 之后不应该有 import
if (line.includes('import ')) continue;
const codeOnly = line.replace(/\/\/.*$/, '').replace(/\/\*.*?\*\//g, '');
const noStrings = codeOnly.replace(/'[^']*'/g, '""').replace(/"[^"]*"/g, '""').replace(/`[^`]*`/g, '""');
const opens = (noStrings.match(/{/g) || []).length;
const closes = (noStrings.match(/}/g) || []).length;
braceCount += opens - closes;
}
console.log(`\nBrace count from export default to </script>: ${braceCount}`);
console.log(braceCount === 0 ? '✓ Balanced!' : '✗ Unbalanced!');
}
// 验证具体的方法结束和 methods 结束
console.log('\n=== Checking methods end ===');
for (let i = lines.length - 10; i < lines.length; i++) {
console.log(`Line ${i + 1}: "${lines[i]}"`);
}