Commit a2628d26 by zangsuyun

fix:资料优化

parent 66117db6
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* @Author: zangsuyun * @Author: zangsuyun
* @Date: 2021-03-12 14:49:40 * @Date: 2021-03-12 14:49:40
* @LastEditors: zangsuyun * @LastEditors: zangsuyun
* @LastEditTime: 2021-04-09 10:18:44 * @LastEditTime: 2021-04-10 10:55:13
* @Copyright: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyright: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -83,6 +83,48 @@ class KnowledgeBaseList extends React.Component { ...@@ -83,6 +83,48 @@ class KnowledgeBaseList extends React.Component {
}); });
}; };
getBlob = (url) => {
return new Promise((resolve) => {
const xhr = new XMLHttpRequest()
xhr.open('GET', url, true)
xhr.responseType = 'blob'
xhr.onload = () => {
if (xhr.status === 200) {
resolve(xhr.response)
}
}
xhr.send()
})
}
saveAs = (blob, filename) => {
if (window.navigator.msSaveOrOpenBlob) {
navigator.msSaveBlob(blob, filename)
} else {
const link = document.createElement('a')
const body = document.querySelector('body')
// 创建对象url
link.href = window.URL.createObjectURL(blob)
link.download = filename
body.appendChild(link)
link.click()
body.removeChild(link)
// 通过调用 URL.createObjectURL() 创建的 URL 对象
window.URL.revokeObjectURL(link.href)
}
}
// 下载文件
handleDownload = (folder) => {
this.getBlob(folder.ossUrl).then((blob) => {
this.saveAs(blob, folder.folderName)
})
}
// 预览文件 // 预览文件
handleScanFile = (folder) => { handleScanFile = (folder) => {
console.log(folder); console.log(folder);
...@@ -113,9 +155,7 @@ class KnowledgeBaseList extends React.Component { ...@@ -113,9 +155,7 @@ class KnowledgeBaseList extends React.Component {
// icon: <Icon type="question-circle" theme="filled" style={{ color: '#FF8534' }}></Icon>, // icon: <Icon type="question-circle" theme="filled" style={{ color: '#FF8534' }}></Icon>,
okText: "下载", okText: "下载",
onOk: () => { onOk: () => {
const a = document.createElement("a"); this.handleDownload(folder)
a.href = ossUrl;
a.click();
}, },
}); });
break; break;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* @Author: zangsuyun * @Author: zangsuyun
* @Date: 2021-03-12 14:25:52 * @Date: 2021-03-12 14:25:52
* @LastEditors: zangsuyun * @LastEditors: zangsuyun
* @LastEditTime: 2021-04-01 16:14:29 * @LastEditTime: 2021-04-10 11:23:08
* @Copyright: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyright: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -76,7 +76,7 @@ export default function KnowledgeBaseOpt({ ...@@ -76,7 +76,7 @@ export default function KnowledgeBaseOpt({
isOpen={true} isOpen={true}
accept=".ppt,.pptx,.doc,.docx,.pdf,.jpg,.jpeg,.png,.xlsx,.xls" accept=".ppt,.pptx,.doc,.docx,.pdf,.jpg,.jpeg,.png,.xlsx,.xls"
tooltip="支持文件类型:ppt、word、excel、pdf、jpg、jpeg、png" tooltip="支持文件类型:ppt、word、excel、pdf、jpg、jpeg、png"
selectTypeList={["JPG", "JPEG", "PNG",'DOC','PDF','EXCEL']} // DOC 包含 .ppt,.pptx,.doc,.docx,.xls selectTypeList={["JPG", "JPEG", "PNG",'DOC','PDF','EXCEL','application/msword','application/vnd.ms-powerpoint']} // DOC 包含 .pptx,.docx,.xls.XLSX,WORD:DOC
onClose={() => { onClose={() => {
setModal(null); setModal(null);
}} }}
......
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