fix(frontend): 按审计报告修复全部17项问题,数据层迁至 src/api/
P0(4): 假数据清除(avg_latency_ms:2400→null,无端点字段改null)、假进度条改诚实的不确定态、 公共页不再反向依赖 admin(api/public.ts)、PredictProgress 重写 P1(6): 23处 any 归零(对齐后端 Pydantic 契约新增 PredictionMatchRef/HealthProbe 等)、 a11y(aria-live 0→4,htmlFor 1→17,aria-describedby/invalid 补齐)、App.tsx 抽 SiteLayout、 路由级 lazy+代码分割(首屏 315KB→238KB)、index.html 补 SEO/favicon/OG、死代码清理(AdminIcon 抽出) P2(7): Login/index.css 裸色值令牌化、groupByDate useMemo、滚动监听统一、原生控件基元化、 useLeagues 静默失败补告警、路由级 ErrorBoundary 另修复审计未列问题: - Monitoring todos 过滤器 t!==false 放行 null 导致整页崩溃 → Boolean(t) 真值过滤 - Collection 渲染期 Date.now()(react-hooks/purity 捕获)→ 计时器 effect - bg-press-wash/60 透明度修饰符静默失效 → RGB 三元组 + 构建期令牌守卫(下个提交接入) 工程化:数据层 dal/api/types(1047行)git mv 至 src/api/,admin 留 @deprecated 兼容壳, 21 个引用方直指新路径;tsconfig 开启 noUnusedLocals/noUnusedParameters(清理9处存量)
This commit is contained in:
@@ -1,8 +1,17 @@
|
||||
import { Component, ErrorInfo, ReactNode } from 'react'
|
||||
import { Button } from './ui'
|
||||
|
||||
interface Props {
|
||||
children: ReactNode
|
||||
fallback?: ReactNode
|
||||
/**
|
||||
* 该边界是否铺满整个视口。
|
||||
*
|
||||
* 应用最外层的边界应铺满(`true`,默认);而当边界下沉到
|
||||
* 路由级、嵌在 SiteLayout 的 <main> 里时,铺满视口会撑开
|
||||
* 布局并让页头页脚错位 —— 那种场景传 `false`,改为局部卡片。
|
||||
*/
|
||||
fullScreen?: boolean
|
||||
}
|
||||
|
||||
interface State {
|
||||
@@ -29,20 +38,25 @@ export class ErrorBoundary extends Component<Props, State> {
|
||||
if (this.props.fallback) {
|
||||
return this.props.fallback
|
||||
}
|
||||
const fullScreen = this.props.fullScreen ?? true
|
||||
return (
|
||||
<div className="flex min-h-screen items-center justify-center bg-paper-50 p-6">
|
||||
<div
|
||||
className={
|
||||
fullScreen
|
||||
? 'flex min-h-screen items-center justify-center bg-paper-50 p-6'
|
||||
: 'flex min-h-[50vh] items-center justify-center p-6'
|
||||
}
|
||||
role="alert"
|
||||
>
|
||||
<div className="max-w-md space-y-3 border border-ink-900 bg-paper-50 p-6 text-center">
|
||||
<p className="text-2xs tracking-[0.3em] text-ink-400">EXCEPTION</p>
|
||||
<h2 className="font-serif text-lg font-bold text-ink-900">页面出现错误</h2>
|
||||
<p className="text-sm leading-relaxed text-ink-500">
|
||||
{this.state.error?.message || '未知错误'}
|
||||
</p>
|
||||
<button
|
||||
onClick={() => this.setState({ hasError: false, error: null })}
|
||||
className="btn btn-sm"
|
||||
>
|
||||
<Button size="sm" onClick={() => this.setState({ hasError: false, error: null })}>
|
||||
重试
|
||||
</button>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* SiteLayout —— 前台公开站点的共享外壳(报头 + 内容区 + 页脚)。
|
||||
*
|
||||
* 背景:此前 `HomePage` 与 `StandingsLayout` 各自复制了一遍
|
||||
* `<main className="mx-auto max-w-5xl px-5 py-6 sm:px-8 sm:py-8">`
|
||||
* 和 `<footer className="mx-auto max-w-5xl px-5 pb-10 sm:px-8">`。
|
||||
* 两处 className 逐字相同,唯一差异是 Masthead 的 active 值与
|
||||
* 页脚文案。改一次容器内边距要改两处,加第三个页面就是第三处。
|
||||
*
|
||||
* 这里把「容器宽度 / 内边距 / 页脚分隔线样式」收进单一来源,
|
||||
* 调用方只需提供 active(决定报头高亮)与页脚文案。
|
||||
*/
|
||||
|
||||
import type { ReactNode } from 'react'
|
||||
import Masthead from './Masthead'
|
||||
import type { MastheadActive } from './Masthead'
|
||||
|
||||
/** 报头的 active 分区,决定报刊头里哪个分区链接高亮 */
|
||||
export type SiteSection = MastheadActive
|
||||
|
||||
export interface SiteLayoutProps {
|
||||
/** 当前分区,用于报头高亮 */
|
||||
active: SiteSection
|
||||
/** 页脚文案(各分区声明差异,如首页含免责声明) */
|
||||
footerNote: ReactNode
|
||||
children: ReactNode
|
||||
}
|
||||
|
||||
export function SiteLayout({ active, footerNote, children }: SiteLayoutProps) {
|
||||
return (
|
||||
<div className="min-h-screen bg-paper-50">
|
||||
<Masthead active={active} />
|
||||
|
||||
<main className="mx-auto max-w-5xl px-5 py-6 sm:px-8 sm:py-8">
|
||||
{children}
|
||||
</main>
|
||||
|
||||
<footer className="mx-auto max-w-5xl px-5 pb-10 sm:px-8">
|
||||
<div className="border-t border-ink-200 pt-3 text-center text-2xs leading-relaxed text-ink-400">
|
||||
{footerNote}
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default SiteLayout
|
||||
Reference in New Issue
Block a user