feat: 添加龙虾 favicon 并修复 middleware 路由拦截

- 创建 lib/constants/theme.ts 统一管理颜色和品牌常量
- 重构 icon.tsx 和 apple-icon.tsx 使用共享常量
- 修复 middleware matcher 排除 icon/apple-icon 路由
This commit is contained in:
richarjiang
2026-03-13 20:16:41 +08:00
parent 6c2a45b257
commit c76ebe04e3
5 changed files with 20 additions and 7 deletions

View File

@@ -1,4 +1,5 @@
import { ImageResponse } from "next/og"; import { ImageResponse } from "next/og";
import { COLORS, BRAND } from "@/lib/constants";
export const size = { width: 180, height: 180 }; export const size = { width: 180, height: 180 };
export const contentType = "image/png"; export const contentType = "image/png";
@@ -13,14 +14,14 @@ export default function AppleIcon() {
display: "flex", display: "flex",
alignItems: "center", alignItems: "center",
justifyContent: "center", justifyContent: "center",
background: "linear-gradient(135deg, #0a0e1a 0%, #111827 100%)", background: `linear-gradient(135deg, ${COLORS.bgPrimary} 0%, ${COLORS.bgSecondary} 100%)`,
borderRadius: "40px", borderRadius: "40px",
fontSize: 120, fontSize: 120,
}} }}
> >
🦞 {BRAND.emoji}
</div> </div>
), ),
{ ...size } size
); );
} }

View File

@@ -1,4 +1,5 @@
import { ImageResponse } from "next/og"; import { ImageResponse } from "next/og";
import { COLORS, BRAND } from "@/lib/constants";
export const size = { width: 64, height: 64 }; export const size = { width: 64, height: 64 };
export const contentType = "image/png"; export const contentType = "image/png";
@@ -13,14 +14,14 @@ export default function Icon() {
display: "flex", display: "flex",
alignItems: "center", alignItems: "center",
justifyContent: "center", justifyContent: "center",
background: "#0a0e1a", background: COLORS.bgPrimary,
borderRadius: "14px", borderRadius: "14px",
fontSize: 44, fontSize: 44,
}} }}
> >
🦞 {BRAND.emoji}
</div> </div>
), ),
{ ...size } size
); );
} }

1
lib/constants/index.ts Normal file
View File

@@ -0,0 +1 @@
export * from "./theme";

10
lib/constants/theme.ts Normal file
View File

@@ -0,0 +1,10 @@
// Theme constants shared across app (including ImageResponse which cannot use CSS variables)
export const COLORS = {
bgPrimary: "#0a0e1a",
bgSecondary: "#111827",
} as const;
export const BRAND = {
emoji: "🦞",
} as const;

View File

@@ -4,5 +4,5 @@ import { routing } from "./i18n/routing";
export default createMiddleware(routing); export default createMiddleware(routing);
export const config = { export const config = {
matcher: ["/((?!api|_next|_vercel|.*\\..*).*)"], matcher: ["/((?!api|_next|_vercel|icon|apple-icon|.*\\..*).*)"],
}; };