feat(search): Added app embedding functionality and optimized search page #3221 (#9499)

### What problem does this PR solve?
feat(search): Added app embedding functionality and optimized search
page #3221

- Added an Embed App button and related functionality
- Optimized the layout and interaction of the search settings interface
- Adjusted the search result display method
- Refactored some code to support new features
### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
chanx
2025-08-15 18:25:00 +08:00
committed by GitHub
parent 99df0766fe
commit f9e5caa8ed
24 changed files with 1299 additions and 493 deletions

View File

@ -1,4 +1,4 @@
import { useFetchMindMap, useFetchRelatedQuestions } from '@/hooks/chat-hooks';
import { useFetchRelatedQuestions } from '@/hooks/chat-hooks';
import { useSetModalState } from '@/hooks/common-hooks';
import {
useTestChunkAllRetrieval,
@ -18,17 +18,23 @@ import {
useRef,
useState,
} from 'react';
import {
useGetSharedSearchParams,
useSearchFetchMindMap,
} from '../next-search/hooks';
export const useSendQuestion = (kbIds: string[]) => {
export const useSendQuestion = (kbIds: string[], tenantId?: string) => {
const { sharedId } = useGetSharedSearchParams();
const { send, answer, done, stopOutputMessage } = useSendMessageWithSse(
api.ask,
sharedId ? api.askShare : api.ask,
);
const { testChunk, loading } = useTestChunkRetrieval();
const { testChunkAll } = useTestChunkAllRetrieval();
const { testChunk, loading } = useTestChunkRetrieval(tenantId);
const { testChunkAll } = useTestChunkAllRetrieval(tenantId);
const [sendingLoading, setSendingLoading] = useState(false);
const [currentAnswer, setCurrentAnswer] = useState({} as IAnswer);
const { fetchRelatedQuestions, data: relatedQuestions } =
useFetchRelatedQuestions();
useFetchRelatedQuestions(tenantId);
const [searchStr, setSearchStr] = useState<string>('');
const [isFirstRender, setIsFirstRender] = useState(true);
const [selectedDocumentIds, setSelectedDocumentIds] = useState<string[]>([]);
@ -43,7 +49,7 @@ export const useSendQuestion = (kbIds: string[]) => {
setIsFirstRender(false);
setCurrentAnswer({} as IAnswer);
setSendingLoading(true);
send({ kb_ids: kbIds, question: q });
send({ kb_ids: kbIds, question: q, tenantId });
testChunk({
kb_id: kbIds,
highlight: true,
@ -61,6 +67,7 @@ export const useSendQuestion = (kbIds: string[]) => {
fetchRelatedQuestions,
setPagination,
pagination.pageSize,
tenantId,
],
);
@ -218,7 +225,7 @@ export const useShowMindMapDrawer = (kbIds: string[], question: string) => {
fetchMindMap,
data: mindMap,
loading: mindMapLoading,
} = useFetchMindMap();
} = useSearchFetchMindMap();
const handleShowModal = useCallback(() => {
const searchParams = { question: trim(question), kb_ids: kbIds };