2026-07-21 11:29:36 +08:00
|
|
|
|
import { Button, Card, Input, Space, Typography } from '@arco-design/web-react'
|
|
|
|
|
|
import {
|
|
|
|
|
|
IconArrowUp,
|
|
|
|
|
|
IconAttachment,
|
|
|
|
|
|
IconPlusCircle,
|
|
|
|
|
|
IconRobot,
|
|
|
|
|
|
} from '@arco-design/web-react/icon'
|
|
|
|
|
|
import type { AISession, ProjectWorkspace } from './project-types'
|
2026-07-20 12:26:21 +08:00
|
|
|
|
|
2026-07-21 11:29:36 +08:00
|
|
|
|
const { Title, Text } = Typography
|
2026-07-20 12:26:21 +08:00
|
|
|
|
|
2026-07-20 13:02:26 +08:00
|
|
|
|
export function ProjectAi({ activeWorkspace, onSelectItem }: { activeWorkspace: ProjectWorkspace; onSelectItem: (title: string) => void }) {
|
2026-07-21 11:37:21 +08:00
|
|
|
|
const { aiSessions } = activeWorkspace
|
2026-07-21 11:29:36 +08:00
|
|
|
|
const groupedSessions = groupSessions(aiSessions)
|
2026-07-20 13:02:26 +08:00
|
|
|
|
|
2026-07-20 12:26:21 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<div className="project-channel-page project-ai-page overview-page">
|
2026-07-21 11:29:36 +08:00
|
|
|
|
<div className="agent-chat-shell">
|
|
|
|
|
|
<Card className="agent-session-list queue-section" bordered>
|
|
|
|
|
|
<Button className="agent-new-chat" icon={<IconPlusCircle />}>
|
|
|
|
|
|
开启新对话
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
|
|
|
|
<div className="agent-session-groups">
|
|
|
|
|
|
{groupedSessions.length ? (
|
|
|
|
|
|
groupedSessions.map((group) => (
|
|
|
|
|
|
<section className="agent-session-group" key={group.label}>
|
|
|
|
|
|
<Text type="secondary">{group.label}</Text>
|
|
|
|
|
|
{group.items.map((session, index) => (
|
|
|
|
|
|
<button
|
|
|
|
|
|
className={index === 0 && group.label === groupedSessions[0]?.label ? 'agent-session active' : 'agent-session'}
|
|
|
|
|
|
key={session.id}
|
|
|
|
|
|
onClick={() => onSelectItem(session.title)}
|
|
|
|
|
|
>
|
|
|
|
|
|
{session.title}
|
|
|
|
|
|
</button>
|
|
|
|
|
|
))}
|
|
|
|
|
|
</section>
|
|
|
|
|
|
))
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<Text type="secondary">暂无对话</Text>
|
|
|
|
|
|
)}
|
2026-07-20 12:26:21 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
2026-07-21 11:29:36 +08:00
|
|
|
|
<Card className="agent-chat-panel queue-section" bordered>
|
|
|
|
|
|
<div className="agent-chat-main">
|
|
|
|
|
|
<Title heading={2}>选择专家,开始对话</Title>
|
2026-07-20 12:26:21 +08:00
|
|
|
|
</div>
|
2026-07-21 11:29:36 +08:00
|
|
|
|
<div className="agent-composer">
|
|
|
|
|
|
<Input.TextArea placeholder="给 DeepSeek 发送消息" autoSize={{ minRows: 3, maxRows: 6 }} />
|
|
|
|
|
|
<div className="agent-composer-footer">
|
|
|
|
|
|
<Button className="agent-model-chip" icon={<IconRobot />}>
|
|
|
|
|
|
DeepSeek V4.0 Flash
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
<Space>
|
|
|
|
|
|
<Button type="text" icon={<IconAttachment />} />
|
|
|
|
|
|
<Button className="agent-send-button" type="primary" shape="circle" icon={<IconArrowUp />} />
|
|
|
|
|
|
</Space>
|
|
|
|
|
|
</div>
|
2026-07-20 12:26:21 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
2026-07-21 11:29:36 +08:00
|
|
|
|
|
|
|
|
|
|
function groupSessions(sessions: AISession[]) {
|
|
|
|
|
|
const labels = ['今天', '昨天', '7 天内']
|
|
|
|
|
|
return labels.map((label) => ({
|
|
|
|
|
|
label,
|
|
|
|
|
|
items: sessions.filter((session, index) => session.time.includes(label) || (!labels.some((item) => session.time.includes(item)) && labels.indexOf(label) === fallbackGroupIndex(index))),
|
|
|
|
|
|
})).filter((group) => group.items.length > 0)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function fallbackGroupIndex(index: number) {
|
|
|
|
|
|
if (index === 0) return 0
|
|
|
|
|
|
if (index === 1) return 1
|
|
|
|
|
|
return 2
|
|
|
|
|
|
}
|