TorqueWrench/frontend/build_exe.sh

61 lines
1.4 KiB
Bash
Raw Permalink Normal View History

2026-02-26 16:39:29 +08:00
#!/bin/bash
# 电动扳手GUI打包脚本Linux/Mac
echo "========================================"
echo "电动扳手GUI打包脚本"
echo "========================================"
echo ""
# 检查 PyInstaller 是否已安装
if ! python3 -c "import PyInstaller" 2>/dev/null; then
echo "[错误] PyInstaller 未安装"
echo "正在安装 PyInstaller..."
pip3 install pyinstaller
if [ $? -ne 0 ]; then
echo "[错误] PyInstaller 安装失败,请手动执行: pip3 install pyinstaller"
exit 1
fi
fi
echo "[信息] PyInstaller 已安装"
echo ""
# 确保在 frontend 目录下执行
cd "$(dirname "$0")"
# 清理之前的构建文件
echo "[信息] 清理之前的构建文件..."
rm -rf build dist
echo ""
echo "[信息] 当前目录: $(pwd)"
echo "[信息] 开始打包..."
echo ""
# 执行打包
pyinstaller wrench_gui.spec
if [ $? -ne 0 ]; then
echo ""
echo "[错误] 打包失败!"
exit 1
fi
echo ""
echo "========================================"
echo "打包完成!"
echo "========================================"
echo ""
echo "可执行文件位置: dist/wrench_gui/wrench_gui"
echo ""
echo "下一步操作:"
echo "1. 复制配置文件到可执行文件目录:"
echo " cp ../config.json dist/wrench_gui/config.json"
echo ""
echo "2. 确保后端API服务已启动http://localhost:5000"
echo ""
echo "3. 运行程序:"
echo " ./dist/wrench_gui/wrench_gui"
echo ""