Fix: The embedded page for search is inaccessible. (#14194)

### What problem does this PR solve?

Fix: The embedded page for search is inaccessible.
### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
balibabu
2026-04-17 21:37:34 +08:00
committed by GitHub
parent 60506ef7a5
commit fa644c5a15
7 changed files with 44 additions and 26 deletions

View File

@@ -8,6 +8,7 @@ import {
LanguageAbbreviationMap,
} from '@/constants/common';
import { useTranslate } from '@/hooks/common-hooks';
import { useFetchTenantInfo } from '@/hooks/use-user-setting-request';
import { useCallback, useMemo, useState } from 'react';
type IEmbedAppModalProps = {
@@ -16,13 +17,14 @@ type IEmbedAppModalProps = {
token: string;
from: string;
setOpen: (e: any) => void;
tenantId: string;
beta?: string;
};
const EmbedAppModal = (props: IEmbedAppModalProps) => {
const { t } = useTranslate('search');
const { open, setOpen, token = '', from, url, tenantId, beta = '' } = props;
const { data: tenantInfo } = useFetchTenantInfo();
const tenantId = tenantInfo.tenant_id;
const { open, setOpen, token = '', from, url, beta = '' } = props;
const [hideAvatar, setHideAvatar] = useState(false);
const [locale, setLocale] = useState('');

View File

@@ -46,8 +46,7 @@ export const useGetSharedSearchParams = () => {
const [searchParams] = useSearchParams();
const data_prefix = 'data_';
const data = Object.fromEntries(
searchParams
.entries()
Array.from(searchParams.entries())
.filter(([key]) => key.startsWith(data_prefix))
.map(([key, value]) => [key.replace(data_prefix, ''), value]),
);

View File

@@ -1,7 +1,6 @@
import { useFetchTokenListBeforeOtherStep } from '@/components/embed-dialog/use-show-embed-dialog';
import { Button } from '@/components/ui/button';
import { SharedFrom } from '@/constants/chat';
import { useFetchTenantInfo } from '@/hooks/use-user-setting-request';
import { cn } from '@/lib/utils';
import { Routes } from '@/routes';
import { Send } from 'lucide-react';
@@ -9,27 +8,14 @@ import { useState } from 'react';
import { useFetchSearchDetail } from '../next-searches/hooks';
import EmbedAppModal from './embed-app-modal';
export function RAGFlowLogo({
onClick,
}: {
onClick?: React.MouseEventHandler<HTMLHeadingElement>;
}) {
function EmbedIcon() {
const [openEmbed, setOpenEmbed] = useState(false);
const { beta, handleOperate } = useFetchTokenListBeforeOtherStep();
const { data: tenantInfo } = useFetchTenantInfo();
const tenantId = tenantInfo.tenant_id;
const { data: SearchData } = useFetchSearchDetail();
return (
<div className="flex gap-4 items-center">
<h1
onClick={onClick}
className={cn(
'text-4xl font-bold bg-gradient-to-l from-[#40EBE3] to-[#4A51FF] bg-clip-text',
)}
>
RAGFlow
</h1>
<>
<Button
variant={'outline'}
onClick={() => {
@@ -48,9 +34,30 @@ export function RAGFlowLogo({
url={Routes.SearchShare}
token={SearchData?.id as string}
from={SharedFrom.Search}
tenantId={tenantId}
beta={beta}
/>
</>
);
}
export function RAGFlowLogo({
onClick,
showEmbedIcon = true,
}: {
onClick?: React.MouseEventHandler<HTMLHeadingElement>;
showEmbedIcon?: boolean;
}) {
return (
<div className="flex gap-4 items-center">
<h1
onClick={onClick}
className={cn(
'text-4xl font-bold bg-gradient-to-l from-[#40EBE3] to-[#4A51FF] bg-clip-text',
)}
>
RAGFlow
</h1>
{showEmbedIcon && <EmbedIcon></EmbedIcon>}
</div>
);
}

View File

@@ -6,7 +6,7 @@ import { Search } from 'lucide-react';
import { Dispatch, SetStateAction } from 'react';
import { useTranslation } from 'react-i18next';
import './index.less';
import { RAGFlowLogo } from './ragflow-log';
import { RAGFlowLogo } from './ragflow-logo';
export default function SearchHome({
isSearching,
@@ -15,6 +15,7 @@ export default function SearchHome({
setSearchText,
userInfo,
canSearch,
showEmbedLogo,
}: {
isSearching: boolean;
setIsSearching: Dispatch<SetStateAction<boolean>>;
@@ -22,13 +23,14 @@ export default function SearchHome({
setSearchText: Dispatch<SetStateAction<string>>;
userInfo?: IUserInfo;
canSearch?: boolean;
showEmbedLogo?: boolean;
}) {
// const { data: userInfo } = useFetchUserInfo();
const { t } = useTranslation();
return (
<section className="relative w-full flex transition-all justify-center items-center mt-[15vh]">
<div className="relative z-10 px-8 pt-8 flex text-transparent flex-col justify-center items-center w-[780px]">
<RAGFlowLogo></RAGFlowLogo>
<RAGFlowLogo showEmbedIcon={showEmbedLogo}></RAGFlowLogo>
<div className="rounded-lg text-primary text-xl sticky flex justify-center w-full transform scale-100 mt-8 p-6 h-[240px] border">
{!isSearching && <Spotlight className="z-0" />}
<div className="flex flex-col justify-center items-center w-2/3">

View File

@@ -25,7 +25,7 @@ import { ISearchReturnProps } from './hooks';
import './index.less';
import MarkdownContent from './markdown-content';
import MindMapDrawer from './mindmap-drawer';
import { RAGFlowLogo } from './ragflow-log';
import { RAGFlowLogo } from './ragflow-logo';
import RetrievalDocuments from './retrieval-documents';
export default function SearchingView({
@@ -57,9 +57,11 @@ export default function SearchingView({
handleSearch,
pagination,
onChange,
showEmbedLogo,
}: ISearchReturnProps & {
setIsSearching?: Dispatch<SetStateAction<boolean>>;
searchData: ISearchAppDetailProps;
showEmbedLogo?: boolean;
}) {
const { t } = useTranslation();
@@ -85,6 +87,7 @@ export default function SearchingView({
onClick={() => {
setIsSearching?.(false);
}}
showEmbedIcon={showEmbedLogo}
></RAGFlowLogo>
<div
className={cn(

View File

@@ -8,11 +8,13 @@ export default function SearchingPage({
data: searchData,
setIsSearching,
setSearchText,
showEmbedLogo,
}: {
searchText: string;
setIsSearching: Dispatch<SetStateAction<boolean>>;
setSearchText: Dispatch<SetStateAction<string>>;
data: ISearchAppDetailProps;
showEmbedLogo?: boolean;
}) {
const searchingParam = useSearching({
searchText,
@@ -25,6 +27,7 @@ export default function SearchingPage({
{...searchingParam}
searchData={searchData}
setIsSearching={setIsSearching}
showEmbedLogo={showEmbedLogo}
/>
);
}

View File

@@ -9,7 +9,7 @@ import { useCheckSettings, useGetSharedSearchParams } from '../hooks';
import '../index.less';
import SearchHome from '../search-home';
import SearchingPage from '../searching';
export default function ShareSeachPage() {
export default function ShareSearchPage() {
const { tenantId, locale, visibleAvatar } = useGetSharedSearchParams();
const {
data: searchData = {
@@ -48,6 +48,7 @@ export default function ShareSeachPage() {
searchText={searchText}
setSearchText={setSearchText}
canSearch={!canSearch}
showEmbedLogo={false}
/>
</div>
)}
@@ -58,6 +59,7 @@ export default function ShareSeachPage() {
searchText={searchText}
setSearchText={setSearchText}
data={searchData as ISearchAppDetailProps}
showEmbedLogo={false}
/>
</div>
)}