69 lines
1.8 KiB
JavaScript
69 lines
1.8 KiB
JavaScript
|
|
const fs = require('fs');
|
||
|
|
const path = require('path');
|
||
|
|
|
||
|
|
function checkSyntax() {
|
||
|
|
try {
|
||
|
|
console.log('🔍 检查个人资料页面语法...');
|
||
|
|
|
||
|
|
const profilePath = path.join(__dirname, 'src', 'app', 'profile', 'page.tsx');
|
||
|
|
|
||
|
|
if (!fs.existsSync(profilePath)) {
|
||
|
|
console.log('❌ 个人资料页面文件不存在');
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
const content = fs.readFileSync(profilePath, 'utf8');
|
||
|
|
|
||
|
|
// 检查基本的语法结构
|
||
|
|
const checks = [
|
||
|
|
{
|
||
|
|
name: 'ProtectedRoute 组件导入',
|
||
|
|
test: content.includes("import { ProtectedRoute } from '@/components/auth/ProtectedRoute'")
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: 'ProtectedRoute 组件使用',
|
||
|
|
test: content.includes('<ProtectedRoute>') && content.includes('</ProtectedRoute>')
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: 'JSX 结构完整性',
|
||
|
|
test: (content.match(/<div/g) || []).length === (content.match(/<\/div>/g) || []).length
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: '函数组件定义',
|
||
|
|
test: content.includes('export default function ProfilePage()')
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: 'useAuth Hook 使用',
|
||
|
|
test: content.includes('const { user, updateProfile, logout } = useAuth()')
|
||
|
|
}
|
||
|
|
];
|
||
|
|
|
||
|
|
let allPassed = true;
|
||
|
|
|
||
|
|
checks.forEach(check => {
|
||
|
|
if (check.test) {
|
||
|
|
console.log(`✅ ${check.name}`);
|
||
|
|
} else {
|
||
|
|
console.log(`❌ ${check.name}`);
|
||
|
|
allPassed = false;
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
if (allPassed) {
|
||
|
|
console.log('🎉 语法检查通过!');
|
||
|
|
return true;
|
||
|
|
} else {
|
||
|
|
console.log('💥 语法检查失败!');
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
} catch (error) {
|
||
|
|
console.error('❌ 语法检查出错:', error.message);
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// 运行语法检查
|
||
|
|
const result = checkSyntax();
|
||
|
|
process.exit(result ? 0 : 1);
|