Skip to content

Commit 3d7ed65

Browse files
author
15367279252qq.com
committed
feat: add dashboard and simplify deployment tasks
1 parent 393f5a1 commit 3d7ed65

31 files changed

Lines changed: 2285 additions & 2812 deletions

.github/workflows/docs-pages.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ on:
66
- main
77
paths:
88
- "docs/**"
9-
- "package.json"
10-
- "package-lock.json"
9+
- "deno.json"
10+
- "deno.lock"
1111
- ".github/workflows/docs-pages.yml"
1212
workflow_dispatch:
1313

@@ -28,19 +28,13 @@ jobs:
2828
- name: Checkout
2929
uses: actions/checkout@v4
3030

31-
- name: Setup Node.js
32-
uses: actions/setup-node@v4
31+
- name: Setup Deno
32+
uses: denoland/setup-deno@v2
3333
with:
34-
node-version: 20
35-
cache: npm
36-
37-
- name: Install dependencies
38-
run: npm ci
34+
deno-version: v2.x
3935

4036
- name: Build docs
41-
env:
42-
NODE_ENV: production
43-
run: npm run docs:build
37+
run: deno task docs build
4438

4539
- name: Setup Pages
4640
uses: actions/configure-pages@v5

CHANGELOG.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,98 @@
22

33
## [Unreleased]
44

5+
## [1.0.10] - 2026-05-22
6+
7+
### Dashboard 工程化
8+
9+
- 新增独立 `dashboard/` 前端工程,使用 React、Vite、TypeScript 和 Tailwind CSS
10+
构建运行看板,不再使用原来的内联 HTML 作为主实现。
11+
- Dashboard 固定挂载到 `/dashboard`,本地服务、Docker 镜像和 Cloudflare Worker
12+
使用同一套构建产物。
13+
- 新增 API key 登录页,密钥仅保存在浏览器 `sessionStorage`,后续请求通过
14+
`Authorization: Bearer <key>` 调用后端 API。
15+
- 首页展示运行环境、健康状态、脱敏配置摘要、最近运行和当前存储 / workflow
16+
状态,便于快速判断部署是否可用。
17+
- 运行列表支持状态筛选、手动刷新和自动刷新;运行详情展示步骤时间线、状态、耗时、
18+
attempt、错误信息、summary 和产物列表。
19+
- Artifact 面板支持 HTML、JSON、文本和图片预览,所有产物仍通过认证 API 读取,
20+
不直接公开本地目录或 R2 bucket。
21+
- 触发任务弹窗默认执行 dry-run;真实发布必须勾选确认并发送
22+
`forcePublish: true`,降低误发布风险。
23+
24+
### API 与服务端
25+
26+
- 本地服务新增 `GET /api/health`,与 Cloudflare Worker 健康检查接口保持一致。
27+
- 新增 `GET /api/config/summary`,仅返回脱敏后的运行配置摘要,不暴露 provider
28+
secret。
29+
- 本地服务新增 dashboard 静态资源托管。存在 `dist/dashboard`
30+
时直接读取;缺少构建产物时返回提示页。
31+
- Cloudflare Worker 新增 Workers Static Assets 支持,`/dashboard`
32+
`/dashboard/*` 直接托管前端资源,`/api/*` 继续走 Worker 后端逻辑。
33+
- Cloudflare Worker 同步支持 `/api/config/summary`,Dashboard 在本地、Docker 和
34+
Cloudflare 下使用一致 API。
35+
- 微信文章 workflow 识别 `forcePublish`,Dashboard 二次确认后可以覆盖默认
36+
dry-run 配置并创建微信公众号草稿。
37+
38+
### 部署体验
39+
40+
- Dockerfile 在镜像构建阶段自动构建 dashboard,GHCR
41+
镜像内置控制台,部署后可直接访问 `/dashboard`
42+
- `wrangler.jsonc` 增加 Workers Static Assets 绑定,Cloudflare 部署会同时上传
43+
dashboard 静态资源。
44+
- `deno task cf dry-run``deno task cf deploy` 会自动先构建 dashboard,再执行
45+
Wrangler 打包或部署。
46+
- 文档站构建改为 Deno 直接驱动 VitePress,GitHub Pages workflow 不再依赖
47+
Node/npm 安装步骤。
48+
- 删除 `package.json``package-lock.json`,项目命令、文档站、Dashboard 和
49+
Wrangler 入口统一由 Deno task / npm compatibility 执行。
50+
- 微信 relay 继续支持源码运行、Docker 运行和 systemd 保活安装;systemd 模板和
51+
compose 配置统一使用新的 `deno task relay` 入口。
52+
53+
### 命令行体验
54+
55+
- 新增基于 `@cliffy/command` 的统一任务入口 `scripts/task-runner.ts`
56+
- 任务入口由声明式命令树维护,不再手写 if/else 分发。
57+
- 精简 `deno task` 公共命令,只保留日常入口:`dev``doctor``verify``test`
58+
`article``preview``relay``docker``cf``build``dashboard``docs`
59+
- 将大量重复别名收敛为参数式子命令:
60+
- `deno task article --dry-run`
61+
- `deno task docker logs`
62+
- `deno task docker relay`
63+
- `deno task docker relay logs`
64+
- `deno task cf dry-run`
65+
- `deno task cf migrate`
66+
- `deno task cf deploy`
67+
- `deno task relay install`
68+
- `deno task relay systemd`
69+
- `deno task docs build`
70+
- `deno task dashboard build`
71+
- 暂时保留 `deno task weixin:relay` 作为兼容别名,避免已经安装的旧 systemd
72+
服务立即失效。
73+
74+
### 文档
75+
76+
- 重写 README 常用命令和部署说明,突出 Deno-only、Docker、Cloudflare、relay 和
77+
dashboard 的推荐入口。
78+
- 更新 `docs/deployment.md`,补充 Docker 推荐部署和 Cloudflare dashboard
79+
静态资源说明。
80+
- 补充 relay 源码部署、Docker 部署、systemd 保活安装,以及新的参数式命令。
81+
- 更新快速开始、配置说明、帮助文档和 JSON-RPC API 文档,统一使用
82+
`deno task article --dry-run``deno task cf deploy` 等新命令。
83+
- 文档中不再推荐 npm 命令、旧 `article:dry`、旧 `cf:*`、旧 `docker:*` 或旧
84+
`relay:*` 任务。
85+
86+
### 验证
87+
88+
- 已通过 `deno task verify`:格式检查、lint、后端类型检查、dashboard 类型检查、
89+
dashboard 生产构建和 78 个测试全部通过。
90+
- 已通过 `deno task doctor`:当前配置 0 个失败,提醒项仅为 Cloudflare
91+
绑定、通知渠道、未启用向量去重。
92+
- 已通过 `deno task docs build`:VitePress 文档站可以正常构建。
93+
- 已通过 `deno task cf dry-run`:Wrangler 能识别 Worker、Workflow、KV、D1 和
94+
Workers Static Assets 绑定。沙箱环境下 Wrangler 写本地日志会出现 EPERM 提示,
95+
但 dry-run 打包本身成功。
96+
597
## [1.0.9] - 2026-05-21
698

799
### 架构与配置

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ ENV TRENDPUBLISH_RUNTIME=docker
77
ENV TRENDPUBLISH_CONFIG=/app/config/trendpublish.config.ts
88

99
COPY deno.json deno.lock ./
10+
COPY dashboard ./dashboard
1011
COPY src ./src
1112
COPY scripts ./scripts
1213
COPY migrations ./migrations
@@ -15,6 +16,7 @@ COPY trendpublish.config.docker.example.ts ./trendpublish.config.docker.example.
1516
COPY trendpublish.config.cloudflare.ts ./trendpublish.config.cloudflare.ts
1617
COPY wrangler.jsonc ./wrangler.jsonc
1718

19+
RUN deno run --config dashboard/deno.json -A npm:vite@8.0.13 build --config dashboard/vite.config.ts
1820
RUN deno cache src/index.ts src/apps/weixin-relay/server.ts scripts/run.workflow.ts scripts/doctor.ts scripts/preview.weixin.ts
1921
RUN mkdir -p /app/config /app/src/temp \
2022
&& ln -s /app/src /app/config/src \

README.md

Lines changed: 25 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,14 @@ deno task doctor
115115
deno task preview
116116

117117
# 跑一次微信文章流程,不上传、不发布
118-
deno task article:dry
118+
deno task article --dry-run
119119

120120
# 启动服务和定时任务
121121
deno task dev
122122
```
123123

124-
`article:dry` 会把渲染后的 HTML 输出到 `src/temp/`,适合正式发布前检查正文效果。
124+
`article --dry-run` 会把渲染后的 HTML 输出到
125+
`src/temp/`,适合正式发布前检查正文效果。
125126

126127
## 配置原则
127128

@@ -288,58 +289,25 @@ features: {
288289
## 常用命令
289290

290291
```bash
291-
# 配置体检
292+
# 日常使用
292293
deno task doctor
294+
deno task dev
295+
deno task article --dry-run
296+
deno task article
297+
deno task preview
293298

294-
# 格式化、lint、类型检查和单元测试
299+
# 质量检查
295300
deno task verify
296-
297-
# 只运行单元测试
298301
deno task test
299302

