跳到主要内容

安装指南

系统要求

系统最低版本
Windows10 (1903+)
macOS11 (Big Sur)
LinuxUbuntu 20.04+

从源码构建

1. 克隆代码

git clone https://github.com/chaosys123/opentree.git
cd opentree

2. 安装依赖

# 推荐使用 npm
npm install

# 或使用 yarn
yarn install

# 或使用 pnpm(更快)
pnpm install

3. 开发模式运行

npm run dev

这会同时启动:

  • Vite 开发服务器 (localhost:5173)
  • Electron 主进程
  • 后端 API 服务

4. 打包构建

# 构建生产版本
npm run build

# 打包成可执行文件
npm run package

# 仅打包当前平台
npm run package:win # Windows
npm run package:mac # macOS
npm run package:linux # Linux

Docker 运行

docker run -d \
--name opentree \
-p 3000:3000 \
-v opentree-data:/app/data \
ghcr.io/opentree/opentree:latest

环境变量

创建 .env 文件:

# 数据库
DB_PATH=./data/opentree.db

# 后端 API
API_PORT=3210

# 开发服务器
DEV_SERVER_PORT=5173

# 元宇宙
METAVERSE_PORT=5174

# 功能开关
ENABLE_TELEMETRY=false
ENABLE_AUTO_UPDATE=true

常见问题

Node 版本不匹配

推荐使用 nvm 管理 Node 版本:

nvm install 18
nvm use 18

Electron 下载慢

设置镜像:

# Windows PowerShell
$env:ELECTRON_MIRROR="https://npmmirror.com/mirrors/electron/"

# Linux/macOS
export ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/

权限问题 (Linux)

sudo chown -R $USER ~/.config/opentree