fix: 修复 Windows 启动脚本编码

This commit is contained in:
2026-05-15 11:57:28 +08:00
parent 9c5a5a54c6
commit bba68f78bf
2 changed files with 17 additions and 11 deletions
+6
View File
@@ -1,5 +1,11 @@
# 项目上下文记录 # 项目上下文记录
## 2026-05-15:修复 Windows 启动脚本编码问题
- `run.bat` 改为纯 ASCII 输出,并规范为 CRLF 行尾,避免 Windows `cmd` 在 PowerShell 中执行 UTF-8 中文批处理时把提示文本解析成碎片命令。
- 启动脚本仍使用 `.venv\Scripts\python.exe`、检查 Python 依赖和 `frontend/dist/index.html`,实际启动方式保持 `python -m app.main` 不变。
- 后续如需中文启动提示,优先放到 PowerShell 脚本或应用日志中,不建议直接写入 `.bat`。
## 2026-05-15:后端拆分与前端迁移 ## 2026-05-15:后端拆分与前端迁移
### 当前架构 ### 当前架构
+11 -11
View File
@@ -1,9 +1,8 @@
@echo off @echo off
chcp 65001 >nul
title CapacityReport v2.0.2 title CapacityReport v2.0.2
echo ======================================== echo ========================================
echo CapacityReport - 容量报表处理程序 echo CapacityReport - report service
echo ======================================== echo ========================================
echo. echo.
@@ -11,25 +10,26 @@ cd /d "%~dp0"
set PYTHON_EXE=.venv\Scripts\python.exe set PYTHON_EXE=.venv\Scripts\python.exe
if not exist "%PYTHON_EXE%" ( if not exist "%PYTHON_EXE%" (
echo [错误] 未找到 uv 创建的虚拟环境: %PYTHON_EXE% echo [ERROR] Python virtual environment not found: %PYTHON_EXE%
echo [提示] 请先在项目根目录执行: uv venv echo [HINT] Run this command in the project root first: uv venv
pause pause
exit /b 1 exit /b 1
) )
"%PYTHON_EXE%" -c "import fastapi, uvicorn, pandas, openpyxl, pymysql, sqlalchemy, chardet" >nul 2>&1 "%PYTHON_EXE%" -c "import fastapi, uvicorn, pandas, openpyxl, pymysql, sqlalchemy, chardet" >nul 2>&1
if errorlevel 1 ( if errorlevel 1 (
echo [提示] 正在安装或补齐 Python 依赖... echo [INFO] Installing or repairing Python dependencies...
uv pip install -r requirements.txt uv pip install -r requirements.txt
if errorlevel 1 ( if errorlevel 1 (
echo [错误] Python 依赖安装失败 echo [ERROR] Failed to install Python dependencies.
pause pause
exit /b 1 exit /b 1
) )
) )
if not exist "frontend\dist\index.html" ( if not exist "frontend\dist\index.html" (
echo [提示] 前端构建产物不存在,请先执行: echo [ERROR] Frontend build output not found.
echo [HINT] Run these commands first:
echo cd frontend echo cd frontend
echo npm install echo npm install
echo npm run build echo npm run build
@@ -39,14 +39,14 @@ if not exist "frontend\dist\index.html" (
:loop :loop
echo. echo.
echo [%date% %time%] 启动服务... echo [%date% %time%] Starting service...
echo [启动] 服务地址: http://localhost:9081 echo [INFO] Service URL: http://localhost:9081
echo [提示] 关闭此窗口即可停止服务 echo [INFO] Close this window to stop the service.
echo. echo.
"%PYTHON_EXE%" -m app.main "%PYTHON_EXE%" -m app.main
echo. echo.
echo [%date% %time%] 服务已停止,3 秒后自动重启... echo [%date% %time%] Service stopped. Restarting in 3 seconds...
timeout /t 3 /nobreak >nul timeout /t 3 /nobreak >nul
goto loop goto loop