2025-02-27 06:54:19 +08:00
|
|
|
import React from 'react';
|
2025-03-01 08:34:56 +08:00
|
|
|
import SvgIcon from '../../components/SvgIcon';
|
2025-03-05 03:46:45 +08:00
|
|
|
import { useNavigate } from 'react-router-dom';
|
2025-02-27 06:54:19 +08:00
|
|
|
|
2025-03-04 08:37:47 +08:00
|
|
|
export default function KnowledgeCard({ id, title, description, documents, date, access, onClick, onRequestAccess }) {
|
2025-03-05 03:46:45 +08:00
|
|
|
const navigate = useNavigate();
|
|
|
|
|
2025-03-04 08:37:47 +08:00
|
|
|
const handleNewChat = (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
2025-03-05 03:46:45 +08:00
|
|
|
navigate(`/chat/${id}`);
|
2025-03-04 08:37:47 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const handleRequestAccess = (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
onRequestAccess(id, title);
|
|
|
|
};
|
|
|
|
|
2025-02-27 06:54:19 +08:00
|
|
|
return (
|
2025-03-04 07:22:05 +08:00
|
|
|
<div className='knowledge-card card shadow border-0 p-0 col' onClick={onClick}>
|
|
|
|
<div className='card-body'>
|
|
|
|
<h5 className='card-title'>{title}</h5>
|
|
|
|
<div className='hoverdown position-absolute end-0 top-0'>
|
|
|
|
<button type='button' className='detail-btn btn'>
|
|
|
|
<SvgIcon className={'more-dot'} />
|
|
|
|
</button>
|
|
|
|
<ul className='hoverdown-menu shadow bg-white p-1 rounded'>
|
|
|
|
<li className='p-1 hoverdown-item px-2'>
|
|
|
|
删除
|
|
|
|
<SvgIcon className={'trash'} />
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<p className='card-text text-muted'>{description}</p>
|
|
|
|
<div className='text-muted d-flex align-items-center gap-1'>
|
|
|
|
<SvgIcon className={'file'} />
|
|
|
|
{documents} 文档
|
|
|
|
<span className='ms-3 d-flex align-items-center gap-1'>
|
|
|
|
<SvgIcon className={'clock'} />
|
|
|
|
{date}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div className='mt-3 d-flex justify-content-between align-items-end'>
|
|
|
|
{access === 'full' ? (
|
|
|
|
<span className='badge bg-success-subtle text-success d-flex align-items-center gap-1'>
|
|
|
|
<SvgIcon className={'circle-yes'} />
|
|
|
|
完全访问
|
|
|
|
</span>
|
|
|
|
) : access === 'read' ? (
|
|
|
|
<span className='badge bg-warning-subtle text-warning d-flex align-items-center gap-1'>
|
|
|
|
<SvgIcon className={'eye'} />
|
|
|
|
只读访问
|
2025-02-27 06:54:19 +08:00
|
|
|
</span>
|
2025-03-04 07:22:05 +08:00
|
|
|
) : (
|
|
|
|
<span className='badge bg-dark-subtle d-flex align-items-center gap-1'>
|
|
|
|
<SvgIcon className={'lock'} />
|
|
|
|
无访问权限
|
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
{access === 'full' || access === 'read' ? (
|
2025-03-04 08:37:47 +08:00
|
|
|
<button
|
|
|
|
className='btn btn-outline-dark btn-sm d-flex align-items-center gap-1'
|
|
|
|
onClick={handleNewChat}
|
|
|
|
>
|
2025-03-04 07:22:05 +08:00
|
|
|
<SvgIcon className={'chat-dot'} />
|
|
|
|
新聊天
|
|
|
|
</button>
|
|
|
|
) : (
|
2025-03-04 08:37:47 +08:00
|
|
|
<button
|
|
|
|
className='btn btn-outline-dark btn-sm d-flex align-items-center gap-1'
|
|
|
|
onClick={handleRequestAccess}
|
|
|
|
>
|
2025-03-04 07:22:05 +08:00
|
|
|
<SvgIcon className={'key'} />
|
|
|
|
申请权限
|
|
|
|
</button>
|
|
|
|
)}
|
2025-02-27 06:54:19 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|