Commit 8df296f9 by weiw

fix:文件下载预览的实现

parent d33135e5
......@@ -29,7 +29,14 @@ export const ChatAnswerAttachment: React.FC<ChatAnswerAttachmentProps> = ({ answ
const docId = `${doc.knowledgeName}/${doc.documentStoreKey}`
const res = await fetchGetDocumentLink(docId)
if (res.data) {
window.open(res.data.docUrl)
const link = document.createElement('a')
link.href = res.data.docUrl
link.target = '_blank'
link.rel = 'noopener noreferrer' // 安全考虑
link.style.display = 'none'
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
}
}
return (
......
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