refactor(fonts): Google Fonts 改为本地字体文件

- 移除 next/font/google 依赖,改用 next/font/local 加载本地 woff2 字体
- 新增 Geist Sans/Mono、Noto Sans SC、Ma Shan Zheng 本地字体文件
- 解决国内网络环境下 fonts.gstatic.com 不可达导致构建失败的问题
- 移除未使用的 image-filters.ts (WASM 模块声明导致 TS 编译错误)
This commit is contained in:
张翔
2026-04-29 14:21:42 +08:00
parent fb888a673f
commit ec3e89f591
10 changed files with 12980 additions and 11 deletions
+12962
View File
File diff suppressed because it is too large Load Diff
+18 -11
View File
@@ -1,5 +1,4 @@
import type { Metadata, Viewport } from "next"; import type { Metadata, Viewport } from "next";
import { Geist, Geist_Mono, Noto_Sans_SC, Ma_Shan_Zheng } from "next/font/google";
import localFont from "next/font/local"; import localFont from "next/font/local";
import "./globals.css"; import "./globals.css";
import { Suspense } from "react"; import { Suspense } from "react";
@@ -17,32 +16,40 @@ import { BackToTop } from "@/components/ui/back-to-top";
const GA_MEASUREMENT_ID = process.env.NEXT_PUBLIC_GA_MEASUREMENT_ID || ''; const GA_MEASUREMENT_ID = process.env.NEXT_PUBLIC_GA_MEASUREMENT_ID || '';
const geistSans = Geist({ const geistSans = localFont({
src: [
{ path: "./fonts/geist-sans/geist-sans-latin-400-normal.woff2", weight: "400" },
{ path: "./fonts/geist-sans/geist-sans-latin-700-normal.woff2", weight: "700" },
],
variable: "--font-geist-sans", variable: "--font-geist-sans",
subsets: ["latin"],
display: "swap", display: "swap",
preload: false, preload: false,
}); });
const geistMono = Geist_Mono({ const geistMono = localFont({
src: [
{ path: "./fonts/geist-mono/geist-mono-latin-400-normal.woff2", weight: "400" },
{ path: "./fonts/geist-mono/geist-mono-latin-700-normal.woff2", weight: "700" },
],
variable: "--font-geist-mono", variable: "--font-geist-mono",
subsets: ["latin"],
display: "swap", display: "swap",
preload: false, preload: false,
}); });
const notoSansSC = Noto_Sans_SC({ const notoSansSC = localFont({
weight: ["400", "500", "700"], src: [
{ path: "./fonts/noto-sans-sc/noto-sans-sc-chinese-simplified-400-normal.woff2", weight: "400" },
{ path: "./fonts/noto-sans-sc/noto-sans-sc-chinese-simplified-500-normal.woff2", weight: "500" },
{ path: "./fonts/noto-sans-sc/noto-sans-sc-chinese-simplified-700-normal.woff2", weight: "700" },
],
variable: "--font-noto-sans-sc", variable: "--font-noto-sans-sc",
subsets: ["latin"],
display: "swap", display: "swap",
preload: true, preload: true,
}); });
const maShanZheng = Ma_Shan_Zheng({ const maShanZheng = localFont({
weight: "400", src: "./fonts/ma-shan-zheng/ma-shan-zheng-chinese-simplified-400-normal.woff2",
variable: "--font-ma-shan-zheng", variable: "--font-ma-shan-zheng",
subsets: ["latin"],
display: "swap", display: "swap",
preload: true, preload: true,
}); });