docs: 说明新克隆可直接编译(static/ 留了占位页)

This commit is contained in:
2026-09-02 10:33:03 +08:00
parent c73dd10f9c
commit 00ba69d899
2 changed files with 15 additions and 67 deletions

View File

@ -53,9 +53,13 @@ npm 只在构建期用到Node ≥ 18`npm run build`)与 Go ≥ 1.22。
`web/dist` 会被复制进 `gateway/internal/static/static/` 再由 `go:embed` 编入二进制,
**部署机上不需要 node**
`web/node_modules``web/dist``gateway/internal/static/static/` 与编译出的二进制都是
构建产物,不进版本库(见 `.gitignore`)。因此**克隆后必须先跑一次 `deploy/install.sh`**
——`go:embed` 要求那个目录存在才能编译,否则 `go build` 直接失败。只想编 Go 的话:
`web/node_modules``web/dist``gateway/internal/static/static/` 的内容与编译出的二进制
都是构建产物,不进版本库(见 `.gitignore`)。
新克隆**可以直接 `go build` / `go test`**`static/` 目录里留了一个占位 index.html
`go:embed` 要求目标目录存在,否则编译失败——只改后端的人不该被迫先装 node
此时打开网页看到的是「前端未构建」提示页API 照常可用。要真正的界面就跑
`deploy/install.sh`,或手工:
```bash
cd web && npm ci && npm run build

View File

@ -1,69 +1,13 @@
<!doctype html>
<!--
占位页。
真实前端由 `deploy/install.sh`(或 npm run build + cp -r web/dist
覆盖本目录后经 go:embed 打进二进制。
这个文件之所以要提交进版本库go:embed 要求目标目录存在才能编译,
否则新克隆连 go test ./... 都跑不起来 —— 只改后端的人不该被迫先装 node。
看到本页说明二进制里没有前端产物,后端 API 仍然可用。
-->
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>AgentMail — 前端未构建</title>
<style>
body {
margin: 0;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: #f1f5f9;
color: #334155;
font: 14px/1.7 system-ui, -apple-system, "Segoe UI", sans-serif;
}
main { max-width: 34rem; padding: 2rem; }
h1 { font-size: 1rem; margin: 0 0 0.75rem; }
code {
background: #e2e8f0;
padding: 0.1rem 0.35rem;
border-radius: 3px;
font-size: 0.85em;
}
pre {
background: #fff;
border: 1px solid #e2e8f0;
border-radius: 6px;
padding: 0.75rem 1rem;
overflow-x: auto;
font-size: 0.85em;
}
p { margin: 0 0 0.75rem; }
.dim { color: #64748b; font-size: 0.9em; }
</style>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AgentMail</title>
<script type="module" crossorigin src="/assets/index-C3ZRvtHr.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-Bi5AQIOl.css">
</head>
<body>
<main>
<h1>AgentMail 前端未构建</h1>
<p>
当前二进制里嵌入的是占位页。后端 API 仍然可用(<code>/api/v1</code>
<code>/health</code>)。
</p>
<p>构建并嵌入前端:</p>
<pre>sudo ./deploy/install.sh</pre>
<p>或者手工:</p>
<pre>cd web &amp;&amp; npm ci &amp;&amp; npm run build
rm -rf ../gateway/internal/static/static
cp -r dist ../gateway/internal/static/static
cd ../gateway &amp;&amp; go build ./cmd/server</pre>
<p class="dim">
构建产物不进版本库;这个占位文件的存在只是为了让
<code>go:embed</code> 在新克隆里能编译通过。
</p>
</main>
<body class="bg-gray-50 text-gray-900 antialiased">
<div id="root"></div>
</body>
</html>