/** * 菜单功能修复验证脚本 */ const fs = require('fs'); const path = require('path'); console.log('=== 菜单功能修复验证 ==='); // 检查Layout.js修复结果 function checkLayoutFix() { console.log('\n1. 检查Layout.js修复结果...'); try { const layoutPath = path.join(__dirname, 'src', 'renderer', 'components', 'Layout.js'); if (fs.existsSync(layoutPath)) { const content = fs.readFileSync(layoutPath, 'utf8'); // 检查是否包含增强的错误处理 if (content.includes('console.log(\'菜单点击:\', key)')) { console.log(' ✅ 菜单点击处理函数已增强'); } else { console.log(' ⚠️ 菜单点击处理函数可能未正确修复'); } // 检查多重备选方案 if (content.includes('window.location.hash = key')) { console.log(' ✅ 已添加window.location.hash备选方案'); } else { console.log(' ⚠️ 未找到window.location.hash备选方案'); } // 检查是否包含最后的备选方案 if (content.includes('window.location.reload()')) { console.log(' ✅ 已添加页面刷新备选方案'); } else { console.log(' ⚠️ 未找到页面刷新备选方案'); } } else { console.log(' ❌ Layout.js文件不存在'); } } catch (error) { console.error(' ❌ 检查Layout.js失败:', error); } } // 检查HTML模板 function checkHtmlTemplate() { console.log('\n2. 检查HTML模板...'); try { const htmlPath = path.join(__dirname, 'src', 'renderer', 'index.html'); if (fs.existsSync(htmlPath)) { const content = fs.readFileSync(htmlPath, 'utf8'); if (content.includes('')) { console.log(' ✅ base标签已正确设置'); } else { console.log(' ⚠️ base标签可能未正确设置'); } } else { console.log(' ❌ index.html文件不存在'); } } catch (error) { console.error(' ❌ 检查HTML模板失败:', error); } } // 检查备份文件 function checkBackup() { console.log('\n3. 检查备份文件...'); try { const backupPath = path.join(__dirname, 'src', 'renderer', 'components', 'Layout.js.backup'); if (fs.existsSync(backupPath)) { console.log(' ✅ 已创建备份文件'); } else { console.log(' ⚠️ 未找到备份文件'); } } catch (error) { console.error(' ❌ 检查备份文件失败:', error); } } // 主函数 function main() { console.log('开始验证菜单功能修复...\n'); checkLayoutFix(); checkHtmlTemplate(); checkBackup(); console.log('\n=== 验证完成 ==='); console.log('如果所有检查都通过✅,菜单功能应该可以正常工作。'); console.log('如果有任何⚠️,建议重新运行修复脚本。'); console.log('\n接下来请运行"启动收银台.bat"测试菜单功能。'); } // 执行验证 main();