111 lines
3.7 KiB
JavaScript
111 lines
3.7 KiB
JavaScript
const fs = require('fs');
|
||
const path = require('path');
|
||
|
||
console.log('=== 收银台应用路由诊断工具 ===');
|
||
console.log('开始检查应用路由配置...');
|
||
|
||
// 检查App.js中的路由配置
|
||
function checkAppRoutes() {
|
||
console.log('\n[1] 检查App.js路由配置:');
|
||
try {
|
||
const appFilePath = path.join(__dirname, 'src', 'renderer', 'App.js');
|
||
const appContent = fs.readFileSync(appFilePath, 'utf8');
|
||
|
||
if (appContent.includes('<Route path="/" element={<Cashier />} />') &&
|
||
appContent.includes('<Route path="/cashier" element={<Cashier />} />')) {
|
||
console.log('✅ App.js路由配置正确,包含收银台路径');
|
||
} else {
|
||
console.log('❌ App.js路由配置中未找到收银台路径');
|
||
}
|
||
|
||
if (appContent.includes('const mockUser = {')) {
|
||
console.log('✅ 找到模拟用户配置,跳过登录');
|
||
} else {
|
||
console.log('❌ 未找到模拟用户配置,可能需要登录');
|
||
}
|
||
} catch (error) {
|
||
console.log('❌ 读取App.js失败:', error.message);
|
||
}
|
||
}
|
||
|
||
// 检查Layout.js中的菜单配置
|
||
function checkLayoutMenu() {
|
||
console.log('\n[2] 检查Layout.js菜单配置:');
|
||
try {
|
||
const layoutFilePath = path.join(__dirname, 'src', 'renderer', 'components', 'Layout.js');
|
||
const layoutContent = fs.readFileSync(layoutFilePath, 'utf8');
|
||
|
||
if (layoutContent.includes("key: '/cashier',")) {
|
||
console.log('✅ Layout.js中找到收银台菜单项');
|
||
} else {
|
||
console.log('❌ Layout.js中未找到收银台菜单项');
|
||
}
|
||
|
||
if (layoutContent.includes('function handleMenuClick')) {
|
||
console.log('✅ 找到菜单点击处理函数');
|
||
} else {
|
||
console.log('❌ 未找到菜单点击处理函数');
|
||
}
|
||
} catch (error) {
|
||
console.log('❌ 读取Layout.js失败:', error.message);
|
||
}
|
||
}
|
||
|
||
// 检查Cashier组件导入
|
||
function checkCashierImport() {
|
||
console.log('\n[3] 检查Cashier组件导入:');
|
||
try {
|
||
const cashierFilePath = path.join(__dirname, 'src', 'renderer', 'pages', 'Cashier.js');
|
||
if (fs.existsSync(cashierFilePath)) {
|
||
console.log('✅ Cashier.js文件存在');
|
||
|
||
const cashierContent = fs.readFileSync(cashierFilePath, 'utf8');
|
||
if (cashierContent.includes('export default Cashier;')) {
|
||
console.log('✅ Cashier组件正确导出');
|
||
} else {
|
||
console.log('❌ Cashier组件未正确导出');
|
||
}
|
||
} else {
|
||
console.log('❌ Cashier.js文件不存在');
|
||
}
|
||
} catch (error) {
|
||
console.log('❌ 检查Cashier组件失败:', error.message);
|
||
}
|
||
}
|
||
|
||
// 检查API服务
|
||
function checkApiService() {
|
||
console.log('\n[4] 检查API服务配置:');
|
||
try {
|
||
const apiFilePath = path.join(__dirname, 'src', 'renderer', 'services', 'api.js');
|
||
const apiContent = fs.readFileSync(apiFilePath, 'utf8');
|
||
|
||
if (apiContent.includes('function findAvailablePort()')) {
|
||
console.log('✅ 找到findAvailablePort函数');
|
||
} else {
|
||
console.log('❌ 未找到findAvailablePort函数');
|
||
}
|
||
|
||
if (apiContent.includes('const apiMethods = {')) {
|
||
console.log('✅ 找到API方法定义');
|
||
} else {
|
||
console.log('❌ 未找到API方法定义');
|
||
}
|
||
|
||
// 检查是否有detectApiPort函数(可能是错误的调用)
|
||
if (apiContent.includes('detectApiPort')) {
|
||
console.log('⚠️ 发现detectApiPort函数调用,可能需要修改为findAvailablePort');
|
||
}
|
||
} catch (error) {
|
||
console.log('❌ 检查API服务失败:', error.message);
|
||
}
|
||
}
|
||
|
||
// 执行所有检查
|
||
checkAppRoutes();
|
||
checkLayoutMenu();
|
||
checkCashierImport();
|
||
checkApiService();
|
||
|
||
console.log('\n=== 诊断完成 ===');
|
||
console.log('请检查是否有任何❌错误项,这些可能是导致收银台菜单无响应的原因。'); |