Files
next-ai-draw-io/docs/cn/offline-deployment.md
T
dayuan.jiang 366d9ee4ff feat(ui): canvas-first redesign with a self-hosted draw.io
The canvas now fills the window and the chat floats on its right. draw.io is
served from our own origin (public/drawio, downloaded at build time and
checked against the release's SHA-256), so the app can drive the editor
directly:

- every AI change becomes a version card with a thumbnail; compare, restore
  or undo it, and Ctrl+Z on the canvas takes an AI change back in one step
- shapes the AI just changed are highlighted on the canvas
- selected shapes appear as a chip and are sent to the model
- the app's own canvas toolbar, shape library and page tabs replace
  draw.io's chrome
- new start screen, session rename and switcher, open .drawio files
- settings split into Models & keys, Appearance, Advanced and About
- phones switch between canvas and chat
- dark mode keeps the diagram on a white sheet and no longer flashes

With an external draw.io (NEXT_PUBLIC_DRAWIO_BASE_URL) the app falls back to
draw.io's own toolbar and the features above that need same origin are off.

The chat logic moved from the 1500-line chat panel into a chat engine plus
small UI components; zustand holds canvas, versions, settings and UI state.
2026-10-06 22:01:09 +09:00

2.1 KiB

离线部署

Next AI Draw.io 自带一份 draw.io。npm run build(包括 Docker 构建)会把 draw.io 的发布包下载到 public/drawio,只下载一次,应用从 /drawio 提供它。使用时浏览器不会访问 embed.diagrams.net,所以只要构建时能联网,应用就能在离线网络或内网里使用。

Docker Compose 设置

  1. 克隆仓库并在 .env 文件中定义 API 密钥。
  2. 运行 docker compose up -d(使用仓库里的 docker-compose.yml)。
  3. 打开 http://localhost:3000。

不需要单独的 draw.io 容器。

构建机器不能联网时

构建会从 draw.io 发布页 下载 draw.war(约 50 MB)。如果构建机器访问不了 GitHub:

  • 在另一台机器上下载 scripts/fetch-drawio.mjs 里写明的那个版本的 draw.war,解压到 public/drawio(删掉 WEB-INF 和 META-INF),再把版本号(例如 v32.0.2)写进 public/drawio/.version。构建时就会使用这份副本。
  • 或者在能联网的机器上构建镜像,再拷到离线网络里。

使用单独的 draw.io 服务器(可选)

仍然可以用构建时变量 NEXT_PUBLIC_DRAWIO_BASE_URL 让应用使用别处的 draw.io,比如 jgraph/drawio 镜像:

services:
  drawio:
    image: jgraph/drawio:latest
    ports: ["8080:8080"]
  next-ai-draw-io:
    build:
      context: .
      args:
        - NEXT_PUBLIC_DRAWIO_BASE_URL=http://localhost:8080
    ports: ["3000:3000"]
    env_file: .env
    depends_on: [drawio]

使用外部 draw.io 时,应用改用 draw.io 自己的工具栏,以下功能不可用:标出 AI 改了哪些图形、针对选中的图形提问、应用自己的画布工具栏、用 Ctrl+Z 撤回 AI 的修改。浏览器不允许页面控制来自其他域名的编辑器。

NEXT_PUBLIC_DRAWIO_BASE_URL 必须是用户浏览器可访问的地址。

场景 URL 值
本地主机 (Localhost) http://localhost:8080
远程/服务器 http://YOUR_SERVER_IP:8080

切勿使用 Docker 内部别名(如 http://drawio:8080),因为浏览器无法解析它们。