Skip to content

Commit 5c87625

Browse files
committed
feat(docs): publish deployment and usage docs on the site
Add a second Vite entry at /docs/ with deployment steps, environment variables, usage flows, limits and licenses for WebMonitor and WebMonitor-Agent. Nav, hero and resource links now point at the internal page instead of the GitHub READMEs.
1 parent c3417a8 commit 5c87625

13 files changed

Lines changed: 479 additions & 34 deletions

File tree

‎README.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ React 19 + Vite + Base UI, same flat warm-paper design as [qfpqhyl.top](https://
1111
页面内容在 `data/site.ts`:
1212

1313
- `projects` — 两个项目(WebMonitor、WebMonitor-Agent)的定位、描述、技术栈与许可证
14-
- `resources` — 演示、文档、mocksite、组织主页等入口
14+
- `resources` — 演示、站内文档、mocksite、组织主页等入口
1515
- `quickStart` — 本地 Docker 启动命令与说明
1616

17+
文档页是独立的 Vite 入口:`docs/index.html` + `docs/main.tsx`,正文在 `components/DocsPage.tsx`,内容取自两个项目的 README(部署步骤、配置项、使用流程、限制与许可证)。构建后输出 `dist/docs/index.html`,站内链接为 `/docs/` 与 `/docs/#<section>`,不再跳转 GitHub。
18+
1719
组件在 `components/`:`Navbar`、`Hero`、`Projects`、`GettingStarted`、`Footer`、`SiteMeta`(运行时写入 title 与 meta)。
1820

1921
## 本地使用

‎components/CodeBlock.tsx‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
interface CodeBlockProps {
2+
title?: string;
3+
code: string;
4+
hint?: string;
5+
}
6+
7+
const CodeBlock = ({ title, code, hint }: CodeBlockProps) => (
8+
<div className="min-w-0 space-y-2">
9+
{title && <p className="text-xs font-medium uppercase tracking-[0.18em] text-muted">{title}</p>}
10+
<pre className="w-full overflow-x-auto rounded-sm border border-line bg-surface p-4 font-mono text-xs leading-7 text-text">
11+
<code>{code}</code>
12+
</pre>
13+
{hint && <p className="text-xs leading-6 text-muted">{hint}</p>}
14+
</div>
15+
);
16+
17+
export default CodeBlock;

‎components/DocsPage.tsx‎

Lines changed: 299 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,299 @@
1+
import type { ReactNode } from 'react';
2+
import { Separator } from '@base-ui/react';
3+
import { ArrowUpRight } from 'lucide-react';
4+
import { site } from '../config/site';
5+
import CodeBlock from './CodeBlock';
6+
7+
const docSections = [
8+
{ id: 'overview', label: '概述' },
9+
{ id: 'what-to-watch', label: '可以关注什么' },
10+
{ id: 'webmonitor', label: 'WebMonitor 部署' },
11+
{ id: 'webmonitor-usage', label: 'WebMonitor 使用' },
12+
{ id: 'agent', label: 'Agent 部署' },
13+
{ id: 'agent-usage', label: 'Agent 使用' },
14+
{ id: 'limits', label: '限制与约定' },
15+
{ id: 'licenses', label: '许可证' },
16+
];
17+
18+
const DocSection = ({ id, title, children }: { id: string; title: string; children: ReactNode }) => (
19+
<section id={id} className="scroll-mt-6 space-y-4">
20+
<div className="space-y-2">
21+
<h2 className="text-xl font-semibold tracking-tight text-text">{title}</h2>
22+
<Separator className="h-px w-full bg-line" />
23+
</div>
24+
<div className="space-y-4 text-sm leading-7 text-muted">{children}</div>
25+
</section>
26+
);
27+
28+
const DocTable = ({ head, rows }: { head: string[]; rows: string[][] }) => (
29+
<div className="w-full overflow-x-auto">
30+
<table className="w-full min-w-[520px] border-collapse text-sm">
31+
<thead>
32+
<tr>
33+
{head.map((cell) => (
34+
<th key={cell} className="border-b border-line py-2 pr-4 text-left text-xs font-medium uppercase tracking-[0.14em] text-muted">
35+
{cell}
36+
</th>
37+
))}
38+
</tr>
39+
</thead>
40+
<tbody>
41+
{rows.map((row) => (
42+
<tr key={row[0]}>
43+
{row.map((cell, index) => (
44+
<td
45+
key={`${row[0]}-${index}`}
46+
className="border-b border-line/60 py-2 pr-4 align-top leading-6 text-muted first:whitespace-nowrap first:text-text"
47+
>
48+
{cell}
49+
</td>
50+
))}
51+
</tr>
52+
))}
53+
</tbody>
54+
</table>
55+
</div>
56+
);
57+
58+
const Note = ({ children }: { children: ReactNode }) => (
59+
<div className="rounded-sm border border-line bg-surface px-4 py-3 text-xs leading-6 text-muted">{children}</div>
60+
);
61+
62+
const DocsPage = () => {
63+
return (
64+
<main className="px-4 pb-12 pt-4 sm:px-6 lg:px-8">
65+
<div className="mx-auto w-full max-w-6xl">
66+
<div className="space-y-3 border-b border-line pb-6 pt-4">
67+
<p className="text-xs font-medium uppercase tracking-[0.3em] text-muted">Documentation</p>
68+
<h1 className="text-4xl font-semibold tracking-tight text-text sm:text-5xl">文档</h1>
69+
<p className="max-w-2xl text-sm leading-7 text-muted sm:text-base">
70+
两个项目的部署步骤、配置项与使用流程。部署方式以 Docker Compose 为准,配置项以各自仓库的{' '}
71+
<span className="text-text">.env.example</span> 为最终依据。
72+
</p>
73+
</div>
74+
75+
<div className="grid gap-10 pt-6 lg:grid-cols-[200px_minmax(0,1fr)] lg:gap-12">
76+
<aside className="lg:sticky lg:top-6 lg:self-start">
77+
<nav aria-label="文档目录">
78+
<p className="mb-3 text-xs font-medium uppercase tracking-[0.28em] text-muted">Contents</p>
79+
<ul className="space-y-1.5 text-sm">
80+
{docSections.map(({ id, label }) => (
81+
<li key={id}>
82+
<a href={`#${id}`} className="text-muted transition hover:text-text">
83+
{label}
84+
</a>
85+
</li>
86+
))}
87+
</ul>
88+
</nav>
89+
</aside>
90+
91+
<article className="min-w-0 space-y-10">
92+
<DocSection id="overview" title="概述">
93+
<p>
94+
WebMonitor 是一个可自行部署的网页监控组织。两个项目共享同一个目标:盯住网页上的一段内容,在它变化时通过邮件通知你。
95+
它们不抓取整页做全文比较,而是比较你指定的区域或条目。
96+
</p>
97+
<DocTable
98+
head={['项目', '创建方式', '采集方式', '状态']}
99+
rows={[
100+
['WebMonitor', '填写网址、XPath 与检查间隔', 'Selenium 驱动的无头浏览器', '初代版本,维护与问题修复'],
101+
['WebMonitor-Agent', '对话描述需求,预览后确认', 'HTTP 抓取 + Playwright 浏览器采集', '当前持续开发的版本'],
102+
]}
103+
/>
104+
<Note>
105+
先想清楚要盯什么:只需要「某块区域文字变了就通知」,用 WebMonitor 更直接;需要「价格低于阈值」「列表新增一条」这类条件,
106+
或不想手写选择器,用 WebMonitor-Agent。
107+
</Note>
108+
</DocSection>
109+
110+
<DocSection id="what-to-watch" title="可以关注什么">
111+
<DocTable
112+
head={['关注的内容', 'WebMonitor:选取的区域', 'Agent:可以这样描述']}
113+
rows={[
114+
['价格与库存', '当前价格或库存状态', '「每 10 分钟检查这个商品,价格降到 200 元以下时通知我。」'],
115+
['网站公告', '通知栏或新闻列表', '「每小时检查这个公告列表,有新公告就通知我。」'],
116+
['版本发布', '发布标题或更新日志', '「发布新版本时发邮件告诉我。」'],
117+
['报名截止日期', '可能调整的日期或说明', '「跟踪这个页面的报名截止日期,有变化就告诉我。」'],
118+
]}
119+
/>
120+
</DocSection>
121+
122+
<DocSection id="webmonitor" title="WebMonitor 部署">
123+
<p>
124+
单容器部署:FastAPI 同时提供 API 和前端静态页面,浏览器只访问一个地址。数据库默认使用容器内的 SQLite
125+
文件,不依赖外部服务。
126+
</p>
127+
<CodeBlock
128+
title="准备"
129+
code={`git clone https://github.com/webmonitor/WebMonitor.git
130+
cd WebMonitor
131+
cp .env.example .env`}
132+
hint="已有 .env 时保留原文件。"
133+
/>
134+
<DocTable
135+
head={['配置项', '说明']}
136+
rows={[
137+
['SECRET_KEY', '必填。至少 32 字符的随机签名密钥,没有默认值。'],
138+
['ADMIN_EMAIL', '首次启动创建的管理员邮箱地址。'],
139+
['ADMIN_PASSWORD', '初始密码,至少 6 字符、最多 72 个 UTF-8 字节。为空且库中没有管理员时启动会失败。'],
140+
['ADMIN_USERNAME', '管理员用户名,默认 admin。'],
141+
['DATABASE_URL', '默认 sqlite:///./data/webmonitor.db,一般无需修改。'],
142+
]}
143+
/>
144+
<CodeBlock
145+
title="启动"
146+
code={`docker compose up --build -d --wait
147+
# http://localhost:8000`}
148+
/>
149+
<p>
150+
打开 <span className="text-text">localhost:8000</span>,用管理员账号登录后创建第一个任务。运行实例自带 API 文档:
151+
<span className="text-text"> localhost:8000/docs</span>。
152+
</p>
153+
<Note>
154+
<span className="text-text">保留数据:</span>
155+
默认部署把数据放在容器内。正式使用前请为 <span className="text-text">/app/data</span> 添加持久数据卷,
156+
否则更换容器会丢失账户、监控任务和历史记录。
157+
</Note>
158+
</DocSection>
159+
160+
<DocSection id="webmonitor-usage" title="WebMonitor 使用">
161+
<ol className="list-decimal space-y-2 pl-5">
162+
<li>
163+
<span className="text-text">选好内容。</span>
164+
填写网址、XPath 和检查间隔创建任务;使用测试功能确认提取到的正是你关心的文字。测试只预览内容,不发送邮件。
165+
</li>
166+
<li>
167+
<span className="text-text">设置通知。</span>
168+
在应用内添加并测试 SMTP 邮件配置,再关联到任务。也可以不配置邮件,只在应用里查看变化。
169+
</li>
170+
<li>
171+
<span className="text-text">启用监控。</span>
172+
按计划检查并记录结果;文字变化后,通知中会展示变化前后的内容。
173+
</li>
174+
</ol>
175+
<p>
176+
工作台还可以:只看指定区域、查看检查历史与采集错误、使用自己的 SMTP 邮箱、把任务设为实例内公开供他人订阅、
177+
随时启用或停用任务,并切换中英文界面。
178+
</p>
179+
<Note>首次成功的定时检查<span className="text-text">可能</span>发送初始通知;之后的检查只在内容变化时通知。</Note>
180+
</DocSection>
181+
182+
<DocSection id="agent" title="WebMonitor-Agent 部署">
183+
<p>
184+
需要 Docker Engine、Docker Compose,以及一个兼容 OpenAI Chat Completions 的模型服务。邮件提醒还需要可用的 SMTP 服务;
185+
采集与页面存档依赖 PostgreSQL 与 S3 兼容存储,随附 Compose 已包含两者。
186+
</p>
187+
<CodeBlock
188+
title="准备"
189+
code={`git clone https://github.com/webmonitor/WebMonitor-Agent.git
190+
cd WebMonitor-Agent
191+
cp .env.example .env`}
192+
hint="已有 .env 时保留原文件。"
193+
/>
194+
<DocTable
195+
head={['配置项', '说明']}
196+
rows={[
197+
['ADMIN_EMAIL、ADMIN_PASSWORD', '初始管理员邮箱与密码,密码为 12–128 字符。'],
198+
['SECRET_KEY', '至少 32 字符的随机密钥。'],
199+
['POSTGRES_PASSWORD', '数据库密码。'],
200+
['OPENAI_API_KEY', '模型服务的密钥。'],
201+
['OPENAI_BASE_URL', '兼容 Chat Completions 的服务地址。'],
202+
['OPENAI_MODEL', '实际可用的模型名称。'],
203+
['SMTP_HOST、SMTP_PORT', '邮件服务地址与端口;不配置则不发邮件。'],
204+
['SMTP_USERNAME、SMTP_PASSWORD', 'SMTP 认证信息。'],
205+
['MAIL_FROM', '发件人地址。'],
206+
['SMTP_USE_SSL、SMTP_STARTTLS', '必须恰有一个为 true,按邮件服务选择。'],
207+
]}
208+
/>
209+
<CodeBlock
210+
title="启动"
211+
code={`docker compose up --build --wait
212+
# http://localhost:8080`}
213+
hint="首次启动在没有用户时自动创建管理员;修改配置不会重置已有账户。"
214+
/>
215+
<p>
216+
默认只监听本机。更改端口时同步调整 <span className="text-text">WEBMONITOR_HTTP_PORT</span> 与{' '}
217+
<span className="text-text">APP_ORIGIN</span>;本地 HTTP 部署需保留{' '}
218+
<span className="text-text">DEVELOPMENT_MODE=true</span>。
219+
</p>
220+
<Note>
221+
<span className="text-text">仅用于试用与开发:</span>
222+
随附部署的 PostgreSQL、MinIO 存储为临时存储,停止、重启或重建数据容器会丢失账户、监控与历史记录。
223+
长期使用前需配置持久存储与备份,并阅读仓库中的数据保留说明。
224+
</Note>
225+
</DocSection>
226+
227+
<DocSection id="agent-usage" title="Agent 使用">
228+
<ol className="list-decimal space-y-2 pl-5">
229+
<li>
230+
<span className="text-text">描述需求。</span>
231+
新建对话,给出网页地址,说明要看什么、多久检查一次、什么情况下通知。
232+
</li>
233+
<li>
234+
<span className="text-text">核对预览。</span>
235+
助手打开真实页面并执行一次实际采集,确认提取内容、检查范围、通知规则、收件人与邮件样式。
236+
</li>
237+
<li>
238+
<span className="text-text">确认启用。</span>
239+
点击「创建监控」后才开始定时检查;之后可在工作台查看变化、暂停或恢复,也可以通过对话调整需求。
240+
</li>
241+
</ol>
242+
<p>
243+
通知条件支持文本与关键词、数值变化与阈值、列表新增与更新;确认完整采集列表后,也可以监控条目删除。
244+
变更记录可对照变化前后的内容,查看当次采集保存的页面存档,浏览器采集还会留下截图。收件人来自管理员维护的通知组,
245+
一项监控可以通知多个邮箱。
246+
</p>
247+
<p>
248+
新成员需要管理员签发的邀请链接。已有部署时,直接使用管理员提供的地址登录即可,无需自行部署。
249+
</p>
250+
<Note>
251+
首次成功检查会记录初始内容作为比较基准,<span className="text-text">不发送</span>变化通知;预览同样不发邮件。
252+
只有真正满足通知规则的后续变化才会触发提醒。投递记录中的 <span className="text-text">sent</span> 表示邮件服务已接收,
253+
不代表目标收件箱已经收到。
254+
</Note>
255+
</DocSection>
256+
257+
<DocSection id="limits" title="限制与约定">
258+
<DocTable
259+
head={['项目', '限制']}
260+
rows={[
261+
['目标页面', '仅支持公网 HTTP/HTTPS 页面;需要登录或内网访问的页面不在范围内。'],
262+
['Agent 检查间隔', '1 分钟至 24 小时。'],
263+
['Agent 提取范围', 'iframe 与 Shadow DOM 内的内容暂不支持提取;预览会说明本次实际采集的范围与限制。'],
264+
['采集失败', '保留上一次成功的内容作为比较依据,失败不会覆盖基准。'],
265+
['邮件发送', '需要可用的 SMTP 服务;SMTP_USE_SSL 与 SMTP_STARTTLS 必须恰有一个为 true。'],
266+
['演示站点', '由维护者单独运行,可能暂时不可用,不适合作为长期依赖。'],
267+
]}
268+
/>
269+
</DocSection>
270+
271+
<DocSection id="licenses" title="许可证">
272+
<DocTable
273+
head={['项目', '许可证', '说明']}
274+
rows={[
275+
['WebMonitor', 'CC BY-NC 4.0', '可署名分享与修改,仅限非商业用途。'],
276+
['WebMonitor-Agent', 'MIT', '允许使用、修改与分发,包括商业用途;需保留版权与许可声明。'],
277+
]}
278+
/>
279+
<p>
280+
源码与问题反馈:
281+
<a
282+
href={site.githubUrl}
283+
target="_blank"
284+
rel="noreferrer"
285+
className="ml-1 inline-flex items-center gap-1 underline decoration-line underline-offset-4 transition hover:text-text"
286+
>
287+
github.com/webmonitor
288+
<ArrowUpRight className="h-3.5 w-3.5" />
289+
</a>
290+
</p>
291+
</DocSection>
292+
</article>
293+
</div>
294+
</div>
295+
</main>
296+
);
297+
};
298+
299+
export default DocsPage;

‎components/GettingStarted.tsx‎

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
import { Separator } from '@base-ui/react';
22
import { site } from '../config/site';
33
import { quickStart } from '../data/site';
4+
import CodeBlock from './CodeBlock';
45

56
const { sections } = site;
67

7-
const CommandBlock = ({ title, commands, hint }: { title: string; commands: readonly string[]; hint: string }) => (
8-
<div className="min-w-0 space-y-2">
9-
<p className="text-xs font-medium uppercase tracking-[0.18em] text-muted">{title}</p>
10-
<pre className="w-full overflow-x-auto rounded-sm border border-line bg-surface p-4 font-mono text-xs leading-7 text-text">
11-
<code>{commands.join('\n')}</code>
12-
</pre>
13-
<p className="text-xs leading-6 text-muted">{hint}</p>
14-
</div>
15-
);
16-
178
const GettingStarted = () => {
189
return (
1910
<section className="space-y-5 py-2">
@@ -26,11 +17,24 @@ const GettingStarted = () => {
2617
<Separator className="h-px w-full bg-line" />
2718

2819
<div className="grid gap-8 lg:grid-cols-2 lg:gap-12">
29-
<CommandBlock title="WebMonitor-Agent" commands={quickStart.agent} hint="启动后访问 http://localhost:8080" />
30-
<CommandBlock title="WebMonitor" commands={quickStart.legacy} hint="启动后访问 http://localhost:8000" />
20+
<CodeBlock
21+
title="WebMonitor-Agent"
22+
code={quickStart.agent.join('\n')}
23+
hint="启动后访问 http://localhost:8080"
24+
/>
25+
<CodeBlock
26+
title="WebMonitor"
27+
code={quickStart.legacy.join('\n')}
28+
hint="启动后访问 http://localhost:8000"
29+
/>
3130
</div>
3231

33-
<p className="max-w-3xl text-xs leading-6 text-muted">{quickStart.note}</p>
32+
<p className="max-w-3xl text-xs leading-6 text-muted">
33+
{quickStart.note}{' '}
34+
<a href="/docs/" className="underline decoration-line underline-offset-4 transition hover:text-text">
35+
完整部署与配置文档
36+
</a>
37+
</p>
3438
</section>
3539
);
3640
};

0 commit comments

Comments
 (0)