Files
teach_sys_Demo/verify_agent_setup.cjs

90 lines
3.6 KiB
JavaScript
Raw Permalink Normal View History

// 验证Agent板块设置
const fs = require('fs');
const path = require('path');
console.log('🔍 验证Agent板块设置\n');
console.log('='.repeat(80));
// 1. 检查AgentPage组件
console.log('\n1. 检查 AgentPage 组件');
const agentPagePath = path.join(__dirname, 'src/pages/AgentPage/index.jsx');
const agentCssPath = path.join(__dirname, 'src/pages/AgentPage/index.css');
const hasAgentPage = fs.existsSync(agentPagePath);
console.log(` ${hasAgentPage ? '✅' : '❌'} AgentPage组件文件存在`);
const hasAgentCss = fs.existsSync(agentCssPath);
console.log(` ${hasAgentCss ? '✅' : '❌'} AgentPage样式文件存在`);
if (hasAgentPage) {
const agentPageContent = fs.readFileSync(agentPagePath, 'utf-8');
const hasIframe = agentPageContent.includes('<iframe');
console.log(` ${hasIframe ? '✅' : '❌'} 包含iframe元素`);
const hasBaiduUrl = agentPageContent.includes('baidu.com');
console.log(` ${hasBaiduUrl ? '✅' : '❌'} 使用百度测试链接`);
}
// 2. 检查路由配置
console.log('\n2. 检查路由配置');
const routesPath = path.join(__dirname, 'src/routes/index.jsx');
const routesContent = fs.readFileSync(routesPath, 'utf-8');
const hasAgentImport = routesContent.includes('import("@/pages/AgentPage")');
console.log(` ${hasAgentImport ? '✅' : '❌'} 导入AgentPage组件`);
const hasAgentRoute = routesContent.includes('path: "/agent"');
console.log(` ${hasAgentRoute ? '✅' : '❌'} 定义/agent路由`);
const hasAgentName = routesContent.includes('name: "Agent"');
console.log(` ${hasAgentName ? '✅' : '❌'} 设置菜单名称为Agent`);
const hasDefaultIcon = routesContent.includes('default: "recuUY5tMX7M6A"');
console.log(` ${hasDefaultIcon ? '✅' : '❌'} 设置未点击图标`);
const hasActiveIcon = routesContent.includes('active: "recuUY5qlmzVhH"');
console.log(` ${hasActiveIcon ? '✅' : '❌'} 设置点击图标`);
const hasShowMenuItem = routesContent.match(/path: "\/agent"[\s\S]*?showMenuItem: true/);
console.log(` ${hasShowMenuItem ? '✅' : '❌'} 设置为显示菜单项`);
// 3. 检查Agent路由在资源板块中
console.log('\n3. 检查Agent在资源板块中的位置');
const resourceSection = routesContent.match(/name: "资源"[\s\S]*?(?=\{[\s\S]*?showMenu:)/);
if (resourceSection) {
const hasAgentInResource = resourceSection[0].includes('path: "/agent"');
console.log(` ${hasAgentInResource ? '✅' : '❌'} Agent路由在资源板块中`);
// 检查顺序
const portfolioIndex = resourceSection[0].indexOf('path: "/portfolio"');
const agentIndex = resourceSection[0].indexOf('path: "/agent"');
const isLastItem = portfolioIndex < agentIndex;
console.log(` ${isLastItem ? '✅' : '❌'} Agent在作品集之后最下方`);
}
console.log('\n' + '='.repeat(80));
const allChecksPassed =
hasAgentPage &&
hasAgentCss &&
hasAgentImport &&
hasAgentRoute &&
hasAgentName &&
hasDefaultIcon &&
hasActiveIcon &&
hasShowMenuItem;
if (allChecksPassed) {
console.log('\n✅ 所有检查通过Agent板块已成功添加到侧边栏。\n');
console.log('📝 功能说明:');
console.log(' - ✅ 在侧边栏"资源"板块最下方添加了Agent菜单项');
console.log(' - ✅ 未点击图标: recuUY5tMX7M6A');
console.log(' - ✅ 点击图标: recuUY5qlmzVhH (白色)');
console.log(' - ✅ 页面内容: iframe嵌入百度测试页面');
console.log(' - ✅ 路由路径: /agent');
console.log('\n💡 下一步: 刷新页面后在侧边栏资源板块最下方可以看到Agent菜单项');
} else {
console.log('\n⚠ 部分检查未通过,请检查上述标记为❌的项目。\n');
}