fix:check
This commit is contained in:
@@ -33,8 +33,8 @@ const DocumentDetails: FC = () => {
|
|||||||
documentId,
|
documentId,
|
||||||
parentId: locationParentId,
|
parentId: locationParentId,
|
||||||
breadcrumbPath
|
breadcrumbPath
|
||||||
} = location.state as {
|
} = (location.state || {}) as {
|
||||||
documentId: string;
|
documentId?: string;
|
||||||
parentId?: string;
|
parentId?: string;
|
||||||
breadcrumbPath?: BreadcrumbPath;
|
breadcrumbPath?: BreadcrumbPath;
|
||||||
};
|
};
|
||||||
@@ -51,6 +51,18 @@ const DocumentDetails: FC = () => {
|
|||||||
const insertModalRef = useRef<InsertModalRef>(null);
|
const insertModalRef = useRef<InsertModalRef>(null);
|
||||||
const isManualRefreshRef = useRef(false);
|
const isManualRefreshRef = useRef(false);
|
||||||
|
|
||||||
|
// Early return if no documentId
|
||||||
|
if (!documentId) {
|
||||||
|
return (
|
||||||
|
<div className="rb:flex rb:items-center rb:justify-center rb:h-full rb:flex-col rb:gap-4">
|
||||||
|
<div className="rb:text-gray-500">{t('knowledgeBase.documentIdRequired') || '文档ID不能为空'}</div>
|
||||||
|
<Button type="primary" onClick={() => navigate(-1)}>
|
||||||
|
{t('common.back') || '返回'}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (documentId) {
|
if (documentId) {
|
||||||
fetchDocumentDetail();
|
fetchDocumentDetail();
|
||||||
|
|||||||
@@ -617,7 +617,7 @@ const CreateModal = forwardRef<CreateModalRef, CreateModalRefProps>(({
|
|||||||
{thirdPartyPlatform === 'feishu' && (
|
{thirdPartyPlatform === 'feishu' && (
|
||||||
<>
|
<>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name={['parser_config', 'app_id']}
|
name={['parser_config', 'feishu_app_id']}
|
||||||
label={t('knowledgeBase.createForm.feishuAppId')}
|
label={t('knowledgeBase.createForm.feishuAppId')}
|
||||||
rules={[{ required: true, message: t('knowledgeBase.createForm.feishuAppIdRequired') }]}
|
rules={[{ required: true, message: t('knowledgeBase.createForm.feishuAppIdRequired') }]}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { NoData } from './noData';
|
|||||||
import { formatDateTime } from '@/utils/format';
|
import { formatDateTime } from '@/utils/format';
|
||||||
import InfiniteScroll from 'react-infinite-scroll-component';
|
import InfiniteScroll from 'react-infinite-scroll-component';
|
||||||
import RbMarkdown from '@/components/Markdown';
|
import RbMarkdown from '@/components/Markdown';
|
||||||
|
import { useMemo } from 'react';
|
||||||
|
|
||||||
interface RecallTestResultProps {
|
interface RecallTestResultProps {
|
||||||
data: RecallTestData[];
|
data: RecallTestData[];
|
||||||
@@ -61,6 +62,36 @@ const RecallTestResult = ({
|
|||||||
return `**${t('knowledgeBase.question')}:** ${question}\n**${t('knowledgeBase.answer')}:** ${answer}`;
|
return `**${t('knowledgeBase.question')}:** ${question}\n**${t('knowledgeBase.answer')}:** ${answer}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Check if content is valid HTML
|
||||||
|
const isValidHTML = (content: string): boolean => {
|
||||||
|
if (!content) return false;
|
||||||
|
// Check if content contains HTML tags
|
||||||
|
const htmlTagPattern = /<[^>]+>/;
|
||||||
|
return htmlTagPattern.test(content);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Render content with HTML or Markdown fallback
|
||||||
|
const renderTextContent = useMemo(() => {
|
||||||
|
return (content: string) => {
|
||||||
|
// Try to render as HTML first
|
||||||
|
if (isValidHTML(content)) {
|
||||||
|
try {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className='rb:prose rb:prose-sm rb:max-w-none'
|
||||||
|
dangerouslySetInnerHTML={{ __html: content }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('HTML parsing failed, falling back to Markdown:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback to Markdown rendering
|
||||||
|
return <RbMarkdown content={content} showHtmlComments={true} />;
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleItemClick = (e: React.MouseEvent, item: RecallTestData, index: number) => {
|
const handleItemClick = (e: React.MouseEvent, item: RecallTestData, index: number) => {
|
||||||
// Check if the click is on an image or image-related element
|
// Check if the click is on an image or image-related element
|
||||||
const target = e.target as HTMLElement;
|
const target = e.target as HTMLElement;
|
||||||
@@ -167,9 +198,9 @@ const RecallTestResult = ({
|
|||||||
const qaContent = parseQAContent(item.page_content);
|
const qaContent = parseQAContent(item.page_content);
|
||||||
if (qaContent) {
|
if (qaContent) {
|
||||||
const formattedContent = formatQAContent(qaContent.question, qaContent.answer);
|
const formattedContent = formatQAContent(qaContent.question, qaContent.answer);
|
||||||
return <RbMarkdown content={formattedContent} showHtmlComments={true} />;
|
return renderTextContent(formattedContent);
|
||||||
}
|
}
|
||||||
return <RbMarkdown content={item.page_content} showHtmlComments={true} />;
|
return renderTextContent(item.page_content);
|
||||||
})()}
|
})()}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user