fix(首页): 使用真实登录用户昵称显示问候语

- 移除 mock 数据中的 currentUser 引用
- 使用 AuthProvider 获取真实登录用户信息
- 未登录时显示默认昵称"用户"
This commit is contained in:
gaoziman 2025-12-22 00:09:33 +08:00
parent d4de4381f2
commit c18bb27794

View File

@ -6,13 +6,15 @@ import { AppLayout } from '@/components/layout/AppLayout';
import { Welcome } from '@/components/features/Welcome'; import { Welcome } from '@/components/features/Welcome';
import { ChatInput } from '@/components/features/ChatInput'; import { ChatInput } from '@/components/features/ChatInput';
import { QuickActions } from '@/components/features/QuickActions'; import { QuickActions } from '@/components/features/QuickActions';
import { currentUser, getGreeting } from '@/data/mock'; import { getGreeting } from '@/data/mock';
import { useAuth } from '@/providers/AuthProvider';
import { useConversations } from '@/hooks/useConversations'; import { useConversations } from '@/hooks/useConversations';
import { useModels, useTools, useSettings } from '@/hooks/useSettings'; import { useModels, useTools, useSettings } from '@/hooks/useSettings';
import type { QuickAction } from '@/types'; import type { QuickAction } from '@/types';
export default function HomePage() { export default function HomePage() {
const router = useRouter(); const router = useRouter();
const { user } = useAuth();
const { createConversation } = useConversations(); const { createConversation } = useConversations();
const { models, loading: modelsLoading } = useModels(); const { models, loading: modelsLoading } = useModels();
const { tools: availableTools, loading: toolsLoading } = useTools(); const { tools: availableTools, loading: toolsLoading } = useTools();
@ -22,7 +24,8 @@ export default function HomePage() {
const [enabledTools, setEnabledTools] = useState<string[]>([]); const [enabledTools, setEnabledTools] = useState<string[]>([]);
const [isSending, setIsSending] = useState(false); const [isSending, setIsSending] = useState(false);
const greeting = getGreeting(currentUser.name); // 使用真实登录用户的昵称,如果未登录则显示"用户"
const greeting = getGreeting(user?.nickname || '用户');
// 初始化默认设置 // 初始化默认设置
useEffect(() => { useEffect(() => {