import { useEffect, useState } from 'react'; import { CopyOutlined, DeleteOutlined, MailOutlined, PlusOutlined, TeamOutlined, UserOutlined } from '@ant-design/icons'; import { Card, Button, List, Tag, Space, Popconfirm, App as AntApp, Modal, Form, Input, Empty } from 'antd'; import { AuthAPI, Team, TeamAPI } from '../api'; export default function TeamsPage() { const { message } = AntApp.useApp(); const [list, setList] = useState([]); const [active, setActive] = useState(null); const [createOpen, setCreateOpen] = useState(false); const [inviteOpen, setInviteOpen] = useState(false); const [lastInviteCode, setLastInviteCode] = useState(null); const load = async () => { const l = await TeamAPI.list(); setList(l); if (l.length && !active) setActive(await TeamAPI.detail(l[0].id)); }; useEffect(() => { load(); }, []); const handleCreate = async (v: any) => { const t = await TeamAPI.create(v.name); setCreateOpen(false); message.success('已创建'); await load(); setActive(await TeamAPI.detail(t.id)); }; const handleInvite = async (v: any) => { if (!active) return; const inv = await AuthAPI.createInvite({ teamId: active.id, email: v.email || undefined, ttlHours: Number(v.ttlHours) || 168 }); setLastInviteCode(inv.code); }; return (
协作组织空间

团队管理

团队不只是成员列表,更是共享智能体、协同运营和权限分工的组织单元。这里统一查看团队、成员和邀请状态。
{[ { label: '团队数量', value: list.length, tone: 'rgba(8, 145, 178, 0.10)', color: 'var(--color-brand)' }, { label: '当前成员数', value: active?.members?.length ?? 0, tone: 'rgba(14, 165, 233, 0.10)', color: 'var(--color-info)' }, { label: '共享智能体', value: active?.agentCount ?? 0, tone: 'rgba(34, 197, 94, 0.10)', color: 'var(--color-success)' } ].map((item) => (
{item.label}
{item.value} 当前选中
))}
团队列表
选择一个团队查看成员与邀请
{list.length === 0 ? ( ) : ( (
setActive(await TeamAPI.detail(item.id))} style={{ padding: '10px 12px', borderRadius: 14, cursor: 'pointer', marginBottom: 6, background: active?.id === item.id ? 'rgba(8, 145, 178, 0.10)' : 'transparent', color: active?.id === item.id ? 'var(--color-brand)' : 'var(--color-text-secondary)', fontWeight: active?.id === item.id ? 600 : 500, border: active?.id === item.id ? '1px solid rgba(8, 145, 178, 0.16)' : '1px solid transparent' }} >
{item.name}
{item.agentCount ?? 0} 个智能体
)} /> )}
{active ? (
{active.name} {active.myRole} {active.agentCount ?? 0} 智能体
管理成员权限、邀请新伙伴,并协同维护团队共享的智能体资产。
{(active.myRole === 'owner' || active.myRole === 'admin') && ( )} {active.myRole === 'owner' && ( { await TeamAPI.remove(active.id); message.success('已删除'); setActive(null); load(); }} > )}
成员规模
{active.members?.length || 0}
共享智能体
{active.agentCount ?? 0}
当前身份
{active.myRole}
成员 ({active.members?.length || 0})
( { await TeamAPI.removeMember(active.id, m.id); message.success('已移除'); setActive(await TeamAPI.detail(active.id)); }} > ] : [] } >
} title={ {m.name} {m.role} } description={
{m.email} 加入时间 {new Date(m.joinedAt).toLocaleDateString('zh-CN')}
} /> )} /> ) : ( )}
setCreateOpen(false)} footer={null} destroyOnHidden >
{ setInviteOpen(false); setLastInviteCode(null); }} footer={null} destroyOnHidden > {lastInviteCode ? (
邀请码生成成功,请发给受邀者:
受邀者在注册页填入此邀请码即可加入团队
) : (
)}
); }