Ai_GirlFriend/诊断问题.bat
2026-02-04 19:26:08 +08:00

83 lines
3.4 KiB
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@echo off
chcp 65001 >nul
title 诊断 PHP 服务器问题
echo.
echo ╔════════════════════════════════════╗
echo ║ 诊断 PHP 服务器问题 ║
echo ╚════════════════════════════════════╝
echo.
REM ==========================================
REM 1. 检查 MySQL 服务
REM ==========================================
echo [1/5] 检查 MySQL 服务...
echo.
netstat -ano | findstr :3306 >nul 2>&1
if errorlevel 1 (
echo [✗] MySQL 服务未运行(端口 3306 未监听)
echo.
echo 这可能是导致 PHP API 超时的原因!
echo 请启动 MySQL 服务后再试。
echo.
) else (
echo [✓] MySQL 服务正在运行
echo.
)
REM ==========================================
REM 2. 检查 PHP 服务器
REM ==========================================
echo [2/5] 检查 PHP 服务器...
echo.
netstat -ano | findstr :30100 >nul 2>&1
if errorlevel 1 (
echo [✗] PHP 服务器未运行(端口 30100 未监听)
echo.
) else (
echo [✓] PHP 服务器正在运行
echo.
)
REM ==========================================
REM 3. 测试 PHP 基本响应
REM ==========================================
echo [3/5] 测试 PHP 基本响应...
echo.
powershell -Command "try { $response = Invoke-WebRequest -Uri 'http://127.0.0.1:30100/test_api.php' -TimeoutSec 5; Write-Host '[✓] PHP 服务器响应正常' -ForegroundColor Green; Write-Host '响应内容:' -ForegroundColor Cyan; $response.Content } catch { Write-Host '[✗] PHP 服务器无响应' -ForegroundColor Red; Write-Host '错误:' $_.Exception.Message -ForegroundColor Red }"
echo.
REM ==========================================
REM 4. 测试 PHP 调试接口
REM ==========================================
echo [4/5] 测试 PHP 调试接口(包含数据库检查)...
echo.
powershell -Command "try { $response = Invoke-WebRequest -Uri 'http://127.0.0.1:30100/debug.php' -TimeoutSec 10; Write-Host '[✓] 调试接口响应正常' -ForegroundColor Green; Write-Host '响应内容:' -ForegroundColor Cyan; $response.Content } catch { Write-Host '[✗] 调试接口无响应' -ForegroundColor Red; Write-Host '错误:' $_.Exception.Message -ForegroundColor Red }"
echo.
REM ==========================================
REM 5. 测试实际 API
REM ==========================================
echo [5/5] 测试实际 API需要有效 token...
echo.
powershell -Command "try { $response = Invoke-WebRequest -Uri 'http://127.0.0.1:30100/api/user_basic/get_user_basic' -Headers @{'token'='test-token'} -TimeoutSec 10; Write-Host '[✓] API 响应正常' -ForegroundColor Green; Write-Host '响应内容:' -ForegroundColor Cyan; $response.Content } catch { Write-Host '[✗] API 无响应或返回错误' -ForegroundColor Yellow; Write-Host '错误:' $_.Exception.Message -ForegroundColor Yellow; Write-Host ''; Write-Host '这是正常的,因为使用了无效的 token' -ForegroundColor Gray }"
echo.
echo ════════════════════════════════════
echo.
echo 诊断完成!
echo.
echo 如果看到以下问题:
echo • MySQL 未运行 → 请启动 MySQL 服务
echo • PHP 服务器无响应 → 检查 PHP 启动窗口的错误信息
echo • 数据库连接失败 → 检查 xunifriend_RaeeC/.env 中的数据库配置
echo.
pause