mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-30 16:45:35 +08:00
### What problem does this PR solve? Feat: Add Sessions component #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
53
web/src/pages/next-chats/chat-card.tsx
Normal file
53
web/src/pages/next-chats/chat-card.tsx
Normal file
@ -0,0 +1,53 @@
|
||||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
|
||||
import { IDialog } from '@/interfaces/database/chat';
|
||||
import { formatPureDate } from '@/utils/date';
|
||||
import { ChevronRight, Trash2 } from 'lucide-react';
|
||||
|
||||
interface IProps {
|
||||
data: IDialog;
|
||||
}
|
||||
|
||||
export function ChatCard({ data }: IProps) {
|
||||
const { navigateToChat } = useNavigatePage();
|
||||
|
||||
return (
|
||||
<Card className="bg-colors-background-inverse-weak border-colors-outline-neutral-standard">
|
||||
<CardContent className="p-4">
|
||||
<div className="flex justify-between mb-4">
|
||||
{data.icon ? (
|
||||
<div
|
||||
className="w-[70px] h-[70px] rounded-xl bg-cover"
|
||||
style={{ backgroundImage: `url(${data.icon})` }}
|
||||
/>
|
||||
) : (
|
||||
<Avatar className="w-[70px] h-[70px]">
|
||||
<AvatarImage src="https://github.com/shadcn.png" />
|
||||
<AvatarFallback>CN</AvatarFallback>
|
||||
</Avatar>
|
||||
)}
|
||||
</div>
|
||||
<h3 className="text-xl font-bold mb-2">{data.name}</h3>
|
||||
<p>An app that does things An app that does things</p>
|
||||
<section className="flex justify-between pt-3">
|
||||
<div>
|
||||
Search app
|
||||
<p className="text-sm opacity-80">
|
||||
{formatPureDate(data.update_time)}
|
||||
</p>
|
||||
</div>
|
||||
<div className="space-x-2">
|
||||
<Button variant="icon" size="icon" onClick={navigateToChat}>
|
||||
<ChevronRight className="h-6 w-6" />
|
||||
</Button>
|
||||
<Button variant="icon" size="icon">
|
||||
<Trash2 />
|
||||
</Button>
|
||||
</div>
|
||||
</section>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
3
web/src/pages/next-chats/chat/app-settings.tsx
Normal file
3
web/src/pages/next-chats/chat/app-settings.tsx
Normal file
@ -0,0 +1,3 @@
|
||||
export function AppSettings() {
|
||||
return <section className="p-6 w-[400px] max-w-[20%]">app-settings</section>;
|
||||
}
|
||||
3
web/src/pages/next-chats/chat/chat-box.tsx
Normal file
3
web/src/pages/next-chats/chat/chat-box.tsx
Normal file
@ -0,0 +1,3 @@
|
||||
export function ChatBox() {
|
||||
return <section className="border-x flex-1">ChatBox</section>;
|
||||
}
|
||||
31
web/src/pages/next-chats/chat/index.tsx
Normal file
31
web/src/pages/next-chats/chat/index.tsx
Normal file
@ -0,0 +1,31 @@
|
||||
import { PageHeader } from '@/components/page-header';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
|
||||
import { EllipsisVertical } from 'lucide-react';
|
||||
import { AppSettings } from './app-settings';
|
||||
import { ChatBox } from './chat-box';
|
||||
import { Sessions } from './sessions';
|
||||
|
||||
export default function Chat() {
|
||||
const { navigateToChatList } = useNavigatePage();
|
||||
|
||||
return (
|
||||
<section className="h-full flex flex-col">
|
||||
<PageHeader back={navigateToChatList} title="Chat app 01">
|
||||
<div className="flex items-center gap-2">
|
||||
<Button variant={'icon'} size={'icon'}>
|
||||
<EllipsisVertical />
|
||||
</Button>
|
||||
<Button variant={'tertiary'} size={'sm'}>
|
||||
Publish
|
||||
</Button>
|
||||
</div>
|
||||
</PageHeader>
|
||||
<div className="flex flex-1">
|
||||
<Sessions></Sessions>
|
||||
<ChatBox></ChatBox>
|
||||
<AppSettings></AppSettings>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
38
web/src/pages/next-chats/chat/sessions.tsx
Normal file
38
web/src/pages/next-chats/chat/sessions.tsx
Normal file
@ -0,0 +1,38 @@
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { EllipsisVertical, Plus } from 'lucide-react';
|
||||
|
||||
function SessionCard() {
|
||||
return (
|
||||
<Card className="bg-colors-background-inverse-weak border-colors-outline-neutral-standard">
|
||||
<CardContent className="px-3 py-2 flex justify-between items-center">
|
||||
xxx
|
||||
<Button variant={'icon'} size={'icon'}>
|
||||
<EllipsisVertical />
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
export function Sessions() {
|
||||
const sessionList = new Array(10).fill(1);
|
||||
|
||||
return (
|
||||
<section className="p-6 w-[400px] max-w-[20%]">
|
||||
<div className="flex justify-between items-center mb-4">
|
||||
<span className="text-colors-text-neutral-strong text-2xl font-bold">
|
||||
Sessions
|
||||
</span>
|
||||
<Button variant={'icon'} size={'icon'}>
|
||||
<Plus></Plus>
|
||||
</Button>
|
||||
</div>
|
||||
<div className="space-y-4">
|
||||
{sessionList.map((x) => (
|
||||
<SessionCard key={x.id}></SessionCard>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
22
web/src/pages/next-chats/index.tsx
Normal file
22
web/src/pages/next-chats/index.tsx
Normal file
@ -0,0 +1,22 @@
|
||||
import ListFilterBar from '@/components/list-filter-bar';
|
||||
import { useFetchNextDialogList } from '@/hooks/chat-hooks';
|
||||
import { Plus } from 'lucide-react';
|
||||
import { ChatCard } from './chat-card';
|
||||
|
||||
export default function ChatList() {
|
||||
const { data: chatList } = useFetchNextDialogList();
|
||||
|
||||
return (
|
||||
<section className="p-8">
|
||||
<ListFilterBar title="Chat apps">
|
||||
<Plus className="mr-2 h-4 w-4" />
|
||||
Create app
|
||||
</ListFilterBar>
|
||||
<div className="grid gap-6 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-4 xl:grid-cols-6 2xl:grid-cols-8">
|
||||
{chatList.map((x) => {
|
||||
return <ChatCard key={x.id} data={x}></ChatCard>;
|
||||
})}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user