一个真正通用的桌面应用启动器,支持任意后端类型(Java、Node.js、Python、Go...),所有配置通过配置文件自定义,无需修改代码。
- 真正通用:支持 Java、Node.js、Python、Go 等任意后端
- 配置驱动:端口、命令、参数全部通过配置文件设置
- 多种健康检查:HTTP、TCP、文件检查或不检查
- 环境变量支持:可设置后端进程的环境变量
- 纯本地运行:前后端代码和 exe 放一起,更新就是替换文件
- 跨平台:支持 Windows、macOS (Intel/ARM)、Linux
- 开箱即用:下载 release 直接运行,无需配置
MyApp/ # 应用根目录(可以任意命名)
├── universal-app-launcher.exe # Windows 启动器
├── universal-app-launcher.app # macOS 启动器
├── universal-app-launcher # Linux 启动器
├── launcher.yml # 启动器配置文件
├── frontend/ # 前端代码(你的 HTML/CSS/JS)
│ ├── index.html
│ └── assets/
└── backend/ # 后端代码
├── app.jar # 或 server.js、app.py 等
└── application.yml # 后端配置(可选)
重要:前后端代码和启动器放在同一目录下,启动器会自动从这个目录加载配置和资源。
universal-launcher/
├── src/ # 前端源码 (Vue)
├── src-tauri/ # Tauri/Rust 后端源码
│ ├── src/
│ │ └── main.rs # Rust 主程序
│ ├── Cargo.toml # Rust 依赖
│ ├── tauri.conf.json # Tauri 配置
│ ├── build.rs # 构建脚本
│ └── icons/ # 应用图标
├── scripts/ # 构建脚本
├── examples/ # 配置示例
├── package.json
└── vite.config.js
从 GitHub Releases 下载对应平台的启动器:
| 平台 | 文件 |
|---|---|
| Windows | universal-app-launcher_x.x.x_x64-setup.exe |
| macOS ARM (Apple Silicon) | universal-app-launcher_x.x.x_aarch64.dmg |
| Linux | universal-app-launcher_x.x.x_amd64.AppImage |
创建一个目录,放入你的前后端代码:
Windows:
mkdir MyApp
copy universal-app-launcher.exe MyApp\
mkdir MyApp\frontend
copy your-frontend\index.html MyApp\frontend\
mkdir MyApp\backend
copy your-app.jar MyApp\backend\macOS / Linux:
mkdir MyApp
cp universal-app-launcher.app MyApp/
mkdir MyApp/frontend
cp your-frontend/index.html MyApp/frontend/
mkdir MyApp/backend
cp your-app.jar MyApp/backend/在 MyApp 目录下创建 launcher.yml:
app_name: "MyApp"
backend:
enabled: true
command: "java"
args:
- "-jar"
- "app.jar"
work_dir: "backend"
startup_timeout: 60
health_check:
enabled: false # 如果没有健康检查接口,设为 false
check_type: "http"
url: "http://127.0.0.1:8080/actuator/health"
frontend:
enabled: true
directory: "frontend"
index_file: "index.html"
window:
title: "MyApp"
width: 1200
height: 800Windows:
双击 MyApp\universal-app-launcher.exe
macOS:
# 方式一:终端直接运行(推荐,这样能看到日志)
open /Applications/MyApp/universal-app-launcher.app
# 方式二:如果你想把 app 放到 Applications 目录
# 需要创建软链接指向你的工作目录:
ln -s ~/MyApp/universal-app-launcher.app /Applications/MyApp.app
open /Applications/MyApp.app
# 然后把 launcher.yml、frontend、backend 放到 ~/MyApp/Linux:
cd MyApp
./universal-app-launchermacOS 上 .app 文件本质是一个目录。如果你下载的是 .dmg,安装后会放在 /Applications/universal-app-launcher.app。
推荐做法:创建工作目录,通过软链接使用:
# 创建工作目录
mkdir ~/MyApp
# 复制启动器
cp -r /Applications/universal-app-launcher.app ~/MyApp/
# 放入你的文件
cp your-frontend/index.html ~/MyApp/frontend/
cp your-app.jar ~/MyApp/backend/
cp launcher.yml ~/MyApp/
# 运行
open ~/MyApp/universal-app-launcher.app# 克隆项目
git clone https://github.com/javpower/universal-launcher.git
cd universal-launcher
# 安装前端依赖
npm install
# 安装 Tauri CLI(可选)
npm install -g @tauri-apps/cli# 构建当前平台的版本
npm run tauri:build或使用脚本:
# 给脚本添加执行权限
chmod +x scripts/build-all.sh
# 构建当前平台的版本
./scripts/build-all.sh
# 构建特定平台(如果当前系统支持)
./scripts/build-all.sh windows
./scripts/build-all.sh macos
./scripts/build-all.sh macos-arm
./scripts/build-all.sh linux无需额外依赖。
无需额外依赖,但需要 Xcode Command Line Tools:
xcode-select --installsudo apt-get update
sudo apt-get install -y \
libgtk-3-dev \
libwebkit2gtk-4.0-dev \
libappindicator3-dev \
librsvg2-dev \
patchelfsudo dnf install \
gtk3-devel \
webkit2gtk4.0-devel \
libappindicator-gtk3-devel \
librsvg2-devel \
patchelfsudo pacman -S \
gtk3 \
webkit2gtk \
libappindicator-gtk3 \
librsvg \
patchelf推送标签时自动构建所有平台:
# 创建新版本标签
git tag v1.0.0
git push origin v1.0.0
# GitHub Actions 会自动构建:
# - Windows (.msi, .exe)
# - macOS Intel (.dmg, .app)
# - macOS ARM (.dmg, .app)
# - Linux (.AppImage, .deb)构建完成后,从 GitHub Releases 下载各平台安装包。
backend:
command: "java"
args:
- "-jar"
- "app.jar"
health_check:
check_type: "http"
url: "http://127.0.0.1:8080/actuator/health"backend:
command: "node"
args:
- "server.js"
env:
NODE_ENV: "production"
PORT: "3000"
health_check:
check_type: "http"
url: "http://127.0.0.1:3000/health"backend:
command: "python"
args:
- "app.py"
env:
FLASK_PORT: "5000"
health_check:
check_type: "http"
url: "http://127.0.0.1:5000/health"backend:
command: "./myapp"
args: []
health_check:
check_type: "http"
url: "http://127.0.0.1:8080/health"backend:
enabled: falsebackend:
command: "java"
args:
- "-jar"
- "server.jar"
health_check:
check_type: "tcp"
address: "127.0.0.1:8080"backend:
health_check:
enabled: false# 应用名称
app_name: "MyApp"
# 后端配置
backend:
enabled: true # 是否启用后端
command: "java" # 启动命令
args: # 启动参数
- "-jar"
- "app.jar"
work_dir: "backend" # 工作目录
env: # 环境变量
JAVA_OPTS: "-Xmx2g"
startup_timeout: 60 # 启动超时(秒)
health_check:
enabled: true # 是否启用健康检查
check_type: "http" # 检查类型: http/tcp/file/none
url: "http://127.0.0.1:8080/actuator/health" # HTTP 检查 URL
address: "127.0.0.1:8080" # TCP 检查地址
file_path: "backend/.ready" # 文件检查路径
interval_ms: 500 # 检查间隔(毫秒)
timeout_secs: 60 # 超时时间(秒)
# 前端配置
frontend:
enabled: true # 是否启用前端
directory: "frontend" # 前端目录
index_file: "index.html" # 入口文件
# 窗口配置
window:
title: "MyApp" # 窗口标题
width: 1200 # 窗口宽度
height: 800 # 窗口高度
min_width: 800 # 最小宽度
min_height: 600 # 最小高度
resizable: true # 是否可调整大小
fullscreen: false # 是否全屏
center: true # 是否居中启动器会按以下顺序查找配置:
launcher.yml(YAML 格式,推荐)launcher.json(JSON 格式)- 使用默认配置
配置文件放在启动器(exe/app)同级目录,和 frontend、backend 目录平级。
MyApp/
├── universal-app-launcher.exe # 或 .app
├── launcher.yml # ← 放这里
├── frontend/
└── backend/
# 更新前端
cp -r new-frontend/* MyApp/frontend/
# 更新后端
cp new-backend.jar MyApp/backend/app.jar
# 更新配置
vim MyApp/launcher.yml
# 更新启动器(替换可执行文件)
# Windows:
cp new-launcher.exe MyApp/MyApp.exe
# macOS:
cp -r new-launcher.app MyApp/MyApp.app
# Linux:
cp new-launcher MyApp/my-app构建完成后,各平台的输出文件:
.msi- Windows 安装包(推荐).exe- 可执行文件
.dmg- 磁盘镜像安装包.app- 应用程序包
.AppImage- 通用 Linux 可执行文件(推荐).deb- Debian/Ubuntu 安装包.rpm- Fedora/RHEL 安装包
- 启动器框架: Tauri (Rust)
- 前端: Vue 3
- 构建工具: Vite
# 克隆项目
git clone https://github.com/javpower/universal-launcher.git
cd universal-launcher
# 安装依赖
npm install
# 本地开发
npm run tauri:dev
# 构建发布版本
npm run tauri:build- 检查终端输出的日志,看哪一步卡住了
- 确认
launcher.yml放在正确位置(和启动器同级) - 如果后端启动失败,检查
command和args是否正确 - 如果健康检查超时,确保
health_check.enabled: false或配置正确的 URL
macOS 从 .dmg 安装后,启动器在 /Applications/ 目录,但配置文件需要放在运行目录。
解决方案:
# 创建工作目录
mkdir ~/MyApp
cp -r /Applications/universal-app-launcher.app ~/MyApp/
# 在工作目录放置文件
cp launcher.yml ~/MyApp/
cp -r frontend backend ~/MyApp/
# 运行
open ~/MyApp/universal-app-launcher.app- 检查命令是否正确(如
java、node、python) - 检查
work_dir是否正确 - 检查
args参数是否正确 - 从终端运行可以看到详细的错误信息
- 确认
frontend/index.html存在 - 检查
frontend.directory配置是否正确(默认是frontend) - 如果你的前端是 SPA(HBuilder/Vite 构建),确保
index.html在正确位置
启动器会输出详细日志到终端:
macOS/Linux:
/Applications/MyApp.app/Contents/MacOS/universal-app-launcherWindows: 直接双击运行,日志会输出到控制台窗口。
MIT