Commit 52f6026a by HoMeTown

feat: card-附件的解析

parent 556f96ae
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
...@@ -2,6 +2,9 @@ import { Button, Link } from '@nextui-org/react' ...@@ -2,6 +2,9 @@ import { Button, Link } from '@nextui-org/react'
import { motion } from 'framer-motion' import { motion } from 'framer-motion'
import type { Answer } from '@/types/chat' import type { Answer } from '@/types/chat'
import AnswerProDetailIcon from '@/assets/svg/answerProDetail.svg?react' import AnswerProDetailIcon from '@/assets/svg/answerProDetail.svg?react'
import CardNavImg from '@/assets/card-nav.png'
import CardCalculation from '@/assets/card-calculation.png'
import CardDetailImg from '@/assets/card-detail.png'
interface ChatAnswerAttachmentProps { interface ChatAnswerAttachmentProps {
answer: Answer answer: Answer
...@@ -14,6 +17,10 @@ export const ChatAnswerAttachment: React.FC<ChatAnswerAttachmentProps> = ({ answ ...@@ -14,6 +17,10 @@ export const ChatAnswerAttachment: React.FC<ChatAnswerAttachmentProps> = ({ answ
onSubmitQuestion(produceName, productCode) onSubmitQuestion(produceName, productCode)
} }
} }
const handleClickCard = (url: string) => {
window.open(url)
}
return ( return (
<div className="attachmentList flex flex-col gap-[20px]"> <div className="attachmentList flex flex-col gap-[20px]">
{answer.attachmentList && answer.attachmentList.map((attachment, index) => ( {answer.attachmentList && answer.attachmentList.map((attachment, index) => (
...@@ -75,6 +82,16 @@ export const ChatAnswerAttachment: React.FC<ChatAnswerAttachmentProps> = ({ answ ...@@ -75,6 +82,16 @@ export const ChatAnswerAttachment: React.FC<ChatAnswerAttachmentProps> = ({ answ
</div> </div>
) )
} }
{
attachment.type.includes('card-') && (
<div onClick={() => handleClickCard(attachment.url)}>
{attachment.type === 'card-nav' && <img className="w-full max-w-[400px] cursor-pointer" src={CardNavImg} alt="" />}
{attachment.type === 'card-detail' && <img className="w-full max-w-[400px] cursor-pointer" src={CardDetailImg} alt="" />}
{attachment.type === 'card-calculation' && <img className="w-full max-w-[400px] cursor-pointer" src={CardCalculation} alt="" />}
</div>
)
}
</div> </div>
))} ))}
</div> </div>
......
...@@ -17,6 +17,7 @@ interface AttachmentContent { ...@@ -17,6 +17,7 @@ interface AttachmentContent {
export interface Attachment { export interface Attachment {
type: string type: string
name: string name: string
url: string
description: string description: string
content: AttachmentContent content: AttachmentContent
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment