feat(knowledge): 优化知识库创建流程并添加 Markdown 预览功能

- 修改知识库创建流程,支持从第 2步直接进入第 3 步
- 添加 Markdown 文件预览功能
- 优化重新上传逻辑,根据路由参数判断当前步骤
- 新增 reviewKnowledge 组件用于直接上传到知识库之前的预览页面
- 调整步骤显示逻辑,根据文件类型和状态动态显示
This commit is contained in:
陈昱达
2025-05-07 14:27:53 +08:00
parent fa25771622
commit 3b9ebaa814
4 changed files with 140 additions and 21 deletions

View File

@@ -215,6 +215,13 @@ export default {
handleClose() { handleClose() {
this.previewVisible = false this.previewVisible = false
}, },
async previewOperation(documentId) {
const previewData = await this.getPreviewOperation(documentId)
// 4. 显示预览组件
this.showPreview(previewData)
},
// 修改主方法,添加预览功能 // 修改主方法,添加预览功能
nextStep(documentId) { nextStep(documentId) {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
@@ -227,9 +234,7 @@ export default {
this.execSplitOperation(params).then(async res => { this.execSplitOperation(params).then(async res => {
if (res) { if (res) {
// 3. 获取预览 // 3. 获取预览
const previewData = await this.getPreviewOperation(documentId) this.previewOperation(documentId)
// 4. 显示预览组件
this.showPreview(previewData)
} }
}) })
} catch (error) { } catch (error) {

View File

@@ -1,7 +1,7 @@
<template> <template>
<div class="render-container"> <div class="render-container">
<div slot="header" class="clearfix"> <div slot="header" class="clearfix">
<h3>创建知识</h3> <h3>上传知识</h3>
</div> </div>
<div class="card-body mt20"> <div class="card-body mt20">
<el-steps <el-steps
@@ -32,12 +32,22 @@
<div class="components"> <div class="components">
<transition name="slide" appear mode="out-in"> <transition name="slide" appear mode="out-in">
<step-preprocessing <div v-if="active === 0">
ref="stepPreProcessing" <step-preprocessing
v-if="active === 0" ref="stepPreProcessing"
@getForm="getForm" v-if="!isMd"
@getDocumentId="getDocumentId" @getForm="getForm"
></step-preprocessing> @getDocumentId="getDocumentId"
></step-preprocessing>
<r-miner-u
class="mt10"
v-else
:documentId="documentId"
@saveMarkDown="saveMarkDown"
></r-miner-u>
</div>
<step-split-config <step-split-config
ref="splitConfig" ref="splitConfig"
v-if="active === 1" v-if="active === 1"
@@ -58,7 +68,7 @@
type="primary" type="primary"
size="medium" size="medium"
@click="nextStep" @click="nextStep"
v-if="active < 2" v-if="active < 2 && !this.isMd"
>下一步</el-button >下一步</el-button
> >
<el-button <el-button
@@ -69,7 +79,7 @@
>确定</el-button >确定</el-button
> >
<el-button <el-button
v-if="active === 0" v-if="active === 0 && !this.isMd"
type="primary" type="primary"
size="medium" size="medium"
class="line-button" class="line-button"
@@ -112,7 +122,8 @@ export default {
magic, magic,
visible: false, visible: false,
active: 0, active: 0,
documentId: '1365038001244180480' documentId: '1365038001244180480',
isMd: false
} }
}, },
props: {}, props: {},
@@ -127,6 +138,7 @@ export default {
saveMarkDown() { saveMarkDown() {
this.visible = false this.visible = false
this.active++ this.active++
this.isMd = false
}, },
beMinerU() { beMinerU() {
setTimeout(() => { setTimeout(() => {
@@ -175,20 +187,54 @@ export default {
}, },
// 重新上传 // 重新上传
handleReUpload() { handleReUpload() {
this.active = 0 if (this.$route.query.activeLevel) {
this.$router.replace(
`/knowledge/detail/create?datasetId=${this.$route.query.datasetId}`
)
this.active = 0
} else {
this.active = 0
}
} }
}, },
created() { created() {},
let { documentId, datasetId, activeLevel } = this.$route.query mounted() {
console.log(123123)
let { documentId, datasetId, activeLevel, isMd } = this.$route.query
if (documentId) { if (documentId) {
this.documentId = documentId this.documentId = documentId
} }
if (activeLevel) { if (activeLevel !== undefined) {
this.active = activeLevel this.active = Number(activeLevel)
switch (this.active) {
case '0':
case 0:
if (isMd) {
this.isMd = isMd
}
break
case '1':
case 1:
setTimeout(() => {
if (isMd) {
console.log(this.$refs.splitConfig)
this.$refs.splitConfig.previewOperation(documentId)
}
}, 1000)
break
case '2':
case 2:
break
default:
break
}
} }
}, },
mounted() {}, computed: {},
computed: {} beforeRouteLeave(to, form, next) {
this.visible = false
next()
}
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@@ -460,6 +460,30 @@ export default {
} }
}) })
}, },
jumpToUpload(params) {
sessionStorage.removeItem('documentId')
let { datasetId } = this.$route.query
let querys = {}
querys.datasetId = datasetId
querys.documentId = params.row.id
if (params.row.optStatus === 0) {
querys.activeLevel = 1
} else {
querys.activeLevel = params.row.optStatus - 1
querys.isMd = true
}
this.$router.push({
path: '/knowledge/detail/create',
query: {
...querys
}
})
},
// 元数据操作 // 元数据操作
handleAddMetadata(row) { handleAddMetadata(row) {
this.metadataOperatorDrawer.visible = true this.metadataOperatorDrawer.visible = true
@@ -689,7 +713,25 @@ export default {
} }
}, },
'标注元数据' '标注元数据'
) ),
params.row.optStatus < 4
? h(
'el-button',
{
class: 'floatSpan',
props: {
type: 'primary',
size: 'mini',
icon: 'el-icon-tickets',
title: '添加元数据'
},
on: {
click: () => this.jumpToUpload(params)
}
},
'文件拆分处理'
)
: ''
]) ])
} }
} }

View File

@@ -0,0 +1,26 @@
<!--直接上传到知识库之前的页面 预览页面-->
<template>
<div class="render-container"></div>
</template>
<script>
import { preprocessEmbedding, embedding } from '@/api/generatedApi/pdfApi'
// preprocessEmbedding 预览页面
// embedding 题词拆分
export default {
name: 'reviewKnowledge',
data() {
return {}
},
props: {},
watch: {},
components: {},
filters: {},
methods: {},
created() {},
mounted() {},
computed: {}
}
</script>
<style scoped lang="scss"></style>