fix: 优化markdown解析器

This commit is contained in:
imeepos 2025-07-22 18:06:46 +08:00
parent 9a0ddb72d5
commit 9d3eb6d925
4 changed files with 51 additions and 19 deletions

View File

@ -14,7 +14,7 @@ use std::sync::{Arc, Mutex};
// 导入会话管理相关模块
use crate::data::models::conversation::{
ConversationMessage, MessageRole, MessageContent, ConversationHistoryQuery,
CreateConversationSessionRequest, AddMessageRequest,
AddMessageRequest,
};
use crate::data::repositories::conversation_repository::ConversationRepository;

View File

@ -401,6 +401,8 @@ export const ChatInterface: React.FC<ChatInterfaceProps> = ({
showSources={showSources}
enableMaterialCards={enableImageCards}
enableReferences={true}
selectedTags={selectedTags}
onTagClick={toggleTag}
/>
))}
</>

View File

@ -47,6 +47,10 @@ interface EnhancedChatMessageV2Props {
enableReferences?: boolean;
/** 自定义样式类名 */
className?: string;
/** 已选中的标签列表 */
selectedTags?: string[];
/** 标签点击回调 */
onTagClick?: (tag: string) => void;
}
/**
@ -58,7 +62,9 @@ export const EnhancedChatMessageV2: React.FC<EnhancedChatMessageV2Props> = ({
showSources = true,
enableMaterialCards = true,
enableReferences = true,
className = ''
className = '',
selectedTags = [],
onTagClick
}) => {
const [copied, setCopied] = useState(false);
const [expandedSources, setExpandedSources] = useState(false);
@ -205,6 +211,8 @@ export const EnhancedChatMessageV2: React.FC<EnhancedChatMessageV2Props> = ({
showDetails={true}
className="cursor-pointer"
onViewLarge={() => handleMaterialClick(source as GroundingSource)}
selectedTags={selectedTags}
onTagClick={onTagClick}
/>
))}
</div>

View File

@ -34,6 +34,10 @@ interface ImageCardProps {
onViewLarge?: (source: GroundingSource) => void;
/** 自定义样式类名 */
className?: string;
/** 已选中的标签列表 */
selectedTags?: string[];
/** 标签点击回调 */
onTagClick?: (tag: string) => void;
}
/**
@ -46,7 +50,9 @@ export const ImageCard: React.FC<ImageCardProps> = ({
position,
onClose,
onDownload,
className = ''
className = '',
selectedTags = [],
onTagClick
}) => {
const [imageLoaded, setImageLoaded] = useState(false);
const [imageError, setImageError] = useState(false);
@ -186,14 +192,22 @@ export const ImageCard: React.FC<ImageCardProps> = ({
<div className="flex items-start space-x-2">
<MapPin className="w-3 h-3 text-gray-400 mt-0.5 flex-shrink-0" />
<div className="flex flex-wrap gap-1 min-w-0">
{(expandedEnvironmentTags ? environmentTags : environmentTags.slice(0, 2)).map((tag: string, index: number) => (
<span
key={index}
className="px-2 py-1 bg-blue-50 text-blue-700 text-xs rounded-md font-medium"
>
{tag}
</span>
))}
{(expandedEnvironmentTags ? environmentTags : environmentTags.slice(0, 2)).map((tag: string, index: number) => {
const isSelected = selectedTags.includes(tag);
return (
<button
key={index}
onClick={() => onTagClick?.(tag)}
className={`px-2 py-1 text-xs rounded-md font-medium transition-all duration-200 cursor-pointer ${
isSelected
? 'bg-pink-500 text-white shadow-md transform scale-105'
: 'bg-blue-50 text-blue-700 hover:bg-pink-100 hover:text-pink-700'
}`}
>
{tag}
</button>
);
})}
{environmentTags.length > 2 && (
<button
onClick={() => setExpandedEnvironmentTags(!expandedEnvironmentTags)}
@ -211,14 +225,22 @@ export const ImageCard: React.FC<ImageCardProps> = ({
<div className="flex items-start space-x-2">
<Shirt className="w-3 h-3 text-gray-400 mt-0.5 flex-shrink-0" />
<div className="flex flex-wrap gap-1 min-w-0">
{(expandedCategories ? categories : categories.slice(0, 2)).map((category: string, index: number) => (
<span
key={index}
className="px-2 py-1 bg-pink-50 text-pink-700 text-xs rounded-md font-medium"
>
{category}
</span>
))}
{(expandedCategories ? categories : categories.slice(0, 2)).map((category: string, index: number) => {
const isSelected = selectedTags.includes(category);
return (
<button
key={index}
onClick={() => onTagClick?.(category)}
className={`px-2 py-1 text-xs rounded-md font-medium transition-all duration-200 cursor-pointer ${
isSelected
? 'bg-pink-500 text-white shadow-md transform scale-105'
: 'bg-pink-50 text-pink-700 hover:bg-pink-100 hover:text-pink-800'
}`}
>
{category}
</button>
);
})}
{categories.length > 2 && (
<button
onClick={() => setExpandedCategories(!expandedCategories)}