crush-level-web/src/app/(main)/chat/[id]/page.tsx

48 lines
1.6 KiB
TypeScript
Raw Normal View History

2025-12-11 11:31:56 +00:00
'use client';
2025-12-09 09:13:46 +00:00
2025-12-11 11:31:56 +00:00
import { IconButton } from '@/components/ui/button';
import Input from './Input';
import MessageList from './MessageList';
2025-12-18 10:14:12 +00:00
import SettingDialog from './Drawer';
import { useStreamChatStore } from '@/app/(main)/chat/[id]/stream-chat';
2025-12-17 10:13:47 +00:00
import { useParams } from 'next/navigation';
import { useEffect, useState } from 'react';
2025-12-19 10:22:04 +00:00
import { useCharacter } from '@/hooks/services/character';
import Background from './Background';
2025-12-09 09:13:46 +00:00
export default function ChatPage() {
2025-12-19 10:22:04 +00:00
const { id } = useParams<{ id: string }>();
const characterId = id?.split('-')[2] || '';
2025-12-17 10:13:47 +00:00
const [settingOpen, setSettingOpen] = useState(false);
const switchToChannel = useStreamChatStore((s) => s.switchToChannel);
const client = useStreamChatStore((s) => s.client);
2025-12-19 10:22:04 +00:00
const { data: character } = useCharacter(characterId);
2025-12-17 10:13:47 +00:00
useEffect(() => {
if (id && client) {
switchToChannel(id as string);
}
}, [id, client]);
2025-12-09 09:13:46 +00:00
return (
2025-12-19 10:22:04 +00:00
<div className="flex bg-[rgba(6,3,24,1)] h-full">
2025-12-15 11:31:18 +00:00
<div className="relative px-4 w-full flex-1 flex justify-center">
2025-12-19 10:22:04 +00:00
<div className="max-w-[752px] w-full relative h-full flex flex-col">
<Background imageUrl={character?.characterStand || character?.coverImage} />
2025-12-09 09:13:46 +00:00
<MessageList />
<Input />
</div>
<IconButton
2025-12-17 10:13:47 +00:00
onClick={() => setSettingOpen(!settingOpen)}
2025-12-18 10:59:55 +00:00
className="absolute top-2 right-2"
2025-12-09 09:13:46 +00:00
variant="ghost"
size="small"
>
2025-12-18 10:59:55 +00:00
<i className="iconfont-v2 iconv2-zhankai-1" />
2025-12-09 09:13:46 +00:00
</IconButton>
</div>
2025-12-17 10:13:47 +00:00
<SettingDialog open={settingOpen} onOpenChange={setSettingOpen} />
2025-12-09 09:13:46 +00:00
</div>
2025-12-11 11:31:56 +00:00
);
2025-12-09 09:13:46 +00:00
}