fix: 修复6个use client页面metadata冲突,创建layout.tsx承载metadata

This commit is contained in:
ZhuiGuangAI Dev
2026-06-12 17:35:30 +08:00
parent 4c325c8699
commit a0a60ee9dc
12 changed files with 58 additions and 34 deletions
+10
View File
@@ -0,0 +1,10 @@
import type { Metadata } from "next";
export const metadata: Metadata = {
title: "追光AI日报 - AI行业前沿资讯",
description: "每日精选AI行业新闻,涵盖模型前沿、产品落地、开源生态、商业产业、政策治理等板块。",
};
export default function DailyLayout({ children }: { children: React.ReactNode }) {
return <>{children}</>;
}
-6
View File
@@ -1,6 +1,5 @@
"use client"; "use client";
import type { Metadata } from "next";
import { useState, useEffect, useMemo } from "react"; import { useState, useEffect, useMemo } from "react";
import Link from "next/link"; import Link from "next/link";
import { HeroBanner } from "@/components/common/HeroBanner"; import { HeroBanner } from "@/components/common/HeroBanner";
@@ -47,11 +46,6 @@ const CATEGORIES: Record<string, { label: string; color: string; bg: string; ico
const CATEGORY_KEYS = Object.keys(CATEGORIES); const CATEGORY_KEYS = Object.keys(CATEGORIES);
const PAGE_SIZE = 15; const PAGE_SIZE = 15;
export const metadata = {
title: "追光AI日报 - AI行业前沿资讯",
description: "每日精选AI行业新闻,涵盖模型前沿、产品落地、开源生态、商业产业、政策治理等板块。",
};
export default function DailyPage() { export default function DailyPage() {
const [allItems, setAllItems] = useState<FlatItem[]>([]); const [allItems, setAllItems] = useState<FlatItem[]>([]);
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
+10
View File
@@ -0,0 +1,10 @@
import type { Metadata } from "next";
export const metadata: Metadata = {
title: "登录 - 追光AI",
description: "登录追光AI,管理你的AI工具收藏与技能评测。",
};
export default function LoginLayout({ children }: { children: React.ReactNode }) {
return <>{children}</>;
}
-6
View File
@@ -1,15 +1,9 @@
"use client"; "use client";
import type { Metadata } from "next";
import { signIn } from "next-auth/react"; import { signIn } from "next-auth/react";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { LoginForm } from "@/components/common/LoginForm"; import { LoginForm } from "@/components/common/LoginForm";
export const metadata: Metadata = {
title: "登录 - 追光AI",
description: "登录追光AI,管理你的AI工具收藏与技能评测。",
};
export default function LoginPage() { export default function LoginPage() {
const router = useRouter(); const router = useRouter();
+10
View File
@@ -0,0 +1,10 @@
import type { Metadata } from "next";
export const metadata: Metadata = {
title: "追光评测 - AI技能深度评测",
description: "五维AI技能评测体系,客观评价开源AI项目的功能性、易用性、文档质量、性能和社区活跃度。",
};
export default function ReviewsLayout({ children }: { children: React.ReactNode }) {
return <>{children}</>;
}
-6
View File
@@ -1,6 +1,5 @@
"use client"; "use client";
import type { Metadata } from "next";
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import { HeroBanner } from "@/components/common/HeroBanner"; import { HeroBanner } from "@/components/common/HeroBanner";
import { ReviewsList } from "./ReviewsList"; import { ReviewsList } from "./ReviewsList";
@@ -22,11 +21,6 @@ interface RankingsData {
totalReviews: number; totalReviews: number;
} }
export const metadata: Metadata = {
title: "追光评测 - AI技能深度评测",
description: "五维AI技能评测体系,客观评价开源AI项目的功能性、易用性、文档质量、性能和社区活跃度。",
};
export default function ReviewsPage() { export default function ReviewsPage() {
const [rankings, setRankings] = useState<RankingsData | null>(null); const [rankings, setRankings] = useState<RankingsData | null>(null);
const [totalReviews, setTotalReviews] = useState(0); const [totalReviews, setTotalReviews] = useState(0);
+9
View File
@@ -0,0 +1,9 @@
import type { Metadata } from "next";
export const metadata: Metadata = {
title: "我的收藏夹 - 追光AI",
};
export default function CollectionsLayout({ children }: { children: React.ReactNode }) {
return <>{children}</>;
}
-5
View File
@@ -1,6 +1,5 @@
"use client"; "use client";
import type { Metadata } from "next";
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import { useSession } from "next-auth/react"; import { useSession } from "next-auth/react";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
@@ -15,10 +14,6 @@ interface Collection {
_count: { items: number }; _count: { items: number };
} }
export const metadata: Metadata = {
title: "我的收藏夹 - 追光AI",
};
export default function CollectionsPage() { export default function CollectionsPage() {
const { data: session, status } = useSession(); const { data: session, status } = useSession();
const router = useRouter(); const router = useRouter();
+9
View File
@@ -0,0 +1,9 @@
import type { Metadata } from "next";
export const metadata: Metadata = {
title: "我的收藏 - 追光AI",
};
export default function FavoritesLayout({ children }: { children: React.ReactNode }) {
return <>{children}</>;
}
-5
View File
@@ -1,6 +1,5 @@
"use client"; "use client";
import type { Metadata } from "next";
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import { useSession } from "next-auth/react"; import { useSession } from "next-auth/react";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
@@ -51,10 +50,6 @@ const sourceTypeColor: Record<string, string> = {
type FilterType = "all" | "tool" | "skill"; type FilterType = "all" | "tool" | "skill";
export const metadata: Metadata = {
title: "我的收藏 - 追光AI",
};
export default function FavoritesPage() { export default function FavoritesPage() {
const { data: session, status } = useSession(); const { data: session, status } = useSession();
const router = useRouter(); const router = useRouter();
+10
View File
@@ -0,0 +1,10 @@
import type { Metadata } from "next";
export const metadata: Metadata = {
title: "个人中心 - 追光AI",
description: "管理你的追光AI个人资料、收藏与成就。",
};
export default function UserLayout({ children }: { children: React.ReactNode }) {
return <>{children}</>;
}
-6
View File
@@ -1,6 +1,5 @@
"use client"; "use client";
import type { Metadata } from "next";
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import { useSession, signOut } from "next-auth/react"; import { useSession, signOut } from "next-auth/react";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
@@ -47,11 +46,6 @@ function getTimeAgo(date: Date | string): string {
return d.toLocaleDateString("zh-CN"); return d.toLocaleDateString("zh-CN");
} }
export const metadata: Metadata = {
title: "个人中心 - 追光AI",
description: "管理你的追光AI个人资料、收藏与成就。",
};
export default function UserProfilePage() { export default function UserProfilePage() {
const { data: session, status } = useSession(); const { data: session, status } = useSession();
const router = useRouter(); const router = useRouter();