feat(landing): 睿视 landing 由本仓统一管理——源码子目录化 + 四道门禁移植 + 契约路由
承接 ADR-0014 §4「第二等产品镜像起必须子目录化 + rewrites 前缀映射并回溯睿视」。
上一轮(2026-12-02)只搬了字节,源码落在 public/ 根命名空间;本轮把源码、门禁、
发布职责一并收进本仓,authority 侧退役对应产物。
源码与 URL 契约:
- public/novavis/{index.html,css,js,assets,images/logos} 一棵树自成一体
- index.html 引用保持站点级绝对路径(/css /js /assets /images/logos)不变。
因为同一份字节要服务两个落点:官网镜像 novalon.cn/novavis/,以及独立子域
novavis.p.novalon.cn/(页面在根路径)。改绝对路径会把子域首页变成 /novavis/
- 故用 4 条 prefix rewrite 把根命名空间映射进子目录,而非改写 HTML
四道门禁(从 authority 的四个 python 脚本移植为 Playwright,已并入 test:all):
- e2e/landing/{layout,motion,demo,a11y}.spec.ts + 独立 config(单引擎单 project 串行)
- layout:几何与焦点 / motion:js-grow 渐进生长与 reduced-motion 直达终态
- demo:首屏剧本四步 + 徽标一一对应 + 无 JS 降级四层真实可见性
- a11y:结构与全量对比度(同色无条件阻断)+ axe critical/serious=0
- 实测 13 passed / EXIT=0(1.4m)
补一个映射期暴露的真缺陷:landing 的 main.js 固定 POST /api/v1/contact 且只认
code===200,而本仓只有 /api/contact(formData + 必填 subject),镜像侧转化路径
一直 404。新增 src/app/api/v1/contact/route.ts 按 authority 契约响应(JSON +
{code:200}),而非改前端去适配本仓——改前端等于把适配成本转嫁给子域,且会让
两个落点的成功判据不一致。9 个单测覆盖校验、限流、上游失败不透传 5xx。
文档与配置同步:CLAUDE.md → AGENTS.md(单文档真源)、docs/landing.md、
docs/deployment.md §八、ADR-0014、qa-tracker §32、README 与 quality-gates 脚本表、
Jenkinsfile 落地「♿ 可访问性门禁」阶段的 landing 四道门禁、eslint 忽略
.next-dev-live 构建产物目录(未忽略时 eslint . 会扫出 21195 errors)。
门禁:tsc 0 / eslint 0 / jest app/api/v1 9/9 / test:landing 13 passed。
This commit was merged in pull request #70.
This commit is contained in:
1 parent
f20fc92dc3
commit
99eaa8c66a
38 files changed
+3904
-48
No files matched your search
+262
@@ -0,0 +1,262 @@
|
||||
# Landing(睿视 NovaVis 产品站)· 归属、URL 契约与门禁
|
||||
|
||||
> **一句话**:landing 的源码、门禁与发布职责都在**本仓**(2026-12-03 从 `novavis-authority`
|
||||
> 迁入)。`novavis-authority` 不再持有 landing 的任何字节。
|
||||
|
||||
---
|
||||
|
||||
## 1. 归属变更(2026-12-03)
|
||||
|
||||
| 项 | 迁移前 | 迁移后 |
|
||||
|---|---|---|
|
||||
| 源码 | `novavis-authority/landing/` | **本仓 `public/novavis/`** |
|
||||
| 四道门禁 | `novavis-authority/scripts/{verify-landing-layout,verify-landing-motion,landing-demo-verify,landing-audit}.py` | **本仓 `e2e/landing/*.spec.ts`**(`npm run test:landing`) |
|
||||
| 门禁在链里? | **否**(一直手动跑) | **是**(已并入 `npm run test:all` 与 Jenkinsfile) |
|
||||
| 发布 | authority `deploy-prod.sh` 阶段六 | 本仓 `scripts/deploy.sh`(官网镜像)+ 子域同步(见 §4) |
|
||||
| Docker 镜像 | authority `Dockerfile` 的 `COPY landing` | **已移除**;authority 镜像不含 landing |
|
||||
|
||||
**为什么迁**:landing 的内容演进与产品 UI 强耦合(仿真外壳要跟 desktop 改版),而 desktop 与官网
|
||||
都在本侧维护;留在 authority 会形成「改一次要跨两个仓、且四道门禁谁都不在链里」的双重失效。
|
||||
迁移同时消解了 authority 仓「一个 Java 后端仓里躺着一份前端静态站」的结构错位。
|
||||
|
||||
**为什么 URL 一个字不改**:同一份字节要服务两个落点(官网 `/novavis/` 与子域根路径
|
||||
`novavis.p.novalon.cn/`),见 §2。
|
||||
|
||||
---
|
||||
|
||||
## 2. 目录结构与 URL 契约
|
||||
|
||||
### 2.1 物理布局
|
||||
|
||||
```
|
||||
public/novavis/
|
||||
├── index.html
|
||||
├── css/style.css
|
||||
├── js/main.js
|
||||
├── assets/{favicon.png,novavis-logo-icon.png}
|
||||
└── images/logos/{apple.svg,windows.svg,uos-symbol.svg,kylin.png}
|
||||
```
|
||||
|
||||
**一棵树自成一体**:landing 的全部资源都在 `public/novavis/` 下,不占任何站点级根命名空间。
|
||||
|
||||
### 2.2 URL 契约(保持源站形态不变)
|
||||
|
||||
`index.html` 里的引用**仍是站点级绝对路径**,一个字未改:
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="/css/style.css" />
|
||||
<script src="/js/main.js"></script>
|
||||
<img src="/assets/novavis-logo-icon.png" />
|
||||
<img src="/images/logos/windows.svg" />
|
||||
```
|
||||
|
||||
**为什么不能改成 `/novavis/css/style.css`**:子域 `novavis.p.novalon.cn` 的 nginx
|
||||
`root /var/www/novavis-landing`,页面在**根路径**。改绝对路径会把子域首页变成
|
||||
`novavis.p.novalon.cn/novavis/` —— 产品站首页带路径,不可接受。
|
||||
|
||||
### 2.3 官网侧的 4 条 prefix rewrite
|
||||
|
||||
`next.config.mjs` 的 `rewrites()` 把这四个前缀映射进子目录:
|
||||
|
||||
```js
|
||||
{ source: '/novavis', destination: '/novavis/index.html' }, // 入口:public 层不做目录默认文档补全
|
||||
{ source: '/css/:path*', destination: '/novavis/css/:path*' },
|
||||
{ source: '/js/:path*', destination: '/novavis/js/:path*' },
|
||||
{ source: '/assets/:path*', destination: '/novavis/assets/:path*' },
|
||||
{ source: '/images/logos/:path*', destination: '/novavis/images/logos/:path*' },
|
||||
```
|
||||
|
||||
**前提**:根 `public/{css,js,assets,images/logos}` 已删除 ⇒ 这四条是这些前缀的**唯一**占用者。
|
||||
新增任何页面若要用同名前缀,必须先改本文件的登记。
|
||||
|
||||
> 这是 ADR-0014 §4「子目录化 + rewrites 前缀映射」模式**回溯到睿视**的落地 ——
|
||||
> 原文写的就是「第二等产品镜像迁入时,必须改用 `public/{product}/` 子目录 + rewrites 前缀映射,
|
||||
> 并回溯睿视」。
|
||||
|
||||
### 2.4 子域侧:平铺
|
||||
|
||||
子域发布时把 `public/novavis/{css,js,assets,images}` **平铺**到宿主目录根,于是
|
||||
`/css/style.css` 等 URL 在子域上原样成立:
|
||||
|
||||
```bash
|
||||
cp -R public/novavis/. "$LANDING_REMOTE_DIR"/ # index.html 与 4 个子目录一起落到根
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. 四道门禁(`npm run test:landing`)
|
||||
|
||||
### 3.1 为什么移植成 Playwright spec
|
||||
|
||||
迁移前是四个 python 脚本,**只在 authority 仓手动跑、从不在任何门禁链里**。本仓反复记录过那个
|
||||
失效模式:**门禁不在链里就等于没有**。而本仓 CI(`Jenkinsfile`,`agent any`)不保证
|
||||
`python3 + python-playwright` 存在;本仓已有 `@playwright/test` + `@axe-core/playwright`,
|
||||
`e2e/` harness 现成(含 dev / `dist/standalone/server.js` 两种 webServer),
|
||||
`page.goto('/novavis')` 直接可用 —— 不需要另起静态服务。
|
||||
|
||||
**移植纪律**:原 python 版**原样保留**在 `scripts/landing/`(参考实现 + 双跑对照用),
|
||||
TS 版通过后才可视为完成;两者的判据映射见下表。
|
||||
|
||||
### 3.2 判据映射(一条不放宽)
|
||||
|
||||
| 原 python 门禁 | 新 spec | 判据 |
|
||||
|---|---|---|
|
||||
| `verify-landing-layout.py` | `e2e/landing/layout.spec.ts` | 五视口下 `.showcase-tabs` 每个 tab 中心不被 `#showcasePause` 覆盖、中心在视口内、页面横向溢出 ≤1px;焦点进入卡片后轮播让位;持焦 tab 不被摘 `tabindex`;失焦后轮播恢复;方向键后 roving tabindex 单点且焦点跟随 active;nav 转化入口与信息链接分层 |
|
||||
| `verify-landing-motion.py` | `e2e/landing/motion.spec.ts` | `html.js-grow` 挂载;hero 剧本 `demo-step-1..4` 单向推进;四屏切 tab 后重播到峰值 = 目标总数;离开视口复位为 0;`prefers-reduced-motion` 直达终态;装饰图形 `aria-hidden="true"` 且子树内无可聚焦元素;暂停控件存在且带 `aria-pressed`;无 JS 运行时错误 |
|
||||
| `landing-demo-verify.py` | `e2e/landing/demo.spec.ts` | 四步类名采样(1.4/4.4/7.6/11.6/16.4s,**时刻未改**)+ 徽标一一对应(每步恰好 1 个且文案同义);**无 JS 上下文四层真实可见性**;`badge_visible===0` 反向断言 + `badge_count>0` 金丝雀;reduced-motion 终态 |
|
||||
| `landing-audit.py` | `e2e/landing/a11y.spec.ts` | 三视口结构项(横向溢出 / `img` 缺 alt / 可聚焦元素无无障碍名 / `h1` 数量 ≠ 1);全量可见文字对比度(**前景先按背景合成 alpha 再算**);同色无条件阻断;P2 只打印不判红;装饰豁免(主动标注 ∧ `aria-hidden` 子树,两条缺一不可)逐条 NOTE;axe critical/serious = 0 |
|
||||
|
||||
### 3.3 三条口径(原脚本用注入探针钉过,不许简化)
|
||||
|
||||
1. **前景必须先按背景合成 alpha**。`ratio()` 只吃 rgb 三元组、不看 alpha;带 alpha 的前景直接
|
||||
喂进去会得到「把半透明色当不透明色」的对比度,alpha 越低算出的对比度越**高**:
|
||||
`color: rgba(0,0,0,.05)` 未合成报 21.00:1、真值 1.12:1;`color: transparent` 未合成报 21.00:1、
|
||||
真值 1.00:1 —— 后者正是「标题消失」的常见写法。
|
||||
2. **同色无条件阻断、与阈值解耦**。只按 `ratio < 3.0` 判的话,把阈值调到 ≤1.0 时同色(恒 1.00)
|
||||
会被静默放行 —— 正好复现 2026-11-04 Blocking① 的形态。
|
||||
3. **分母金丝雀**。`a11y.spec.ts` 断言 `scanned > 0`(实际评估过的元素数),**不是**
|
||||
`total > 0`(低于判据的条数 —— 全绿时恒为 0,拿它当金丝雀会把「没扫到」与「扫到了且全达标」
|
||||
判成同一个数)。
|
||||
|
||||
### 3.4 判别性取证(已实做,2026-12-03)
|
||||
|
||||
门禁改动最容易被读成「改测试迁就实现」。三处注入探针确认 TS 版**仍能判红**:
|
||||
|
||||
| 注入 | 结果 |
|
||||
|---|---|
|
||||
| `.features .section-title { color: transparent }` | a11y spec 三视口全红,报 `P1 同色前景/背景 rgb(255,255,255) on rgb(255,255,255)(对比度 1)` 并点名 `#features-heading` |
|
||||
| `html:not(.js-demo) .nv-home-rows { opacity:0; visibility:hidden }` | demo spec 红:`无 JS 时任务行不可见:0/4` |
|
||||
| `.demo-chrome-badge-item { display:inline-flex !important }` | demo spec 红:每步「应恰好显示 1 个徽标,实测 4 个」 |
|
||||
|
||||
注入后均已复原,`diff` 确认 `style.css` / `main.js` 与源站原件逐字节一致(`main.js` 仅 6 处
|
||||
`catch` 绑定改动,见 §6)。
|
||||
|
||||
### 3.5 运行方式
|
||||
|
||||
```bash
|
||||
npm run test:landing # 独立 config:单引擎、单 project、串行(判据含视口,串行才可复现)
|
||||
cd e2e && npx playwright test --config=playwright.landing.config.ts landing/a11y.spec.ts # 单文件
|
||||
```
|
||||
|
||||
`playwright.landing.config.ts` 与主 config 分开的理由写在文件头:若塞进主 config 的 4 个功能
|
||||
project,同一套断言会在 4 引擎 × 4 视口下重复执行,而判据里多处「窄视口下 X 不可见」会被 spec
|
||||
自己的 `setViewportSize` 覆盖 —— 跑 4 遍等于跑 1 遍却贵 4 倍,还会把引擎差异混进读数。
|
||||
|
||||
---
|
||||
|
||||
## 4. 发布
|
||||
|
||||
### 4.1 官网镜像(本仓 `scripts/deploy.sh`)
|
||||
|
||||
`public/` 由 `deploy.sh` 步骤 1.5 拷进 `dist/`(既有机制,**零改动**),`/novavis/` 随官网一起发布。
|
||||
|
||||
### 4.2 子域(`novavis.p.novalon.cn`)
|
||||
|
||||
**实测口径(2026-12-03 现取 `docker inspect novalon-nginx-secure`)**:
|
||||
|
||||
| 项 | 值 |
|
||||
|---|---|
|
||||
| 宿主目录 | `/home/novalon/docker-app/novalon-static` |
|
||||
| 容器挂载 | `/var/www/novavis-landing`(`:ro`) |
|
||||
| nginx root | `/var/www/novavis-landing`(`conf.d/novavis-authority.conf:42`) |
|
||||
| 页面位置 | **根路径**(`index.html` 在目录根) |
|
||||
|
||||
**同步动作**:把 `public/novavis/.` 平铺到该宿主目录。注意 authority 的旧脚本是
|
||||
`cp -a` 覆盖式(无 `--delete`),历史上出现过「仓库里删掉的资产在宿主机残留并被继续服务」
|
||||
(v1.0.38 的 Swiper 与白 logo 就踩过),故同步后应显式清理已下线路径。
|
||||
|
||||
> ⚠ **未在本次迁移中执行任何生产写入**。子域发布属破坏性/共享状态动作,须单独授权
|
||||
> (AGENTS.md §5.1)。
|
||||
|
||||
---
|
||||
|
||||
## 5. 与 authority 的边界(迁移后)
|
||||
|
||||
authority 侧已移除:
|
||||
|
||||
- `landing/`(10 文件)
|
||||
- `scripts/{landing-audit,landing-demo-verify,verify-landing-layout,verify-landing-motion}.py`
|
||||
- `scripts/selfcheck/fixture-failing-landing.html` 与 `selfcheck-gates.sh` 的 P3 探针
|
||||
(连同随之失效的 `PORT` / `--port` 参数)
|
||||
- `Dockerfile` 的 `COPY landing`
|
||||
- `deploy-prod.sh` 阶段六(landing 静态资源同步),阶段总数 7 → 6
|
||||
|
||||
**authority 仍保留**:`/authority/` 管理台、`/api/v1/*` 后端。子域 nginx 仍把这些路径反代到
|
||||
`novavis-authority:8080`;**只有静态页那一半换了主人**。
|
||||
|
||||
---
|
||||
|
||||
## 6. 已知差异与未闭环项
|
||||
|
||||
| 项 | 状态 |
|
||||
|---|---|
|
||||
| `public/novavis/js/main.js` 与源站原件 | 仅 6 处 `catch (e)` / `catch (err)` → `catch`(未使用的绑定),语义等价。原因:迁移前 `.lintstagedrc.json` 用 `!(public)/**` 把整个 `public/` 排除在 lint 之外,而这 6 处会让 `npm run lint` 恒红(EXIT=1)。迁移后 landing 纳入本仓门禁面,故修掉并同步把 `public/novavis/js/**` 加进 lint-staged |
|
||||
| 深色主题 | landing 现 **0 处**深色支持;desktop 已有三档主题。**未做**,登记为后续项 |
|
||||
| 仿真外壳与 desktop 最新 UI 的差距 | 未在本轮处理。hero 画的 `/home` 任务台账页已于 2026-11-16 在 desktop 退役(ADR-0437),外壳几何(header 48 / 侧栏 212 单列 / 导航 9 组)也停在 2026-11-06。**登记为独立的 UI 对齐批次** |
|
||||
| 文案事实核对 | 未在本轮处理。已知需核对项:`TSV` 导入(引擎 `Dialect` 无 tsv)、物流单据(78 条规则无物流族)、「监管报送格式」(报告只出 docx)、「4 类桌面系统原生安装包」(`electron-builder.yml` 仅 mac arm64 / win x64 / linux x64,无 UOS/麒麟专用包) |
|
||||
| `scripts/landing/*.py` | 作为**参考实现**保留(双跑对照与判据溯源用),**不在任何 CI 链里**。若后续确认 TS 版完全覆盖,可整体删除 |
|
||||
| CTA 表单端点 | **已修(2026-12-03)**:landing 固定向 `/api/v1/contact` POST JSON 且只认 `data.code === 200`,而本仓只有 `/api/contact`(formData + 必填 `subject`)⇒ 镜像侧表单一提交就落进失败兜底。新增 `src/app/api/v1/contact/route.ts` 匹配该契约(9 例契约测试 + 浏览器端到端实测:`POST` → 200 → 成功块渲染)。见本文 §8 |
|
||||
|
||||
---
|
||||
|
||||
## 7. 变更历史
|
||||
|
||||
| 日期 | 变更 |
|
||||
|---|---|
|
||||
| 2026-12-02 | landing 从 `novavis-authority/landing` **原样**迁入 `public/` 根命名空间(commit `901e1025`),内容零修改 |
|
||||
| 2026-12-03 | **本仓接管**:9 文件收敛到 `public/novavis/` 子目录 + 4 条 prefix rewrite;四道门禁移植为 Playwright spec 并进 `test:all`;authority 侧退役;单 agent 文档收敛(`CLAUDE.md` 删除,正文并入 `AGENTS.md` §9) |
|
||||
|
||||
---
|
||||
|
||||
## 8. CTA 表单端点 `/api/v1/contact`
|
||||
|
||||
### 8.1 为什么需要它(迁移暴露的第一个真实缺陷)
|
||||
|
||||
landing 的 `js/main.js` 固定:
|
||||
|
||||
```js
|
||||
fetch('/api/v1/contact', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(payload) })
|
||||
.then(...)
|
||||
.then(({ok, data}) => { if (ok && data.code === 200) { /* 成功 */ } else { /* 失败兜底 */ } })
|
||||
```
|
||||
|
||||
这个契约来自 `novavis-authority`(子域上由它的 Java 后端 `/api/v1/contact` 响应)。
|
||||
但本仓只有 `/api/contact`(formData + 必填 `subject`,成功判据是 `success`)。
|
||||
于是**官网镜像 `/novavis/` 的转化路径一直 404** —— 表单一提交就落进「服务器返回异常」的兜底。
|
||||
迁移前没人从官网入口点过那个表单,所以这个断点一直没被看见。
|
||||
|
||||
### 8.2 处置:加一个契约匹配的薄适配层,而不是改 landing
|
||||
|
||||
| 方案 | 结论 |
|
||||
|---|---|
|
||||
| 改 `main.js` 去打 `/api/contact` + formData | ❌ 同一份字节要服务两个落点。子域上 authority 的契约是 JSON + `code:200`,改前端等于把「适配本仓」的成本转嫁给子域,且两侧成功判据会分叉 |
|
||||
| **新增 `/api/v1/contact` 路由** | ✅ 本仓多一个薄层,landing 与 authority 都不动;可逆 |
|
||||
|
||||
**不复用 `/api/contact` 的实现**:输入形状(JSON vs formData)与成功判据(`code` vs `success`)
|
||||
都不同,硬合并会造出一个两套语义的分支函数。但**投递通道一致**:都走 formsubmit.co 到
|
||||
`COMPANY_INFO.email`。字段映射:`org` 由服务端合成为 `subject`(`睿视试用申请 · {org}`),
|
||||
因为 landing 表单里没有 subject 字段。
|
||||
|
||||
### 8.3 三个不显然的决定
|
||||
|
||||
1. **失败也返回 HTTP 200 + `code !== 200`**(除 429/500)。landing 只看 `data.code`;
|
||||
而 4xx 响应在某些中间层(CDN/WAF)会被替换成 HTML 错误页 ⇒ `res.json()` 直接抛异常 ⇒
|
||||
用户只能看到最不具体的「网络异常」。用 200 + 结构化 message 能让文案落到具体原因上。
|
||||
2. **zod 4 的两级消息都要给**。`.min(1, "请输入您的姓名")` 只管「存在但为空」;
|
||||
字段**缺失**(undefined)走构造器参数,只写 `.min` 会返回英文
|
||||
`Invalid input: expected string, received undefined` —— 直接展示给用户就是一句没法读的话。
|
||||
实测确认:`z.string({ error: '…' })` 生效,`.min(1, '…')` 对 undefined 不生效。
|
||||
3. **两个端点的限流桶独立**。共享会让「官网留言 5 次」把「睿视申请」也堵死。
|
||||
默认同为 5 次/小时/IP,可用 `CONTACT_RATE_LIMIT_MAX` 覆盖。
|
||||
|
||||
### 8.4 验证
|
||||
|
||||
- 契约测试 `src/app/api/v1/contact/route.test.ts` **9/9**:成功形状 / org→subject 合成 /
|
||||
选填字段缺失 / 必填缺失给出具体字段名 / 手机号格式 / 非 JSON 请求 / 危险字符过滤 /
|
||||
上游失败不透传 5xx / 限流 429。
|
||||
- 浏览器端到端(Playwright,真实 dev server):填表 → `#submitBtn` → `POST /api/v1/contact`
|
||||
**200** → `.cta-form-success` 渲染。**注意上游 formsubmit.co 耗时 5s+**,
|
||||
探针等待窗口小于 5s 会误判为失败(首次探针就是这么假红的)。
|
||||
- 实测 curl 三条校验分支:缺 `org` → `{"code":400,"message":"请输入您所在的单位名称"}`;
|
||||
手机号错 → `{"code":400,"message":"请输入正确的手机号码"}`;
|
||||
非 JSON → `{"code":400,"message":"请求格式无效(需要 JSON)"}`。
|
||||
Reference in new issue
Block a user