Commit 55d8a609 by HoMeTown

feat: doc的跳转

parent 219000a0
...@@ -29,3 +29,15 @@ export function fetchGetDocumentLinks(docIdList: string[]) { ...@@ -29,3 +29,15 @@ export function fetchGetDocumentLinks(docIdList: string[]) {
docIdList, docIdList,
}) })
} }
/**
* 获取文档链接
* @param recordId
* @returns
*/
export function fetchGetDocumentLink(docId: string) {
return http.post('/conversation/api/conversation/mobile/v1/get_document', {
ossType: 'private',
docId,
})
}
...@@ -5,13 +5,15 @@ import AnswerProDetailIcon from '@/assets/svg/answerProDetail.svg?react' ...@@ -5,13 +5,15 @@ import AnswerProDetailIcon from '@/assets/svg/answerProDetail.svg?react'
import CardNavImg from '@/assets/card-nav.png' import CardNavImg from '@/assets/card-nav.png'
import CardCalculation from '@/assets/card-calculation.png' import CardCalculation from '@/assets/card-calculation.png'
import CardDetailImg from '@/assets/card-detail.png' import CardDetailImg from '@/assets/card-detail.png'
import { fetchGetDocumentLink } from '@/api/common'
interface ChatAnswerAttachmentProps { interface ChatAnswerAttachmentProps {
answer: Answer answer: Answer
isLastAnswer?: boolean isLastAnswer?: boolean
fromParser?: boolean
onSubmitQuestion?: (question: string, productCode?: string) => void onSubmitQuestion?: (question: string, productCode?: string) => void
} }
export const ChatAnswerAttachment: React.FC<ChatAnswerAttachmentProps> = ({ answer, isLastAnswer, onSubmitQuestion }) => { export const ChatAnswerAttachment: React.FC<ChatAnswerAttachmentProps> = ({ fromParser, answer, isLastAnswer, onSubmitQuestion }) => {
const handleClickBoxItem = (produceName: string, productCode: string) => { const handleClickBoxItem = (produceName: string, productCode: string) => {
if (onSubmitQuestion) { if (onSubmitQuestion) {
onSubmitQuestion(produceName, productCode) onSubmitQuestion(produceName, productCode)
...@@ -21,6 +23,17 @@ export const ChatAnswerAttachment: React.FC<ChatAnswerAttachmentProps> = ({ answ ...@@ -21,6 +23,17 @@ export const ChatAnswerAttachment: React.FC<ChatAnswerAttachmentProps> = ({ answ
const handleClickCard = (url: string) => { const handleClickCard = (url: string) => {
window.open(url) window.open(url)
} }
const handleClickDocLink = async (docId: string) => {
if (fromParser) {
const res = await fetchGetDocumentLink(docId)
if (res.data)
window.location.href = res.data.docUrl
}
else {
window.location.href = docId
}
}
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) => (
...@@ -46,7 +59,7 @@ export const ChatAnswerAttachment: React.FC<ChatAnswerAttachmentProps> = ({ answ ...@@ -46,7 +59,7 @@ export const ChatAnswerAttachment: React.FC<ChatAnswerAttachmentProps> = ({ answ
</p> </p>
<div className="flex flex-col gap-[9px]"> <div className="flex flex-col gap-[9px]">
{ attachment.content.docList.map((doc, docIdx) => ( { attachment.content.docList.map((doc, docIdx) => (
<Link size="sm" key={doc.docId} isExternal href={doc.docId} showAnchorIcon underline="hover"> <Link className="cursor-pointer" onPress={() => handleClickDocLink(doc.docId)} size="sm" key={doc.docId} isExternal showAnchorIcon underline="hover">
{docIdx + 1} {docIdx + 1}
. .
{' '} {' '}
......
...@@ -139,7 +139,7 @@ export const ChatAnswerParser: React.FC<ChatAnswerParserProps> = ({ isLastAnswer ...@@ -139,7 +139,7 @@ export const ChatAnswerParser: React.FC<ChatAnswerParserProps> = ({ isLastAnswer
{!isTyping {!isTyping
&& answer.attachmentList && answer.attachmentList
&& answer.attachmentList?.length !== 0 && answer.attachmentList?.length !== 0
&& <ChatAnswerAttachment isLastAnswer={isLastAnswer} onSubmitQuestion={onSubmitQuestion} answer={answer} />} && <ChatAnswerAttachment fromParser isLastAnswer={isLastAnswer} onSubmitQuestion={onSubmitQuestion} answer={answer} />}
{!isTyping && !hideOperate && <ChatAnswerOperate answer={answer} />} {!isTyping && !hideOperate && <ChatAnswerOperate answer={answer} />}
</div> </div>
......
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