fix: 补充被覆盖掉的更新

This commit is contained in:
wenjinbo 2025-09-23 08:44:51 +08:00
parent 0ef003e0b1
commit c0a3c956aa
2 changed files with 217 additions and 37 deletions

View File

@ -78,17 +78,18 @@
</div>
<!-- 文件表格 -->
<el-table
v-loading="tableLoading"
:element-loading-text="$t('vabI18n.knowledge.document.messages.loading')"
:data="fileList"
stripe
class="file-table"
:row-style="{ height: '50px' }"
:header-row-style="{ height: '50px' }"
@selection-change="handleSelectionChange"
@row-dblclick="handleRowDoubleClick"
>
<el-table
v-loading="tableLoading"
:element-loading-text="$t('vabI18n.knowledge.document.messages.loading')"
:data="fileList"
stripe
class="file-table"
:row-style="{ height: '50px' }"
:header-row-style="{ height: '50px' }"
@selection-change="handleSelectionChange"
@row-dblclick="handleRowDoubleClick"
@sort-change="handleSortChange"
>
<el-table-column type="selection" width="55" />
<el-table-column
:label="$t('vabI18n.knowledge.document.table.index')"
@ -97,7 +98,7 @@
type="index"
:index="indexMethod"
/>
<el-table-column prop="fileName" :label="t('vabI18n.knowledge.document.table.fileName')" min-width="250">
<el-table-column prop="fileName" :label="t('vabI18n.knowledge.document.table.fileName')" min-width="250" sortable="custom" :sort-orders="['ascending', 'descending']">
<template #default="{ row }">
<div class="file-name-cell">
<img
@ -132,14 +133,14 @@
<span v-else class="folder-status">--</span>
</template>
</el-table-column>
<el-table-column prop="createDate" :label="t('vabI18n.knowledge.document.table.createDate')" width="180" />
<el-table-column prop="charCount" :label="t('vabI18n.knowledge.document.table.charCount')" width="120" align="right">
<el-table-column prop="createDate" :label="t('vabI18n.knowledge.document.table.createDate')" width="180" sortable="custom" :sort-orders="['ascending', 'descending']" />
<el-table-column prop="charCount" :label="t('vabI18n.knowledge.document.table.charCount')" width="120" align="right" sortable="custom" :sort-orders="['ascending', 'descending']">
<template #default="{ row }">
<span class="char-count" v-if="row.type === 'file'">{{ formatFileSize(row.charCount) }}</span>
<span v-else class="folder-indicator">--</span>
</template>
</el-table-column>
<el-table-column :label="t('vabI18n.knowledge.document.table.actions')" width="320" fixed="right">
<el-table-column :label="t('vabI18n.knowledge.document.table.actions')" width="380" fixed="right">
<template #default="{ row }">
<div class="action-buttons">
<!-- 文件操作 -->
@ -166,6 +167,15 @@
>
{{t('vabI18n.knowledge.document.buttons.download')}}
</el-button>
<el-button
type="warning"
:icon="Upload"
text
class="action-btn"
@click="handleFileReplaceFromRow(row)"
>
替换
</el-button>
</template>
<!-- 文件夹操作 -->
<template v-else>
@ -234,6 +244,43 @@
@success="handleUploadSuccess"
/>
</el-dialog>
<!-- 文件替换对话框 -->
<el-dialog
v-model="replaceDialogVisible"
title="替换文件"
width="900px"
:close-on-click-modal="false"
class="upload-dialog"
>
<div v-if="replaceTargetFile" class="replace-info">
<div class="target-file-info">
<h4>将要替换的文件</h4>
<div class="file-info-card">
<img
:src="getFileTypeIcon(replaceTargetFile.fileType)"
alt="文件图标"
class="file-icon"
/>
<div class="file-details">
<div class="file-name">{{ replaceTargetFile.fileName }}</div>
<div class="file-meta">
<span>大小{{ formatFileSize(replaceTargetFile.charCount) }}</span>
<span>创建时间{{ replaceTargetFile.createDate }}</span>
</div>
</div>
</div>
</div>
</div>
<DocUpload
:visible="replaceDialogVisible"
:dataset-id="datasetId"
:parent-id="currentParentId"
:replace-file-id="replaceTargetFile?.id"
@update:visible="replaceDialogVisible = $event"
@success="handleReplaceSuccess"
/>
</el-dialog>
<!-- 预览抽屉 -->
@ -312,7 +359,7 @@
<el-dialog
v-model="previewDialogVisible"
:title="分段详情"
title="分段详情"
:direction="'rtl'"
size="80%"
class="preview-drawer"
@ -513,7 +560,7 @@ const segmentIsLoading = ref(false)
const segmentPage = ref(2)
const segmentPageSize = ref(10)
const segmentdocId = ref('')
const previewSegment = ref("")
const previewSegment = ref<any>({})
const previewDialogVisible = ref(false)
const route = useRoute();
const router = useRouter();
@ -522,6 +569,8 @@ const datasetName = ref('');
const previewLoading = ref(true)
const uploadDialogVisible = ref(false)
const replaceDialogVisible = ref(false)
const replaceTargetFile = ref<FileItem | null>(null)
//
const renameDialogVisible = ref(false)
@ -577,6 +626,8 @@ const handleClose = () => {
onUnmounted(() => {
//
document.removeEventListener('click', hideContextMenu)
//
stopAutoRefresh()
})
const getFileTypeIcon = (fileType: string) => {
@ -829,6 +880,12 @@ const triggerFileInput = () => {
uploadDialogVisible.value = true
}
// -
const handleFileReplaceFromRow = (row: FileItem) => {
replaceTargetFile.value = row
replaceDialogVisible.value = true
}
const indexMethod = (index: number) => {
return (pagination.current - 1) * pagination.size + index + 1
}
@ -839,9 +896,22 @@ return (pagination.current - 1) * pagination.size + index + 1
const handleUploadSuccess = async () => {
uploadDialogVisible.value = false
await fetchDocuments()
// ElNotification({
// title: t('vabI18n.knowledge.document.messages.uploadSuccess'),
// message: t('vabI18n.knowledge.document.messages.uploadSuccessEnd'),
// type: 'success'
// })
}
//
const handleReplaceSuccess = async () => {
replaceDialogVisible.value = false
replaceTargetFile.value = null
selectedRows.value = [] //
await fetchDocuments()
ElNotification({
title: t('vabI18n.knowledge.document.messages.uploadSuccess'),
message: t('vabI18n.knowledge.document.messages.uploadSuccessEnd'),
title: '替换成功',
message: '文件替换成功',
type: 'success'
})
}
@ -971,6 +1041,34 @@ const handlePreview = async (row: FileItem) => {
// script setuploading
const tableLoading = ref(false)
//
const refreshTimer = ref<NodeJS.Timeout | null>(null)
//
const sortConfig = reactive({
orderBy: 'name',
orderDirection: 'ASC'
})
//
const startAutoRefresh = () => {
stopAutoRefresh() //
refreshTimer.value = setInterval(() => {
//
if (!tableLoading.value) {
fetchDocuments()
}
}, 30000) // 30
}
//
const stopAutoRefresh = () => {
if (refreshTimer.value) {
clearInterval(refreshTimer.value)
refreshTimer.value = null
}
}
// fetchDocuments
const fetchDocuments = async () => {
tableLoading.value = true
@ -979,8 +1077,8 @@ try {
difyDatasetId: datasetId.value,
parentId: currentParentId.value, // 使ID
fileName: searchKeyword.value || undefined,
orderBy: 'name',
orderDirection: 'ASC',
orderBy: sortConfig.orderBy,
orderDirection: sortConfig.orderDirection,
pageNo: pagination.current,
pageSize: pagination.size
}
@ -1119,6 +1217,8 @@ datasetId.value = route.params.id as string
datasetName.value = route.query.name as string
// API
await fetchDocuments()
//
startAutoRefresh()
})
//
@ -1132,6 +1232,25 @@ pagination.current = 1
fetchDocuments()
}
//
const handleSortChange = (sortInfo: any) => {
if (sortInfo.prop && sortInfo.order) {
//
const fieldMapping: Record<string, string> = {
'fileName': 'name',
'createDate': 'created_at',
'charCount': 'size'
}
sortConfig.orderBy = fieldMapping[sortInfo.prop] || sortInfo.prop
sortConfig.orderDirection = sortInfo.order === 'ascending' ? 'ASC' : 'DESC'
//
pagination.current = 1
fetchDocuments()
}
}
//
const handleOpenFolder = (row: FileItem) => {
// ID
@ -2337,20 +2456,21 @@ transform: scale(0.9) translateY(-5px);
word-break: break-word; //
}
h4 {
font-family: "Microsoft YaHei", "微软雅黑", sans-serif; //
font-size: 14px;
font-weight: 600;
color: #4a4a4a;
margin: 0;
line-height: 1.6;
display: -webkit-box;
-webkit-line-clamp: 4;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
word-break: break-word;
}
h4 {
font-family: "Microsoft YaHei", "微软雅黑", sans-serif; //
font-size: 14px;
font-weight: 600;
color: #4a4a4a;
margin: 0;
line-height: 1.6;
display: -webkit-box;
-webkit-line-clamp: 4;
line-clamp: 4;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
word-break: break-word;
}
}
.empty-state {
@ -2442,4 +2562,64 @@ transform: scale(0.9) translateY(-5px);
//
.replace-info {
margin-bottom: 24px;
padding: 20px;
background: #f8f9fa;
border-radius: 8px;
border-left: 4px solid #e6a23c;
.target-file-info {
h4 {
margin: 0 0 16px 0;
color: #303133;
font-size: 16px;
font-weight: 600;
}
.file-info-card {
display: flex;
align-items: center;
gap: 12px;
padding: 16px;
background: white;
border-radius: 6px;
border: 1px solid #ebeef5;
.file-icon {
width: 32px;
height: 32px;
flex-shrink: 0;
object-fit: contain;
}
.file-details {
flex: 1;
.file-name {
font-size: 14px;
font-weight: 600;
color: #303133;
margin-bottom: 4px;
}
.file-meta {
display: flex;
gap: 16px;
font-size: 12px;
color: #909399;
span {
&:not(:last-child)::after {
content: '•';
margin-left: 8px;
color: #dcdfe6;
}
}
}
}
}
}
}
</style>

View File

@ -172,7 +172,7 @@ public class DifyDatasetApiServiceImpl implements DifyDatasetApiService {
// 5. 如果是深度解析提交到队列处理
if (DifyConstants.ANALYSIS_STRATEGY_DEEP.equals(request.getAnalysisStrategyType())) {
if (DifyConstants.ANALYSIS_STRATEGY_DEEP.equals(request.getAnalysisStrategyType()) && "pdf".equals(fileExtension)) {
stepStartTime = System.currentTimeMillis();
logger.info("开始PDF深度解析队列处理");
@ -630,7 +630,7 @@ public class DifyDatasetApiServiceImpl implements DifyDatasetApiService {
}
return strategy;
} else {
List<DocAnalysisStrategy> strategies = docAnalysisStrategyService.queryByName(analysisStrategyType);
List<DocAnalysisStrategy> strategies = docAnalysisStrategyService.queryByName("adaption");
if (strategies == null || strategies.isEmpty()) {
throw new DifyServiceException(DifyConstants.ERROR_STRATEGY_NULL);
}