feat:前端新增初版知识库管理页面
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
import React, { useState } from 'react';
|
||||
import { DownOutlined, UpOutlined, BulbOutlined } from '@ant-design/icons';
|
||||
import '../../styles/components/chat-with-llm/thinking-block.css';
|
||||
|
||||
interface ThinkingBlockProps {
|
||||
/** 思考过程内容 */
|
||||
content: string;
|
||||
/** 是否默认展开 */
|
||||
defaultExpanded?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 思考过程展示组件
|
||||
* 参考 GPT-5 和 Claude 网页版的思考过程UI设计
|
||||
* 可折叠的思考过程区域,契合当前淡绿色配色方案
|
||||
*/
|
||||
export default function ThinkingBlock({ content, defaultExpanded = false }: ThinkingBlockProps) {
|
||||
const [expanded, setExpanded] = useState(defaultExpanded);
|
||||
|
||||
if (!content) return null;
|
||||
|
||||
return (
|
||||
<div className="thinking-block">
|
||||
{/* 折叠/展开按钮 */}
|
||||
<div
|
||||
className="thinking-header"
|
||||
onClick={() => setExpanded(!expanded)}
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
setExpanded(!expanded);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className="thinking-title">
|
||||
<BulbOutlined className="thinking-icon" />
|
||||
<span className="thinking-label">思考过程</span>
|
||||
</div>
|
||||
<div className="thinking-toggle">
|
||||
{expanded ? (
|
||||
<UpOutlined className="toggle-icon" />
|
||||
) : (
|
||||
<DownOutlined className="toggle-icon" />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 思考内容 */}
|
||||
{expanded && (
|
||||
<div className="thinking-content">
|
||||
<div className="thinking-text">
|
||||
{content.split('\n').map((line, index) => (
|
||||
<p key={index} className="thinking-paragraph">
|
||||
{line || '\u00A0'}
|
||||
</p>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user