feat(knowledge): 添加下载知识文件模板功能

- task-page.js
  1. 添加对应的接口
- request.js
  1. 更改校验显示
- preprocessing.vue
  实现 下载模板的功能
This commit is contained in:
Huangzhe
2025-04-17 15:03:07 +08:00
parent eb3be6ba57
commit 3f9f96646d
3 changed files with 74 additions and 16 deletions

View File

@@ -46,7 +46,8 @@
<el-form-item label="是否进行预处理:" required prop="beMinerU">
<template slot="label">
是否进行预处理
<el-tooltip class="item" effect="dark" content="通过整合最先进的文档解析模型来提高内容提取质量" placement="top">
<el-tooltip class="item" effect="dark" content="通过整合最先进的文档解析模型来提高内容提取质量"
placement="top">
<i class="el-icon-info ml5" style="color: #909399;"></i>
</el-tooltip>
@@ -82,7 +83,9 @@
</div>
</template>
<script>
import { uploadFileByCustom, uploadFileByTemplate } from '@/api/generatedApi/index'
import { uploadFileByCustom, uploadFileByTemplate } from '@/api/generatedApi'
import { downloadKnowledgeTemplate } from '@/api/knowledge/task-page'
export default {
name: 'preprocessing',
data() {
@@ -110,7 +113,40 @@ export default {
getFileType() {
this.$emit('getFileType', this.form.radio)
},
downloadTemplate() {},
downloadTemplate() {
downloadKnowledgeTemplate().then((res) => {
// 创建Blob URL
const blob = new Blob([res.data])
const url = window.URL.createObjectURL(blob)
console.log(`blob url: `, url)
// 创建一个临时a标签并触发点击
const link = document.createElement('a')
link.href = url
// 尝试从响应头获取文件名,如果没有则使用默认名称
// const contentDisposition = res.headers['content-disposition']
// console.log(`content-disposition: `, contentDisposition)
let filename = '知识文件模板.pdf'
// if (contentDisposition) {
// const filenameMatch = contentDisposition.match(/filename="?(.+)"?/)
// if (filenameMatch && filenameMatch[1]) {
// filename = filenameMatch[1]
// }
// }
link.setAttribute('download', filename)
document.body.appendChild(link)
link.click()
// 清理
window.URL.revokeObjectURL(url)
document.body.removeChild(link)
}).catch(error => {
this.$message.error(error)
})
},
// 生成filed
createFiled() {
@@ -204,8 +240,10 @@ export default {
return true
}
},
created() {},
mounted() {},
created() {
},
mounted() {
},
computed: {}
}
</script>
@@ -219,9 +257,11 @@ export default {
height: 330px;
width: 50%;
text-align: center;
&:hover {
border-color: #409eff;
}
&.drag-over {
border-color: #409eff;
background-color: #ecf5ff;
@@ -238,6 +278,7 @@ export default {
}
}
}
#preprocessing-container {
}
@@ -271,6 +312,7 @@ export default {
overflow-y: auto;
}
}
.dialog-footer {
text-align: center;
}