fix: 补充被覆盖掉的更新
This commit is contained in:
parent
0ef003e0b1
commit
c0a3c956aa
|
|
@ -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 setup部分添加loading状态
|
||||
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>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue