Compare commits

..

24 Commits

Author SHA1 Message Date
codex-bot 558039a8de Clean up repository documentation and maintenance tests
Endoleap brand checks / verify (pull_request) Successful in 12s
creative workspace review checks / verify-deployed-canvas (pull_request) Successful in 4m46s
creative workspace review checks / verify (pull_request) Successful in 13m49s
2026-11-04 22:05:14 +08:00
Zayden-Jung ef290f769b Merge pull request 'fix(ci): 以应用就绪验证生产页面并前置完整线上验收' (#45) from codex/production-navigation-ready into main
creative workspace CI and deployment / verify-and-deploy (push) Successful in 17m23s
Reviewed-on: #45
2026-11-02 09:06:22 +00:00
codex-bot 38a71e04ca fix(ci): accept hydrated markers hidden by responsive layouts
creative workspace review checks / verify-deployed-canvas (pull_request) Successful in 3m24s
creative workspace review checks / verify (pull_request) Successful in 25m23s
2026-11-02 16:32:37 +08:00
codex-bot 7f397fd3a2 fix(ci): verify production readiness without network idle
creative workspace review checks / verify-deployed-canvas (pull_request) Failing after 2m45s
creative workspace review checks / verify (pull_request) Has been cancelled
2026-11-02 16:20:08 +08:00
Zayden-Jung 5a317008df Merge pull request 'feat(home): 手绘场景与编辑式内容丰富首页' (#44) from codex/landing-editorial into main
creative workspace CI and deployment / verify-and-deploy (push) Failing after 15m54s
Reviewed-on: #44
2026-11-02 07:56:43 +00:00
codex-bot 602263084f feat(home): add illustrated editorial landing sections
creative workspace review checks / verify-deployed-canvas (pull_request) Successful in 55s
creative workspace review checks / verify (pull_request) Successful in 27m17s
2026-11-02 14:56:44 +08:00
Zayden-Jung 5b4644749d Merge pull request 'feat(auth): 啡跃品牌视觉与居中表单的分屏登录页' (#42) from codex/auth-layout-polish into main
creative workspace CI and deployment / verify-and-deploy (push) Successful in 15m2s
Reviewed-on: #42
2026-11-01 17:13:07 +00:00
Zayden-Jung 7656f0438c Merge pull request 'feat(auth): 邮件重设密码与旧会话撤销' (#43) from codex/account-recovery into main
creative workspace CI and deployment / verify-and-deploy (push) Successful in 16m6s
Reviewed-on: #43
2026-11-01 16:45:16 +00:00
codex-bot ca08f44137 merge: integrate password recovery dependency for combined auth validation
creative workspace review checks / verify-deployed-canvas (pull_request) Successful in 1m5s
creative workspace review checks / verify (pull_request) Successful in 28m38s
2026-11-02 00:13:07 +08:00
codex-bot b31a4835ee test(auth): verify recovery endpoints over HTTP with real storage
creative workspace review checks / verify-deployed-canvas (pull_request) Successful in 53s
creative workspace review checks / verify (pull_request) Successful in 25m37s
2026-11-02 00:02:32 +08:00
codex-bot fd96b6d9e9 fix(auth): preserve form state after email-only actions
creative workspace review checks / verify-deployed-canvas (pull_request) Successful in 59s
creative workspace review checks / verify (pull_request) Has been cancelled
2026-11-01 23:54:21 +08:00
codex-bot ee72835ea3 feat(auth): add recovery UI and stable viewport login interactions
creative workspace review checks / verify-deployed-canvas (pull_request) Successful in 52s
creative workspace review checks / verify (pull_request) Has been cancelled
2026-11-01 23:50:32 +08:00
codex-bot 6800a1b1c4 feat(auth): add single-use email password recovery and session revocation
creative workspace review checks / verify-deployed-canvas (pull_request) Successful in 58s
creative workspace review checks / verify (pull_request) Has been cancelled
2026-11-01 23:43:26 +08:00
codex-bot 1da1114d52 fix(auth): clarify verification resend eligibility
creative workspace review checks / verify-deployed-canvas (pull_request) Successful in 56s
creative workspace review checks / verify (pull_request) Has been cancelled
2026-11-01 23:33:25 +08:00
codex-bot 8c48812a11 test(auth): capture deployed split login layouts in release acceptance
creative workspace review checks / verify-deployed-canvas (pull_request) Successful in 47s
creative workspace review checks / verify (pull_request) Has been cancelled
2026-11-01 23:24:31 +08:00
codex-bot 88d68f3d3c feat(auth): introduce immersive split-screen login design
creative workspace review checks / verify-deployed-canvas (pull_request) Successful in 54s
creative workspace review checks / verify (pull_request) Has been cancelled
2026-11-01 23:19:23 +08:00
codex-bot 6819db40a8 fix(auth): rebalance account introduction typography and spacing
creative workspace review checks / verify-deployed-canvas (pull_request) Successful in 59s
creative workspace review checks / verify (pull_request) Has been cancelled
2026-11-01 23:10:36 +08:00
Zayden-Jung b2381a1cdf Merge pull request 'fix(ci): 以客户端就绪判定脚本取消是否阻断启动' (#41) from codex/ci-bootstrap-readiness into main
creative workspace CI and deployment / verify-and-deploy (push) Successful in 15m57s
Reviewed-on: #41
2026-11-01 14:45:13 +00:00
codex-bot 150e4b3af8 fix(ci): accept hydrated documents with cancelled preload requests
creative workspace review checks / verify-deployed-canvas (pull_request) Successful in 1m7s
creative workspace review checks / verify (pull_request) Successful in 26m21s
2026-11-01 22:14:37 +08:00
Zayden-Jung e36b8aea6c Merge pull request 'fix(ci): 等待浏览器脚本与账户状态就绪后再操作' (#40) from codex/ci-browser-readiness into main
creative workspace CI and deployment / verify-and-deploy (push) Failing after 10m12s
Reviewed-on: #40
2026-11-01 13:58:14 +00:00
codex-bot 517c31ca04 fix(ci): wait for document bootstrap before browser interactions
creative workspace review checks / verify-deployed-canvas (pull_request) Successful in 1m23s
creative workspace review checks / verify (pull_request) Successful in 24m43s
2026-11-01 21:36:24 +08:00
Zayden-Jung fafdae66bb Merge pull request 'fix(auth): 独立登录注册页面并弱化主题切换' (#39) from codex/auth-page-fix into main
creative workspace CI and deployment / verify-and-deploy (push) Failing after 9m31s
Reviewed-on: #39
2026-11-01 13:16:22 +00:00
codex-bot a45d43f5f7 fix(auth): separate account page from workspace navigation
creative workspace review checks / verify-deployed-canvas (pull_request) Successful in 1m13s
creative workspace review checks / verify (pull_request) Failing after 20m8s
2026-11-01 20:40:01 +08:00
Zayden-Jung 5b68c5b84e Merge pull request 'fix(ci): 统一画布验收、导航恢复与 review 资源清理' (#38) from codex/ci-acceptance-stability into main
creative workspace CI and deployment / verify-and-deploy (push) Successful in 15m58s
Reviewed-on: #38
2026-11-01 09:34:53 +00:00
41 changed files with 622 additions and 1025 deletions
+21 -15
View File
@@ -10,30 +10,36 @@ on:
- 'compose.creative-review.yml'
- 'scripts/integration.sh'
- 'scripts/cleanup-integration.sh'
- 'scripts/test-integration-cleanup.py'
- 'tests/test_integration_cleanup.py'
- 'scripts/cleanup-review-images.sh'
- 'scripts/test-review-image-cleanup.py'
- 'tests/test_review_image_cleanup.py'
concurrency:
group: creative-workspace-${{ gitea.event.pull_request.number }}
cancel-in-progress: true
jobs:
verify-deployed-canvas:
runs-on: ces-control
timeout-minutes: 10
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Verify canvas acceptance script against the designated deployed server
- name: Verify production acceptance against the designated deployed server
run: |
node --check scripts/verify-studio-visual.cjs
node --check apps/studio/scripts/infinite-canvas-smoke.cjs
wiki_image=$(docker inspect --format '{{.Config.Image}}' prompt-waterfall-wiki-1)
[[ "$wiki_image" =~ ^waterfall-wiki:[0-9a-f]{40}$ ]]
test_image="waterfall-wiki-tests:${wiki_image#waterfall-wiki:}"
docker image inspect "$test_image" >/dev/null
docker run --rm \
--mount "type=bind,src=$PWD,dst=/delivery,readonly" \
-e NODE_PATH=/repo/apps/waterfall-wiki/node_modules \
-e CHROMIUM_PATH=/usr/bin/chromium \
--entrypoint node "$test_image" /delivery/apps/studio/scripts/infinite-canvas-smoke.cjs
bash -n scripts/verify-studio-production.sh
bash scripts/verify-studio-production.sh
- name: Save server acceptance evidence
id: acceptance_evidence
if: always()
uses: actions/upload-artifact@v3
with:
name: studio-production-acceptance
path: artifacts/studio-acceptance/
if-no-files-found: ignore
retention-days: 7
- name: Remove temporary acceptance output after upload
if: always() && steps.acceptance_evidence.outcome == 'success'
run: rm -rf artifacts/studio-acceptance
verify:
runs-on: ces-control
timeout-minutes: 60
@@ -46,8 +52,8 @@ jobs:
git diff --check HEAD^ HEAD
bash -n scripts/integration.sh scripts/cleanup-integration.sh scripts/verify-studio-production.sh scripts/cleanup-review-images.sh
node --check scripts/verify-studio-visual.cjs
python3 scripts/test-integration-cleanup.py
python3 scripts/test-review-image-cleanup.py
python3 tests/test_integration_cleanup.py
python3 tests/test_review_image_cleanup.py
node --test apps/waterfall-wiki/tests/brand-navigation.test.mjs
- name: Verify Studio types, tests, build and smoke
run: docker build -f apps/studio/Dockerfile -t "creative-studio-review:${{ gitea.sha }}" .
+2 -2
View File
@@ -17,7 +17,7 @@ on:
- 'scripts/auth-admin.sh'
- 'scripts/integration.sh'
- 'scripts/cleanup-integration.sh'
- 'scripts/test-integration-cleanup.py'
- 'tests/test_integration_cleanup.py'
- 'pnpm-workspace.yaml'
jobs:
@@ -31,7 +31,7 @@ jobs:
fetch-depth: 0
- name: Check shared content and documentation contracts
run: |
python3 scripts/test-integration-cleanup.py
python3 tests/test_integration_cleanup.py
bash -n scripts/integration.sh scripts/cleanup-integration.sh
node scripts/check-studio-contracts.mjs
node --check scripts/export-studio-series.cjs
+8 -10
View File
@@ -8,16 +8,14 @@ This block is written and re-added by `next dev` — verify at `node_modules/nex
<!-- END:nextjs-agent-rules -->
## 交付与视觉验收
## 构建与验收
- 用户指定服务器为唯一运行与验收入口:http://8.211.154.134:18131/。
- 页面改动必须先 push,等待 ces-control 的 CI/CD 成功部署,再直接访问服务器检查效果。
- 不启动本地网页预览,不使用 localhost / 127.0.0.1 页面进行视觉验收,也不把本地预览链接交付给用户。
- 类型检查、单元测试等不提供网页预览的检查可以本地执行;完整运行检查由 Docker CI 完成。
- 在 ces-control 上执行构建、产物生成和需要编译的检查。本地可执行差异审查及无需构建的轻量检查。
- 页面改动经主线部署后,在指定的 [服务器入口](http://8.211.154.134:18131/) 验收。不要启动本地网页预览。
- CI 触发条件与发布路径见 [构建与入口](docs/ci-and-entrypoints.md)。
## 啡跃 Endoleap 品牌与主题
## 品牌
- 共享品牌包位于 [`packages/brand`](packages/brand/README.md)。修改品牌色、主题或标志前,阅读包内的 [品牌边界](packages/brand/docs/overview.md)、[配色与交互规范](packages/brand/docs/colors.md)、[Tailwind / shadcn 接入](packages/brand/docs/integration.md) 和 [Logo 规则](packages/brand/docs/logo.md)。不在仓库根 docs 重复维护一套品牌规范。
- 四套正式主题为 home-light、home-dark、canvas-light、canvas-dark;不创建 drafts,不恢复 proposed 命名。画布 Light / Dark 背景保持中性近白 / 近黑,用户素材与作品不整体染色。
- 基础色只在 tokens/palette.json 定义,主题引用色板键;Logo 轮廓只在 tokens/geometry.json 定义。保持 CSS、类型声明、资产与清单一致,不通过图片模型重画已固定的图形。
- 本地仅运行不生成产物的轻量读取检查。品牌导出、Tailwind/TypeScript 编译和 SVG 栅格化检查必须通过已确认的 ces-control Docker CI 执行,不在本机启动预览或构建。
- 修改品牌色、主题或 Logo 前,查阅 [共享品牌包](packages/brand/README.md)。
- 使用 home-light、home-dark、canvas-light、canvas-dark 四套主题。画布背景保持中性近白或近黑,用户素材保持原色。
- 色板和 Logo 轮廓分别以品牌包的 `tokens/palette.json` 和 `tokens/geometry.json` 为准,更新时保持 CSS、类型、资产和清单一致。
+27 -89
View File
@@ -1,104 +1,42 @@
# PROMPT
# 啡跃 Endoleap
把提示词、参考图、分步文档和创作工具收进同一个可连接的知识库。人可以浏览瀑布流、搜索和编辑;AI 可以从同一篇 post 读取纯文本、图片与 API 说明,再调用 Studio 生成作品。
啡跃把笔记、参考素材和创作工作台放在同一个网站。知识库用于浏览、搜索和发布内容,Studio 提供图文排版与无限画布。
**PROMPT 是网站与项目品牌;`waterfall-wiki` 是知识库应用的内部名称。** 目录、包、CI、镜像和 Compose 服务使用内部名称,网站导航与页面标题使用 PROMPT。
[打开啡跃](http://8.211.154.134:18131/)
线上入口:[PROMPT](http://8.211.154.134:18131/)。内容、媒体、API 与 Studio 共用登录入口。
## 从一篇 post 开始
每篇内容都有稳定的 `/explore/<id>` 地址。标题、标签、正文和封面可以修改,链接保持不变。数据库内容可以保留 24 位 public ID,内部仍使用 UUID;旧 `/p/<slug>`、`/skills/...` 等地址保留兼容跳转。
- **浏览**:首页按不同笔记的反向引用数优先排序。重复引用和自引用不重复计数,代码、图片与外站链接不冒充笔记引用。详情可以查看引用来源。
- **搜索**:标题、简介、正文、普通标签和系统标签共同匹配。支持多个关键词及双引号短语,先按相关性、再按引用数和时间排序;先筛选再分页。
- **标签**:普通标签使用 `#中国风`、`#贴纸` 等名称,可以创建、添加或移除。系统标签是固定列表,目前为“文档入口”和“参考图”,只能搜索并勾选,不能通过 `#` 创建。系统标签显示在图片角标,普通标签显示在文字区;分类页顶部按系统标签筛选。
- **编辑**:卡片与详情都能直接编辑标签;完整编辑器可以修改标题、简介、Markdown。保存使用 revision 检测并发冲突,避免旧窗口覆盖新修改。
- **素材**:原件和加工结果都是普通资产,可被多篇 post 引用。文档封面与实际参考素材分开,子文档可以有自己的封面,同时保留原参考图。
## 给 AI 的入口
在同一个 post 地址加 `?agent_mode=True` 可以读取纯文本正文和媒体链接。业务 API 的相同参数会先返回接口说明;已有查询参数时使用 `&agent_mode=True`。这些入口同样需要登录或有效 Bearer JWT。
| 地址 | 用途 |
| 入口 | 用途 |
| --- | --- |
| `/explore/<id>` | 人看的 post;加 `?agent_mode=True` 读纯文本 |
| `/api?agent_mode=True` | 业务 API 目录 |
| `/api/explore-feed` | 统一搜索、系统/普通标签筛选与分页 |
| `/api/notes/<id>` | GET 读取;PUT 编辑全文;PATCH 仅更新标签 |
| `/api/tags` | GET 查看普通/系统标签;POST 创建或复用普通标签 |
| `/api/upload` | 上传媒体;`assetOnly=true` 独立保存,不创建 post |
| `/api/posts` | 用正文和已有资产创建普通 post |
| `/api/media/<id>` | 媒体原件与衍生文件,支持 Range |
| `/api/preview` | 有尺寸上限的 WebP 预览,不接受任意远程 URL |
| `/` | 浏览内容,打开 `/explore/<id>` 查看单篇笔记 |
| `/guide` | 浏览指导文档 |
| `/graphic` | 打开图文工作台 |
| `/infinite_canvas` | 打开无限画布 |
| `/api?agent_mode=True` | 查看业务 API 目录 |
标签 PATCH 请求为 `{ "tags": ["标签 UUID"], "revision": "GET 返回的 revision" }`。它不会要求用户重输正文。Tag 对象的 `kind` 为 `normal` 或 `system`;系统标签还有稳定的 `system_key`。普通创建接口不允许提交 `kind` 或 `system_key`。
Wiki 中的教程是普通 post 与媒体数据,不需要为每份资料增加专用网页路由、JSON 文件端点或代码注册。
## Studio:从教程进入工具
Studio 负责交互式排版与无状态渲染,知识库负责教程、来源和入口。`/studio` 返回 PROMPT 首页;请从对应 post 打开具体工具。
27 套排版工具:`/studio/layouts/ref-01` 至 `/studio/layouts/ref-27`,每套对应原图 T/I/D 构件。目录与参数 API 为 `/studio/api/layouts` 和 `/studio/api/layouts/<id>`;POST 参数生成 SVG。效果通过 `/api/studio/designs` 存入 Wiki 现有 PostgreSQL,返回独立 ID,`/studio/designs/<id>` 可再次打开;PATCH 携带 revision 更新同一效果。Studio 不需要数据库连接或第二套数据库。详见 [27 套排版 API 教程](content/studio-tools/layouts-api.md)。
其他试版工具:
- `/studio/ideas/learning-skills-template`:ref-17 同一母版的四张占位封面。
- `/studio/ideas/layout-selection`:ref-01、ref-07、ref-26 三种构图;可修改文字与配色,核对构件边界。
- `/studio/api/export/<slug>`:GET 读取方案或初始 SVG;POST 校验自定义参数并生成 SVG/JSON。详细说明读取该地址的 `?agent_mode=True`。
渲染不自动保存作品,也不自动发布 post。需要保留的结果应下载后再通过普通媒体和 post API 发布。原图的 T/I/D 构件、画板比例与来源保留为可读取数据;文字替换和矢量重建的范围应在教程中明确。
自动化客户端可以在支持的页面或业务接口上加 `?agent_mode=True` 获取纯文本。读写权限与认证要求见对应接口说明。
## 仓库结构
| 路径 | 职责 |
| --- | --- |
| `apps/waterfall-wiki` | Next.js Pages Router 知识库、搜索、标签、媒体 API、认证与后台视频加工 |
| `apps/studio` | 独立 Next.js 创作工具与封面渲染 API |
| `apps/python` | 按需运行的 PNG/视频导出 CLI,没有常驻网络服务 |
| `content` | 本地作者资料、教程及排版源图,不打入 Wiki 运行镜像 |
| `scripts` | CI 部署、运维、API 发布与作者工具 |
| `docs` | 数据模型、接口、认证与部署说明 |
| `apps/waterfall-wiki` | Next.js Pages Router 主站、账户、内容和媒体 API,以及后台媒体处理 |
| `apps/studio` | Next.js Pages Router 创作工作台及渲染 API,由主站提供统一入口 |
| `apps/python` | 按需运行的 PNG 和视频导出工具 |
| `packages/brand` | 共享主题、品牌资产及接入规范 |
| `content` | 排版源数据、发布教程和示例,供作者工具与契约检查读取 |
| `scripts` | 构建部署、运维与内容发布工具 |
| `tests` | 跨应用的仓库媒体与运维检查。应用自身的测试位于各自目录 |
两个 JavaScript 应用分别维护冻结的 pnpm 锁文件。根 Dockerfile 是 waterfall-wiki 的构建入口;应用目录的 Dockerfile 与它保持一致。
## 验证与发布
## 环境与检查
JavaScript 工作区使用 Node.js 24 和 pnpm 11.25.0。生产服务由 Docker Compose 编排,数据保存在 PostgreSQL 和 S3 兼容对象存储中。
运行环境:Node.js 24、pnpm 11.25.0、PostgreSQL 17、S3 兼容对象存储;视频处理使用 FFmpeg,部分导出使用 Chromium。Python 工具需要 Python 3.12+。
需要编译或生成产物的验证在 ces-control 执行。发布工作流由匹配路径的 `main` 推送触发。页面验收使用部署后的指定服务器,详见 [AGENTS.md](AGENTS.md) 和 [构建与发布说明](docs/ci-and-entrypoints.md)。
```sh
pnpm install
pnpm --dir apps/waterfall-wiki typecheck
pnpm --dir apps/waterfall-wiki test
pnpm --dir apps/studio typecheck
bash -n scripts/deploy.sh scripts/integration.sh scripts/deploy-studio.sh
```
## 维护文档
完整集成测试只针对显式隔离的数据库、对象存储和生产容器运行,覆盖存储、视频加工、编辑冲突、真实搜索与引用、标签规则和登录保护。不要把生产存储配置拿来运行集成测试。
本项目以指定服务器为唯一网页运行与验收入口:先推送,再等待 ces-control CI/CD,最后直接检查服务器。不要启动本地网页预览,不用 localhost 页面作为视觉验收或交付入口。具体约定见 [AGENTS.md](AGENTS.md)。
## 部署与持久化
Web 应用由 `waterfall-wiki.yml` 统一发布,两个应用的路径都能触发它:先检查并构建 Studio,再完成 Wiki 的类型检查、单元测试、生产构建、冒烟及隔离 PostgreSQL/S3 集成测试并部署 Wiki,随后部署 Studio,最后在指定服务器验收。顺序在同一个 ces-control 作业内保证,避免独立作业互相等待。PR 检查也运行隔离集成测试,但不部署。Python 检查仍由 `python.yml` 承担;文档与作者数据本身不触发应用部署。
| 服务 | 入口/端口 |
| --- | --- |
| `waterfall-wiki` | 公网 `18131`,也是 Studio 的统一入口 |
| PostgreSQL | `127.0.0.1:18132` |
| 对象存储 | `127.0.0.1:18133` |
| Studio | `127.0.0.1:18134`;编辑器公网入口为 `/graphic`、`/infinite_canvas`,资源和 API 保留 `/studio` 代理 |
| Python | 无网络端口,按需运行 |
生产 Compose 项目仍为 `prompt`,部署根目录仍为 `/opt/prompt`。既有 `prompt_postgres_data`、`prompt_objects`、`prompt_auth_data` 卷与数据库身份保留;应用更名不会重新创建一套空存储。Compose 应用服务改为 `waterfall-wiki` 和 `waterfall-wiki-worker`,镜像参数为 `WATERFALL_WIKI_IMAGE` / `WATERFALL_WIKI_TEST_IMAGE`。
部署在停止写入后备份数据库,再运行迁移和启动新版。失败时恢复兼容旧镜像的备份并回滚服务。生产不执行 `down -v`,也不清空对象文件。早期合集验证会遍历分页,不假定旧文章一定在第一页。
## 登录与自动化
共享验证器的 6 位 TOTP 动态码登录,JWT 保存在 HttpOnly Cookie 中;这属于单因素动态码登录,不是 2FA。密钥保存在服务器认证卷,不进入 Git、镜像或 HTTP 二维码接口。
服务器管理员在交互式 SSH 终端运行 `sudo /opt/prompt/auth qr` 绑定验证器。不要把二维码、动态密钥或 JWT 粘贴到聊天、日志和仓库。服务端自动化可使用 `node auth-cli.cjs run <脚本>`,在进程内为本机 API 请求附加短期凭据,不输出令牌。
更多说明:[登录与 SSH 绑定](docs/dynamic-code-login.md) · [API](docs/api.md) · [数据模型](docs/data-model.md) · [项目结构与部署](docs/monorepo.md)。
- [业务 API](docs/api.md)与[数据模型](docs/data-model.md)
- [动态码登录与运维](docs/dynamic-code-login.md)
- [指导文档入口](docs/guidance.md)与[发布协议](docs/linked-guidance/publishing.md)
- [对象存储](docs/s3-media.md)与[镜像保留策略](docs/wiki-image-retention.md)
- [Studio 排版 API 与示例](content/studio-tools/layouts-api.md)
- [共享品牌包](packages/brand/README.md)
@@ -0,0 +1,5 @@
BEGIN;
ALTER TABLE account_tokens DROP CONSTRAINT account_tokens_kind_check;
ALTER TABLE account_tokens ADD CONSTRAINT account_tokens_kind_check CHECK (kind IN ('verify','session','reset'));
INSERT INTO schema_migrations(version) VALUES ('017_password_reset');
COMMIT;
@@ -1,3 +1,4 @@
import a from "@/styles/account.module.css";
import { ThemeToggle } from "./ThemeToggle";
import { Brand } from "./Brand";
import Head from "next/head";
@@ -48,9 +49,11 @@ export const useGuidanceAccount = () => useContext(AccountContext);
export default function GuidanceShell({
children,
title = "探索文档",
standalone = false,
}: {
children: ReactNode;
title?: string;
standalone?: boolean;
}) {
const router = useRouter();
const dialog = useRef<HTMLDialogElement>(null);
@@ -187,6 +190,18 @@ export default function GuidanceShell({
</>
);
}
if (standalone) return (
<AccountContext.Provider value={{ user, loading, error, refresh }}>
<div className={a.page}>
<Head><title>{`${title} · 啡跃`}</title></Head>
<a className={s.skipLink} href="#account-content">跳到正文</a>
<header className={a.header}>
<div><Link href="/">返回首页</Link><ThemeToggle /></div>
</header>
<main id="account-content">{children}</main>
</div>
</AccountContext.Provider>
);
return (
<AccountContext.Provider value={{ user, loading, error, refresh }}>
<div className={s.site}>
@@ -0,0 +1,25 @@
type Pose = "idea" | "read" | "make" | "collect" | "dream";
/** Original theme-aware line drawings, independent of the fixed brand mark. */
export function CreatorSketch({ pose }: { pose: Pose }) {
return <svg viewBox="0 0 200 220" fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
<path d="M13 17 185 14l3 176-174 3ZM17 202q42-3 86 0m-85 8 62 1" strokeWidth="1.5" />
<path d="M42 188q3-46 31-60l42 1q28 16 42 59" fill="var(--selection)" />
<path d="M78 64q-20-3-15-20 5-15 21-11 11-15 29-6 20 7 11 31l-18-10-15 18Z" fill="currentColor" />
<path d="M79 63q-11 5-5 17l8 2q1 27 21 29 21-4 21-39l-3-15m-34 52-5 20m24-18 7 18m-17-58-2 13 8 2m-9 13q9 5 17-3m-23-23h1m24-1h1" />
{pose === "idea" && <><path d="m117 135 17-38 13-48 11 3-7 53-14 49M68 143l-5 27 37 15" fill="var(--background)" /><path d="m141 70-8-31 26-9 11 29Z" fill="var(--selection)" /><path d="m142 42 14-5m-11 14 13-5m-10 13 12-5M151 22V12m16 14 8-7m-41 12-9-4" /></>}
{pose === "read" && <><path d="m49 132 49 16 46-20-4 58-41 15-46-15Z" fill="var(--background)" /><path d="m98 148 1 53m-35-54 23 8m-22 3 20 7m-19 3 16 6m28-16 20-8m-20 19 18-7m-18 17 15-6" /><path d="m50 162 12-5q8 1 5 8l-14 13m89-17-12-4q-9 0-6 7l15 12" fill="var(--background)" /></>}
{pose === "make" && <><path d="m99 143 65-7 15 51-68 5Z" fill="var(--background)" /><path d="m101 150-22 3-8 19 32 5m-39-6 16 7 29-2m21-12h13m-28 29H37" /><path d="m151 46 5-14 8 12 15 2-11 9 1 15-13-8-13 5 4-13-10-10Z" fill="var(--selection)" /></>}
{pose === "collect" && <><path d="m60 156 15-18 53 7-5 40-62-5Z" fill="var(--background)" /><path d="m76 138 8-11 19 3 7 13m-12 9a12 12 0 1 0 1 24 12 12 0 0 0-1-24m-36 10-11-5-8 8 15 15m64-21 15 9-13 11" /><path d="m143 68 25-7 7 31-25 7Zm7 14 6-6 10 9m-8-14h1" stroke="var(--primary)" /></>}
{pose === "dream" && <><path d="m82 136 16 30 26-6 12-36m-18 38 18 11 11-35-7-20q-4-7-8-3l-2 14-6-7m-46 26-9 25 28 14 37-13" fill="var(--background)" /><path d="m142 32 29-10-13 25-4-12-12-3 12 3 17-13m-36 25q-21 4-15 17t25 2" stroke="var(--primary)" /></>}
</svg>;
}
export function IdeaSketch({ kind }: { kind: "collect" | "connect" | "read" | "make" }) {
return <svg viewBox="0 0 140 110" fill="none" stroke="currentColor" strokeWidth="2.1" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
{kind === "collect" && <><path d="m43 25 49-5 7 64-53 6Z" fill="var(--selection)" /><path d="m54 39 25-2m-24 14 30-3m-28 14 21-2m20-23 18-20 7 7-20 21-9 3ZM34 18l-6-8m19 3-1-10m61 62 8 3m-81 2-10 2" /></>}
{kind === "connect" && <><path d="M42 37q27-31 50-1m-48 8q27-17 47-1M45 62q23 28 46 2" /><path d="m18 32 29-3 3 34-31 2Zm72-8 32 4-3 33-30-3ZM52 73l32-1 2 25-32 2Z" fill="var(--selection)" /><path d="m26 43 14-1m-13 9 10-1m62-13 13 2m-13 7 11 1M62 83h13m-12 7h9" /></>}
{kind === "read" && <><path d="M20 30q25-8 49 7 24-17 51-10l-3 56q-24-5-48 10-22-13-47-7Z" fill="var(--selection)" /><path d="m69 37 0 56M32 42q13-1 25 5m-23 8 21 5m-21 8 20 4m27-27 24-6m-23 19 21-6m-20 18 18-4m-35-44-2-11m17 10 6-10" /></>}
{kind === "make" && <><path d="m24 29 85-3 5 63-86 4ZM31 41h71M45 34h1m-10 0h1m20-1h1m-18 21 21-2 1 26-22 1Zm31 0 27-1m-26 12 20-1m-19 13 24-1" /><path d="m103 14 7-11 4 12 13 2-10 8 2 11-10-6-10 7 2-12-10-7Z" fill="var(--selection)" /></>}
</svg>;
}
@@ -3,5 +3,5 @@ export function ThemeToggle() {
const [dark, setDark] = useState(false);
const [ready, setReady] = useState(false);
useEffect(() => { const sync = () => setDark(document.documentElement.dataset.mode === 'dark'); sync(); setReady(true); window.addEventListener('endoleap-theme', sync); return () => window.removeEventListener('endoleap-theme', sync); }, []);
return <button type="button" data-theme-ready={ready} className="endoleap-theme-toggle" aria-label="切换明暗主题" title={dark ? '切换浅色模式' : '切换深色模式'} onClick={() => { const mode = document.documentElement.dataset.mode === 'dark' ? 'light' : 'dark'; const scope = document.documentElement.dataset.theme?.startsWith('canvas-') ? 'canvas' : 'home'; document.documentElement.dataset.mode = mode; document.documentElement.dataset.theme = `${scope}-${mode}`; try { localStorage.setItem('endoleap.theme', mode); } catch {} window.dispatchEvent(new Event('endoleap-theme')); }}>◐<span>{dark ? '浅色' : '深色'}</span></button>;
return <button type="button" data-theme-ready={ready} className="endoleap-theme-toggle" aria-label="切换明暗主题" title={dark ? '切换浅色模式' : '切换深色模式'} onClick={() => { const mode = document.documentElement.dataset.mode === 'dark' ? 'light' : 'dark'; const scope = document.documentElement.dataset.theme?.startsWith('canvas-') ? 'canvas' : 'home'; document.documentElement.dataset.mode = mode; document.documentElement.dataset.theme = `${scope}-${mode}`; try { localStorage.setItem('endoleap.theme', mode); } catch {} window.dispatchEvent(new Event('endoleap-theme')); }}><span aria-hidden="true">◐</span></button>;
}
+15 -2
View File
@@ -1,6 +1,6 @@
import { NextResponse } from 'next/server';
import { normalizeEmail,validPassword, trustedOrigin,accountCookie } from './account-crypto';
import { rateLimit,registerAccount,resendVerification,verifyAccount,loginAccount,currentAccount,logoutAccount } from './account';
import { requestPasswordReset,resetPassword,rateLimit,registerAccount,resendVerification,verifyAccount,loginAccount,currentAccount,logoutAccount } from './account';
export const runtime = 'nodejs';
const headers = {'Cache-Control':'private, no-store','Referrer-Policy':'no-referrer'};
const json = (body: object,status=200) => NextResponse.json(body,{status,headers});
@@ -12,7 +12,7 @@ export async function GET(request: Request,context: Context) {
export async function POST(request: Request,context: Context) {
if (!trustedOrigin(request)) return json({error:'请求来源不受信任'},403);
const {action} = await context.params;
if (!['register','resend','verify','login','logout'].includes(action)) return json({error:'不存在'},404);
if (!['register','resend','verify','login','logout','forgot','reset'].includes(action)) return json({error:'不存在'},404);
try {
// Revocation remains available even when login or mail limits are exhausted.
if (action === 'logout') { await logoutAccount(request); const r=json({ok:true});r.headers.set('Set-Cookie',accountCookie('',true));return r; }
@@ -27,6 +27,19 @@ export async function POST(request: Request,context: Context) {
if(typeof body.token!=='string'||! /^[a-f0-9]{64}$/.test(body.token))return json({error:'验证链接无效或已过期'},400);
return await verifyAccount(body.token) ? json({ok:true,message:'邮箱已验证,请登录'}) : json({error:'验证链接无效或已过期'},400);
}
if(action==='reset') {
if(typeof body.token!=='string'||!/^[a-f0-9]{64}$/.test(body.token)||!validPassword(body.password))return json({error:'重设链接无效,或密码不符合要求'},400);
if(!await rateLimit('reset:'+body.token,5))return json({error:'请求过于频繁,请稍后再试'},429);
if(!await resetPassword(body.token,body.password))return json({error:'重设链接无效或已过期,请重新申请'},400);
const r=json({ok:true,message:'密码已更新,请使用新密码登录'});r.headers.set('Set-Cookie',accountCookie('',true));return r;
}
if(action==='forgot') {
const email=normalizeEmail(body.email);
if(!email)return json({error:'请输入有效邮箱'},400);
if(!await rateLimit('forgot:'+email,3))return json({error:'请求过于频繁,请 15 分钟后再试'},429);
await requestPasswordReset(email);
return json({ok:true,message:'若该邮箱对应已验证账户,重设链接将发送至邮箱,有效期 30 分钟。'});
}
const email=normalizeEmail(body.email);
if(!email||!validPassword(body.password))return json({error:'请输入有效邮箱及 12–256 字节密码'},400);
if(!await rateLimit(action+':'+email,action==='login'?10:3))return json({error:'请求过于频繁,请 15 分钟后再试'},429);
+32 -6
View File
@@ -1,20 +1,44 @@
import { randomUUID } from 'node:crypto';
import nodemailer from 'nodemailer';
import { db, transaction } from './db';
import { ACCOUNT_COOKIE, SESSION_TTL, newToken, tokenDigest, hashPassword, checkPassword } from './account-crypto';
import { ACCOUNT_COOKIE, SESSION_TTL, newToken, tokenDigest, hashPassword, checkPassword, validPassword } from './account-crypto';
export async function rateLimit(key: string, limit: number) {
const result = await db().query(`INSERT INTO account_limits(key,attempts,window_start) VALUES ($1,1,now())
ON CONFLICT(key) DO UPDATE SET attempts=CASE WHEN account_limits.window_start < now()-interval '15 minutes' THEN 1 ELSE account_limits.attempts+1 END,
window_start=CASE WHEN account_limits.window_start < now()-interval '15 minutes' THEN now() ELSE account_limits.window_start END RETURNING attempts`,[tokenDigest(key)]);
return result.rows[0].attempts <= limit;
}
export async function sendVerification(email: string, token: string) {
async function sendAccountMail(email: string, token: string, kind: 'verify' | 'reset') {
const origin = process.env.ACCOUNT_PUBLIC_ORIGIN;
if (!origin || !process.env.SMTP_PASSWORD || !process.env.SMTP_USERNAME) throw Error('SMTP unavailable');
const url = new URL('/account',origin); url.searchParams.set('verify',token);
const url = new URL('/account',origin); url.searchParams.set(kind,token);
const smtp = nodemailer.createTransport({host:process.env.SMTP_HOST || 'smtpdm.aliyun.com',port:Number(process.env.SMTP_PORT || 465),secure:true,
auth:{user:process.env.SMTP_USERNAME,pass:process.env.SMTP_PASSWORD},connectionTimeout:10000,socketTimeout:15000});
await smtp.sendMail({from:process.env.SMTP_FROM || process.env.SMTP_USERNAME,to:email,subject:'验证你的知识站邮箱',text:`请在 30 分钟内打开链接并点击确认验证邮箱:\n${url.href}\n如果你没有注册,请忽略。`});
await smtp.sendMail({from:process.env.SMTP_FROM || process.env.SMTP_USERNAME,to:email,subject:kind==='reset'?'重设你的啡跃账户密码':'验证你的知识站邮箱',text:kind==='reset'?`请在 30 分钟内打开链接,由你设置新的密码:\n${url.href}\n如果你没有请求重设密码,请忽略;你的密码不会改变。`:`请在 30 分钟内打开链接并点击确认验证邮箱:\n${url.href}\n如果你没有注册,请忽略。`});
}
export async function sendVerification(email: string,token: string) { await sendAccountMail(email,token,'verify'); }
export async function requestPasswordReset(email: string) {
const result=await db().query('SELECT id FROM account_users WHERE email=$1 AND verified_at IS NOT NULL',[email]);
if(!result.rowCount)return;
const token=newToken(),digest=tokenDigest(token);
await db().query("INSERT INTO account_tokens(digest,user_id,kind,expires_at) VALUES ($1,$2,'reset',now()+interval '30 minutes')",[digest,result.rows[0].id]);
try { await sendAccountMail(email,token,'reset'); } catch { await db().query('DELETE FROM account_tokens WHERE digest=$1',[digest]);throw Error('SMTP unavailable'); }
}
export async function resetPassword(token: string,password: string) {
if(!/^[a-f0-9]{64}$/.test(token)||!validPassword(password))return false;
const hash=await hashPassword(password),digest=tokenDigest(token);
return transaction(async client=>{
const lookup=await client.query("SELECT user_id FROM account_tokens WHERE digest=$1 AND kind='reset' AND expires_at>now()",[digest]);
if(!lookup.rowCount)return false;
const id=lookup.rows[0].user_id;
// Serialize all reset links for one account, then recheck after acquiring the lock.
await client.query('SELECT id FROM account_users WHERE id=$1 FOR UPDATE',[id]);
const consumed=await client.query("DELETE FROM account_tokens WHERE digest=$1 AND kind='reset' AND expires_at>now() RETURNING user_id",[digest]);
if(!consumed.rowCount)return false;
await client.query('UPDATE account_users SET password_hash=$1 WHERE id=$2',[hash,id]);
await client.query('DELETE FROM account_tokens WHERE user_id=$1',[id]);
return true;
});
}
export async function registerAccount(email: string,password: string) {
const hash = await hashPassword(password);
@@ -42,14 +66,16 @@ export async function verifyAccount(token: string) {
});
}
export async function loginAccount(email: string,password: string) {
const result = await db().query('SELECT * FROM account_users WHERE email=$1',[email]);
return transaction(async client=>{
const result = await client.query('SELECT * FROM account_users WHERE email=$1 FOR UPDATE',[email]);
const user = result.rows[0];
// A fixed dummy hash makes unknown accounts perform the same expensive KDF.
const hash = user?.password_hash || 'scrypt:00000000000000000000000000000000:'+'0'.repeat(128);
if (!await checkPassword(password,hash) || !user?.verified_at) return null;
const token = newToken();
await db().query("INSERT INTO account_tokens(digest,user_id,kind,expires_at) VALUES ($1,$2,'session',now()+$3*interval '1 second')",[tokenDigest(token),user.id,SESSION_TTL]);
await client.query("INSERT INTO account_tokens(digest,user_id,kind,expires_at) VALUES ($1,$2,'session',now()+$3*interval '1 second')",[tokenDigest(token),user.id,SESSION_TTL]);
return token;
});
}
export function requestToken(request: Request) {
const value = request.headers.get('cookie')?.split(';').map(s=>s.trim()).find(s=>s.startsWith(ACCOUNT_COOKIE+'='))?.slice(ACCOUNT_COOKIE.length+1);
+82 -309
View File
@@ -1,23 +1,19 @@
import { Brand } from "../components/Brand";
import { Brand } from "@/components/Brand";
import a from "@/styles/account.module.css";
import Link from "next/link";
import { useRouter } from "next/router";
import { useEffect, useState, type FormEvent } from "react";
import {
ArrowRight,
BookOpen,
CheckCircle2,
Eye,
EyeOff,
GitBranch,
Link2,
LogOut,
MailCheck,
Waypoints,
} from "lucide-react";
import GuidanceShell, { useGuidanceAccount } from "@/components/GuidanceShell";
import { Notice } from "@/components/GuidanceUI";
import s from "@/styles/guidance.module.css";
type Mode = "login" | "register" | "resend";
type Mode = "login" | "register" | "resend" | "forgot" | "reset" | "verify";
function localNext(value: string | string[] | undefined) {
if (
typeof value !== "string" ||
@@ -36,327 +32,104 @@ function localNext(value: string | string[] | undefined) {
}
}
export default function AccountPage() {
return (
<GuidanceShell title="邮箱账户">
<AccountContent />
</GuidanceShell>
);
return <GuidanceShell title="登录与注册" standalone><AccountContent /></GuidanceShell>;
}
function AccountContent() {
const account = useGuidanceAccount(),
router = useRouter();
const [mode, setMode] = useState<Mode>("login"),
[email, setEmail] = useState(""),
[password, setPassword] = useState(""),
[showPassword, setShowPassword] = useState(false);
const [busy, setBusy] = useState(false),
[token, setToken] = useState(""),
[feedback, setFeedback] = useState<{
tone: "success" | "error";
text: string;
} | null>(null);
const account = useGuidanceAccount(), router = useRouter();
const [mode, setMode] = useState<Mode>("login");
const [email, setEmail] = useState(""), [password, setPassword] = useState(""), [confirm, setConfirm] = useState("");
const [showPassword, setShowPassword] = useState(false), [busy, setBusy] = useState(false);
const [token, setToken] = useState("");
const [feedback, setFeedback] = useState<{tone: "success" | "error"; text: string} | null>(null);
useEffect(() => {
const url = new URL(window.location.href);
const value = url.searchParams.get("verify");
if (value) {
setToken(value);
url.searchParams.delete("verify");
const reset = url.searchParams.get("reset"), verify = url.searchParams.get("verify");
if (reset || verify) {
setToken(reset || verify || ""); setMode(reset ? "reset" : "verify");
url.searchParams.delete("reset"); url.searchParams.delete("verify");
window.history.replaceState({}, "", url.pathname + url.search + url.hash);
}
}, []);
async function action(name: Mode | "verify" | "logout", body: object = {}) {
function switchMode(value: Mode) { setMode(value); setFeedback(null); setPassword(""); setConfirm(""); setShowPassword(false); }
async function action(name: Mode | "logout", body: object = {}) {
if (busy) return;
setBusy(true);
setFeedback(null);
setBusy(true); setFeedback(null);
try {
const response = await fetch("/api/account/" + name, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
const response = await fetch("/api/account/" + name, {method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify(body)});
const data = await response.json();
if (!response.ok) throw Error(data.error || "暂时无法完成操作,请重试");
if (name === "verify") {
setToken("");
setMode("login");
setFeedback({ tone: "success", text: "邮箱已验证,现在可以登录。" });
} else if (name === "login") {
setPassword("");
setFeedback({ tone: "success", text: "登录成功,欢迎回到啡跃。" });
} else if (name === "logout") {
setPassword("");
setFeedback({ tone: "success", text: "已退出登录。" });
} else
setFeedback({
tone: "success",
text:
data.message ||
"如果信息符合条件,验证邮件已发送。请检查收件箱和垃圾邮件。",
});
await account.refresh();
if (name === "verify" || name === "reset") { setToken(""); switchMode("login"); }
if (name === "login" || name === "logout" || name === "reset") { setPassword(""); setConfirm(""); }
setFeedback({tone: "success", text: name === "verify" ? "邮箱已验证,现在可以登录。" : name === "reset" ? "密码已更新,请使用新密码登录。" : name === "login" ? "登录成功,欢迎回到啡跃。" : name === "logout" ? "已退出登录。" : data.message || "若账户符合条件,邮件将发送到你的邮箱。"});
if (["verify", "login", "logout", "reset"].includes(name)) await account.refresh();
if (name === "login") await router.push(localNext(router.query.next));
} catch (e) {
setFeedback({
tone: "error",
text: e instanceof Error ? e.message : "网络异常,请稍后重试",
});
} finally {
setBusy(false);
}
} catch (error) { setFeedback({tone: "error", text: error instanceof Error ? error.message : "网络异常,请稍后重试"}); }
finally { setBusy(false); }
}
function submit(event: FormEvent<HTMLFormElement>) {
event.preventDefault();
void action(mode, { email, password });
if (mode === "reset" && password !== confirm) { setFeedback({tone: "error", text: "两次输入的密码不一致。"}); return; }
void action(mode, mode === "reset" ? {token, password} : mode === "verify" ? {token} : {email, password});
}
function switchMode(value: Mode) {
setMode(value);
setFeedback(null);
}
return (
<div className={s.accountLayout}>
<section className={s.accountIntro}>
<span className={s.accountSymbol}>
<Brand compact/>
</span>
<span className={s.eyebrow}>YOUR KNOWLEDGE, CONNECTED</span>
<h1>
让有用的知识,
<br />
成为下一次行动的起点。
</h1>
<p>
用邮箱建立你的知识空间。把工作方法写成独立文档,让 Agent
在需要的时候找到它。
</p>
<div className={s.accountFeatures}>
<div>
<BookOpen size={18} />
<div>
<strong>每篇文档,都能独立使用</strong>
<p>从当前任务出发,无需加载整个集合。</p>
</div>
</div>
<div>
<GitBranch size={18} />
<div>
<strong>每次更新,都有固定版本</strong>
<p>历史引用保持可读,修改始终有迹可循。</p>
</div>
</div>
<div>
<Link2 size={18} />
<div>
<strong>知识之间,按条件连接</strong>
<p>需要更多背景时,再沿有用的链接继续阅读。</p>
</div>
</div>
const user = mode === "reset" || mode === "verify" || mode === "forgot" ? null : account.user;
const title = user ? "你的账户" : ({login: "欢迎回来", register: "创建你的账户", resend: "重发验证邮件", forgot: "找回你的账户", reset: "设置新密码", verify: "确认验证邮箱"})[mode];
const description = user ? "你的知识与创作,随时继续。" : ({login: "使用邮箱与密码登录,继续你的创作。", register: "用邮箱建立你的知识与创作空间。", resend: "仅适用于尚未验证的账户,输入邮箱和原密码。", forgot: "输入注册邮箱,我们会发送重设密码链接。", reset: "由你设置新密码,原有内容会完整保留。", verify: "确认后,即可使用邮箱和密码登录。"})[mode];
const toast = feedback || (account.error ? {tone: "error" as const, text: account.error} : null);
return <div className={a.layout}>
<section className={a.intro} data-theme="home-dark" aria-label="啡跃创作空间">
<Link className={a.brand} href="/" aria-label="啡跃首页"><Brand /></Link>
<div className={a.story}>
<p className={a.eyebrow}>A SPACE FOR YOUR NEXT IDEA</p>
<h1>给想法留白,<br />让灵感有形。</h1>
<p className={a.description}>收集一闪而过的灵感,把有用的知识连接起来。下一件作品,从这里开始。</p>
<div className={a.art} aria-hidden="true">
<div className={a.orbit} />
<div className={a.idea}><span>01 / THE IDEA</span><strong>留住清晨<br />的一束光。</strong><i>灵感片段 · 随手记下</i></div>
<div className={a.work}><span>02 / IN THE MAKING</span><div className={a.artwork} /><strong>光的形状</strong><i>让一个念头,慢慢成形。</i></div>
<span className={a.artCaption}>COLLECT. CONNECT. CREATE.</span>
</div>
</section>
<section className={s.authCard} aria-label="邮箱账户">
<h2>
{account.user
? "你的账户"
: mode === "register"
? "创建你的账户"
: mode === "resend"
? "重发验证邮件"
: "欢迎回来"}
</h2>
<p className={s.authDescription}>
{account.user
? "已准备好发布和管理你的独立文档。"
: mode === "register"
? "验证邮箱后,就可以发布第一篇文档。"
: mode === "resend"
? "输入注册时的邮箱和密码,重新获取验证链接。"
: "使用邮箱与密码登录,继续你的知识工作。"}
</p>
{token && (
<section className={s.verificationCard}>
<h3>
<MailCheck size={17} />
确认验证邮箱
</h3>
<p>验证链接有效期为 30 分钟。确认后,再使用邮箱与密码登录。</p>
<button
type="button"
className={s.primaryButton}
disabled={busy}
onClick={() => void action("verify", { token })}
>
{busy ? "正在验证…" : "确认验证邮箱"}
</button>
</section>
)}
{feedback && <Notice tone={feedback.tone}>{feedback.text}</Notice>}
{account.error && (
<Notice tone="error">
{account.error}{" "}
<button
type="button"
className={s.textLink}
onClick={() => void account.refresh()}
>
重新连接
</button>
</Notice>
)}
{account.loading ? (
<div className={s.accountLoading} aria-busy="true">
正在检查账户状态…
</div>
<p className={a.signature}>啡跃 Endoleap <span>为下一次创作,留一个起点。</span></p>
</section>
<section className={a.form} aria-label="邮箱账户">
<div className={a.frame}>
<h2 key={title}>{title}</h2><p className={a.formDescription}>{description}</p>
{account.loading ? <div className={a.loading} aria-busy="true">正在检查账户状态…</div> : user ? <>
<div className={a.accountDetails}><CheckCircle2 size={22} /><strong>{user.email}</strong><span>邮箱已验证</span></div>
<Link className={s.primaryButton} href={localNext(router.query.next)}>继续使用啡跃 <ArrowRight size={15} /></Link>
<button className={a.secondary} type="button" disabled={busy} onClick={() => void action("logout")}><LogOut size={14} />退出登录</button>
</> : <>
<div className={a.tabSlot}>
{(mode === "login" || mode === "register") && <nav className={a.tabs} aria-label="账户操作" data-active={mode}>
<button type="button" aria-pressed={mode === "login"} disabled={busy} onClick={() => switchMode("login")}>登录</button>
<button type="button" aria-pressed={mode === "register"} disabled={busy} onClick={() => switchMode("register")}>创建账户</button>
</nav>}
</div>
) : account.user ? (
<>
<div className={s.loggedUser}>
<span className={s.avatar}>
{account.user.email.slice(0, 1).toUpperCase()}
</span>
<div>
<strong>{account.user.email}</strong>
<span className={s.verifiedBadge}>
<CheckCircle2 size={13} />
邮箱已验证
</span>
</div>
</div>
<div className={s.accountInfo}>
<p>
<strong>你的内容,由你管理。</strong>
<br />
你可以发布文档、创建新版本,以及撤下自己的内容。公开文档的固定历史版本会继续保留。
</p>
</div>
<Link
className={s.primaryButton}
href={localNext(router.query.next)}
>
继续使用啡跃
<ArrowRight size={15} />
</Link>
<div className={s.authSecondary}>
<button
type="button"
disabled={busy}
onClick={() => void action("logout")}
>
<LogOut size={12} /> 退出登录
</button>
</div>
</>
) : (
<>
{mode !== "resend" && (
<nav className={s.authTabs} aria-label="账户操作">
<button
type="button"
aria-pressed={mode === "login"}
disabled={busy}
onClick={() => switchMode("login")}
>
登录
</button>
<button
type="button"
aria-pressed={mode === "register"}
disabled={busy}
onClick={() => switchMode("register")}
>
创建账户
</button>
</nav>
)}
<form onSubmit={submit}>
<fieldset className={s.formFieldset} disabled={busy}>
<div className={s.formField}>
<form onSubmit={submit}>
<fieldset className={a.fieldset} disabled={busy}>
<div className={a.fields} key={mode}>
{mode !== "reset" && mode !== "verify" && <div className={a.field}>
<label htmlFor="account-email">邮箱地址</label>
<input
id="account-email"
className={s.input}
type="email"
name="email"
autoComplete="email"
placeholder="you@example.com"
required
maxLength={254}
value={email}
onChange={(e) => setEmail(e.target.value)}
/>
</div>
<div className={s.formField}>
<label htmlFor="account-password">密码</label>
<input id="account-email" className={s.input} type="email" name="email" autoComplete="email" placeholder="you@example.com" required maxLength={254} value={email} onChange={event => setEmail(event.target.value)} />
</div>}
{mode !== "forgot" && mode !== "verify" && <div className={a.field}>
<div className={a.labelRow}><label htmlFor="account-password">{mode === "reset" ? "新密码" : "密码"}</label>{mode === "login" && <button type="button" onClick={() => switchMode("forgot")}>忘记密码?</button>}</div>
<div className={s.passwordField}>
<input
id="account-password"
className={s.input}
type={showPassword ? "text" : "password"}
name="password"
autoComplete={
mode === "register"
? "new-password"
: "current-password"
}
placeholder={
mode === "register"
? "设置至少 12 个字符的密码"
: "输入你的密码"
}
minLength={12}
maxLength={256}
required
value={password}
onChange={(e) => setPassword(e.target.value)}
/>
<button
type="button"
aria-label={showPassword ? "隐藏密码" : "显示密码"}
onClick={() => setShowPassword((value) => !value)}
>
{showPassword ? <EyeOff size={16} /> : <Eye size={16} />}
</button>
<input id="account-password" className={s.input} type={showPassword ? "text" : "password"} name="password" autoComplete={mode === "register" || mode === "reset" ? "new-password" : "current-password"} placeholder={mode === "register" || mode === "reset" ? "设置至少 12 个字符的密码" : "输入你的密码"} minLength={12} maxLength={256} required value={password} onChange={event => setPassword(event.target.value)} />
<button type="button" aria-label={showPassword ? "隐藏密码" : "显示密码"} onClick={() => setShowPassword(value => !value)}>{showPassword ? <EyeOff size={16} /> : <Eye size={16} />}</button>
</div>
{mode === "register" && (
<small className={s.fieldHint}>
建议使用包含字母、数字的长密码。
</small>
)}
</div>
<button className={s.primaryButton} type="submit">
{busy
? "正在处理…"
: mode === "login"
? "登录"
: mode === "register"
? "创建账户"
: "发送验证邮件"}
{!busy && <ArrowRight size={15} />}
</button>
</fieldset>
</form>
<div className={s.authSecondary}>
{mode === "resend" ? (
<button
type="button"
disabled={busy}
onClick={() => switchMode("login")}
>
返回登录
</button>
) : (
<button
type="button"
disabled={busy}
onClick={() => switchMode("resend")}
>
没有收到验证邮件?重新发送
</button>
)}
</div>
<p className={s.authFootnote}>
注册后需要先验证邮箱。公开文档始终可以直接阅读。
</p>
</>
)}
</section>
</div>
);
</div>}
{mode === "reset" && <div className={a.field}><label htmlFor="account-confirm">确认新密码</label><input id="account-confirm" className={s.input} type={showPassword ? "text" : "password"} autoComplete="new-password" required minLength={12} maxLength={256} value={confirm} onChange={event => setConfirm(event.target.value)} /></div>}
{mode === "verify" && <div className={a.verifyInfo}><MailCheck size={28} /><p>验证链接有效期为 30 分钟。请确认这是你注册的邮箱。</p></div>}
</div>
<button className={`${s.primaryButton} ${a.submit}`} type="submit">{busy ? "正在处理…" : ({login: "登录", register: "创建账户", resend: "发送验证邮件", forgot: "发送重设链接", reset: "保存新密码", verify: "确认验证邮箱"})[mode]}{!busy && <ArrowRight size={15} />}</button>
</fieldset>
</form>
<div className={a.secondarySlot}>{mode === "login" || mode === "register" ? <button className={a.secondary} type="button" disabled={busy} onClick={() => switchMode("resend")}>没有收到验证邮件?重新发送</button> : <button className={a.secondary} type="button" disabled={busy} onClick={() => switchMode("login")}>返回登录</button>}</div>
<p className={a.footnote}>{mode === "forgot" || mode === "reset" ? "链接仅供本人使用。重设成功后,所有旧会话将退出。" : "首次注册需要验证邮箱;已验证的账户可直接登录。"}</p>
</>}
</div>
</section>
{toast && <div className={a.toast} data-tone={toast.tone} role={toast.tone === "error" ? "alert" : "status"}><span aria-hidden="true">{toast.tone === "error" ? "!" : "✓"}</span><p>{toast.text}</p><button type="button" aria-label={!feedback && account.error ? "重新连接" : "关闭提示"} onClick={() => {setFeedback(null); if (account.error) void account.refresh();}}>×</button></div>}
</div>;
}
+15 -5
View File
@@ -1,12 +1,22 @@
import { ThemeToggle } from "../components/ThemeToggle";
import { Brand } from "../components/Brand";
import Head from 'next/head';
import {ArrowUpRight, MousePointer2, Plus, Type, Image, Sparkles, Workflow, Layers, ArrowRight} from 'lucide-react';
import {ArrowUpRight, Workflow, Layers, ArrowRight} from 'lucide-react';
import {CreatorSketch, IdeaSketch} from "@/components/LandingSketches";
import s from '@/styles/landing.module.css';
export default function Home(){return <main className={s.page}>
<Head><title>啡跃 啡跃 Endoleap · 让灵感,有形。</title><meta name="description" content="连接你的 coding agent,在图形编辑器与无限画布中,把想法组织成作品。"/></Head>
<nav className={s.nav}><a className={s.logo} href="/"><Brand/></a><div><a href="#tools">创作工具</a><a href="/documents">知识与教程</a><a href="#workflow">工作方式</a></div><ThemeToggle/><a href="/account?next=/workspace">登录</a><a className={s.dark} href="/account?next=/workspace">进入工作台 <ArrowUpRight size={15}/></a></nav>
<section className={s.hero}><p className={s.eyebrow}>A SPACE FOR HUMAN IDEAS & AGENTS</p><h1>想法不该停在对话里。<br/><span>让灵感,有形。</span></h1><p className={s.intro}>从一闪而过的念头,到值得分享的作品。<br/>连接你的 coding agent,在一张画布上,把创作继续下去。</p><div className={s.actions}><a className={s.dark} href="/account?next=/workspace">开始创作 <ArrowRight size={17}/></a><a href="#tools">探索你的创作空间 ↓</a></div><div className={s.product}><div className={s.productBar}><Brand compact/><span>日常的另一种可能 / 创意探索</span><span>本机草稿</span></div><div className={s.demo}><aside>工作空间<hr/>图层与素材<p>◈ 创意简报</p><p>▧ 视觉探索</p><p>✳ 镜头构思</p><small>把线索连接起来</small></aside><div className={s.demoWorld}><svg viewBox="0 0 800 330" preserveAspectRatio="none"><path d="M190 170 C300 170 260 120 360 120 S520 240 620 240"/></svg><article className={s.note}><small>01 / THE IDEA</small><h3>把日常,<br/>拍成一场电影。</h3><p>自然光、细腻颗粒,<br/>让每一帧都有呼吸感。</p></article><article className={s.art}><small>02 / VISUAL STUDY</small><div className={s.orbit}/><h3>光的形状</h3><span>LIGHT / SPACE / EMOTION</span></article><article className={s.prompt}><Sparkles size={17}/><small>03 / PROMPT</small><h3>留住清晨的光。</h3><p>窗边的植物,安静的房间。<br/>35mm 胶片,缓慢推进。</p></article><div className={s.dock}><MousePointer2/><Plus/><Type/><Image/><Sparkles/></div></div></div></div><p className={s.caption}>一个创作场景示意。你的想法、素材与工具,在这里相遇。</p></section>
<Head><title>啡跃 Endoleap · 让灵感,有形。</title><meta name="description" content="收藏灵感、连接知识,与熟悉的 Agent 一起,把想法变成作品。探索图形编辑器、无限画布与知识文档。"/></Head>
<nav className={s.nav} aria-label="主导航"><a className={s.logo} href="/"><Brand/></a><div><a href="#tools">创作工具</a><a href="/documents">知识与教程</a><a href="#workflow">工作方式</a></div><ThemeToggle/><a href="/account?next=/workspace">登录</a><a className={s.dark} href="/account?next=/workspace">进入工作台 <ArrowUpRight size={15}/></a></nav>
<section className={s.hero}><p className={s.eyebrow}>A SPACE FOR HUMAN IDEAS & AGENTS</p><h1>想法不该停在对话里。<br/><span>让灵感,有形。</span></h1><p className={s.intro}>从一闪而过的念头,到值得分享的作品。<br/>连接你的 coding agent,在一张画布上,把创作继续下去。</p><div className={s.actions}><a className={s.dark} href="/account?next=/workspace">开始创作 <ArrowRight size={17}/></a><a href="#tools">探索你的创作空间 ↓</a></div><div className={s.peopleStrip}><span className={s.stripNote}>每一种好奇,都有自己的起点。</span>{([
['collect','收藏生活的切片'],['read','遇见新的工作方法'],['idea','记下突然出现的灵感'],['dream','给想法一点自由'],['make','做一件属于你的作品']
] as const).map(([pose,label])=><figure key={pose}><CreatorSketch pose={pose}/><figcaption>{label}</figcaption></figure>)}<span className={s.stripSpark} aria-hidden="true">✳</span></div></section>
<section className={s.possibilities} id="possibilities" aria-labelledby="possibilities-title"><p className={s.eyebrow}>MAKE ROOM FOR WHAT COMES NEXT</p><h2 id="possibilities-title">给好奇心一点空间,<br/>让下一步<em>自然发生。</em></h2><div className={s.featureGrid}>{([
['collect','留住一闪而过','一句念头、一张参考图、一个还没想好的方向。先留下,再慢慢展开。'],
['connect','让线索相遇','把笔记、图片和提示词放上画布,用连接看见它们之间的新可能。'],
['read','找到有用的方法','阅读可独立使用的知识文档,需要更多背景时,沿链接继续探索。'],
['make','把创作继续下去','用熟悉的 coding agent 探索,再亲手调整细节,让想法成为自己的作品。']
] as const).map(([kind,title,copy])=><article key={kind}><IdeaSketch kind={kind}/><h3>{title}</h3><p>{copy}</p></article>)}</div></section>
<section className={s.tools} id="tools"><p className={s.eyebrow}>TWO TOOLS. ONE CREATIVE FLOW.</p><h2>给不同的想法,<br/>恰好的空间。</h2><div className={s.toolGrid}><a href="/graphic"><Layers/><span>01 / GRAPHIC</span><h3>把灵感排成作品。</h3><p>文字、图形与图片自由编排。精确调整图层和位置,把设计导出为 SVG。</p><div className={s.poster}><span>MAKE<br/>ROOM<br/><i>for ideas.</i></span><b>✳</b></div><strong>打开图形编辑器 <ArrowUpRight size={17}/></strong></a><a href="/infinite_canvas"><Workflow/><span>02 / INFINITE CANVAS</span><h3>让思路,自由生长。</h3><p>把笔记、参考图与提示词连成线索。在无限画布上平移、缩放,整理下一次创作。</p><div className={s.miniCanvas}><b>一个念头</b><i>⟶</i><b>一张参考</b><i>⟶</i><b>新的可能</b></div><strong>打开无限画布 <ArrowUpRight size={17}/></strong></a></div></section>
<section className={s.reading} aria-labelledby="reading-title"><div><p className={s.eyebrow}>GOOD IDEAS DESERVE GOOD COMPANY</p><h2 id="reading-title">不必每一次,<br/>都从空白开始。</h2><p>把有用的工作方法,留给下一次的自己。<br/>一篇文档讲清一件事,需要时再沿着链接走远一点。</p><a href="/documents">去知识空间逛逛 <ArrowUpRight size={16}/></a></div><div className={s.readingArt} aria-hidden="true"><span>读到这里,<br/><em>想到了什么?</em></span><CreatorSketch pose="read"/><small>READ. CONNECT. MAKE.</small><svg viewBox="0 0 440 380"><path d="M35 105q-20-55 35-64m-15 0 17-2-8 17M348 267q46 33 32 68m-14-13 14 15 14-13"/></svg></div></section>
<section className={s.workflow} id="workflow"><div><p className={s.eyebrow}>YOUR AGENT. YOUR WORKFLOW.</p><h2>用熟悉的 Agent,<br/>继续你的创作。</h2><p>通过项目已有的 API 与文档,让 coding agent 理解模板和创作内容。画布负责呈现,你来决定下一步。</p><a href="/studio/api">查看 Agent 接入文档 <ArrowUpRight size={16}/></a></div><ol><li><b>01</b><div><h3>找到起点</h3><p>从空白设计、素材或一段灵感出发。</p></div></li><li><b>02</b><div><h3>连接工作方式</h3><p>将接入文档交给你的 coding agent。</p></div></li><li><b>03</b><div><h3>亲手打磨,保存作品</h3><p>在编辑器中调整细节,导出并保留备份。</p></div></li></ol></section>
<section className={s.end}><span><Brand compact/></span><h2>下一件作品,<br/>从这里开始。</h2><a className={s.dark} href="/account?next=/workspace">进入你的工作台 <ArrowRight size={17}/></a></section><footer className={s.footer}><a className={s.logo} href="/"><Brand/></a><span>给想法留白,给创作空间。</span><a href="/documents">知识与教程 ↗</a></footer></main>}
<section className={s.end}><div className={s.endWall} aria-hidden="true">{(['collect','read','connect','make'] as const).map(kind=><div key={kind}><IdeaSketch kind={kind}/><i/><i/><i/></div>)}</div><div className={s.endContent}><p className={s.eyebrow}>YOUR NEXT IDEA STARTS HERE</p><h2>给下一个念头,<br/><em>留一个起点。</em></h2><p>不用想好全部。带着一点好奇,先开始。</p><a className={s.dark} href="/account?next=/workspace">进入你的工作台 <ArrowRight size={17}/></a><a className={s.endSecondary} href="/documents">或先读一篇有用的文档 ↗</a></div></section><footer className={s.footer}><a className={s.logo} href="/"><Brand/></a><span>给想法留白,给创作空间。</span><a href="/documents">知识与教程 ↗</a></footer></main>}
@@ -0,0 +1,95 @@
.page { height: 100dvh; overflow: hidden; background: var(--surface); color: var(--foreground); }
.page > main { height: 100%; min-height: 0; }
.header { position: absolute; z-index: 2; top: 28px; right: 36px; }
.header > div { display: flex; align-items: center; gap: 20px; font-size: 13px; color: var(--muted-foreground); }
.header a:hover { color: var(--foreground-strong); }
.layout { display: grid; grid-template-columns: 46% minmax(0, 1fr); height: 100%; min-height: 0; }
.intro { position: relative; isolation: isolate; display: flex; flex-direction: column; min-width: 0; padding: 38px clamp(32px, 5vw, 80px) 30px; overflow: hidden; background: var(--background); color: var(--foreground); }
.intro::before { content: ''; position: absolute; z-index: -1; inset: 0; background: radial-gradient(ellipse at 0% 35%, color-mix(in srgb, var(--el-deep-mocha) 85%, transparent), transparent 60%), radial-gradient(ellipse at 100% 92%, color-mix(in srgb, var(--primary) 45%, transparent), transparent 65%); }
.brand { align-self: flex-start; }
.story { margin: auto 0; padding-top: clamp(16px, 4dvh, 40px); }
.eyebrow { margin: 0 0 20px; font-size: 10px; letter-spacing: .18em; color: var(--muted-foreground); line-height: 1.7; }
.story h1 { margin: 0 0 22px; font-size: clamp(32px, 3.3vw, 50px); font-weight: 600; line-height: 1.3; letter-spacing: -.035em; color: var(--foreground-strong); }
.description { margin: 0; max-width: 340px; font-size: 15px; line-height: 1.9; color: var(--foreground); }
.signature { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 32px 0 0; font-size: 11px; line-height: 1.7; color: var(--muted-foreground); }
.signature span { opacity: .8; }
.art { position: relative; height: clamp(180px, 28dvh, 280px); margin: 28px -12px 0; pointer-events: none; }
.orbit { position: absolute; width: 245px; height: 245px; left: 15%; top: 5%; border: 1px solid color-mix(in srgb, var(--foreground) 18%, transparent); border-radius: 50%; }
.orbit::after { content: ''; position: absolute; inset: 25px -35px; border: inherit; border-radius: 50%; transform: rotate(-38deg); }
.idea, .work { position: absolute; display: flex; flex-direction: column; border: 1px solid color-mix(in srgb, var(--foreground) 24%, transparent); border-radius: 14px; box-shadow: 0 20px 50px var(--shadow); }
.idea { left: 0; top: 42px; width: 48%; min-height: 196px; padding: 22px 18px; transform: rotate(-8deg); background: color-mix(in srgb, var(--surface) 78%, transparent); backdrop-filter: blur(16px); }
.idea span, .work > span { font-size: 8px; letter-spacing: .12em; line-height: 1.6; }
.idea strong { margin: 24px 0 18px; font-size: clamp(18px, 1.8vw, 26px); font-weight: 500; line-height: 1.5; }
.idea i, .work i { font-size: 9px; font-style: normal; line-height: 1.7; opacity: .72; }
.work { right: 0; top: 15px; width: 51%; padding: 18px; transform: rotate(8deg); background: var(--el-cream); color: var(--el-espresso); }
.artwork { height: 110px; margin: 16px 0 14px; overflow: hidden; border-radius: 100px 100px 8px 8px; background: radial-gradient(ellipse at 75% 20%, var(--el-cream), transparent 60%), linear-gradient(135deg, var(--el-deep-mocha), var(--el-espresso)); }
.work strong { margin-bottom: 6px; font-size: 19px; font-weight: 500; }
.artCaption { position: absolute; bottom: 0; left: 0; right: 0; text-align: center; font-size: 8px; letter-spacing: .2em; color: var(--muted-foreground); }
.form { align-self: center; justify-self: center; width: min(400px, calc(100% - 80px)); min-width: 0; padding: 0; }
.frame { height: 560px; display: flex; flex-direction: column; justify-content: center; }
.frame h2 { margin: 0; font-size: 28px; font-weight: 600; line-height: 1.3; text-align: center; letter-spacing: -.04em; animation: mode-in 180ms ease-out; }
.formDescription { height: 42px; flex-shrink: 0; margin: 10px 0 20px; font-size: 14px; line-height: 1.5; text-align: center; color: var(--muted-foreground); }
.tabSlot { height: 44px; flex-shrink: 0; margin-bottom: 24px; }
.tabs { position: relative; display: grid; grid-template-columns: 1fr 1fr; height: 44px; padding: 4px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-muted); isolation: isolate; }
.tabs::before { content: ''; position: absolute; z-index: -1; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 5px; background: var(--surface); box-shadow: 0 1px 3px var(--shadow); transition: transform 180ms ease; }
.tabs[data-active='register']::before { transform: translateX(100%); }
.tabs button { border: 0; background: transparent; font-size: 13px; color: var(--muted-foreground); }
.tabs button[aria-pressed='true'] { color: var(--foreground-strong); font-weight: 600; }
.fieldset { margin: 0; padding: 0; min-width: 0; border: 0; }
.fields { height: 168px; display: flex; flex-direction: column; gap: 16px; animation: mode-in 180ms ease-out; }
.field { min-width: 0; }
.field label { display: block; margin-bottom: 7px; font-size: 13px; line-height: 20px; font-weight: 500; }
.labelRow { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.labelRow button { font-size: 12px; color: var(--muted-foreground); }
.labelRow button:hover { color: var(--foreground-strong); }
.page .form input { width: 100%; height: 44px; min-height: 44px; padding: 0 12px; font-size: 14px; background: var(--surface); border: 1px solid var(--input); border-radius: 8px; box-shadow: 0 1px 2px var(--shadow); }
.page .form input[name='password'] { padding-right: 44px; }
.page .submit { width: 100%; min-height: 44px; margin-top: 8px; font-size: 14px; border-radius: 8px; }
.secondarySlot { min-height: 38px; display: grid; place-items: center; margin-top: 14px; }
.secondary { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; padding: 0; font-size: 12px; color: var(--muted-foreground); text-decoration: underline; text-underline-offset: 4px; }
.footnote { height: 60px; flex-shrink: 0; margin: 18px 0 0; padding-top: 16px; border-top: 1px solid var(--border); font-size: 12px; line-height: 1.7; text-align: center; color: var(--muted-foreground); }
.verifyInfo, .accountDetails { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; height: 168px; text-align: center; color: var(--muted-foreground); }
.accountDetails strong { color: var(--foreground-strong); overflow-wrap: anywhere; }
.accountDetails span, .verifyInfo p { font-size: 13px; line-height: 1.8; }
.loading { height: 320px; display: grid; place-items: center; font-size: 13px; color: var(--muted-foreground); }
.toast { position: fixed; z-index: 50; right: 20px; bottom: 20px; width: min(420px, calc(100% - 40px)); display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--foreground); box-shadow: 0 8px 32px var(--shadow); animation: mode-in 180ms ease-out; }
.toast > span { flex: 0 0 20px; height: 20px; text-align: center; border-radius: 50%; background: var(--success-background); color: var(--success); font-size: 13px; font-weight: 600; }
.toast[data-tone='error'] > span { color: var(--danger); background: var(--danger-background); }
.toast p { flex: 1; min-width: 0; margin: 0; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.toast button { flex: 0 0 24px; min-height: 24px; color: var(--muted-foreground); }
@keyframes mode-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@media (min-width: 1500px) { .story { max-width: 480px; width: 100%; margin-left: auto; margin-right: auto; } }
@media (max-width: 1000px) { .intro { padding-left: 28px; padding-right: 28px; } .story h1 { font-size: 34px; } .description { font-size: 14px; } .form { width: min(380px, calc(100% - 64px)); } .header { right: 28px; } }
@media (max-width: 760px) {
.header { top: 20px; right: 20px; }
.layout { grid-template-columns: minmax(0, 1fr); }
.intro { position: absolute; top: 20px; left: 24px; padding: 0; background: transparent; overflow: visible; }
.intro::before, .story, .signature { display: none; }
.brand { padding: 5px; border-radius: 8px; background: var(--background); }
.form { width: min(400px, calc(100% - 48px)); padding-top: 40px; }
.frame h2 { font-size: 25px; }
}
@media (max-height: 760px) {
.art, .signature { display: none; }
.intro { padding-top: 24px; padding-bottom: 24px; }
.formDescription { height: 34px; font-size: 13px; margin: 8px 0 14px; }
.frame { height: 460px; }
.frame h2 { font-size: 25px; }
.tabSlot { margin-bottom: 18px; }
.fields { height: 158px; gap: 12px; }
.footnote { display: none; }
.secondarySlot { margin-top: 10px; }
}
@media (max-height: 560px) {
.header a { display: none; }
.formDescription { display: none; }
.frame { height: 340px; }
.frame h2 { font-size: 22px; margin-bottom: 14px; }
.tabSlot { height: 36px; margin-bottom: 14px; }
.tabs { height: 36px; }
.story h1 { font-size: 28px; }
.eyebrow { display: none; }
}
@media (max-width: 760px) and (max-height: 760px) { .intro { padding: 0; } }
@media (prefers-reduced-motion: reduce) { .frame h2, .fields, .toast { animation: none; } .tabs::before { transition: none; } }
+2 -2
View File
@@ -8,11 +8,11 @@ body{margin:0}
[data-theme$="-dark"] .endoleap-mark-dark{display:block!important}
.endoleap-wordmark{display:flex!important;flex-direction:column;font-size:17px!important;color:var(--foreground-strong)!important;letter-spacing:.02em!important;margin:0!important;gap:3px}
.endoleap-wordmark small{display:block;font-size:9px;font-weight:500;letter-spacing:.08em;color:var(--muted-foreground)}
button.endoleap-theme-toggle{display:inline-flex;align-items:center;justify-content:center;gap:5px;border:1px solid var(--border);background:var(--surface);color:var(--foreground);border-radius:8px;padding:7px 9px;font-size:12px;line-height:1.2;flex-shrink:0;cursor:pointer}
button.endoleap-theme-toggle{display:inline-flex;align-items:center;justify-content:center;gap:5px;border:0;background:transparent;color:var(--muted-foreground);border-radius:8px;padding:8px;width:32px;height:32px;font-size:16px;line-height:1.2;flex-shrink:0;cursor:pointer}
button.endoleap-theme-toggle:hover{background:var(--row-hover)}
:where(a,button,input,textarea,select):focus-visible{outline:2px solid var(--ring);outline-offset:3px}
::selection{background:var(--selection);color:var(--foreground)}
@media(max-width:600px){.endoleap-theme-toggle span{display:none}.endoleap-brand{gap:5px}.endoleap-brand .endoleap-mark{width:26px;height:26px}.endoleap-wordmark{font-size:14px!important}}
@media(max-width:600px){.endoleap-theme-toggle span{display:inline}.endoleap-brand{gap:5px}.endoleap-brand .endoleap-mark{width:26px;height:26px}.endoleap-wordmark{font-size:14px!important}}
button:disabled{cursor:default}
input,textarea,select{accent-color:var(--primary)}
@@ -1678,66 +1678,11 @@
height: 31px;
color: var(--muted-foreground);
}
.accountLayout {
display: grid;
grid-template-columns: minmax(0, 1fr) 410px;
max-width: 990px;
gap: 70px;
align-items: center;
margin: 50px auto 70px;
}
.accountIntro {
padding: 20px 0;
}
.accountSymbol {
width: 54px;
height: 54px;
display: grid;
place-items: center;
background: var(--selection);
border: 1px solid var(--selection-border);
border-radius: 14px;
color: var(--primary);
margin-bottom: 28px;
}
.accountIntro h1 {
font-size: 32px;
line-height: 1.5;
letter-spacing: -1px;
font-weight: 650;
margin-bottom: 17px;
}
.accountIntro > p {
font-size: 13px;
line-height: 1.9;
color: var(--muted-foreground);
max-width: 360px;
}
.accountFeatures {
display: grid;
gap: 21px;
margin-top: 35px;
}
.accountFeatures > div {
display: flex;
align-items: flex-start;
gap: 12px;
}
.accountFeatures svg {
color: var(--muted-foreground);
margin-top: 2px;
}
.accountFeatures strong {
display: block;
font-size: 12px;
font-weight: 600;
}
.accountFeatures p {
font-size: 11px;
color: var(--muted-foreground);
line-height: 1.8;
margin-top: 5px;
}
.authCard {
padding: 28px;
border: 1px solid var(--line);
@@ -1922,13 +1867,7 @@
grid-template-columns: minmax(0, 1fr) 230px;
gap: 20px;
}
.accountLayout {
gap: 35px;
grid-template-columns: minmax(0, 1fr) 370px;
}
.accountIntro h1 {
font-size: 29px;
}
.protocolLayout {
grid-template-columns: minmax(0, 1fr) 190px;
}
@@ -1968,30 +1907,9 @@
.protocolLayout > aside {
display: none;
}
.accountLayout {
grid-template-columns: 1fr;
max-width: 430px;
margin: 15px auto 40px;
gap: 25px;
}
.accountIntro {
padding: 0;
}
.accountIntro h1 {
font-size: 26px;
margin-bottom: 8px;
}
.accountSymbol,
.accountFeatures {
display: none;
}
.accountIntro > p {
max-width: none;
font-size: 12px;
}
.accountIntro h1 br {
display: none;
}
.topbarProtocol {
display: none;
}
@@ -2302,19 +2220,8 @@
.authCard {
padding: 24px;
}
.accountLayout {
margin-top: 8px;
gap: 24px;
}
.accountIntro h1 {
font-size: 24px;
}
.accountIntro > p {
font-size: 11px;
}
.accountSymbol {
display: none;
}
.modalBody {
padding: 23px;
}
File diff suppressed because one or more lines are too long
@@ -2,8 +2,8 @@ import assert from 'node:assert/strict';
import { randomUUID } from 'node:crypto';
import { db } from '../src/lib/db';
import { hashPassword,newToken,tokenDigest } from '../src/lib/account-crypto';
import { loginAccount,verifyAccount,currentAccount,logoutAccount,rateLimit } from '../src/lib/account';
export async function verifyEmailAccounts() {
import { resetPassword,loginAccount,verifyAccount,currentAccount,logoutAccount,rateLimit } from '../src/lib/account';
export async function verifyEmailAccounts(base: string) {
const id=randomUUID(), email=id+'@example.com', password='a secure test password';
const request=(token:string)=>new Request('https://wiki.example',{headers:{cookie:'wiki_account='+token}});
try {
@@ -17,6 +17,34 @@ export async function verifyEmailAccounts() {
await db().query("UPDATE account_tokens SET expires_at=now()-interval '1 second' WHERE digest=$1",[tokenDigest(token)]);
assert.equal(await currentAccount(request(token)),null,'expired sessions rejected');
const fresh=await loginAccount(email,password);assert.ok(fresh);await logoutAccount(request(fresh));assert.equal(await currentAccount(request(fresh)),null,'logout revokes token');
const oldSession=await loginAccount(email,password);assert.ok(oldSession);
const resets=[newToken(),newToken()],replacement='a new secure test password';
for(const value of resets)await db().query("INSERT INTO account_tokens VALUES ($1,$2,'reset',now()+interval '30 minutes')",[tokenDigest(value),id]);
const resetResults=await Promise.all(resets.map(value=>resetPassword(value,replacement)));
assert.deepEqual(resetResults.sort(),[false,true],'Only one concurrent reset may succeed for one account');
assert.equal(await currentAccount(request(oldSession)),null,'Reset revokes existing sessions');
assert.equal(await loginAccount(email,password),null,'Original password is no longer accepted');
assert.ok(await loginAccount(email,replacement));
assert.equal(await resetPassword(resets[0],password),false,'Reset links are single-use, including sibling links');
const expired=newToken();await db().query("INSERT INTO account_tokens VALUES ($1,$2,'reset',now()-interval '1 minute')",[tokenDigest(expired),id]);
assert.equal(await resetPassword(expired,password),false);
const wrongKind=newToken();await db().query("INSERT INTO account_tokens VALUES ($1,$2,'verify',now()+interval '30 minutes')",[tokenDigest(wrongKind),id]);
assert.equal(await resetPassword(wrongKind,password),false,'Email verification cannot reset a password');
assert.equal(await resetPassword(newToken(),'short'),false);
const post=(action:string,body:object,origin=process.env.ACCOUNT_PUBLIC_ORIGIN||base)=>fetch(base+'/api/account/'+action,{method:'POST',headers:{'Content-Type':'application/json',Origin:origin},body:JSON.stringify(body)});
assert.equal((await post('forgot',{email},'https://untrusted.invalid')).status,403,'Cross-origin recovery is rejected');
const unknown=await post('forgot',{email:randomUUID()+'@example.com'});
assert.equal(unknown.status,200,'Unknown email receives the same non-enumerating response without sending mail');
assert.match((await unknown.json()).message,/若该邮箱/);
const httpToken=newToken(),httpPassword='http replacement secure password';
const priorHttpSession=await loginAccount(email,replacement);assert.ok(priorHttpSession);
await db().query("INSERT INTO account_tokens VALUES ($1,$2,'reset',now()+interval '30 minutes')",[tokenDigest(httpToken),id]);
const changed=await post('reset',{token:httpToken,password:httpPassword});
assert.equal(changed.status,200);
assert.match(changed.headers.get('set-cookie')||'',/Max-Age=0/);
assert.equal(await currentAccount(request(priorHttpSession)),null);
assert.ok(await loginAccount(email,httpPassword),'HTTP recovery changes the stored password');
assert.equal((await post('reset',{token:httpToken,password:replacement})).status,400,'HTTP recovery rejects a consumed token');
const key=randomUUID();assert.deepEqual(await Promise.all(Array.from({length:5},()=>rateLimit(key,3))).then(a=>a.sort()),[false,false,true,true,true]);
await db().query('DELETE FROM account_limits WHERE key=$1',[tokenDigest(key)]);
} finally {await db().query('DELETE FROM account_users WHERE id=$1',[id]);}
@@ -30,3 +30,41 @@ export async function navigateBrandDocument(navigate, url, now = Date.now) {
}
throw new Error(`Document navigation failed: ${url}`);
}
/** Load a document fully before relying on server-rendered text or leaving it.
* Only document GETs may recover; application assertions remain outside retry.
* @param {import('playwright-core').Page} page
* @param {string} url
* @param {boolean} reload
*/
export async function visitBrowserDocument(page, url, reload = false) {
return navigateBrandDocument(async timeout => {
const started = Date.now();
const scripts = new Set(), failures = [];
const requested = request => { if (request.resourceType() === 'script') scripts.add(request); };
const failed = request => { if (scripts.has(request)) failures.push(request.failure()?.errorText || 'unknown script failure'); };
page.on('request', requested);
page.on('requestfailed', failed);
try {
const response = await (reload ? page.reload({waitUntil: 'domcontentloaded', timeout}) : page.goto(url, {waitUntil: 'domcontentloaded', timeout}));
if (response?.ok()) {
const remaining = timeout - (Date.now() - started);
if (remaining <= 0) throw new Error('Document hydration budget exhausted: ' + url);
try {
// Responsive layouts may hide the toggle. Its mounted ready marker
// proves hydration; each caller still checks the controls it needs.
// A cancelled script may be a preload duplicate. Hydration is the
// authority; recover only when cancellation actually blocks startup.
await page.locator('button[data-theme-ready="true"]').first().waitFor({state: 'attached', timeout: failures.length ? Math.min(5000, remaining) : remaining});
} catch (error) {
if (failures.length) throw new Error('Document bootstrap script request failed: ' + failures.join('; '), {cause: error});
throw error;
}
}
return response;
} finally {
page.off('request', requested);
page.off('requestfailed', failed);
}
}, url);
}
@@ -1,6 +1,6 @@
import {test} from 'node:test';
import assert from 'node:assert/strict';
import {navigateBrandDocument} from './brand-navigation.mjs';
import {navigateBrandDocument, visitBrowserDocument} from './brand-navigation.mjs';
const response = status => ({ok: () => status === 200, status: () => status});
test('successful documents are fetched once', async () => {
@@ -48,3 +48,48 @@ test('recovery cannot extend the total navigation budget', async () => {
}, '/canvas', () => elapsed), /budget exhausted/);
assert.equal(calls, 1);
});
function browserFixture(failBootstrap = false, failHydration = false, blockedOnce = false, readyVisible = true) {
const listeners = new Map(), calls = [];
const page = {
on(event, fn) { if (!listeners.has(event)) listeners.set(event, new Set()); listeners.get(event).add(fn); },
off(event, fn) { listeners.get(event)?.delete(fn); },
async goto(url, options) {
calls.push(options.waitUntil);
const request = {resourceType: () => 'script', failure: () => ({errorText: 'net::ERR_ABORTED'})};
for (const fn of listeners.get('request') || []) fn(request);
if (failBootstrap && calls.length === 1) for (const fn of listeners.get('requestfailed') || []) fn(request);
return response(200);
},
locator() { return {first: () => ({waitFor: async options => { calls.push('hydrated'); if (!readyVisible && options.state !== 'attached') throw Error('Ready marker is hidden by responsive CSS'); if (failHydration || (blockedOnce && calls.length === 2)) throw Error('Hydration timeout'); }})}; },
};
return {page, calls, listeners};
}
test('document visit completes deferred scripts before checking hydration and removes listeners', async () => {
const {page, calls, listeners} = browserFixture();
await visitBrowserDocument(page, '/account');
assert.deepEqual(calls, ['domcontentloaded', 'hydrated']);
assert.ok([...listeners.values()].every(set => set.size === 0));
});
test('interrupted bootstrap retries only document loading before hydration', async () => {
const {page, calls} = browserFixture(true, false, true);
await visitBrowserDocument(page, '/account');
assert.deepEqual(calls, ['domcontentloaded', 'hydrated', 'domcontentloaded', 'hydrated']);
});
test('hydration failure is surfaced without retrying the application', async () => {
const {page, calls} = browserFixture(false, true);
await assert.rejects(visitBrowserDocument(page, '/account'), /Hydration timeout/);
assert.deepEqual(calls, ['domcontentloaded', 'hydrated']);
});
test('cancelled script does not reject an already hydrated document', async () => {
const {page, calls} = browserFixture(true);
await visitBrowserDocument(page, '/account');
assert.deepEqual(calls, ['domcontentloaded', 'hydrated']);
});
test('hydrated pages are ready even when responsive CSS hides the marker', async () => {
const {page, calls} = browserFixture(false, false, false, false);
await visitBrowserDocument(page, '/graphic');
assert.deepEqual(calls, ['domcontentloaded', 'hydrated']);
});
@@ -1,7 +1,7 @@
/** CI-only checks against the disposable stack, never against personal documents. */
import assert from 'node:assert/strict';
import { chromium, type Request } from 'playwright-core';
import { navigateBrandDocument } from './brand-navigation.mjs';
import { visitBrowserDocument } from './brand-navigation.mjs';
export async function verifyBrandUI(base: string) {
for (const prefix of process.env.VERIFY_CANVAS_UI === '1' ? ['', '/studio'] : ['']) {
const icon = await fetch(`${base}${prefix}/favicon.ico`);
@@ -28,21 +28,7 @@ export async function verifyBrandUI(base: string) {
const visit = async (path: string, theme: string) => {
const started = Date.now();
try {
// DOMContentLoaded also waits for this document's deferred scripts, unlike commit.
await navigateBrandDocument(async timeout => {
const attemptStarted=Date.now(), bootstrapFailures:string[]=[];
const failed=(request:Request)=>{
if(request.resourceType()==='script'&&(scriptStarted.get(request)??0)>=attemptStarted)
bootstrapFailures.push(request.failure()?.errorText||'unknown script failure');
};
page.on('requestfailed',failed);
try {
const response=await page.goto(base+path,{waitUntil:'domcontentloaded',timeout});
if(response?.ok()&&bootstrapFailures.length)throw new Error('Document bootstrap script request failed: '+bootstrapFailures.join('; '));
return response;
} finally {page.off('requestfailed',failed);}
}, base + path);
await page.locator('button[data-theme-ready="true"]').first().waitFor();
await visitBrowserDocument(page, base + path);
await page.waitForFunction(expected => document.documentElement.dataset.theme === expected, theme);
console.log('Brand UI route ready:', path, theme, Date.now() - started);
} catch (error) {
@@ -76,6 +62,14 @@ export async function verifyBrandUI(base: string) {
await page.setViewportSize({ width: 390, height: 844 });
assert.equal(await page.locator('.endoleap-mark-light').first().isVisible(), true);
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1), 'mobile home has no horizontal overflow');
for (const width of [390, 320]) {
await page.setViewportSize({ width, height: 844 });
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1), 'Editorial home fits narrow screens');
const entry = await page.getByRole('navigation', {name: '主导航'}).getByRole('link', {name: /进入工作台/}).boundingBox();
assert.ok(entry && entry.x >= 0 && entry.x + entry.width <= width, 'Workspace entry is visible, not clipped');
assert.equal(await page.getByRole('link', {name: /去知识空间逛逛/}).getAttribute('href'), '/documents');
assert.equal(await page.getByRole('link', {name: '开始创作', exact: true}).getAttribute('href'), '/account?next=/workspace');
}
console.log('Endoleap logos, both favicon paths, persisted home/canvas themes and artwork color isolation passed.');
} finally { await browser.close(); }
}
@@ -1,3 +1,4 @@
import { visitBrowserDocument } from "./brand-navigation.mjs";
import assert from 'node:assert/strict';
import {randomUUID} from 'node:crypto';
import {chromium,type Request} from 'playwright-core';
@@ -22,12 +23,13 @@ export async function verifyCanvasAgentUI(base:string){
page.on('response',response=>{const url=new URL(response.url());if(url.pathname.startsWith('/api/canvases'))canvasRequests.push(`${response.request().method()} ${url.pathname} ${response.status()}`)});
try{
page.setDefaultTimeout(60000);page.setDefaultNavigationTimeout(60000);page.on('pageerror',e=>errors.push(e.message));
mark('open landing');await page.goto(base+'/',{waitUntil:'commit'});
mark('open landing');await visitBrowserDocument(page,base+'/');
await page.getByRole('heading',{name:/想法不该停在对话里/,level:1}).waitFor();
const accountSession=page.waitForResponse(response=>new URL(response.url()).pathname==='/api/account/session'&&response.request().method()==='GET');
const [,sessionResponse]=await Promise.all([page.getByRole('link',{name:'开始创作',exact:true}).click(),accountSession]);
assert.equal(sessionResponse.status(),200);assert.equal((await sessionResponse.json()).user,null);
await page.getByRole('heading',{name:'欢迎回来',exact:true,level:2}).waitFor();
await page.locator('button[data-theme-ready="true"]').first().waitFor();
mark('login form ready');
await page.getByLabel('邮箱地址',{exact:true}).fill(email);
await page.getByLabel('密码',{exact:true}).fill(password);
@@ -36,10 +38,13 @@ export async function verifyCanvasAgentUI(base:string){
await page.waitForURL(url=>url.pathname==='/workspace',{waitUntil:'commit'});
mark('workspace URL accepted');
await page.getByRole('heading',{name:'今天,让哪个想法成形?',exact:true}).waitFor();
await page.locator('button[data-theme-ready="true"]').first().waitFor();
mark('workspace rendered');
const session=(await context.cookies()).find(c=>c.name===ACCOUNT_COOKIE);assert.ok(session?.httpOnly,'The actual login response establishes an HTTP-only account session');
const ownerHeaders={cookie:ACCOUNT_COOKIE+'='+session.value};
await page.getByRole('link',{name:'无限画布',exact:true}).click();
const canvasLink=page.getByRole('link',{name:'无限画布',exact:true});
assert.equal(await canvasLink.getAttribute('href'),'/infinite_canvas');
await visitBrowserDocument(page,base+'/infinite_canvas');
await page.getByRole('link',{name:email,exact:true}).waitFor({state:'attached'});
await page.getByRole('button',{name:'从示例开始 ↗',exact:true}).click();
const shot=page.locator('[data-node-id="shot"] [data-node-content]');
@@ -97,7 +102,7 @@ export async function verifyCanvasAgentUI(base:string){
assert.equal((await fetch(base+root,{headers:{authorization:second.authorization}})).status,404);
await page.setViewportSize({width:390,height:844});
const bounds=await panel.boundingBox();assert.ok(bounds&&bounds.x>=0&&bounds.x+bounds.width<=390,'Agent panel stays within the mobile viewport');
await page.reload({waitUntil:'commit'});
await visitBrowserDocument(page,page.url(),true);
await page.getByRole('link',{name:email,exact:true,includeHidden:true}).waitFor({state:'attached'});
await page.getByRole('button',{name:'Agent',exact:true}).click();
const reopened=page.getByRole('region',{name:'Agent 连接',exact:true});
@@ -1,3 +1,4 @@
import { visitBrowserDocument } from "./brand-navigation.mjs";
import assert from 'node:assert/strict';
import {verifyGuidanceWorkspaceUI} from './guidance-workspace-ui';
import {chromium} from 'playwright-core';
@@ -46,7 +47,7 @@ export async function verifyGuidancePublishing(base:string){
page.on('response',response=>{const path=new URL(response.url()).pathname;if(path.startsWith('/api/')||path.includes('/_next/data/'))void response.text().then(body=>record(`data ${response.status()} ${path}: ${body.slice(0,1400)}`)).catch(()=>{});else if(response.status()>=400||response.request().resourceType()==='script')record(`resource ${response.status()} ${path}`);});
try{
const link=`a[href="/documents/${httpDoc.id}?revision=1"]`;
const navigation=await page.goto(base+'/documents',{waitUntil:'commit'});record('directory HTTP '+navigation?.status());
const navigation=await visitBrowserDocument(page,base+'/documents');record('directory HTTP '+navigation?.status());
await page.locator(link).waitFor({state:'visible'});assert.equal(await page.locator(link).getByRole('heading').textContent(),httpDoc.title);
// Published matches must not inherit the examples' empty state; submitted filters survive reload.
const search=page.getByRole('textbox',{name:'搜索文档'});
@@ -54,7 +55,7 @@ export async function verifyGuidancePublishing(base:string){
await page.waitForURL(url=>url.searchParams.get('q')===httpDoc.title,{waitUntil:'commit'});
await page.getByRole('status').filter({hasText:'找到 2 篇文档'}).waitFor();
assert.equal(await page.getByText('没有匹配文档',{exact:false}).count(),0);
await page.reload({waitUntil:'commit'});
await visitBrowserDocument(page,page.url(),true);
await page.getByRole('status').filter({hasText:'找到 2 篇文档'}).waitFor();
// The matching count can also describe the unfiltered list before router hydration.
await page.waitForFunction(title=>document.querySelector<HTMLInputElement>('input[aria-label="搜索文档"]')?.value===title,httpDoc.title);
@@ -72,7 +73,7 @@ export async function verifyGuidancePublishing(base:string){
await page.waitForURL(url=>url.pathname==='/documents/'+httpDoc.id&&url.searchParams.get('revision')==='1',{waitUntil:'commit'});
await page.getByRole('heading',{name:httpDoc.title,exact:true,level:1}).waitFor();
assert.equal(await page.locator('h1').textContent(),httpDoc.title);
await page.goto(base+'/write',{waitUntil:'commit'});await page.getByRole('heading',{name:'发布独立文档',exact:true,level:1}).waitFor();assert.equal(await page.locator('h1').textContent(),'发布独立文档');
await visitBrowserDocument(page,base+'/write');await page.getByRole('heading',{name:'发布独立文档',exact:true,level:1}).waitFor();assert.equal(await page.locator('h1').textContent(),'发布独立文档');
}catch(error){console.error('Document navigation diagnostics',JSON.stringify({url:page.url(),headings:await page.locator('h1').allTextContents(),body:(await page.locator('body').innerText()).slice(0,2200),inflight:[...inflight].map(url=>new URL(url).pathname),events:navigationDiagnostics}));throw error;}
await page.close();
await verifyGuidanceWorkspaceUI(base,browser);
@@ -1,5 +1,6 @@
/** UI fixtures run in a fresh context; real storage and authentication have separate coverage. */
import assert from "node:assert/strict";
import { visitBrowserDocument } from "./brand-navigation.mjs";
import { mkdir } from "node:fs/promises";
import type { Browser } from "playwright-core";
import { documentInput, parseDocumentXml } from "../src/lib/guidance-input";
@@ -100,9 +101,14 @@ export async function verifyGuidanceWorkspaceUI(base: string, browser: Browser)
async function navigate(url: string, reload = false) {
const previousSessionReplies = sessionReplies;
try {
const navigation = await (reload ? page.reload({waitUntil:"commit"}) : page.goto(url,{waitUntil:"commit"}));
const navigation = await visitBrowserDocument(page, url, reload);
assert.ok(navigation?.ok(), "Navigation returns a successful document");
await page.getByText(signedIn ? "editor@example.com" : "登录你的账户",{exact:true}).first().waitFor({state:"attached"});
if (new URL(url).pathname === "/account") {
await page.getByRole("heading", { name: signedIn ? "你的账户" : "欢迎回来", exact: true }).waitFor();
} else {
await page.getByText(signedIn ? "editor@example.com" : "登录你的账户",{exact:true}).first().waitFor({state:"attached"});
}
await page.getByText("正在检查账户状态…", {exact: true}).waitFor({state: "hidden"});
assert.ok(sessionReplies > previousSessionReplies, "The new document requests its account fixture and renders the resulting account state");
} catch (error) {
const probeStarted=Date.now();
@@ -155,6 +161,29 @@ export async function verifyGuidanceWorkspaceUI(base: string, browser: Browser)
fullPage: true,
});
await navigate(base + "/account");
assert.equal(await page.getByRole("complementary").count(), 0, "Account page has no workspace sidebar");
assert.equal(await page.getByRole("link", { name: "创建文档", exact: true }).count(), 0);
await page.getByRole("link", { name: "返回首页", exact: true }).waitFor();
const accountFits = async () => assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1 && document.documentElement.scrollHeight <= innerHeight + 1), "Account page fits the viewport on both axes");
await accountFits();
await context.route("**/api/account/login", route => route.fulfill({status: 401, json: {error: "测试登录失败,请重试"}}));
await page.getByLabel("邮箱地址", {exact: true}).fill("fixture@example.com");
await page.getByLabel("密码", {exact: true}).fill("fixture-password-long");
await page.waitForFunction(() => document.getAnimations().every(animation => animation.playState !== "running"));
const beforeMessage = await page.getByLabel("邮箱地址", {exact: true}).boundingBox();
await page.locator("form").getByRole("button", {name: "登录", exact: true}).click();
await page.getByRole("alert").getByText("测试登录失败,请重试").waitFor();
const afterMessage = await page.getByLabel("邮箱地址", {exact: true}).boundingBox();
assert.equal(afterMessage?.y, beforeMessage?.y, "Status messages must not move the form");
await accountFits();
await page.getByRole("button", {name: "关闭提示", exact: true}).click();
await context.route("**/api/account/forgot", route => route.fulfill({json: {ok: true, message: "若账户符合条件,重设链接将发送到邮箱。"}}));
await page.getByRole("button", {name: "忘记密码?", exact: true}).click();
await page.getByRole("heading", {name: "找回你的账户", exact: true}).waitFor();
await page.getByLabel("邮箱地址", {exact: true}).fill("fixture@example.com");
await page.getByRole("button", {name: "发送重设链接", exact: true}).click();
await page.getByRole("status").getByText("若账户符合条件,重设链接将发送到邮箱。").waitFor();
await page.getByRole("button", {name: "返回登录", exact: true}).click();
await page.getByRole("button", { name: "创建账户", exact: true }).click();
await page.getByRole("heading", { name: "创建你的账户" }).waitFor();
await page
@@ -172,6 +201,26 @@ export async function verifyGuidanceWorkspaceUI(base: string, browser: Browser)
path: process.env.WORKSPACE_SCREENSHOT_DIR + "/account.png",
fullPage: true,
});
for (const viewport of [{width: 390, height: 844}, {width: 320, height: 568}]) {
await page.setViewportSize(viewport);
await accountFits();
await page.getByLabel("邮箱地址", {exact: true}).waitFor({state: "visible"});
}
await page.setViewportSize({width: 1440, height: 1000});
await context.route("**/api/account/reset", async route => {
const body = route.request().postDataJSON();
assert.equal(body.token, "f".repeat(64));
assert.equal(body.password, "replacement-fixture-password");
await route.fulfill({json: {ok: true}});
});
await visitBrowserDocument(page, base + "/account?reset=" + "f".repeat(64));
await page.getByRole("heading", {name: "设置新密码", exact: true}).waitFor();
assert.equal(new URL(page.url()).searchParams.has("reset"), false, "Recovery token is removed from the visible URL");
await page.getByLabel("新密码", {exact: true}).fill("replacement-fixture-password");
await page.getByLabel("确认新密码", {exact: true}).fill("replacement-fixture-password");
await page.getByRole("button", {name: "保存新密码", exact: true}).click();
await page.getByRole("heading", {name: "欢迎回来", exact: true}).waitFor();
await accountFits();
await navigate(base + "/write");
await page.getByRole("heading", { name: "登录后开始编写" }).waitFor();
signedIn = true;
@@ -42,7 +42,7 @@ test('real PostgreSQL + S3 notes, flat tags, resource sharing and video processi
let ready=false;for(let i=0;i<60;i++){try{if((await fetch(base+'/api/health')).ok){ready=true;break;}}catch{}await setTimeout(250);}assert.ok(ready);
for(const route of ['/','/images','/videos','/audio','/articles','/motion','/library/import','/tools/doodle','/tools/skills','/tools/skills/street-people','/tools/skills/shadow-puppet'])assert.equal((await fetch(base+route)).status,200,route);
if(!external)await verifyBrandUI(base);
await verifyEmailAccounts();
await verifyEmailAccounts(base);
await verifyCanvasWorkspace(base);
if(process.env.VERIFY_CANVAS_UI==='1')await verifyCanvasAgentUI(base);
await verifyGuidancePublishing(base);
-11
View File
@@ -1,11 +0,0 @@
# Studio 固定构图视觉审查
2026-10-28:先搜索互联网设计 skills,再检查源文件。采用 [Anthropic frontend-design 原始 SKILL.md](https://github.com/anthropics/claude-code/blob/main/plugins/frontend-design/skills/frontend-design/SKILL.md) 中与本任务适用的字体层级、基于内容选择配色、保留构图个性及逐版审视方法;不采用其自由重构产品布局的方向,因为本任务要求保留27套构图及现有工具箱。只阅读说明,没有安装依赖或执行第三方代码。
搜索结果中的第三方技能聚合页只用于发现,不作为实现依据。另检查了 Impeccable 候选源路径,但该路径返回404,未读取到可信内容,因此不采用,也不声称安装或使用了该技能。
实现把每套构图的纸色、文字、主图位、副图位组织成独立四色色谱。蓝灰用于横向英文刊头,暖赭用于出血椭圆与斜题,苔绿用于竖题与同心圆;没有把构图改为统一卡片。竖向中文使用宋体栈,英文大刊头保留衬线,模块式构图加强字重与字距,小字替换成适合槽位的简短可编辑内容。原始画板、元素ID、裁切轮廓与主要坐标保持不变。
可视化目录用原生文字和几何展示构图,页面本身继续由现有 LayoutWorkbench 原生渲染。颜色、字体和几何显式参数优先于模板默认值;模板默认外观会跟随版本美化,要求固定外观的调用者应传入显式参数。
验收应在部署完成后仅访问指定服务器,检查27套页面、移动宽度、保存ID恢复、字体/几何扩展、图片网络请求,以及旧工具功能。原生页面不能以旧SVG导出代替视觉验收。
+2 -2
View File
@@ -4,13 +4,13 @@
`ces-control` 必须预装 Docker、Compose,并允许 Runner 访问持久 Docker daemon。CI 只检查环境,不安装系统包、不启停主机服务。当前服务器没有 buildx,先继续使用 daemon 自带层缓存;不要直接粘贴依赖 GitHub cache 服务的 `type=gha` 参数。后续若换 Docker daemon 或清理缓存,会重新冷构建。
Dockerfile 保持单次 COPY,`.dockerignore` 排除非构建输入;根 Markdown 和 docs 不再使应用构建层失效。只有 main 的 push 事件触发 CI/CD(对应 PR 合并后的主线更新),工作分支 push、PR 创建/更新和手动 dispatch 均不触发;三个应用均有同样的作业级守卫。main 对纯文档改动使用 paths,但 public 下的 Markdown 属于产品资源,必须构建部署。public 下的技能 Markdown 继续纳入构建。旧 builder 每条 COPY 实测约 47 秒,避免拆成多条 COPY 增加快照成本。完整路径保留类型检查、单元测试、smoke 与完整隔离栈集成测试。
Dockerfile 保持单次 COPY,`.dockerignore` 排除非构建输入;根 Markdown 和 docs 不再使应用构建层失效。发布由 main 上匹配路径的 push 触发。creative-workspace.yml 另对匹配路径的 PR 执行远程评审检查,包括隔离集成与已部署页面验收。public 下的 Markdown 属于产品资源。public 下的技能 Markdown 继续纳入构建。旧 builder 每条 COPY 实测约 47 秒,避免拆成多条 COPY 增加快照成本。完整路径保留类型检查、单元测试、smoke 与完整隔离栈集成测试。
当前页面为 Next.js SSR 与编译组件,改 TSX 仍需 next build。Web 快速路径只编译生产 Web,并以不可变的版本目录挂载完整 standalone 产物,保持版本与回滚一致;不重新编译 worker 或导出运行镜像。
## Web 快速发布
main 的 push 与当前已部署 SHA 比较;只有页面、组件、样式、技能文档数据和 public 改动才走 Web 路径,API、共享库、依赖、配置、worker、脚本及数据库变化均回退完整流水线。PR 阶段只做不会触发编译的阅读、差异审查与轻量配置检查,完整远程验证在用户手动合并到 main 后执行;依赖构建镜像缺失也回退完整流水线。
main 的 push 与当前已部署 SHA 比较;只有页面、组件、样式、技能文档数据和 public 改动才走 Web 路径,API、共享库、依赖、配置、worker、脚本及数据库变化均回退完整流水线。本地只做差异审查与轻量检查,匹配路径的 PR 在 ces-control 执行远程检查;依赖构建镜像缺失也回退完整流水线。
Web 路径复用当前 runtime 对应的已验证 integration 镜像作为工具环境,在临时容器构建生产 Web,不运行 docker build。编译缓存按基础镜像隔离持久保存。类型检查、单元测试和 Web smoke 仍同步执行,完整隔离栈测试只在全量路径执行。
Binary file not shown.

Before

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

-55
View File
@@ -1,55 +0,0 @@
# 本阶段逐文件变更说明
- `Dockerfile`:分离依赖下载与离线安装层,保留跨源码改动的下载缓存。
- `apps/studio/Dockerfile`:配置 /studio 访问前缀,并同步创作站页面、导出与 AI 索引链接。
- `apps/studio/next.config.ts`:配置 /studio 访问前缀,并同步创作站页面、导出与 AI 索引链接。
- `apps/studio/src/pages/api/index.ts`:配置 /studio 访问前缀,并同步创作站页面、导出与 AI 索引链接。
- `apps/studio/src/pages/ideas/[slug].tsx`:配置 /studio 访问前缀,并同步创作站页面、导出与 AI 索引链接。
- `apps/studio/src/pages/index.tsx`:配置 /studio 访问前缀,并同步创作站页面、导出与 AI 索引链接。
- `apps/waterfall-wiki/Dockerfile`:分离依赖下载与离线安装层,保留跨源码改动的下载缓存。
- `apps/waterfall-wiki/next.config.ts`:更新样式或生产烟测以支持统一详情和轻量展示。
- `apps/waterfall-wiki/package.json`:更新样式或生产烟测以支持统一详情和轻量展示。
- `apps/waterfall-wiki/scripts/smoke.mjs`:更新样式或生产烟测以支持统一详情和轻量展示。
- `apps/waterfall-wiki/src/components/ArticleGallery.tsx`:更新内容展示、压缩预览、首页分类导航或左右分栏详情交互。
- `apps/waterfall-wiki/src/components/Feed.tsx`:更新内容展示、压缩预览、首页分类导航或左右分栏详情交互。
- `apps/waterfall-wiki/src/components/Shell.tsx`:更新内容展示、压缩预览、首页分类导航或左右分栏详情交互。
- `apps/waterfall-wiki/src/components/SkillCard.tsx`:更新内容展示、压缩预览、首页分类导航或左右分栏详情交互。
- `apps/waterfall-wiki/src/components/SkillDocs.tsx`:更新内容展示、压缩预览、首页分类导航或左右分栏详情交互。
- `apps/waterfall-wiki/src/content/skills/guidance.ts`:维护持久内容 ID、统一地址与文档引用。
- `apps/waterfall-wiki/src/lib/library.ts`:实现内容统一读取或安全、限流、缓存的图片压缩。
- `apps/waterfall-wiki/src/pages/api/wiki-index.ts`:新增或更新统一 ID 页面、纯文本模式、分类、旧地址跳转或轻量预览 API。
- `apps/waterfall-wiki/src/pages/index.tsx`:新增或更新统一 ID 页面、纯文本模式、分类、旧地址跳转或轻量预览 API。
- `apps/waterfall-wiki/src/pages/p/[slug].tsx`:新增或更新统一 ID 页面、纯文本模式、分类、旧地址跳转或轻量预览 API。
- `apps/waterfall-wiki/src/pages/skills/[[...path]].tsx`:新增或更新统一 ID 页面、纯文本模式、分类、旧地址跳转或轻量预览 API。
- `apps/waterfall-wiki/src/pages/tools/skills/[skill]/[[...doc]].tsx`:新增或更新统一 ID 页面、纯文本模式、分类、旧地址跳转或轻量预览 API。
- `apps/waterfall-wiki/src/pages/tools/skills/street-people.tsx`:新增或更新统一 ID 页面、纯文本模式、分类、旧地址跳转或轻量预览 API。
- `apps/waterfall-wiki/src/pages/tools/skills/street-people/[doc].tsx`:新增或更新统一 ID 页面、纯文本模式、分类、旧地址跳转或轻量预览 API。
- `apps/waterfall-wiki/src/pages/wiki/[key].tsx`:新增或更新统一 ID 页面、纯文本模式、分类、旧地址跳转或轻量预览 API。
- `apps/waterfall-wiki/src/styles/globals.css`:更新样式或生产烟测以支持统一详情和轻量展示。
- `apps/waterfall-wiki/tests/integration.test.ts`:验证稳定 ID、纯文本响应、图片体积与缓存、旧文档引用及集成行为。
- `apps/waterfall-wiki/tests/skill-docs.test.ts`:验证稳定 ID、纯文本响应、图片体积与缓存、旧文档引用及集成行为。
- `docs/monorepo.md`:记录新入口、兼容关系、图片预览和构建缓存行为。
- `pnpm-workspace.yaml`:关闭运行命令前的自动依赖重装,使用显式安装与冻结锁文件。
- `scripts/deploy-studio.sh`:连接 Wiki Docker 网络、验证新路径并按 Studio 相关改动判断过期发布。
- `apps/waterfall-wiki/src/components/ExploreDetail.tsx`:更新内容展示、压缩预览、首页分类导航或左右分栏详情交互。
- `apps/waterfall-wiki/src/components/ExploreFeed.tsx`:更新内容展示、压缩预览、首页分类导航或左右分栏详情交互。
- `apps/waterfall-wiki/src/content/page-ids.json`:维护持久内容 ID、统一地址与文档引用。
- `apps/waterfall-wiki/src/content/page-links.ts`:维护持久内容 ID、统一地址与文档引用。
- `apps/waterfall-wiki/src/lib/explore.ts`:实现内容统一读取或安全、限流、缓存的图片压缩。
- `apps/waterfall-wiki/src/lib/preview.ts`:实现内容统一读取或安全、限流、缓存的图片压缩。
- `apps/waterfall-wiki/src/pages/api/explore-feed.ts`:新增或更新统一 ID 页面、纯文本模式、分类、旧地址跳转或轻量预览 API。
- `apps/waterfall-wiki/src/pages/api/preview.ts`:新增或更新统一 ID 页面、纯文本模式、分类、旧地址跳转或轻量预览 API。
- `apps/waterfall-wiki/src/pages/categories.tsx`:新增或更新统一 ID 页面、纯文本模式、分类、旧地址跳转或轻量预览 API。
- `apps/waterfall-wiki/src/pages/explore/`:新增或更新统一 ID 页面、纯文本模式、分类、旧地址跳转或轻量预览 API。
- `apps/waterfall-wiki/tests/explore.test.ts`:验证稳定 ID、纯文本响应、图片体积与缓存、旧文档引用及集成行为。
- `apps/waterfall-wiki/tests/preview.test.ts`:验证稳定 ID、纯文本响应、图片体积与缓存、旧文档引用及集成行为。
- `apps/studio/src/pages/api/health.ts`:新增明确的健康检查接口,避免把 API 目录的 index 文件错误理解为 /api/index 路由。
- `scripts/deploy-studio.sh`:健康检查修正为 `/studio/api/health`。
- `apps/studio/src/pages/index.tsx`:AI 索引入口修正为实际 `/studio/api`。
- `scripts/deploy.sh`:Wiki 发布过期检查限定 Wiki 相关路径,避免 Studio 单独更新时阻止已验证的 Wiki 发布。
- `apps/waterfall-wiki/tests/integration.test.ts`:移除已按需求删除的旧工具入口文案断言,改为检查 ID 链接和分类;新增真实存储图片的压缩体积检查,以及数据库内容的 agent_mode 响应检查。
- `apps/waterfall-wiki/src/content/page-links.ts`:默认预览尺寸改为已支持的 480 像素档位。
-35
View File
@@ -1,35 +0,0 @@
# 扁平笔记、标签与统一资源:变更说明
本阶段保留 posts.slug(旧链接与导入去重)、cover_asset_id(明确封面)、media_jobs(异步视频处理)及 contribution_events。删除 page_key、tags.parent_id、asset_variants、page_snapshots、render_jobs;原文件不删除,旧截图和加工文件转换为普通 assets/post_assets 引用。所有笔记平等,不引入附属文档关系。
## 文件与目的
- `apps/waterfall-wiki/db/004_flat_notes.sql`:新增事务迁移。保存旧截图引用,将加工文件转换为普通资源,合并同名标签且保留笔记/资源关联,再移除旧字段和表。
- `apps/waterfall-wiki/src/lib/model.ts`:更新扁平标签和资源来源字段,移除代码页绑定与截图数量字段。
- `apps/waterfall-wiki/src/lib/library.ts`:取消递归标签查询和代码页注册过滤;从普通资源计算加工类型,允许直接保存文字笔记。
- `apps/waterfall-wiki/src/lib/asset-links.ts`:新增共享视频资源的加工结果关联逻辑,锁住笔记以避免并发追加占用同一位置。
- `apps/waterfall-wiki/src/lib/write.ts`:创建笔记不再依赖 page_key,复用视频时补齐已有加工文件引用。
- `apps/waterfall-wiki/src/worker.ts`:仅保留视频任务,FFmpeg 输出进入普通资源表并关联到使用该视频的笔记,继续支持重试。
- `apps/waterfall-wiki/src/lib/publish-learning-series.ts`:发布完整文字和扁平标签,保留已有图片和封面,不再排截图任务;同步静态文档中可见的标签名称。
- `apps/waterfall-wiki/src/lib/explore.ts`:直接从普通资源展示笔记,图片计数排除视频加工文件;正文中提供加工资源链接,不再读取截图状态或代码页面。
- `apps/waterfall-wiki/src/lib/api.ts`:移除“必须注册代码页面”的旧错误映射。
- `apps/waterfall-wiki/src/pages/api/media/[id].ts`、`apps/waterfall-wiki/src/pages/api/preview.ts`:直接读取普通加工资源,同时兼容已有 variant 媒体地址,继续提供小文件预览。
- `apps/waterfall-wiki/src/pages/api/tags.ts`:名称全局唯一,支持带 # 创建;同名请求复用已有标签,不需要 parentId 或手写 slug。
- `apps/waterfall-wiki/src/components/TagInput.tsx`:新增 #标签输入、回车创建、现有标签建议和移除交互。
- `apps/waterfall-wiki/src/pages/library/import.tsx`:接入标签输入,成功后直接进入 ID 地址,更新视频处理提示。
- `apps/waterfall-wiki/src/components/ExploreDetail.tsx`:正文链接增加小图标和轻量行内样式。
- `apps/waterfall-wiki/src/styles/globals.css`:新增行内链接和标签输入样式及焦点反馈。
- `apps/waterfall-wiki/src/components/Feed.tsx`:旧列表组件改用平级标签,不再寻找子分类。
- `apps/waterfall-wiki/src/pages/p/[slug].tsx`:精简为兼容旧地址的跳转,移除失效的旧详情渲染代码。
- 删除 `apps/waterfall-wiki/src/lib/snapshots.ts`、`apps/waterfall-wiki/src/components/ArticleGallery.tsx`、`apps/waterfall-wiki/src/pages/api/posts/[slug]/snapshots.ts`、`apps/waterfall-wiki/src/pages/p/[slug]/pages/[page].tsx`、`apps/waterfall-wiki/scripts/wait-snapshots.mjs`:移除截图执行器、轮询界面、任务 API、画布路由与部署等待脚本。
- 删除 `apps/waterfall-wiki/src/content/registry.tsx`:移除 Wiki 代码作品注册绑定。
- `Dockerfile`、`apps/waterfall-wiki/Dockerfile`:不再复制截图等待脚本,保留现有依赖层缓存。
- `scripts/deploy.sh`:停止写入后备份,迁移失败时恢复兼容旧镜像的数据库,再恢复服务;删除截图等待与共享封面假设。
- `apps/waterfall-wiki/tests/flat-note-migration.ts`:新增隔离数据库 schema 的真实迁移验证,覆盖旧图片、视频文件、同名标签关联及保留的视频任务。
- `apps/waterfall-wiki/tests/integration.test.ts`:改为验证平级标签复用、无代码绑定的文字笔记、普通视频加工资源引用及已移除的截图入口。
- `docs/monorepo.md`:更新存储、迁移、媒体引用与截图流程退役说明。
- `docs/flat-notes-stage.md`:本阶段逐文件变更说明。
## 验证
本地 TypeScript 检查通过,18 项单元测试通过,部署脚本语法与 diff 空白检查通过。完整 PostgreSQL/S3 迁移、视频加工、生产构建与上线验证由 Wiki CI 执行。Studio 和 Python 源码未修改。
-38
View File
@@ -1,38 +0,0 @@
# PROMPT monorepo
- `apps/waterfall-wiki`: existing Pages Router application, media library, PostgreSQL, object storage and video processing worker. `/wiki/Namespace:slug` has matching `/api/wiki/Namespace:slug` Markdown; `/api/wiki-index` discovers pages. Existing `/p/slug` has `/api/wiki-post/slug` and alternate metadata. Main/File/Category/Template/Draft/Help are public content types, not permission boundaries. Categories cross namespaces; template pages currently describe reusable structures rather than a transclusion engine.
- `apps/studio`: independent Next.js + TypeScript + Tailwind Pages Router. Add ideas in `src/content/ideas.ts`, open `/ideas/slug`, export Markdown or versioned JSON, or print to PDF. Add custom React pages under `src/pages` when a composition needs bespoke rendering.
- `apps/python`: install with `pip install -e apps/python`. Run `prompt-export idea.json --output ./output --font /path/to/cjk.ttf [--video]`. Generates 1080×1440 PNGs and an optional silent MP4 (4 seconds per slide), requiring FFmpeg. JSON describes standard slides; arbitrary React animations need a separate browser recording pipeline. Python Docker image includes CJK fonts and FFmpeg.
## Development
Node 24, pnpm 11.25.0, Python 3.12+. `pnpm install`; `pnpm dev:waterfall-wiki`; `pnpm dev:studio`. Do not use local preview for acceptance; see root AGENTS.md. Each JS application owns its frozen pnpm lockfile. Production Docker builds install each project independently.
## Releases
Three path-filtered Gitea workflows run on ces-control. Changes to one app trigger that app only. Workspace configuration changes intentionally verify both JS applications. Documentation changes do not deploy. Each workflow can be manually dispatched for recovery after a failed release. All app content, including Markdown, triggers its workflow.
Wiki keeps `/opt/prompt`, port 18131 and existing persistent volumes. Studio uses its own Compose project, `/opt/prompt-studio`, port 18134, and verifies its AI index before recording the release; port 18134 is bound to loopback so access goes through Wiki authentication. Python publishes `prompt-python:<sha>` and the local `latest` alias, used on demand rather than running an empty daemon. No Python network port is exposed. Root Dockerfile is Wiki's build entry; `apps/waterfall-wiki/Dockerfile` mirrors it for discovery.
CI uses root build context and application-scoped COPY instructions. Wiki runs its existing Docker integration suite before deploying. The former Web-only release path is retired because its source-copy and image assumptions predated the monorepo. No `down -v` is used in production.
## Explore 页面与轻量图片
首页 `/` 与分类 `/categories` 统一浏览;内容固定地址 `/explore/<id>`。文档 ID 持久保存在 `apps/waterfall-wiki/src/content/page-ids.json`,改标题或位置时保留 ID;数据库素材使用原有 UUID。旧 `/skills/...`、`/p/...` 和 `/wiki/...` 网页跳转到内容地址,媒体与纯文本 API 保持兼容;Wiki 不再提供截图画布与截图任务。`?agent_mode=True`(大小写不敏感)在相同地址返回 `text/plain`,保留全部正文与媒体链接。
`/api/preview` 只接受本站静态栅格图或媒体 ID,限制四档尺寸,输出 WebP:列表目标最多 100 KB、详情目标最多 220 KB。原图按需下载。服务端预览使用并发限制、请求合并、磁盘缓存和 ETag;缓存数量有限并定期清理。SVG 图标不经过栅格化。
Studio 部署到同一 Docker 网络,通过 `http://8.211.154.134:18131/studio` 访问,不依赖额外公网端口。直连端口 `127.0.0.1:18134/studio` 仅服务器本机可用;公网访问统一经过 Wiki 登录保护。
Docker 在单独的依赖下载层执行 `pnpm fetch`,再离线安装。源码变化复用依赖层,包脚本变化复用已下载的包。CI 不清理 Docker 缓存,不使用 `--no-cache`。
## 扁平标签与资源引用
`posts` 保留稳定 UUID、兼容 slug、标题、description、类型、封面资源 ID 与时间;移除代码页绑定 `page_key`。`tags` 为全局唯一名称,不含 `parent_id`,输入 `#标签` 并回车可创建或复用;`post_tags` 和 `asset_tags` 仍是多对多关联。静态 Wiki 页面目前仍使用代码内容,发布步骤将其可见标签同步到标签表。
所有文件统一进入 `assets`。视频加工结果通过 `source_asset_id` 和 `derivation` 记录来源,并以 `post_assets` 的 `silent_video`、`audio_track`、`poster` 角色供笔记引用;它们可以像其他资源一样复用。旧 `?variant=` 媒体地址继续读取相应普通资源。保留 `media_jobs` 用于异步处理和失败重试,保留 `contribution_events`,不再使用 `asset_variants`、`page_snapshots`、`render_jobs`。已有截图转换成普通图片引用后保留。创作站与 Python 导出功能独立运行。
部署在停止 Wiki 写入后备份数据库,再运行迁移和启动新版;失败时使用同一备份恢复旧版所需的数据库结构。对象文件和持久卷保留。
内部应用名统一为 waterfall-wiki,网站品牌为 PROMPT。Compose 业务服务为 waterfall-wiki / waterfall-wiki-worker,镜像参数为 WATERFALL_WIKI_IMAGE / WATERFALL_WIKI_TEST_IMAGE;历史 prompt 项目与持久卷保留。系统标签为固定文档入口/参考图,普通标签可通过 # 新建,详见根 README。
-28
View File
@@ -1,28 +0,0 @@
# 笔记详情编辑与 Markdown 修复
本阶段修复列表显示,详情底栏改为复制网页链接、复制纯文本链接、编辑。编辑支持标题、描述、Markdown 正文和 #标签;保存后同步预览和 AI 纯文本。代码中的 Wiki 文档同样可编辑,保存内容存入数据库,媒体与唯一地址保留。
## 逐文件说明
- `apps/waterfall-wiki/package.json`:固定引入 react-markdown、remark-gfm,并将新的渲染测试加入测试命令。
- `apps/waterfall-wiki/pnpm-lock.yaml`:锁定 Markdown 渲染依赖及传递依赖,支持 CI 冻结安装。
- `apps/waterfall-wiki/db/005_note_editing.sql`:新增代码文档编辑记录与标签关联表,为数据库笔记新增手动编辑标记,保证内容可持久保存。
- `apps/waterfall-wiki/src/components/NoteMarkdown.tsx`:新增标准 Markdown 渲染,支持嵌套列表、编号、任务清单、表格、代码块;保留轻量链接样式,图片引用显示为链接,不执行原始 HTML。
- `apps/waterfall-wiki/src/components/NoteEditor.tsx`:新增详情内编辑表单,支持读取最新内容、修改标题/描述/正文、#标签、预览、取消、保存与失败提示。
- `apps/waterfall-wiki/src/components/ExploreDetail.tsx`:接入标准渲染和编辑表单;移除原文件入口,提供两种复制链接;调整编辑中的方向键、焦点循环和遮罩交互。
- `apps/waterfall-wiki/src/components/TagInput.tsx`:通知父表单标签创建状态,避免标签请求尚未结束就保存笔记。
- `apps/waterfall-wiki/src/lib/note-edits.ts`:新增读取代码文档修改、内容版本校验和事务保存;共享文本采用新资源引用,不改动其他笔记使用的文本。
- `apps/waterfall-wiki/src/lib/explore.ts`:详情与列表合并已保存的代码文档修改,提供可编辑正文和版本标识,保留自动生成的媒体资源链接。
- `apps/waterfall-wiki/src/lib/library.ts`:支持在同一事务连接中读取笔记和标签;保留清空正文后仍存在的文字笔记。
- `apps/waterfall-wiki/src/lib/publish-learning-series.ts`:后续部署发布内容时保留用户手动编辑过的笔记,避免覆盖正文和标签。
- `apps/waterfall-wiki/src/pages/api/notes/[id].ts`:新增读取、保存笔记接口,校验来源、字段长度和并发版本;旧版本写入返回 409。
- `apps/waterfall-wiki/src/pages/api/wiki-index.ts`:AI 索引采用编辑后的标题。
- `apps/waterfall-wiki/src/pages/explore/[id].tsx`:详情背景使用最新预览,网页与纯文本读取同一份已保存内容。
- `apps/waterfall-wiki/src/styles/globals.css`:恢复列表标记、缩进和嵌套层级,增加表格、引用、代码、编辑表单和预览样式。
- `apps/waterfall-wiki/tests/note-markdown.test.tsx`:新增列表、编号、任务清单、表格、代码、链接与 HTML 安全渲染测试。
- `apps/waterfall-wiki/tests/integration.test.ts`:新增代码文档与媒体笔记保存、#标签关联、并发冲突、共享文本保护、手动内容发布保护及两个复制入口的验证。
- `docs/note-editor-stage.md`:本阶段逐文件说明与验证记录。
## 验证
本地 TypeScript 检查及 22 项单元测试通过;完整构建、数据库迁移、在线编辑与媒体保留测试由 Wiki CI 执行。仅 Wiki 项目及其依赖发生变化,Studio、Python 不需要重建。
-21
View File
@@ -1,21 +0,0 @@
# 笔记预览更新
所有笔记保持平级,通过标签和链接关联。没有入口优先、父子或附属文档关系,现有 ID 不变。
## 逐文件说明
- `apps/waterfall-wiki/src/components/ExploreFeed.tsx`:卡片展示封面、标题、description 和可点击标签;去掉头像与爱心;多图在封面右上角显示真实图数。
- `apps/waterfall-wiki/src/components/ExploreDetail.tsx`:移除 PROMPT 作者栏,在标题下展示 description、标签;切换独立笔记时重置图序和复制状态。
- `apps/waterfall-wiki/src/styles/globals.css`:增加描述截断、标签和图数角标样式,调整去作者栏后的详情间距。
- `apps/waterfall-wiki/src/content/note-descriptions.ts`:为每篇现有指导笔记编写独立的简短 description。
- `apps/waterfall-wiki/src/lib/explore.ts`:统一 description 和 imageCount;保留所有去重后的图片;图文按真实截图数量统计,纯文本返回 description。
- `apps/waterfall-wiki/src/lib/library.ts`:读取笔记实际截图数量,避免把共用封面误计为图文页数。
- `apps/waterfall-wiki/src/lib/model.ts`:补充 description 和截图计数字段类型。
- `apps/waterfall-wiki/db/003_note_descriptions.sql`:独立存储 description,为现有记录从说明文字回填摘要,原正文保留,迁移在事务内执行并记录版本。
- `apps/waterfall-wiki/src/lib/write.ts`:创建笔记 API 支持保存独立 description,标签机制保持可用。
- `apps/waterfall-wiki/src/pages/api/upload.ts`:上传的说明同步保存为笔记 description,完整文字保留。
- `apps/waterfall-wiki/src/lib/publish-learning-series.ts`:发布图文时使用各自副标题作为 description。
- `apps/waterfall-wiki/src/pages/index.tsx`、`apps/waterfall-wiki/src/pages/categories.tsx`:搜索与降级展示使用独立 description。
- `apps/waterfall-wiki/tests/explore.test.ts`:检查每篇笔记的 description、独立地址、去重图片与准确计数。
- `apps/waterfall-wiki/tests/integration.test.ts`:检查 description 的真实存储,以及八页图文在列表中的实际计数。
- `docs/note-preview-stage.md`:记录本次行为与逐文件改动。
-27
View File
@@ -1,27 +0,0 @@
# Infinite canvas rebuild
The previous workspace displays node bodies but keeps editing in a fixed inspector. Header dragging exists in source, but the user's observed failure has not yet been reproduced in a browser. Do not claim otherwise.
References: https://docs.comfy.org/interface/overview (node canvas, parameters, canvas navigation); https://www.runninghub.cn/runninghub-api-doc-en/ (workflow API requires a real connected service). Image searches covered ComfyUI and RunningHub workspace layouts.
Implementation plan:
1. Keep document coordinates independent from viewport translation and scale. Scale around the pointer, or viewport center for toolbar buttons.
2. Put usable text/prompt editors and image actions inside movable nodes. Header is an explicit drag handle; bottom corner resizes. Inputs never initiate gestures.
3. Store width/height and viewport alongside the existing v1 document; preserve old drafts and JSON imports. Links follow actual node dimensions.
4. Add duplicate and gesture-level undo/redo, with keyboard shortcuts excluded from form fields.
5. Browser acceptance must move two nodes before and after zoom, edit without moving, resize, check connections, undo/redo, pan, and reload persistence. Existing smoke test is insufficient.
Constraints: repository AGENTS requires server-only visual acceptance. Production redirects unauthenticated requests to /login. CI deploys only main; this branch must not merge or deploy without explicit authorization. Therefore a ready implementation alone is not completed visual acceptance.
Current checks: TypeScript noEmit (without next typegen/build) passed. Existing 13 unit tests passed; these do not validate canvas gestures. Browser script syntax and git diff checks passed. Browser acceptance and build have NOT run for this revision. Server unauthenticated HEAD returns 307 to /login?next=%2Fstudio%2Finfinite_canvas; in-app browser creation timed out. Waiting for user choice of permitted isolated acceptance environment before marking ready.
## Final layout and acceptance
User explicitly authorized temporary local runtime acceptance in this chat, overriding the server-only rule for this revision. A subsequent request requires the whole screen to be the dotted canvas. All reserved header/sidebar layout has been removed; compact floating chrome remains, and properties open on demand. Grid spacing adapts at low zoom to keep dots legible.
Browser acceptance ran in Chrome at 1600x1100 and 390x844. Passed: actual world-space movement of two nodes at two scales; editing without movement; resizing; gesture undo/redo; SVG connection start aligned to node geometry after resizing and panning; refresh document and viewport restoration; pointer-anchored Ctrl+wheel zoom; create/duplicate/delete/undo/redo; viewport equals window bounds and no horizontal mobile overflow. Production webpack compilation passed. Isolated-worktree dependency symlinks caused standalone tracing warnings (28 files outside tracing root), so deployment package completeness is not claimed. Local account-session request returns 404 because the shared account service runs in the full site; production authentication was not changed or validated here. Model generation remains explicitly unavailable.
Evidence screenshots are retained as intentional review deliverables under docs/evidence/canvas-rebuild/, not temporary output. Local server, dependency links and generated build/cache output are removed after acceptance. PR targets main for manual user merge; no deployment performed.
## Theme and unobstructed canvas follow-up
Added persistent light/dark themes covering the grid, cards, input fields, floating chrome and connection lines. Removed the left tool strip and the inspector. The tool strip is now a centered bottom dock; zoom/history floats at top right. Clicking empty canvas opens add actions; node ellipsis or right-click opens copy/delete/connect actions near the pointer. Escape or clicking elsewhere dismisses the menu. Node editors remain inline. Browser checks cover dock placement, theme persistence and contextual CRUD in addition to the existing gesture suite. TypeScript, 13 canvas-branch tests and webpack compilation passed; 19 S3-branch tests passed separately. User explicitly authorized merging PR #23 and #24 in this follow-up. Shared account-service and standalone tracing limitations remain as noted above.
-23
View File
@@ -1,23 +0,0 @@
# Infinite canvas plan
Scope: only /studio/infinite_canvas, its CSS module, browser interaction checks. Based on main f490543 in isolated worktree. No homepage, graphic, shared authentication or deployment changes.
## Research before implementation
- Baseline server screenshot captured 2026-10-29: existing server requires dynamic-code authentication before route access. Do not bypass it.
- Internet image search: AI infinite canvas ComfyUI RunningHub interface; reviewed workflow canvas and media card arrangements. No unlicensed product screenshots copied into product.
- https://jimeng.jianying.com — prompt-driven creation, image references, canvas.
- https://klingai.com — attempted primary source; robots denied access. No unsupported detailed claims.
- https://hailuoai.video — reference input and media-first exploration.
- https://www.liblib.art and https://www.liblib.tv — Liblib/LibTV reference targets; client-rendered content limits source inspection.
- https://docs.comfy.org/interface/overview — explicit node workflow and workspace regions.
- https://www.runninghub.cn — canvas-oriented creation and reusable workflows.
- https://github.com/bergside/awesome-design-skills — reference catalogue; apply deliberate typography, spacing, accessible controls and consistent hierarchy, without installing external skills.
## Design and behavior
Dark graphite creation desk with warm lime accent. Narrow left tool rail, large dotted canvas, editable right inspector and floating zoom controls. Start with a clearly labelled sample storyboard: brief → reference → shot plan. Native drag and zoom, selection, editable text/prompt cards, image upload, visible links, add/delete, undo/redo, fit view. Persist bounded browser-local drafts and export/import portable JSON. Images remain local. No simulated generation; generation cards explicitly say model service is not connected. Account link uses existing /account and GET /api/account/session contract.
## Validation
Local TypeScript and existing tests; local build explicitly authorized for this task. Browser checks for desktop/mobile, creation, drag, undo, reload, JSON export and disconnected AI notice. Clean owned screenshots, build directories and temporary dependency links before delivery. Push branch and open PR against main; no merge or deployment.
## Results
TypeScript passed; existing 10 tests passed. Project-local Next CLI webpack build passed. Default Turbopack cannot resolve dependencies outside isolated worktree; webpack standalone tracing warns about the temporary dependency symlinks, so deployment artifact completeness is not claimed. Browser smoke passed on desktop and mobile. No deployment performed.
-159
View File
@@ -1,159 +0,0 @@
# 本阶段逐文件变更说明
- `.dockerignore`:更新 monorepo 工作区、部署构建、忽略规则或使用说明。
- `.gitea/workflows/ci.yml`:移除全仓统一触发的旧工作流。
- `.gitea/workflows/python.yml`:按项目路径拆分 CI/CD,独立检查与发布。
- `.gitea/workflows/studio.yml`:按项目路径拆分 CI/CD,独立检查与发布。
- `.gitea/workflows/waterfall-wiki.yml`:按项目路径拆分 CI/CD,独立检查与发布。
- `.gitignore`:更新 monorepo 工作区、部署构建、忽略规则或使用说明。
- `Dockerfile`:更新 monorepo 工作区、部署构建、忽略规则或使用说明。
- `README.md`:更新 monorepo 工作区、部署构建、忽略规则或使用说明。
- `apps/python/Dockerfile`:新增 Python 内容包校验、图文/视频导出及配套安装、镜像或测试文件。
- `apps/python/pyproject.toml`:新增 Python 内容包校验、图文/视频导出及配套安装、镜像或测试文件。
- `apps/python/src/prompt_tools/__init__.py`:新增 Python 内容包校验、图文/视频导出及配套安装、镜像或测试文件。
- `apps/python/src/prompt_tools/export.py`:新增 Python 内容包校验、图文/视频导出及配套安装、镜像或测试文件。
- `apps/python/tests/test_export.py`:新增 Python 内容包校验、图文/视频导出及配套安装、镜像或测试文件。
- `apps/studio/Dockerfile`:新增创作站的独立依赖、类型配置或生产构建配置。
- `apps/studio/next-env.d.ts`:从 `next-env.d.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/studio/next.config.ts`:新增创作站的独立依赖、类型配置或生产构建配置。
- `apps/studio/package.json`:新增创作站的独立依赖、类型配置或生产构建配置。
- `apps/studio/pnpm-lock.yaml`:新增创作站的独立依赖、类型配置或生产构建配置。
- `apps/studio/postcss.config.mjs`:从 `postcss.config.mjs` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/studio/src/content/ideas.ts`:新增创作站的页面、AI 索引或内容导出接口。
- `apps/studio/src/pages/_app.tsx`:新增创作站的页面、AI 索引或内容导出接口。
- `apps/studio/src/pages/api/export/[slug].ts`:新增创作站的页面、AI 索引或内容导出接口。
- `apps/studio/src/pages/api/index.ts`:新增创作站的页面、AI 索引或内容导出接口。
- `apps/studio/src/pages/ideas/[slug].tsx`:新增创作站的页面、AI 索引或内容导出接口。
- `apps/studio/src/pages/index.tsx`:新增创作站的页面、AI 索引或内容导出接口。
- `apps/studio/src/styles/globals.css`:新增创作站的页面、AI 索引或内容导出接口。
- `apps/studio/tsconfig.json`:从 `tsconfig.json` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/.env.example`:从 `.env.example` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/Dockerfile`:Wiki 名字空间、AI 正文、发现页或配套依赖与验证配置。
- `apps/waterfall-wiki/db/001_library.sql`:从 `db/001_library.sql` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/db/002_page_snapshots.sql`:从 `db/002_page_snapshots.sql` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/next-env.d.ts`:Wiki 名字空间、AI 正文、发现页或配套依赖与验证配置。
- `apps/waterfall-wiki/next.config.ts`:从 `next.config.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/package.json`:Wiki 名字空间、AI 正文、发现页或配套依赖与验证配置。
- `apps/waterfall-wiki/pnpm-lock.yaml`:Wiki 名字空间、AI 正文、发现页或配套依赖与验证配置。
- `apps/waterfall-wiki/postcss.config.mjs`:Wiki 名字空间、AI 正文、发现页或配套依赖与验证配置。
- `apps/waterfall-wiki/public/brand-mark.svg`:从 `public/brand-mark.svg` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/public/learning-skills/cover.png`:从 `public/learning-skills/cover.png` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/public/learning-skills/cover.svg`:从 `public/learning-skills/cover.svg` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/public/llms.txt`:从 `public/llms.txt` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/public/skills/shadow-puppet/dancer-example.png`:从 `public/skills/shadow-puppet/dancer-example.png` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/public/skills/shadow-puppet/egret-example.png`:从 `public/skills/shadow-puppet/egret-example.png` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/public/skills/street-people/reference.png`:从 `public/skills/street-people/reference.png` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/public/skills/street-people/sample.png`:从 `public/skills/street-people/sample.png` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/scripts/bootstrap.ts`:从 `scripts/bootstrap.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/scripts/container-health.mjs`:从 `scripts/container-health.mjs` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/scripts/import-character-packs.mjs`:从 `scripts/import-character-packs.mjs` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/scripts/prepare-standalone.mjs`:从 `scripts/prepare-standalone.mjs` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/scripts/publish-learning-series.ts`:从 `scripts/publish-learning-series.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/scripts/smoke.mjs`:从 `scripts/smoke.mjs` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/scripts/wait-snapshots.mjs`:从 `scripts/wait-snapshots.mjs` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/seed/characters/extraction.json`:从 `seed/characters/extraction.json` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/seed/characters/original/01-florist.png`:从 `seed/characters/original/01-florist.png` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/seed/characters/original/02-reader.png`:从 `seed/characters/original/02-reader.png` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/seed/characters/original/03-cyclist.png`:从 `seed/characters/original/03-cyclist.png` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/seed/characters/original/04-coffee.png`:从 `seed/characters/original/04-coffee.png` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/seed/characters/packs.json`:从 `seed/characters/packs.json` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/seed/characters/prompts.json`:从 `seed/characters/prompts.json` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/seed/characters/reference/01-basket.png`:从 `seed/characters/reference/01-basket.png` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/seed/characters/reference/02-phone.png`:从 `seed/characters/reference/02-phone.png` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/seed/characters/reference/03-coffee.png`:从 `seed/characters/reference/03-coffee.png` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/seed/characters/reference/04-red-coat.png`:从 `seed/characters/reference/04-red-coat.png` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/seed/characters/reference/05-blue-dogs.png`:从 `seed/characters/reference/05-blue-dogs.png` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/seed/characters/reference/06-dark-dog.png`:从 `seed/characters/reference/06-dark-dog.png` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/seed/characters/reference/07-pockets.png`:从 `seed/characters/reference/07-pockets.png` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/seed/characters/reference/08-blue-board.png`:从 `seed/characters/reference/08-blue-board.png` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/seed/characters/reference/09-scarf-dog.png`:从 `seed/characters/reference/09-scarf-dog.png` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/seed/characters/reference/10-elder.png`:从 `seed/characters/reference/10-elder.png` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/seed/characters/reference/11-long-coat.png`:从 `seed/characters/reference/11-long-coat.png` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/seed/characters/reference/12-trolley.png`:从 `seed/characters/reference/12-trolley.png` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/seed/characters/reference/13-bucket.png`:从 `seed/characters/reference/13-bucket.png` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/seed/characters/reference/14-curly.png`:从 `seed/characters/reference/14-curly.png` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/seed/characters/reference/15-red-walk.png`:从 `seed/characters/reference/15-red-walk.png` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/components/ArticleGallery.tsx`:从 `src/components/ArticleGallery.tsx` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/components/Feed.tsx`:从 `src/components/Feed.tsx` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/components/GuidanceIndex.tsx`:从 `src/components/GuidanceIndex.tsx` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/components/Shell.tsx`:从 `src/components/Shell.tsx` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/components/SkillCard.tsx`:从 `src/components/SkillCard.tsx` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/components/SkillDocs.tsx`:从 `src/components/SkillDocs.tsx` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/content/learning-skills/Series.tsx`:从 `src/content/learning-skills/Series.tsx` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/content/learning-skills/cover.ts`:从 `src/content/learning-skills/cover.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/content/learning-skills/data.ts`:从 `src/content/learning-skills/data.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/content/registry.tsx`:从 `src/content/registry.tsx` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/content/skills/catalog.ts`:从 `src/content/skills/catalog.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/content/skills/guidance.ts`:从 `src/content/skills/guidance.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/content/skills/shadow-puppet.ts`:从 `src/content/skills/shadow-puppet.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/content/wiki.ts`:Wiki 名字空间、AI 正文、发现页或配套依赖与验证配置。
- `apps/waterfall-wiki/src/lib/api.ts`:从 `src/lib/api.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/lib/character-image.ts`:从 `src/lib/character-image.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/lib/db.ts`:从 `src/lib/db.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/lib/health.ts`:从 `src/lib/health.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/lib/library.ts`:从 `src/lib/library.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/lib/markdown-response.ts`:从 `src/lib/markdown-response.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/lib/model.ts`:从 `src/lib/model.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/lib/probe.ts`:从 `src/lib/probe.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/lib/publish-learning-series.ts`:从 `src/lib/publish-learning-series.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/lib/snapshots.ts`:从 `src/lib/snapshots.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/lib/storage.ts`:从 `src/lib/storage.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/lib/street-people.ts`:从 `src/lib/street-people.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/lib/write.ts`:从 `src/lib/write.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/[section]/[[...taxonomy]].tsx`:从 `src/pages/[section]/[[...taxonomy]].tsx` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/_app.tsx`:从 `src/pages/_app.tsx` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/api/agent-index.ts`:从 `src/pages/api/agent-index.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/api/feed.ts`:从 `src/pages/api/feed.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/api/guidance/[[...path]].ts`:从 `src/pages/api/guidance/[[...path]].ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/api/health.ts`:从 `src/pages/api/health.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/api/media/[id].ts`:从 `src/pages/api/media/[id].ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/api/posts/[slug]/snapshots.ts`:从 `src/pages/api/posts/[slug]/snapshots.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/api/posts/index.ts`:从 `src/pages/api/posts/index.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/api/ready.ts`:从 `src/pages/api/ready.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/api/skill-docs/[skill]/[doc].ts`:从 `src/pages/api/skill-docs/[skill]/[doc].ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/api/skill-docs/street-people/[doc].ts`:从 `src/pages/api/skill-docs/street-people/[doc].ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/api/skills/street-people.ts`:从 `src/pages/api/skills/street-people.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/api/tags.ts`:从 `src/pages/api/tags.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/api/upload.ts`:从 `src/pages/api/upload.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/api/wiki-index.ts`:Wiki 名字空间、AI 正文、发现页或配套依赖与验证配置。
- `apps/waterfall-wiki/src/pages/api/wiki-post/[slug].ts`:Wiki 名字空间、AI 正文、发现页或配套依赖与验证配置。
- `apps/waterfall-wiki/src/pages/api/wiki/[key].ts`:Wiki 名字空间、AI 正文、发现页或配套依赖与验证配置。
- `apps/waterfall-wiki/src/pages/index.tsx`:Wiki 名字空间、AI 正文、发现页或配套依赖与验证配置。
- `apps/waterfall-wiki/src/pages/library/import.tsx`:从 `src/pages/library/import.tsx` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/p/[slug].tsx`:从 `src/pages/p/[slug].tsx` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/p/[slug]/pages/[page].tsx`:从 `src/pages/p/[slug]/pages/[page].tsx` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/skills/[[...path]].tsx`:从 `src/pages/skills/[[...path]].tsx` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/tools/doodle.tsx`:从 `src/pages/tools/doodle.tsx` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/tools/skills/[skill]/[[...doc]].tsx`:从 `src/pages/tools/skills/[skill]/[[...doc]].tsx` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/tools/skills/index.tsx`:从 `src/pages/tools/skills/index.tsx` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/tools/skills/street-people.tsx`:从 `src/pages/tools/skills/street-people.tsx` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/tools/skills/street-people/[doc].tsx`:从 `src/pages/tools/skills/street-people/[doc].tsx` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/pages/wiki/[key].tsx`:Wiki 名字空间、AI 正文、发现页或配套依赖与验证配置。
- `apps/waterfall-wiki/src/styles/globals.css`:从 `src/styles/globals.css` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/styles/learning-series.css`:从 `src/styles/learning-series.css` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/styles/skill-docs.css`:从 `src/styles/skill-docs.css` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/src/worker.ts`:从 `src/worker.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/tests/health.test.ts`:从 `tests/health.test.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/tests/integration.test.ts`:从 `tests/integration.test.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/tests/learning-series.test.ts`:从 `tests/learning-series.test.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/tests/model.test.ts`:从 `tests/model.test.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/tests/skill-docs.test.ts`:从 `tests/skill-docs.test.ts` 迁移到 Wiki 项目,保留原功能并隔离构建范围。
- `apps/waterfall-wiki/tests/wiki.test.ts`:Wiki 名字空间、AI 正文、发现页或配套依赖与验证配置。
- `apps/waterfall-wiki/tsconfig.json`:Wiki 名字空间、AI 正文、发现页或配套依赖与验证配置。
- `docs/monorepo.md`:更新 monorepo 工作区、部署构建、忽略规则或使用说明。
- `package-lock.json`:移除旧目录入口或不再适用的 Web-only 发布逻辑。
- `package.json`:更新 monorepo 工作区、部署构建、忽略规则或使用说明。
- `pnpm-lock.yaml`:更新 monorepo 工作区、部署构建、忽略规则或使用说明。
- `pnpm-workspace.yaml`:更新 monorepo 工作区、部署构建、忽略规则或使用说明。
- `scripts/deploy-python.sh`:更新 monorepo 工作区、部署构建、忽略规则或使用说明。
- `scripts/deploy-studio.sh`:更新 monorepo 工作区、部署构建、忽略规则或使用说明。
- `scripts/deploy-web.sh`:移除旧目录入口或不再适用的 Web-only 发布逻辑。
- `scripts/release-mode.sh`:移除旧目录入口或不再适用的 Web-only 发布逻辑。
- `src/pages/index.tsx`:移除旧目录入口或不再适用的 Web-only 发布逻辑。
- `tests/release-mode.sh`:移除旧目录入口或不再适用的 Web-only 发布逻辑。
后续校正:`.gitea/workflows/waterfall-wiki.yml`、`studio.yml`、`python.yml` 将根目录部署脚本也精确归属到对应项目,防止修改 Studio/Python 部署脚本时错误运行 Wiki CI。
后续构建修复:`Dockerfile`、`apps/waterfall-wiki/Dockerfile`、`apps/studio/Dockerfile` 将 pnpm 下载超时提高到 300 秒,并发限制为 8,处理服务器下载 Next.js / SWC 大文件超时的问题。
构建许可修复:`pnpm-workspace.yaml` 改用 pnpm 11 的 `allowBuilds`,明确允许 esbuild、sharp 安装脚本;`Dockerfile`、`apps/waterfall-wiki/Dockerfile`、`apps/studio/Dockerfile` 在依赖安装层读取同一许可策略,解决独立镜像中缺失许可导致构建失败的问题。
-31
View File
@@ -1,31 +0,0 @@
# Studio Graphic 实施计划
## 研究与范围
- 改造前证据:ProjectMedia/studio-editor-workspace-qa.png(2026-10-27);本次在线截图因内置浏览器超时未成功,不当作最新截图。
- https://github.com/bergside/awesome-design-skills :参考 token、组件规范、可访问性与质量检查组织方法;其 Stitch 风格不等同于 Google Stitch 产品界面。
- https://codelabs.developers.google.com/design-to-code-with-antigravity-stitch :官方界面图参考。
- https://moda.app/blog/google-stitch-review :图片搜索找到的多画板与设计系统截图,仅作视觉参考。
- Figma 的三栏编辑器布局:图层、画布、属性。采用白色工具栏、冷灰点阵底、蓝紫选中态、集中式底部工具条。
## 五个交付阶段
1. 阅读现有代码、引用 chat,独立分支,协调 infinite_canvas。
2. 收集参考与截图、明确设计与复用边界,记录计划。
3. /studio/graphic 实现可编辑画板、图层、历史、保存、导出与同站邮箱账户。
4. 本地类型、行为、构建和视觉检查;记录真实结果及限制。
5. 检查完整差异,提交、推送、创建 PR;清理临时产物,等待人工合并。
## 清理边界
Studio 首页不再展示旧 27 套项目。保留旧路由与数据库,避免破坏现有链接与用户作品;不删除其他 chat 文件。新工作台默认空白,预设只能由用户显式插入。浏览器草稿明确标识本机保存,邮箱账户使用已有 /api/account/* 服务,避免另建身份系统。未配置模型时不提供虚假 AI 生成。
## 分工
Infinite Canvas 独立 chat 01a18775-33e3-7770-ba63-64b4a6a00c89,仅负责 /studio/infinite_canvas 与专属文件。两分支完成后再评估集成,不自动合并 main。
## 验证记录
- 用户已确认只清理入口、保留历史数据。
- 13 项单元测试和 TypeScript 通过。webpack 生产构建通过;默认 Turbopack 被本地 CSS 工作进程端口权限阻止。
- 自动浏览器检查通过:新增文字/矩形、文字修改、撤销/重做、刷新恢复、SVG 下载、账户弹窗、390px 无横向溢出。截图布局已检查,交付前清理截图。
- 账户 session 使用访客 fixture;真实邮件注册登录未在本次验证。独立 Studio 本地进程没有账户后端,部署后复用同域 /api/account 服务。
- 单画板与本机草稿,无云端设计同步、协作或 AI 生成。完整属性编辑以桌面为主。
- Infinite Canvas 独立 PR #19 已由外部操作合入 main;本分支交付前同步该主线,检查共存。
- standalone 兼容检查通过:27 套历史页面、保存作品读取、旧重定向与渲染 API;测试脚本支持本地 monorepo standalone 路径。
+59 -13
View File
@@ -8,54 +8,100 @@ const assert=require('node:assert/strict');
const now=Math.floor(Date.now()/1000),part=o=>Buffer.from(JSON.stringify(o)).toString('base64url');
const content=part({alg:'HS256',typ:'JWT'})+'.'+part({iss:'prompt',aud:'prompt-web',sub:'shared',iat:now,exp:now+1200,jti:randomBytes(16).toString('hex')});
const token=content+'.'+createHmac('sha256',Buffer.from(config.jwtKey,'hex')).update(content).digest('base64url');
const {navigateBrandDocument,visitBrowserDocument}=await import('../apps/waterfall-wiki/tests/brand-navigation.mjs');
const browser=await chromium.launch({executablePath:'/usr/bin/chromium',headless:true,args:['--no-sandbox','--disable-dev-shm-usage']});
const context=await browser.newContext({viewport:{width:1100,height:1000},deviceScaleFactor:1});
await context.route('**/*',async route=>{const u=new URL(route.request().url());if(u.origin===origin)return route.continue({headers:{...route.request().headers(),Authorization:'Bearer '+token}});if(['data:','blob:'].includes(u.protocol))return route.continue();return route.abort()});
const page=await context.newPage(),errors=[],images=[];
page.on('pageerror',error=>errors.push({url:page.url(),message:error.message}));
page.setDefaultTimeout(60000);
page.on('pageerror',error=>errors.push({url:page.url(),message:error.message,stack:error.stack}));
page.on('response',async response=>{if(response.request().resourceType()==='image'){const url=new URL(response.url());images.push({path:url.pathname+url.search,status:response.status(),type:response.headers()['content-type'],bytes:(await response.body().catch(()=>Buffer.alloc(0))).length})}});
// Wait for the actual document and application, not an idle background network.
// Shared navigation recovery is limited to safe GETs; assertions are never retried.
const visitDocument=async(url,interactive=false,reload=false)=>{
if(interactive)await visitBrowserDocument(page,url,reload);
else await navigateBrandDocument(timeout=>page.goto(url,{waitUntil:'domcontentloaded',timeout}),url);
await page.waitForFunction(()=>Array.from(document.images).every(img=>img.complete&&img.naturalWidth>0));
console.log('Production document ready:',new URL(url).pathname);
};
// The retired catalogue is retained for existing API consumers, not a release UI gate.
// Explicit legacy/diagnostic runs still exercise its full overflow assertions.
const checkLegacy=process.argv.includes('--legacy-layouts')||process.argv.includes('--diagnose');
const metrics=[];
for(let i=1;i<=27&&checkLegacy;i++){
const id='ref-'+String(i).padStart(2,'0');await page.goto(base+'/studio/layouts/'+id,{waitUntil:'networkidle'});await page.locator('article.native-layout').screenshot({path:dir+'/'+id+'.png',style:'.page-tools{visibility:hidden}'});
const id='ref-'+String(i).padStart(2,'0');await visitDocument(base+'/studio/layouts/'+id);await page.locator('article.native-layout').screenshot({path:dir+'/'+id+'.png',style:'.page-tools{visibility:hidden}'});
const m=await page.locator('article.native-layout').evaluate(el=>{
const overflow=[...el.querySelectorAll('.native-copy')].filter(e=>e.scrollHeight>e.clientHeight+2||e.scrollWidth>e.clientWidth+2);
return {id:el.dataset.layoutId,elements:el.querySelectorAll('[data-element]').length,width:el.clientWidth,height:el.clientHeight,overflow:overflow.map(e=>e.closest('[data-element]').dataset.element),overflowDetails:overflow.map(e=>{const style=getComputedStyle(e);return {id:e.closest('[data-element]').dataset.element,text:e.textContent,clientWidth:e.clientWidth,scrollWidth:e.scrollWidth,clientHeight:e.clientHeight,scrollHeight:e.scrollHeight,fontSize:style.fontSize,lineHeight:style.lineHeight,letterSpacing:style.letterSpacing,fontFamily:style.fontFamily,fontWeight:style.fontWeight,writingMode:style.writingMode}})};
});metrics.push(m);await writeFile(dir+'/metrics.json',JSON.stringify({metrics,images,errors},null,2));
}
if(checkLegacy&&!process.argv.includes('--diagnose'))assert.deepEqual(metrics.filter(m=>m.overflow.length),[],'Default copy must fit every native slot');
await page.goto(base+'/',{waitUntil:'networkidle'});await page.getByRole('heading',{name:/想法不该停在对话里/}).waitFor();await page.screenshot({path:dir+'/landing-desktop.png',fullPage:true});
await page.goto(base+'/graphic',{waitUntil:'networkidle'});
await visitDocument(base+'/',true);await page.getByRole('heading',{name:/想法不该停在对话里/}).waitFor();await page.screenshot({path:dir+'/landing-desktop.png',fullPage:true});
// Capture the complete editorial home at both narrow breakpoints on the deployed server.
await page.getByRole('heading',{name:/给好奇心一点空间/}).waitFor();
for(const [width,name] of [[390,'landing-mobile'],[320,'landing-mobile-compact']]){
await page.setViewportSize({width,height:844});
assert.ok(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+1),'Landing fits narrow screens');
const entry=await page.getByRole('navigation',{name:'主导航'}).getByRole('link',{name:/进入工作台/}).boundingBox();
assert.ok(entry&&entry.x>=0&&entry.x+entry.width<=width,'Landing workspace entry remains inside the viewport');
await page.screenshot({path:dir+'/'+name+'.png',fullPage:true});
}
// Verify the public account flow in this fresh context, without submitting credentials.
await page.setViewportSize({width:1128,height:959});
await visitDocument(base+'/account?next=/workspace',true);
await page.locator('button[data-theme-ready="true"]').waitFor();
await page.getByLabel('邮箱地址',{exact:true}).waitFor();
assert.equal(await page.locator('aside').count(),0,'Authentication must not include a workspace sidebar');
assert.equal(await page.getByRole('link',{name:'创建文档',exact:true}).count(),0);
assert.equal(await page.locator('.endoleap-brand').count(),1,'Only one brand belongs on the account page');
const accountSections=await page.locator('#account-content > div > section').evaluateAll(elements=>elements.map(el=>{const r=el.getBoundingClientRect();return {x:r.x,right:r.right,width:r.width}}));
assert.equal(accountSections.length,2);
assert.ok(accountSections[0].right<=accountSections[1].x,'Brand panel and credentials occupy separate columns');
const accountFits=async()=>assert.ok(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+1&&document.documentElement.scrollHeight<=innerHeight+1),'Account document fits both viewport axes');
const accountControlsFit=async()=>assert.ok(await page.locator('#account-content input, #account-content button[type="submit"]').evaluateAll(elements=>elements.every(el=>{const r=el.getBoundingClientRect();return r.left>=0&&r.right<=innerWidth&&r.top>=0&&r.bottom<=innerHeight})),'Account inputs and submit button remain visible, not merely clipped');
await accountFits();await accountControlsFit();
await page.screenshot({path:dir+'/account-desktop.png',fullPage:true});
await page.getByRole('button',{name:'创建账户',exact:true}).click();
await page.getByRole('heading',{name:'创建你的账户',exact:true}).waitFor();
await page.waitForFunction(()=>document.querySelector('#account-content').getAnimations({subtree:true}).every(animation=>animation.playState!=='running'));
await page.screenshot({path:dir+'/account-register.png',fullPage:true});
await page.getByRole('button',{name:'登录',exact:true}).click();
await page.waitForFunction(()=>document.querySelector('#account-content').getAnimations({subtree:true}).every(animation=>animation.playState!=='running'));
await page.setViewportSize({width:390,height:844});
await accountFits();await accountControlsFit();
await page.screenshot({path:dir+'/account-mobile.png',fullPage:true});
await page.setViewportSize({width:320,height:568});await accountFits();await accountControlsFit();
await page.screenshot({path:dir+'/account-mobile-compact.png',fullPage:true});
await page.setViewportSize({width:1100,height:1000});
await visitDocument(base+'/graphic',true);
assert.equal(new URL(page.url()).pathname,'/graphic');
await page.getByRole('button',{name:'添加文字',exact:true}).waitFor({state:'visible'});
assert.equal(await page.locator('.library-item').count(),0,'Old catalog is retired from the entry page');
await page.getByRole('button',{name:'添加文字',exact:true}).click();
await page.getByRole('textbox',{name:'文字内容',exact:true}).fill('Studio 线上验收');
await page.reload({waitUntil:'networkidle'});
await visitDocument(page.url(),true,true);
assert.ok(await page.evaluate(()=>JSON.parse(localStorage.getItem('studio.graphic.v1')).items.some(i=>i.text==='Studio 线上验收')));
await page.screenshot({path:dir+'/graphic-desktop.png',fullPage:true});
await page.goto(base+'/infinite_canvas',{waitUntil:'networkidle'});
await visitDocument(base+'/infinite_canvas',true);
assert.equal(new URL(page.url()).pathname,'/infinite_canvas');
await page.getByRole('button',{name:'添加笔记',exact:true}).waitFor({state:'visible'});
await page.screenshot({path:dir+'/infinite-canvas-desktop.png',fullPage:true});
const verify=JSON.parse(await readFile('/tmp/studio-library/verification.json','utf8'));
for(const d of verify.results){await page.goto(base+d.url,{waitUntil:'networkidle'});assert.equal(await page.locator('img').count(),1);const current=await page.locator('img').evaluate(img=>({src:img.currentSrc,complete:img.complete,width:img.naturalWidth}));assert.ok(current.complete&&current.width>0);assert.equal(new URL(current.src).pathname,'/api/preview');await page.locator('article.native-layout').screenshot({path:dir+'/'+d.layoutId+'-saved.png',style:'.page-tools{visibility:hidden}'});
for(const d of verify.results){await visitDocument(base+d.url);assert.equal(await page.locator('img').count(),1);const current=await page.locator('img').evaluate(img=>({src:img.currentSrc,complete:img.complete,width:img.naturalWidth}));assert.ok(current.complete&&current.width>0);assert.equal(new URL(current.src).pathname,'/api/preview');await page.locator('article.native-layout').screenshot({path:dir+'/'+d.layoutId+'-saved.png',style:'.page-tools{visibility:hidden}'});
assert.equal(new URL(page.url()).pathname,'/studio/template-layout');
assert.equal(await page.locator('button,input,textarea,select,[contenteditable],.page-tools,.workbench-top').count(),0);
await page.locator('.native-copy').first().dblclick();await page.locator('.native-copy').first().dispatchEvent('contextmenu');
assert.equal(await page.locator('button,input,textarea,select,[contenteditable],.workbench-top').count(),0);
const plain=await browser.newContext({viewport:{width:1100,height:1000},javaScriptEnabled:false});
await plain.route('**/*',async route=>{const u=new URL(route.request().url());if(u.origin===origin)return route.continue({headers:{...route.request().headers(),Authorization:'Bearer '+token}});return route.abort()});
const direct=await plain.newPage();await direct.goto(base+d.url,{waitUntil:'networkidle'});assert.equal(await direct.locator('article[data-design-id="'+d.id+'"]').count(),1);assert.ok((await direct.locator('article').innerText()).includes('API 验收'));await plain.close();
const direct=await plain.newPage();await navigateBrandDocument(timeout=>direct.goto(base+d.url,{waitUntil:'domcontentloaded',timeout}),base+d.url);assert.equal(await direct.locator('article[data-design-id="'+d.id+'"]').count(),1);assert.ok((await direct.locator('article').innerText()).includes('API 验收'));await plain.close();
}
for(const slug of ['learning-skills-template','layout-selection']){await page.goto(base+'/studio/ideas/'+slug,{waitUntil:'networkidle'});await page.screenshot({path:dir+'/tool-'+slug+'.png',fullPage:true})}
await page.setViewportSize({width:390,height:844});await page.goto(base+'/graphic',{waitUntil:'networkidle'});assert.ok(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth));await page.screenshot({path:dir+'/graphic-mobile.png',fullPage:true});
await page.goto(base+verify.results[0].url,{waitUntil:'networkidle'});await page.screenshot({path:dir+'/standard-mobile.png',fullPage:true});
await page.goto(base+'/categories?category='+encodeURIComponent('文档入口'),{waitUntil:'domcontentloaded',timeout:60000});await page.getByRole('navigation',{name:'系统标签分类',exact:true}).waitFor({state:'visible'});assert.equal(await page.locator('.discovery-card').count(),3);await page.waitForFunction(()=>Array.from(document.querySelectorAll('.discovery-card img')).every(img=>img.complete&&img.naturalWidth>0),null,{timeout:60000});await page.screenshot({path:dir+'/document-entries.png',fullPage:true});
for(const slug of ['learning-skills-template','layout-selection']){await visitDocument(base+'/studio/ideas/'+slug);await page.screenshot({path:dir+'/tool-'+slug+'.png',fullPage:true})}
await page.setViewportSize({width:390,height:844});await visitDocument(base+'/graphic',true);assert.ok(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth));await page.screenshot({path:dir+'/graphic-mobile.png',fullPage:true});
await visitDocument(base+verify.results[0].url);await page.screenshot({path:dir+'/standard-mobile.png',fullPage:true});
await visitDocument(base+'/categories?category='+encodeURIComponent('文档入口'),true);await page.getByRole('navigation',{name:'系统标签分类',exact:true}).waitFor({state:'visible'});assert.equal(await page.locator('.discovery-card').count(),3);await page.waitForFunction(()=>Array.from(document.querySelectorAll('.discovery-card img')).every(img=>img.complete&&img.naturalWidth>0),null,{timeout:60000});await page.screenshot({path:dir+'/document-entries.png',fullPage:true});
await writeFile(dir+'/metrics.json',JSON.stringify({metrics,images,errors},null,2));
assert.equal(images.filter(r=>new URL(r.path,base).pathname.startsWith('/api/media/')).length,0,'Display must never fetch originals');if(!process.argv.includes('--diagnose'))assert.equal(errors.length,0,JSON.stringify(errors));for(const image of images){if(/^\/(?:studio\/)?brand\/(?:logo-light|logo-dark|icon-dark)\.svg$/.test(new URL(image.path,base).pathname)){assert.equal(image.status,200);assert.match(image.type,/image\/svg\+xml/);continue;}assert.equal(new URL(image.path,base).pathname,'/api/preview');assert.equal(image.status,200);assert.equal(image.type,'image/webp');assert.ok(image.bytes>0&&image.bytes<=220000)}
await writeFile(dir+'/metrics.json',JSON.stringify({metrics,images,errors},null,2));await browser.close();
console.log(JSON.stringify({diagnostic:process.argv.includes('--diagnose'),legacyLayoutsChecked:checkLegacy,legacyPages:metrics.length,errors:errors.length,displayImages:images.length,originalImageRequests:0,overflow:metrics.filter(m=>m.overflow.length)}));
})().catch(e=>{console.error(e.message);process.exit(1)});
})().catch(e=>{console.error(e.stack||e.message);process.exit(1)});
@@ -7,7 +7,7 @@ import subprocess
import tempfile
import unittest
SCRIPT = Path(__file__).with_name('cleanup-integration.sh')
SCRIPT = Path(__file__).resolve().parents[1] / 'scripts/cleanup-integration.sh'
FAKE_DOCKER = '''#!/usr/bin/env python3
import json, os, sys
args = sys.argv[1:]
@@ -7,7 +7,7 @@ import subprocess
import tempfile
import unittest
SCRIPT = Path(__file__).with_name('cleanup-review-images.sh')
SCRIPT = Path(__file__).resolve().parents[1] / 'scripts/cleanup-review-images.sh'
SHA = 'a' * 40
FAKE_DOCKER = '''#!/usr/bin/env python3
import json, os, sys