import type { FC } from "react"; import { useContext } from 'use-context-selector' import { DocumentTextIcon } from "@heroicons/react/24/solid"; import { useTranslation } from "react-i18next"; import { hitTesting } from "@/service/datasets"; import DatasetDetailContext from '@/context/dataset-detail' import { HitTestingResponse } from "@/models/datasets"; import cn from "classnames"; import Button from "../../base/button"; import Tag from "../../base/tag"; import Tooltip from "../../base/tooltip"; import s from "./style.module.css"; import { asyncRunSafe } from "@/utils"; type Props = { datasetId: string; onUpdateList: () => void; setHitResult: (res: HitTestingResponse) => void; loading: boolean; setLoading: (v: boolean) => void; text: string; setText: (v: string) => void; }; const TextAreaWithButton: FC = ({ datasetId, onUpdateList, setHitResult, setLoading, loading, text, setText, }) => { const { t } = useTranslation(); const { indexingTechnique } = useContext(DatasetDetailContext) // 处理文本框内容变化的函数 function handleTextChange(event: any) { setText(event.target.value); } // 处理按钮点击的函数 const onSubmit = async () => { setLoading(true); const [e, res] = await asyncRunSafe( hitTesting({ datasetId, queryText: text }) as Promise ); if (!e) { setHitResult(res); onUpdateList?.(); } setLoading(false); }; return ( <>
{t("datasetHitTesting.input.title")}