diff --git a/components/home/lovart-home.tsx b/components/home/lovart-home.tsx index a0fbd71e7..a8f5786e2 100644 --- a/components/home/lovart-home.tsx +++ b/components/home/lovart-home.tsx @@ -2,7 +2,7 @@ import { Fragment, useEffect, useMemo, useRef, useState } from "react"; import { useRouter } from "next/navigation"; -import { signIn } from "next-auth/react"; +import { signIn, signOut } from "next-auth/react"; import useSWR from "swr"; import useSWRInfinite from "swr/infinite"; import { @@ -12,11 +12,12 @@ import { ChevronDown, Clapperboard, Folder, - Heart, Home, ImageIcon, Info, Loader2, + LogOut, + Mail, Monitor, Palette, Plus, @@ -26,6 +27,7 @@ import { Star, Upload, User, + Users, X, Zap, } from "lucide-react"; @@ -161,6 +163,12 @@ const PROMPT_TAGS = [ const MASONRY_HEIGHTS = [420, 290, 340, 470, 300, 360, 430, 320]; const FEATURED_PAGE_SIZE = 24; +function getUserInitials(user: HomeUser | null) { + const source = (user?.name || user?.email || "mu").trim(); + if (!source) return "mu"; + return source.slice(0, 2).toLowerCase(); +} + function formatRelativeTime(value?: string) { if (!value) return "更新于今天"; const date = new Date(value); @@ -179,6 +187,29 @@ function formatPrice(currency: string, value: number) { return `${currency}${value}`; } +function AccountMenuItem({ + icon: Icon, + label, + onClick, +}: { + icon: typeof User; + label: string; + onClick: () => void; +}) { + return ( + + ); +} + export function LovartHome({ user, isAuthenticated, @@ -669,6 +700,12 @@ export function LovartHome({ previewCursorVisible ? " |" : "" }`; + const userInitials = useMemo(() => getUserInitials(user), [user]); + const userDisplayName = useMemo(() => { + if (!user) return ""; + return (user.name || user.email || "用户").toString(); + }, [user]); + return (
@@ -754,9 +791,94 @@ export function LovartHome({ {isAuthenticated ? ( - + + + + + +
+
+
+
+ {userInitials} +
+
+ +
+
+
+ {userDisplayName} +
+
+ {user?.email || ""} +
+
+ +
+ +
+ +
+
+ +
+ toast.info("团队功能后续开放")} + /> + toast.info("账户管理后续开放")} + /> + toast.info("使用指南后续开放")} + /> + toast.info("联系我们后续开放")} + /> + { + void signOut({ redirect: true, callbackUrl: "/" }); + }} + /> +
+
+
+
) : (