diff --git a/src/components/HintText.tsx b/src/components/HintText.tsx
index 34fabd3..ace88c4 100644
--- a/src/components/HintText.tsx
+++ b/src/components/HintText.tsx
@@ -1,12 +1,13 @@
import React from 'react';
import './HintText.css';
-const HintText: React.FC = () => {
- return (
-
- 提示:支持输入多行文本与上传图片。按 Enter 发送,Shift+Enter 换行。
-
- );
+type Props = { showUpload?: boolean };
+
+const HintText: React.FC = ({ showUpload = true }) => {
+ const text = showUpload
+ ? '提示:支持输入多行文本与上传图片。按 Enter 发送,Shift+Enter 换行。'
+ : '提示:支持输入多行文本。按 Enter 发送,Shift+Enter 换行。';
+ return {text}
;
};
export default HintText;
\ No newline at end of file
diff --git a/src/components/InputDrawer.tsx b/src/components/InputDrawer.tsx
index 3c73d88..4863fd1 100644
--- a/src/components/InputDrawer.tsx
+++ b/src/components/InputDrawer.tsx
@@ -9,9 +9,11 @@ type Props = {
onClose: () => void;
onResult?: (data: any) => void;
containerEl?: HTMLElement | null; // 抽屉挂载容器(用于放在标题栏下方)
+ showUpload?: boolean; // 透传到输入面板,控制图片上传按钮
+ mode?: 'input' | 'search'; // 透传到输入面板,控制工作模式
};
-const InputDrawer: React.FC = ({ open, onClose, onResult, containerEl }) => {
+const InputDrawer: React.FC = ({ open, onClose, onResult, containerEl, showUpload = true, mode = 'input' }) => {
const screens = Grid.useBreakpoint();
const isMobile = !screens.md;
const [topbarHeight, setTopbarHeight] = React.useState(56);
@@ -64,8 +66,8 @@ const InputDrawer: React.FC = ({ open, onClose, onResult, containerEl })
diff --git a/src/components/InputPanel.tsx b/src/components/InputPanel.tsx
index ac59968..35f65c5 100644
--- a/src/components/InputPanel.tsx
+++ b/src/components/InputPanel.tsx
@@ -1,25 +1,54 @@
import React from 'react';
import { Input, Upload, message, Button, Spin } from 'antd';
-import { PictureOutlined, SendOutlined, LoadingOutlined } from '@ant-design/icons';
-import { postInput, postInputImage } from '../apis';
+import { PictureOutlined, SendOutlined, LoadingOutlined, SearchOutlined } from '@ant-design/icons';
+import { postInput, postInputImage, getPeoples } from '../apis';
import './InputPanel.css';
const { TextArea } = Input;
interface InputPanelProps {
onResult?: (data: any) => void;
+ showUpload?: boolean; // 是否显示图片上传按钮,默认显示
+ mode?: 'input' | 'search'; // 输入面板工作模式,默认为表单填写(input)
}
-const InputPanel: React.FC = ({ onResult }) => {
+const InputPanel: React.FC = ({ onResult, showUpload = true, mode = 'input' }) => {
const [value, setValue] = React.useState('');
const [fileList, setFileList] = React.useState([]);
const [loading, setLoading] = React.useState(false);
const send = async () => {
- const hasText = value.trim().length > 0;
- const hasImage = fileList.length > 0;
- if (!hasText && !hasImage) {
- message.info('请输入内容或上传图片');
+ const trimmed = value.trim();
+ const hasText = trimmed.length > 0;
+ const hasImage = showUpload && fileList.length > 0;
+
+ // 搜索模式:仅以文本触发检索,忽略图片
+ if (mode === 'search') {
+ if (!hasText) {
+ message.info('请输入内容');
+ return;
+ }
+
+ setLoading(true);
+ try {
+ console.log('检索文本:', trimmed);
+ const response = await getPeoples({ search: trimmed, top_k: 10 });
+ console.log('检索响应:', response);
+ if (response.error_code === 0) {
+ message.success('已获取检索结果');
+ onResult?.(response.data || []);
+ // 清空输入
+ setValue('');
+ setFileList([]);
+ } else {
+ message.error(response.error_info || '检索失败,请重试');
+ }
+ } catch (error) {
+ console.error('检索调用失败:', error);
+ message.error('网络错误,请检查连接后重试');
+ } finally {
+ setLoading(false);
+ }
return;
}
@@ -39,8 +68,8 @@ const InputPanel: React.FC = ({ onResult }) => {
response = await postInputImage(file);
} else {
// 只有文本时,调用文本处理 API
- console.log('处理文本:', value.trim());
- response = await postInput(value.trim());
+ console.log('处理文本:', trimmed);
+ response = await postInput(trimmed);
}
console.log('API响应:', response);
@@ -88,7 +117,7 @@ const InputPanel: React.FC = ({ onResult }) => {