feat: 画布欢迎语展示用户名与累计生图数
This commit is contained in:
parent
81ccf96cbd
commit
278418ff7d
@ -3,6 +3,7 @@
|
||||
import { useChat } from "@ai-sdk/react";
|
||||
import { DefaultChatTransport } from "ai";
|
||||
import { useEffect, useRef, useState, useCallback, useMemo } from "react";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { createPortal } from "react-dom";
|
||||
import useSWR, { useSWRConfig } from "swr";
|
||||
import { Send, Loader2, ImagePlus, Paperclip, X, Plus, History, LayoutGrid, Maximize2, RefreshCw, Globe, Box, ArrowUp, Video, Sparkles, Check, ChevronDown, ChevronUp, AlertCircle, CheckCircle2, Brain, ThumbsUp, ThumbsDown, Eye, Trash2, Download, MessageCircle } from "lucide-react";
|
||||
@ -1383,6 +1384,7 @@ function buildDetailReviewAppendMarkdown(params: {
|
||||
}
|
||||
|
||||
export function CanvasChatPanel({ chatId, initialMessages = [], onClose, onOpenFileList }: CanvasChatPanelProps) {
|
||||
const { data: session } = useSession();
|
||||
const [input, setInput] = useState("");
|
||||
const [attachments, setAttachments] = useState<PickedObjectAttachment[]>([]);
|
||||
const [selectedModelId, setSelectedModelId] = useState<string>("");
|
||||
@ -2251,12 +2253,29 @@ export function CanvasChatPanel({ chatId, initialMessages = [], onClose, onOpenF
|
||||
};
|
||||
summary?: {
|
||||
currentCredits?: number;
|
||||
totalImages?: number;
|
||||
};
|
||||
} | null>("/api/user/membership-summary", async (url: string) => {
|
||||
const response = await fetch(url, { cache: "no-store" });
|
||||
if (!response.ok) return null;
|
||||
return response.json();
|
||||
});
|
||||
const greetingUserName = useMemo(() => {
|
||||
const userName = String(session?.user?.name || "").trim();
|
||||
if (userName) return userName;
|
||||
const email = String(session?.user?.email || "").trim();
|
||||
if (email.includes("@")) {
|
||||
return email.split("@")[0];
|
||||
}
|
||||
return "";
|
||||
}, [session?.user?.email, session?.user?.name]);
|
||||
const greetingTitle = greetingUserName
|
||||
? `Hi, ${greetingUserName},我是你的AI设计师`
|
||||
: "Hi, 我是你的AI设计师";
|
||||
const totalGeneratedImages = Number(membershipSummary?.summary?.totalImages ?? NaN);
|
||||
const subtitleSuffix = Number.isFinite(totalGeneratedImages)
|
||||
? ` 累计为你生成了 ${totalGeneratedImages.toLocaleString()} 张图。`
|
||||
: "";
|
||||
const aiDetailGenerationEnabled = siteSettings?.aiDetailGenerationEnabled === true;
|
||||
|
||||
const VIDEO_PROVIDER_TYPES = new Set(["volcano-video", "doubao-video", "qianwen-video", "fal-video"]);
|
||||
@ -6247,8 +6266,10 @@ export function CanvasChatPanel({ chatId, initialMessages = [], onClose, onOpenF
|
||||
<div className={cn("flex flex-col h-full", isDetailGenerationMode ? "pt-0" : "pt-4")}>
|
||||
{/* Greeting */}
|
||||
<div className={cn(isDetailGenerationMode ? "mb-4" : "mb-8")}>
|
||||
<h1 className="text-2xl font-bold mb-2">Hi, 我是你的AI设计师</h1>
|
||||
<p className="text-muted-foreground">让我们开始今天的创作吧!</p>
|
||||
<h1 className="text-2xl font-bold mb-2">{greetingTitle}</h1>
|
||||
<p className="text-muted-foreground">
|
||||
让我们开始今天的创作吧!{subtitleSuffix}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Suggestions - Removed */}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user