6c08a68413
性能与用户体验全面优化
前端性能:
- 移除 Three.js 依赖(~600KB),天气粒子改为纯 CSS 动画 + Canvas 2D
- Google Fonts 切换为 next/font 自托管,消除跨域字体请求
- 合并 ScanTerminalLightTheme.module.css (37KB) 到主 CSS,亮/暗主题统一用 CSS 变量
- 新增 /api/dashboard/init 聚合端点,首次加载 4 次往返 → 1 次
- 添加 Service Worker 静态资源缓存,修复 PWA manifest 配置
用户体验:
- 新增全局错误边界 error.tsx / global-error.tsx,崩溃不再白屏
- 决策卡和城市详情的更新时间改为相对时间("15秒前"),每秒自动刷新
- 数据陈旧时状态标签从青色切换为琥珀色提示
DEB 算法增强:
- 市场扫描路径接入 Open-Meteo 多模型数据(ECMWF/GFS/ICON/JMA/HRDPS 等)
- MAE 计算加入时间衰减(decay_factor=0.85),近期模型误差权重更高
Scope-risk: MEDIUM — 全量 170 测试通过,前端 TypeScript/build 通过,ruff 零告警
Tested: python -m pytest -q (170 passed), npx tsc --noEmit (0 errors), npm run build (success), ruff check .
@
59 lines
1.6 KiB
TypeScript
59 lines
1.6 KiB
TypeScript
import type { Metadata } from "next";
|
|
import { Inter, JetBrains_Mono } from "next/font/google";
|
|
import { RegisterSW } from "@/components/dashboard/RegisterSW";
|
|
import "./globals.css";
|
|
|
|
const inter = Inter({
|
|
subsets: ["latin"],
|
|
display: "swap",
|
|
variable: "--font-inter",
|
|
weight: ["300", "400", "500", "600", "700", "800"],
|
|
});
|
|
|
|
const jetbrainsMono = JetBrains_Mono({
|
|
subsets: ["latin"],
|
|
display: "swap",
|
|
variable: "--font-jetbrains-mono",
|
|
weight: ["400", "500", "600", "700"],
|
|
});
|
|
|
|
export const metadata: Metadata = {
|
|
title: "PolyWeather | Weather Intelligence",
|
|
description:
|
|
"PolyWeather pro dashboard with global weather risk map and city analytics.",
|
|
manifest: "/site.webmanifest",
|
|
icons: {
|
|
icon: [
|
|
{ url: "/favicon.ico", type: "image/x-icon" },
|
|
{ url: "/favicon-32x32.png", sizes: "32x32", type: "image/png" },
|
|
{ url: "/favicon-16x16.png", sizes: "16x16", type: "image/png" },
|
|
],
|
|
apple: [
|
|
{ url: "/apple-touch-icon.png", sizes: "180x180", type: "image/png" },
|
|
],
|
|
shortcut: ["/favicon.ico"],
|
|
},
|
|
};
|
|
|
|
export default function RootLayout({
|
|
children,
|
|
}: Readonly<{ children: React.ReactNode }>) {
|
|
return (
|
|
<html
|
|
lang="zh-CN"
|
|
className={`${inter.variable} ${jetbrainsMono.variable} dark`}
|
|
>
|
|
<head>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
</head>
|
|
<body className="min-h-screen font-sans antialiased">
|
|
<a href="#main-content" className="skip-to-content">
|
|
Skip to content
|
|
</a>
|
|
<main id="main-content">{children}</main>
|
|
<RegisterSW />
|
|
</body>
|
|
</html>
|
|
);
|
|
}
|