feat: add forum seed categories, improve page layouts and navigation

- Seed default forum categories (announcements, learning, feedback) on startup
- Update forum pages with improved category/post/reply UI
- Refine navbar, mobile nav, and home page content layout
- Improve analytics, course-content, knowledge, profile, settings, spatial pages

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-27 10:02:30 +08:00
parent 45e3da82e1
commit 50faf7ad4e
13 changed files with 592 additions and 389 deletions
+7 -25
View File
@@ -38,7 +38,7 @@ const modules = [
visual: "spatial" as const,
},
{
title: "论坛社区",
title: "课程社区",
description: "课程讨论与学习经验交流平台,促进师生互动与同伴学习",
href: "/forum",
tags: ["协作"],
@@ -436,20 +436,12 @@ export default function HomePageContent() {
<p className="text-sm text-muted-foreground leading-relaxed mb-5">
AI技术的国土空间规划智能学习平台RAG检索增强生成
</p>
<div className="flex gap-3">
<Button asChild variant="outline" size="sm">
<a href="https://tsp.spacekg.com/#/" target="_blank" rel="noopener noreferrer">
<BookOpen className="mr-2 h-4 w-4" />
</a>
</Button>
<Button asChild variant="outline" size="sm">
<a href="https://homepage.hit.edu.cn/wusongtao" target="_blank" rel="noopener noreferrer">
<Users className="mr-2 h-4 w-4" />
</a>
</Button>
</div>
<Button asChild variant="outline" size="sm">
<a href="https://homepage.hit.edu.cn/wusongtao" target="_blank" rel="noopener noreferrer">
<Users className="mr-2 h-4 w-4" />
</a>
</Button>
</div>
{/* 快速链接 */}
@@ -463,16 +455,6 @@ export default function HomePageContent() {
</Link>
</li>
))}
<li>
<Link href="/analytics" className="text-sm text-muted-foreground hover:text-foreground transition-colors">
</Link>
</li>
<li>
<Link href="/settings" className="text-sm text-muted-foreground hover:text-foreground transition-colors">
</Link>
</li>
</ul>
</div>
+62 -34
View File
@@ -1,12 +1,13 @@
"use client";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { Button } from "@/components/ui/button";
import { Avatar, AvatarFallback } from "@/components/ui/avatar";
import { ThemeToggle } from "@/components/ui/theme-toggle";
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
import { useAuthStore } from "@/store/auth";
import { BookOpen, LogOut, User as UserIcon, Settings, ChevronDown, MessageSquare, Database, Image, TrendingUp, GraduationCap } from "lucide-react";
import { BookOpen, LogOut, User as UserIcon, Settings, ChevronDown, MessageSquare, Database, Image, TrendingUp, GraduationCap, Users } from "lucide-react";
import { User } from "@/types";
interface NavbarProps {
@@ -14,14 +15,28 @@ interface NavbarProps {
user: User | null;
}
const NAV_LINKS = [
{ href: "/course-content", label: "课程内容", icon: GraduationCap },
{ href: "/chat", label: "智能问答", icon: MessageSquare },
{ href: "/knowledge", label: "知识库", icon: Database },
{ href: "/spatial", label: "空间设计", icon: Image },
{ href: "/forum", label: "课程社区", icon: Users },
];
export default function Navbar({ isAuthenticated, user }: NavbarProps) {
const { logout } = useAuthStore();
const pathname = usePathname();
const isActive = (href: string) => {
if (href === "/forum") return pathname === "/forum" || pathname.startsWith("/forum/");
return pathname === href || pathname.startsWith(href + "/");
};
return (
<nav className="border-b bg-background/95 backdrop-blur-sm sticky top-0 z-50">
<div className="mit-container">
<div className="flex justify-between items-center h-16">
{/* Logo 和标题 */}
{/* Logo */}
<Link href="/" className="flex items-center space-x-3 hover:opacity-80 transition-opacity cursor-pointer">
<div className="w-10 h-10 bg-primary rounded-lg flex items-center justify-center shadow-sm">
<BookOpen className="w-6 h-6 text-white" />
@@ -36,46 +51,60 @@ export default function Navbar({ isAuthenticated, user }: NavbarProps) {
</div>
</Link>
{/* 导航链接 */}
{/* 导航链接 — 带底部下划线指示 */}
{isAuthenticated && (
<div className="hidden md:flex items-center space-x-1">
<Link href="/course-content">
<Button variant="ghost" className="flex items-center space-x-2 px-3 py-2 hover:bg-muted/50">
<GraduationCap className="w-4 h-4" />
<span className="text-sm"></span>
</Button>
</Link>
<Link href="/chat">
<Button variant="ghost" className="flex items-center space-x-2 px-3 py-2 hover:bg-muted/50">
<MessageSquare className="w-4 h-4" />
<span className="text-sm"></span>
</Button>
</Link>
<Link href="/knowledge">
<Button variant="ghost" className="flex items-center space-x-2 px-3 py-2 hover:bg-muted/50">
<Database className="w-4 h-4" />
<span className="text-sm"></span>
</Button>
</Link>
<Link href="/spatial">
<Button variant="ghost" className="flex items-center space-x-2 px-3 py-2 hover:bg-muted/50">
<Image className="w-4 h-4" />
<span className="text-sm"></span>
</Button>
<div className="hidden md:flex items-center h-full -mb-px">
{NAV_LINKS.map((item) => {
const active = isActive(item.href);
return (
<Link
key={item.href}
href={item.href}
className={`
relative flex items-center gap-1.5 px-3 h-full text-sm transition-colors
${active
? "text-primary font-medium"
: "text-muted-foreground hover:text-foreground"
}
`}
>
<item.icon className="w-4 h-4" />
<span>{item.label}</span>
{active && (
<span className="absolute bottom-0 left-3 right-3 h-0.5 bg-primary rounded-full" />
)}
</Link>
);
})}
</div>
)}
{/* 未登录时也显示课程社区链接 */}
{!isAuthenticated && (
<div className="hidden md:flex items-center h-full -mb-px">
<Link
href="/forum"
className={`
relative flex items-center gap-1.5 px-3 h-full text-sm transition-colors
${isActive("/forum")
? "text-primary font-medium"
: "text-muted-foreground hover:text-foreground"
}
`}
>
<Users className="w-4 h-4" />
<span></span>
{isActive("/forum") && (
<span className="absolute bottom-0 left-3 right-3 h-0.5 bg-primary rounded-full" />
)}
</Link>
</div>
)}
<div className="flex items-center space-x-3">
<ThemeToggle />
<Link href="/forum">
<Button variant="outline" size="sm">
</Button>
</Link>
{isAuthenticated && user ? (
// 登录后状态 - 用户下拉菜单
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" className="flex items-center space-x-2 px-3 hover:bg-muted/50">
@@ -127,7 +156,6 @@ export default function Navbar({ isAuthenticated, user }: NavbarProps) {
</DropdownMenuContent>
</DropdownMenu>
) : (
// 未登录状态
<div className="flex items-center space-x-2">
<Button variant="ghost" asChild>
<Link href="/login"></Link>
+7 -5
View File
@@ -4,17 +4,18 @@ import { useState } from "react";
import { useRouter, usePathname } from "next/navigation";
import { useAuthStore } from "@/store/auth";
import { Button } from "@/components/ui/button";
import {
MessageSquare,
BookOpen,
Image,
import {
MessageSquare,
BookOpen,
Image,
Settings,
Menu,
X,
User,
LogOut,
GraduationCap,
TrendingUp
TrendingUp,
Users
} from "lucide-react";
const navItems = [
@@ -22,6 +23,7 @@ const navItems = [
{ id: "chat", name: "对话", icon: MessageSquare, href: "/chat" },
{ id: "knowledge", name: "知识库", icon: BookOpen, href: "/knowledge" },
{ id: "spatial", name: "空间出图", icon: Image, href: "/spatial" },
{ id: "forum", name: "社区", icon: Users, href: "/forum" },
];
export default function MobileNav() {