Some checks failed
Deploy / deploy (push) Has been cancelled
Full-stack web application for Telegram management - Frontend: Vue 3 + Vben Admin - Backend: NestJS - Features: User management, group broadcast, statistics 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
67 lines
2.5 KiB
JavaScript
67 lines
2.5 KiB
JavaScript
const axios = require('axios');
|
||
const mysql = require('mysql2/promise');
|
||
|
||
async function testSystemStatus() {
|
||
console.log('=== 系统状态检查 ===\n');
|
||
|
||
// 1. 检查后端服务
|
||
try {
|
||
await axios.get('http://localhost:3000');
|
||
console.log('✅ 后端服务运行正常 (端口 3000)');
|
||
} catch (error) {
|
||
if (error.response && error.response.status === 404) {
|
||
console.log('✅ 后端服务运行正常 (端口 3000)');
|
||
} else {
|
||
console.log('❌ 后端服务未运行或无法访问');
|
||
}
|
||
}
|
||
|
||
// 2. 检查数据库连接
|
||
try {
|
||
const connection = await mysql.createConnection({
|
||
host: '127.0.0.1',
|
||
user: 'root',
|
||
password: '',
|
||
database: 'tg_manage'
|
||
});
|
||
|
||
// 查询账号数量
|
||
const [accounts] = await connection.execute('SELECT COUNT(*) as count FROM accounts WHERE status = 1');
|
||
console.log(`✅ 数据库连接正常,有 ${accounts[0].count} 个激活账号`);
|
||
|
||
// 查询已登录账号
|
||
const [loggedIn] = await connection.execute('SELECT id, phone, firstname FROM accounts WHERE session IS NOT NULL AND status = 1 LIMIT 5');
|
||
if (loggedIn.length > 0) {
|
||
console.log('\n已登录的账号:');
|
||
loggedIn.forEach(acc => {
|
||
console.log(` - ID: ${acc.id}, 手机: ${acc.phone}, 名称: ${acc.firstname || '未知'}`);
|
||
});
|
||
} else {
|
||
console.log('\n⚠️ 没有已登录的账号');
|
||
}
|
||
|
||
await connection.end();
|
||
} catch (error) {
|
||
console.log('❌ 数据库连接失败:', error.message);
|
||
}
|
||
|
||
// 3. 测试API接口(模拟前端请求)
|
||
console.log('\n=== API 接口测试 ===\n');
|
||
|
||
// 测试获取账号列表
|
||
try {
|
||
// 需要先获取 token,这里简化处理
|
||
console.log('ℹ️ API 需要认证,请在前端界面测试');
|
||
} catch (error) {
|
||
console.log('API 测试失败:', error.message);
|
||
}
|
||
|
||
console.log('\n=== 建议 ===\n');
|
||
console.log('1. 访问前端页面: http://localhost:5173 或 http://localhost:3000');
|
||
console.log('2. 使用默认账号密码登录系统');
|
||
console.log('3. 进入"账号列表"查看已有账号');
|
||
console.log('4. 如果没有账号,点击"添加账号"进行扫码登录');
|
||
console.log('5. 已登录的账号可以点击"查看聊天"使用聊天功能');
|
||
}
|
||
|
||
testSystemStatus(); |