fix(minerU): 修复 PDF 识别状态和Markdown 加载问题

- 在 getPDFDetailBbox 方法中添加 iframe 刷新和 Markdown 加载
- 完善 getMinerUStatus 方法,增加识别失败的错误提示
- 优化代码结构,提高可读性和维护性
This commit is contained in:
陈昱达
2025-04-16 17:51:13 +08:00
parent a220919485
commit b4b8674487
2 changed files with 9 additions and 4 deletions

View File

@@ -75,7 +75,7 @@ export function minerUQuery(params) {
} }
//minerU 获取markdown //minerU 获取markdown
export function minerUMarkDown(params) { export function minerUMarkDown(params) {
return getUrl(`document/mineru/md?documentId=${params.documentId}`) return getUrl(`/document/mineru/md?documentId=${params.documentId}`)
} }
// minerU 获取pdf // minerU 获取pdf

View File

@@ -7,6 +7,7 @@
<iframe <iframe
v-if="isShowPdf" v-if="isShowPdf"
id="iframe" id="iframe"
ref="iframe"
:src="`${iframeSrc}/pdfjs-dist/web/viewer.html?file=${encodeURIComponent(prdUrl)}`" :src="`${iframeSrc}/pdfjs-dist/web/viewer.html?file=${encodeURIComponent(prdUrl)}`"
class="miner-u el-card is-always-shadow ml20" class="miner-u el-card is-always-shadow ml20"
></iframe> ></iframe>
@@ -221,6 +222,9 @@ export default {
getPDFDetailBbox() { getPDFDetailBbox() {
minerUBbox({ documentId: this.documentId }).then(res => { minerUBbox({ documentId: this.documentId }).then(res => {
this.bboxList = this.formatJson(JSON.parse(JSON.stringify(res.content.content))) this.bboxList = this.formatJson(JSON.parse(JSON.stringify(res.content.content)))
// this.$refs.iframe 重新刷新iframe
this.$refs.iframe.contentWindow.location.reload()
this.getPDFDetailMarkDown()
}) })
}, },
changeTab() { changeTab() {
@@ -263,8 +267,6 @@ export default {
getMinerUStatus() { getMinerUStatus() {
this.finishedMiner = true this.finishedMiner = true
minerUQuery({ id: this.documentId }).then(res => { minerUQuery({ id: this.documentId }).then(res => {
console.log(res)
let mineruStatus = res.content.content.mineruStatus let mineruStatus = res.content.content.mineruStatus
switch (mineruStatus) { switch (mineruStatus) {
case 0: case 0:
@@ -277,10 +279,13 @@ export default {
case '1': case '1':
this.finishedMiner = false this.finishedMiner = false
this.getPDFDetailBbox() this.getPDFDetailBbox()
this.getPDFDetailMarkDown()
break break
default: default:
this.finishedMiner = false this.finishedMiner = false
this.$message({
message: '识别失败',
type: 'error'
})
break break
} }
}) })