300-
# 本地模板预览
301-
deno task preview
302-
303-
# 微信文章 dry-run
304-
deno task article:dry
305-
306-
# 正式执行微信文章工作流
307-
deno task article
308-
309-
# Docker 本地开发构建
310-
deno task docker:build
311-
312-
# 固定 IP 机器上的微信发布中转服务
313-
deno task weixin:relay
303+
# 本地服务
304+
deno task dashboard
305+
deno task docs
314306

315-
# 一键安装 relay 为 systemd 保活服务
316-
deno task relay:install --config ./config/trendpublish.config.ts --port 8080
317-
318-
# 生成 relay 的 systemd 保活服务文件
319-
deno task relay:systemd
320-
321-
# Cloudflare Worker/Workflow 类型检查
322-
deno task cf:check
323-
324-
# Cloudflare 打包 dry-run,不真正部署
325-
deno task cf:dry-run
326-
327-
# Cloudflare 本地 D1 migration + 本地 Worker
328-
deno task cf:migrate:local
329-
deno task cf:dev
330-
331-
# Cloudflare 远端 D1 migration + 部署
332-
deno task cf:migrate:remote
333-
deno task cf:deploy
334-
335-
# 部署后健康检查和 dry-run 冒烟
336-
deno task cf:smoke --url https://your-worker.workers.dev --api-key your-api-key
337-
338-
# 编译当前平台二进制
339-
deno task build
340-
341-
# 编译全部平台
342-
deno task build:all
307+
# 部署
308+
deno task docker
309+
deno task relay
310+
deno task cf deploy
343311
```
344312

345313
## 项目结构
@@ -364,7 +332,7 @@ src/
364332

365333
```bash
366334
deno task doctor
367-
deno task article:dry
335+
deno task article --dry-run
368336
deno task dev
369337
```
370338

@@ -377,22 +345,27 @@ docker compose up -d
377345

378346
容器默认读取 `/app/config/trendpublish.config.ts`,通常把本地
379347
`./config/trendpublish.config.ts` 挂载进去即可。镜像由 GitHub Actions 自动构建,
380-
不需要在服务器上本地构建。
348+
不需要在服务器上本地构建。镜像内已经包含 dashboard 构建产物,启动后访问
349+
`http://localhost:8000/dashboard`
381350

382351
微信 relay 也是同一个镜像、同一个配置文件名,只是启动命令不同:
383352

384353
```bash
385354
cp trendpublish.config.example.ts config/trendpublish.config.ts
386-
deno task docker:relay:up
355+
deno task docker relay
387356
```
388357

389358
Cloudflare 提供 Worker / Workflows 原生入口,适合远程 HTTP 触发或 Cron
390359
定时发布。运行状态写入 KV/D1,文章产物和 dry-run HTML 写入 R2 或 KV
391360
fallback,并可通过 `/dashboard` 查看步骤、错误和产物。部署后可以用
392-
`deno task cf:smoke` 检查 `/api/health`、创建一次 dry-run
361+
`deno task cf smoke` 检查 `/api/health`、创建一次 dry-run
393362
Workflow,并轮询到最终结果。Cloudflare 真实发布 建议调用固定 IP 机器上的
394363
`weixin-relay`,避免微信 IP 白名单问题。
395364

365+
源码部署时,`deno task dev``deno task cf dry-run``deno task cf deploy`
366+
都会自动构建 dashboard。Cloudflare 部署会把 dashboard 作为 Workers Static Assets
367+
发布。
368+
396369
正式发布微信公众号前,需要:
397370

398371
1. 本地/Docker 直连发布:配置 `providers.publish.weixin.appId`

dashboard/deno.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"nodeModulesDir": "auto",
3+
"compilerOptions": {
4+
"jsx": "react-jsx",
5+
"jsxImportSource": "npm:react@19.2.6",
6+
"lib": ["dom", "dom.iterable", "esnext"]
7+
},
8+
"imports": {
9+
"@tailwindcss/vite": "npm:@tailwindcss/vite@4.3.0",
10+
"@vitejs/plugin-react": "npm:@vitejs/plugin-react@6.0.2",
11+
"lucide-react": "npm:lucide-react@^0.561.0",
12+
"react": "npm:react@19.2.6",
13+
"react-dom/client": "npm:react-dom@19.2.6/client",
14+
"tailwindcss": "npm:tailwindcss@4.3.0",
15+
"vite": "npm:vite@8.0.13"
16+
}
17+
}

dashboard/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="zh-CN">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>TrendPublish Dashboard</title>
7+
</head>
8+
<body>
9+
<div id="root"></div>
10+
<script type="module" src="/src/app.tsx"></script>
11+
</body>
12+
</html>

0 commit comments

Comments
 (0)