登录页接入常驻探针并改用 kit 用词:「页签」一词收口到页面内部
产品口径落地复查(内容页不做多 Tab / 菜单只到两级 / 页签=页面内部页面)时发现两处该修的: 1) 常驻探针压根量不到登录页:登录之后再访问 /login 会被守卫回落首页, 第 4 条的 URL 比对只能报「路由不存在」(实测退出码 1),而默认路由表里 干脆没有 /login。改成**登录之前**先按 逐档宽度 × 明暗把 chromeless 的 登录页量一遍并截图,尺子检查从主循环抽成 audit() 由两处共用(同一份断言, 不给登录页开第二条口径);/login 进默认路由表,主循环跳过它。 实测 430 / 768 / 1440 × 明暗:断言 0、console 0、HTTP 失败 0。 2) 登录页还留着手写用词:两个 <label><span> 字段换成 FieldBlock(标签在上, 与全站同尺),三条自己拼「描边 + 底色」的提示条换成 Notice。截图逐像素对过, 版面没动,只是不再各写一份。 顺带把词收口:ProjectDetail 注释里的「各业务页签」改成「各业务子页」—— 「页签」从本轮起只指页面内部页签(§6.4),外壳没有页签条(§6.1); §6 表格里 Header 那一行按真实三块(折叠开关+品牌簇 / PipelineConsole / 状态+手册+主题+UserMenu)重写, §15.2 登记探针的登录前置一趟。main
parent
62c356952c
commit
85a95a9ba3
|
|
@ -304,7 +304,7 @@ antd 三档(24/32/40)套不进去的,才是自定义表面,允许裸元
|
|||
|
||||
| 文件 | 本体 | 要点 |
|
||||
|---|---|---|
|
||||
| `app/layout/AppHeader.tsx` | `Layout.Header` | 高度 = `theme/antd.ts` 导出的 **`HEADER_HEIGHT`(56)** 唯一出处(Sider 与内容区算 `calc(100vh - HEADER_HEIGHT)` 时引用同一个数);左:品牌 + 项目切换,右:主题开关 + `UserMenu`(antd `Dropdown`)。**没有**接口文档入口、系统信息页脚、「最近刷新」 |
|
||||
| `app/layout/AppHeader.tsx` | `Layout.Header` | 高度 = `theme/antd.ts` 导出的 **`HEADER_HEIGHT`(56)** 唯一出处(Sider 与内容区算 `calc(100vh - HEADER_HEIGHT)` 时引用同一个数);左:折叠开关 + 品牌簇(`Avatar` + `Typography.Text`);中:`PipelineConsole`(唯一的弹性出气口,见下一段);右:系统状态 `Badge` + 手册 + 主题开关 + `UserMenu`(antd `Dropdown`)。**没有**接口文档入口、系统信息页脚、「最近刷新」,也**没有**页签条(§6.1) |
|
||||
| `app/layout/AppSider.tsx` | `Layout.Sider` + `Menu theme="light"` | `collapsible` + `breakpoint="md"` + `collapsedWidth={64}`,折叠/浮层/内嵌缩进全部交 antd;导航表在 `app/layout/nav.tsx`(含 `projectIdOf` / `pathOf`),**菜单只到两级**(§6.2),选中态 = `selectedKeys={[pathname]}`,**不在页面里手写** |
|
||||
| `app/App.tsx` 的 `Layout.Content` | `Layout.Content` | 自上而下只有两样:系统异常 `Alert` → 页面。留白 `p-6 max-lg:p-4 max-md:p-3`,`maxWidth: 1680` 居中;页面自己不再写外壳级 padding |
|
||||
|
||||
|
|
@ -329,6 +329,8 @@ antd 三档(24/32/40)套不进去的,才是自定义表面,允许裸元
|
|||
|
||||
### 6.2 侧栏只到两级
|
||||
|
||||
产品口径(2026-11 重设计定死):**菜单只到两级**,指定项目的二级并入「当前项目」这一支。
|
||||
|
||||
一级 = 全局三项(项目总览 / 平台资产库 / 模型管理中心)+ **当前项目**;
|
||||
二级 = 当前项目下的七个环节。**不要三级**,也不要为了分组再插一层。
|
||||
|
||||
|
|
@ -845,7 +847,9 @@ node scripts/ui/classaudit.mjs frontend/src/pages/Help.tsx
|
|||
|
||||
### 15.2 `.venv/bin/python scripts/ui/visualcheck.py` —— 量渲染结果
|
||||
|
||||
登录 → 逐路由 × 逐档宽度 × 明暗截图,同时读浏览器计算样式做断言,现在钉死八件事:
|
||||
**登录之前**先把 chromeless 的登录页按 逐档宽度 × 明暗各量一遍并截图(`audit()` 与业务页共用同一把尺子):
|
||||
登录后再访问 `/login` 会被守卫回落首页,拿它跑第 4 条的 URL 比对只会报假故障。
|
||||
随后登录 → 逐路由 × 逐档宽度 × 明暗截图,同时读浏览器计算样式做断言,现在钉死八件事:
|
||||
|
||||
1. `:root` 上的 `--ant-*` 尺子非空(`applyRootVars` 真的铺下去了,`app.css` 全靠它);
|
||||
2. 文字行高没塌成 px(无单位倍数被误写 px 时肉眼很容易漏,见 §3 的事故登记);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
import { useEffect, useRef, useState, type FormEvent } from 'react'
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom'
|
||||
import { SecretInput } from '../components/forms'
|
||||
import { Button, Input } from '../components/ui'
|
||||
import { Button, FieldBlock, Input, Notice } from '../components/ui'
|
||||
import { login, useAuthStore } from '../stores/auth'
|
||||
import { setTheme, useAppliedTheme } from '../stores/theme'
|
||||
import { IconMoon, IconSun } from '../components/icons'
|
||||
|
|
@ -75,27 +75,21 @@ export default function Login() {
|
|||
|
||||
<h1 className="mb-5 mt-0 text-xl font-bold" title="账号决定你能做什么:管理员管模型与账号,制作可以跑生产,观摩只读。">登录以继续</h1>
|
||||
|
||||
{params.get('loggedOut') === '1' && (
|
||||
<p className="mb-1 rounded-lg border border-border-secondary bg-info-bg px-3 py-2 text-xs text-info">已退出登录。</p>
|
||||
)}
|
||||
{offline && (
|
||||
<p className="mb-1 rounded-lg border border-error-border bg-error-bg px-3 py-2 text-xs text-error">后端连接不上:{connError || '请确认服务已启动'}</p>
|
||||
)}
|
||||
{error && (
|
||||
<p className="mb-1 rounded-lg border border-error-border bg-error-bg px-3 py-2 text-xs text-error">{error}</p>
|
||||
)}
|
||||
{params.get('loggedOut') === '1' && <Notice className="mb-1">已退出登录。</Notice>}
|
||||
{offline && <Notice danger className="mb-1">后端连接不上:{connError || '请确认服务已启动'}</Notice>}
|
||||
{error && <Notice danger className="mb-1">{error}</Notice>}
|
||||
|
||||
<label className="mb-3 flex flex-col gap-1 text-xs">
|
||||
<span className="text-text-tertiary">用户名</span>
|
||||
<Input id="login-user" ref={userRef} value={form.username} autoComplete="username" spellCheck={false} placeholder={'如 ' + (user?.username || 'admin')} onChange={(e) => setForm((f) => ({ ...f, username: e.target.value }))} />
|
||||
</label>
|
||||
<label className="mb-3 flex flex-col gap-1 text-xs">
|
||||
<span className="text-text-tertiary">密码</span>
|
||||
<FieldBlock className="mb-3" label="用户名">
|
||||
<Input id="login-user" ref={userRef} value={form.username} autoComplete="username" spellCheck={false}
|
||||
placeholder={'如 ' + (user?.username || 'admin')}
|
||||
onChange={(e) => setForm((f) => ({ ...f, username: e.target.value }))} />
|
||||
</FieldBlock>
|
||||
<FieldBlock className="mb-3" label="密码">
|
||||
<SecretInput id="login-pass" ref={passRef} value={form.password} autocomplete="current-password"
|
||||
placeholder="输入密码后点右侧图标可查看"
|
||||
onChange={(next) => setForm((f) => ({ ...f, password: next }))}
|
||||
onKeyUp={(e) => { if (e.key === 'Enter') void submit() }} />
|
||||
</label>
|
||||
</FieldBlock>
|
||||
|
||||
<Button htmlType="submit" type="primary" size="lg" disabled={busy} className="mt-4 w-full">
|
||||
{busy ? '正在验证…' : '登录'}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
/**
|
||||
* 项目工作台外壳:标题行 + 可折叠「项目概况」+ 各业务页签(<Outlet/>)。
|
||||
* 项目工作台外壳:标题行 + 可折叠「项目概况」+ 各业务子页(<Outlet/>)。
|
||||
* 「页签」这个词从本轮起只指页面内部页签(UI规范 §6.4),路由级子页不叫页签——
|
||||
* 内容页没有外壳级页签条(§6.1)。
|
||||
*
|
||||
* GL-1:项目概况(4 张指标卡 + 12 节点流程条)在桌面端同样要能收起。
|
||||
* 以前只有 ≤900px 才折叠,正文被顶出首屏 ≈470px,每个页签都要先滚一屏废话。
|
||||
* 以前只有 ≤900px 才折叠,正文被顶出首屏 ≈470px,每个子页都要先滚一屏废话。
|
||||
* 折叠状态记在 project.ts(useBriefStore):分镜工作台也要能收起这块概况,
|
||||
* 两处按钮共用同一份偏好,不会各说各话。
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -34,9 +34,11 @@ ROUTES = [r for r in os.environ.get(
|
|||
"/,/assets,/models,/projects/{id}/overview,/projects/{id}/library,"
|
||||
"/projects/{id}/storyboard,/projects/{id}/dispatch,/projects/{id}/review,"
|
||||
"/projects/{id}/timeline,/projects/{id}/delivery,"
|
||||
"/account,/users,/help").split(",") if r]
|
||||
# 侧栏导航覆盖到的路由:这些必须有选中项,否则 selectedKeys 断了
|
||||
NAV_ROUTES = [r for r in ROUTES if "/account" not in r and "/users" not in r and "/help" not in r]
|
||||
"/account,/users,/help,/login").split(",") if r]
|
||||
# 侧栏导航覆盖到的路由:这些必须有选中项,否则 selectedKeys 断了。
|
||||
# 登录页不在导航里(chromeless),主循环也不跑它——见下面登录前的专用一趟。
|
||||
NAV_ROUTES = [r for r in ROUTES
|
||||
if not any(x in r for x in ("/account", "/users", "/help", "/login"))]
|
||||
USER = os.environ.get("NEX_USER", "admin")
|
||||
PWD = os.environ.get("NEX_PASS", "admin1234")
|
||||
# rc-resize-observer 在 React 18 下的已知告警,antd 内部依赖,与应用代码无关
|
||||
|
|
@ -235,6 +237,55 @@ LAYOUT = r"""() => {
|
|||
}"""
|
||||
|
||||
|
||||
def audit(page, route: str, width: int, theme: str, problems: list[str], *,
|
||||
menu_required: bool = False, shot_prefix: bool = True) -> None:
|
||||
"""量一把渲染结果并截图:登录页与业务页共用同一份尺子,不允许两套口径。
|
||||
|
||||
`menu_required` 只由调用方按「这一条在不在侧栏导航里」给:账号 / 用户管理 /
|
||||
手册 / 登录页没有选中项是正常的,业务路由没有就是 selectedKeys 断了。
|
||||
"""
|
||||
probe = page.evaluate(PROBE)
|
||||
lay = page.evaluate(LAYOUT)
|
||||
for o in lay["out"]:
|
||||
problems.append(f"{width}/{theme}{route}: 捅出视口 {o}")
|
||||
for o in lay["clip"]:
|
||||
problems.append(f"{width}/{theme}{route}: 文字被切 {o}")
|
||||
for o in lay["disp"]:
|
||||
problems.append(f"{width}/{theme}{route}: display utility 被组件样式盖掉 {o}")
|
||||
for o in lay["trunc"]:
|
||||
problems.append(f"{width}/{theme}{route}: 控件标签被省略号截断 {o}")
|
||||
if probe["theme"] != theme:
|
||||
problems.append(f"{width}/{theme}{route}: data-theme={probe['theme']}")
|
||||
for k, val in probe["root"].items():
|
||||
if not val:
|
||||
problems.append(f"{width}/{theme}{route}: :root 缺 --{k}")
|
||||
for bad in probe["text"]:
|
||||
problems.append(f"{width}/{theme}{route}: 行高塌了 {bad}")
|
||||
if menu_required:
|
||||
if not probe["menu"]:
|
||||
problems.append(f"{width}/{theme}{route}: 菜单没有选中项")
|
||||
elif probe.get("collapsed") and probe.get("subSelected"):
|
||||
# 折叠态下只验到父级还不够:selectedKeys 传错时父级照样会亮。
|
||||
# 展开浮层,确认这一条路由对应的二级项真的在里面被选中。
|
||||
try:
|
||||
page.hover(".ant-menu-submenu-selected > .ant-menu-submenu-title")
|
||||
page.wait_for_timeout(450)
|
||||
hit = page.evaluate(
|
||||
"() => { const p = document.querySelector('.ant-menu-submenu-popup');"
|
||||
" const s = p && p.querySelector('.ant-menu-item-selected');"
|
||||
" return s ? s.textContent.trim().slice(0, 12) : null; }")
|
||||
if not hit:
|
||||
problems.append(f"{width}/{theme}{route}: 折叠态浮层里没有选中的二级项")
|
||||
finally:
|
||||
page.mouse.move(5, 5)
|
||||
page.wait_for_timeout(150)
|
||||
slug = route.strip("/").replace("/", "-") or "home"
|
||||
name = f"{width}-{theme}-{slug}.png"
|
||||
page.screenshot(path=str(SHOTS / name))
|
||||
if shot_prefix and width == WIDTHS[0]:
|
||||
print(f"shot {name:38} menu={probe['menu']} header={probe['header']}")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
problems: list[str] = []
|
||||
errors: list[str] = []
|
||||
|
|
@ -262,6 +313,21 @@ def main() -> int:
|
|||
http_bad.append(f"{page.url.replace(BASE, '') or '/'} → {status} {url}")
|
||||
page.on("response", on_response)
|
||||
|
||||
# 登录页专用的一趟(必须在登录之前跑):它没有 Header/Sider,
|
||||
# 而且登录之后再访问 /login 会被守卫回落首页——URL 比对就成了假故障。
|
||||
# 先落地一个同源页面:about:blank 上没有 localStorage 可写。
|
||||
page.goto(BASE + "/login", wait_until="domcontentloaded")
|
||||
for width in WIDTHS:
|
||||
page.set_viewport_size({"width": width, "height": 900})
|
||||
for theme in THEMES:
|
||||
page.evaluate("(t) => localStorage.setItem('nex-the', t)", theme)
|
||||
page.goto(BASE + "/login", wait_until="networkidle")
|
||||
page.wait_for_timeout(500)
|
||||
if not page.locator("#login-user").count():
|
||||
problems.append(f"{width}/{theme}/login: 登录表单没渲染(#login-user 不在)")
|
||||
continue
|
||||
audit(page, "/login", width, theme, problems)
|
||||
|
||||
page.goto(BASE + "/login", wait_until="networkidle")
|
||||
if page.locator("#login-user").count():
|
||||
page.fill("#login-user", USER)
|
||||
|
|
@ -279,6 +345,8 @@ def main() -> int:
|
|||
page.evaluate("(t) => localStorage.setItem('nex-the', t)", theme)
|
||||
for route in ROUTES:
|
||||
r = route
|
||||
if r == "/login":
|
||||
continue # 登录前那一趟量过了,这里再访问只会撞守卫
|
||||
if "{id}" in r:
|
||||
if not pid:
|
||||
pid = page.evaluate("""async () => {
|
||||
|
|
@ -299,46 +367,7 @@ def main() -> int:
|
|||
if not page.url.rstrip("/").endswith(r.rstrip("/")):
|
||||
problems.append(f"{width}/{theme}{r}: 路由不存在,实际落在 {page.url}")
|
||||
continue
|
||||
probe = page.evaluate(PROBE)
|
||||
lay = page.evaluate(LAYOUT)
|
||||
for o in lay["out"]:
|
||||
problems.append(f"{width}/{theme}{r}: 捅出视口 {o}")
|
||||
for o in lay["clip"]:
|
||||
problems.append(f"{width}/{theme}{r}: 文字被切 {o}")
|
||||
for o in lay["disp"]:
|
||||
problems.append(f"{width}/{theme}{r}: display utility 被组件样式盖掉 {o}")
|
||||
for o in lay["trunc"]:
|
||||
problems.append(f"{width}/{theme}{r}: 控件标签被省略号截断 {o}")
|
||||
if probe["theme"] != theme:
|
||||
problems.append(f"{width}/{theme}{r}: data-theme={probe['theme']}")
|
||||
for k, val in probe["root"].items():
|
||||
if not val:
|
||||
problems.append(f"{width}/{theme}{r}: :root 缺 --{k}")
|
||||
for bad in probe["text"]:
|
||||
problems.append(f"{width}/{theme}{r}: 行高塌了 {bad}")
|
||||
# 账号 / 用户管理 / 手册不在侧栏导航里,没有选中项是正常的
|
||||
if r in NAV_ROUTES and not probe["menu"]:
|
||||
problems.append(f"{width}/{theme}{r}: 菜单没有选中项")
|
||||
elif r in NAV_ROUTES and probe.get("collapsed") and probe.get("subSelected"):
|
||||
# 折叠态下只验到父级还不够:selectedKeys 传错时父级照样会亮。
|
||||
# 展开浮层,确认这一条路由对应的二级项真的在里面被选中。
|
||||
try:
|
||||
page.hover(".ant-menu-submenu-selected > .ant-menu-submenu-title")
|
||||
page.wait_for_timeout(450)
|
||||
hit = page.evaluate(
|
||||
"() => { const p = document.querySelector('.ant-menu-submenu-popup');"
|
||||
" const s = p && p.querySelector('.ant-menu-item-selected');"
|
||||
" return s ? s.textContent.trim().slice(0, 12) : null; }")
|
||||
if not hit:
|
||||
problems.append(f"{width}/{theme}{r}: 折叠态浮层里没有选中的二级项")
|
||||
finally:
|
||||
page.mouse.move(5, 5)
|
||||
page.wait_for_timeout(150)
|
||||
slug = r.strip("/").replace("/", "-") or "home"
|
||||
name = f"{width}-{theme}-{slug}.png"
|
||||
page.screenshot(path=str(SHOTS / name))
|
||||
if width == WIDTHS[0]:
|
||||
print(f"shot {name:38} menu={probe['menu']} header={probe['header']}")
|
||||
audit(page, r, width, theme, problems, menu_required=r in NAV_ROUTES)
|
||||
browser.close()
|
||||
|
||||
print("\n=== :root 尺子 ===")
|
||||
|
|
|
|||
Loading…
Reference in New Issue