增加日志功能,增加打包成exe功能,点击exe就可以使用

This commit is contained in:
2026-03-03 14:07:54 +08:00
parent 9f54a0cb2e
commit b47962e5c8
23 changed files with 172395 additions and 65 deletions

View File

@@ -43,21 +43,42 @@ python remo_disp_server.py [装置IP]
python remo_disp_server.py 192.168.253.3
```
## 打包为 exeWindows
在项目目录下执行:
```bash
# 安装 PyInstaller 后打包
pip install pyinstaller
python -m PyInstaller remo_disp_server.spec --noconfirm
```
或直接双击运行 `build_exe.bat`
打包完成后可执行文件为 **dist\\remo_disp_server.exe**。双击运行,或在命令行:
```bash
dist\remo_disp_server.exe
dist\remo_disp_server.exe 192.168.253.3
```
运行后浏览器访问 http://localhost:8181。日志会输出到控制台同目录下会生成 `remo_disp.log`
## 项目结构
```
DTU-RemoteLCD/
├── remo_disp_server.py # Web 服务Flask + Socket.IO
├── remo_disp_server.spec # PyInstaller 打包配置
├── build_exe.bat # 一键打包脚本Windows
├── remo_disp_ui.html # Web 前端页面
├── requirements.txt # Python 依赖
├── requirements.txt # Python 依赖
├── static/ # 静态资源(可选)
│ └── favicon.ico # 网站图标
│ └── favicon.ico # 网站图标
└── README.md
```
## 协议说明RemoDispBus
`HMI/RemoeDisp/RemoDispBus.c` 兼容:
## 协议说明
| 项目 | 说明 |
|------|------|
@@ -96,6 +117,15 @@ DTU-RemoteLCD/
| flask-socketio | WebSocket 支持 |
| python-socketio | Socket.IO 服务端 |
| Pillow | 1bpp 位图转 PNG |
| loguru | 结构化日志、错误追踪 |
## 日志与调试
- 后端使用 `loguru` 输出日志,默认会打印到控制台,并写入当前目录下的 `remo_disp.log`
-`remo_disp_server.py` 顶部有 `LOG_LEVEL` 常量:
- `LOG_LEVEL = "INFO"`:只输出 INFO/WARNING/ERROR 级别日志(默认)。
- `LOG_LEVEL = "DEBUG"`:输出包括 DEBUG 在内的详细调试信息。
- exe 版本(`remo_disp_server.exe`)同样会在运行目录生成 `remo_disp.log`,方便线下排查问题。
## 配置说明