diff --git a/frontend/src/components/doc-content.vue b/frontend/src/components/doc-content.vue
index 6f659607..f22c41d8 100644
--- a/frontend/src/components/doc-content.vue
+++ b/frontend/src/components/doc-content.vue
@@ -8,7 +8,7 @@ import mermaid from "mermaid";
import { onMounted, ref, nextTick, onUnmounted, watch, computed } from "vue";
import { downKnowledgeDetails, deleteGeneratedQuestion, getChunkByIdOnly, previewKnowledgeFile } from "@/api/knowledge-base/index";
import { MessagePlugin, DialogPlugin } from "tdesign-vue-next";
-import { sanitizeHTML, safeMarkdownToHTML, createSafeImage, isValidImageURL, hydrateProtectedFileImages } from '@/utils/security';
+import { sanitizeHTML, safeMarkdownToHTML, createSafeImage, isValidImageURL, hydrateProtectedFileImages, isValidURL } from '@/utils/security';
import { openMermaidFullscreen } from '@/utils/mermaidViewer';
import { useI18n } from 'vue-i18n';
import DocumentPreview from '@/components/document-preview.vue';
@@ -778,7 +778,7 @@ const handleDetailsScroll = () => {
{{ $t('knowledgeBase.urlSource') }}
-
+
{{ details.source }}
diff --git a/frontend/src/views/knowledge/KnowledgeBase.vue b/frontend/src/views/knowledge/KnowledgeBase.vue
index 5e347eba..96b74206 100644
--- a/frontend/src/views/knowledge/KnowledgeBase.vue
+++ b/frontend/src/views/knowledge/KnowledgeBase.vue
@@ -166,7 +166,7 @@ const onVisibleChange = (visible: boolean) => {
}
};
let isCardDetails = ref(false);
-let timeout: ReturnType | null = null;
+let timeout: ReturnType | null = null;
let delDialog = ref(false)
let rebuildDialog = ref(false)
let rebuildKnowledgeItem = ref({ id: '', parse_status: '' })
@@ -715,6 +715,10 @@ onUnmounted(() => {
window.removeEventListener('knowledgeFileUploaded', handleFileUploaded as EventListener);
window.removeEventListener('openURLImportDialog', handleOpenURLImportDialog as EventListener);
stopMovePoll();
+ if (timeout !== null) {
+ clearTimeout(timeout);
+ timeout = null;
+ }
});
watch(() => cardList.value, (newValue) => {
if (isFAQ.value) return;
@@ -734,7 +738,7 @@ watch(() => cardList.value, (newValue) => {
return isParsing || isSummaryPending;
})
if (timeout !== null) {
- clearInterval(timeout);
+ clearTimeout(timeout);
timeout = null;
}
if (analyzeList.length) {
@@ -761,25 +765,59 @@ type KnowledgeCard = {
tag_id?: string;
};
const updateStatus = (analyzeList: KnowledgeCard[]) => {
+ if (timeout !== null) {
+ clearTimeout(timeout);
+ timeout = null;
+ }
+ if (!analyzeList.length) return;
+
let query = ``;
for (let i = 0; i < analyzeList.length; i++) {
query += `ids=${analyzeList[i].id}&`;
}
- timeout = setInterval(() => {
+ timeout = setTimeout(() => {
batchQueryKnowledge(query).then((result: any) => {
+ let hasChanges = false;
if (result.success && result.data) {
(result.data as KnowledgeCard[]).forEach((item: KnowledgeCard) => {
const index = cardList.value.findIndex(card => card.id == item.id);
if (index == -1) return;
- // Always update the card data
- cardList.value[index].parse_status = item.parse_status;
- cardList.value[index].summary_status = item.summary_status;
- cardList.value[index].description = item.description;
+ if (cardList.value[index].parse_status !== item.parse_status ||
+ cardList.value[index].summary_status !== item.summary_status ||
+ cardList.value[index].description !== item.description) {
+
+ // Always update the card data
+ cardList.value[index].parse_status = item.parse_status;
+ cardList.value[index].summary_status = item.summary_status;
+ cardList.value[index].description = item.description;
+ hasChanges = true;
+ }
});
}
+ // If there are no changes, the watch won't trigger, so we must manually poll again
+ // Even if there are changes, we can manually poll again just to be safe.
+ // The watch will clear this timeout if it triggers.
+ const stillPending = cardList.value.filter(item => {
+ const isParsing = item.parse_status == 'pending' || item.parse_status == 'processing';
+ const isSummaryPending = item.parse_status == 'completed' &&
+ (item.summary_status == 'pending' || item.summary_status == 'processing');
+ return isParsing || isSummaryPending;
+ });
+ if (stillPending.length > 0) {
+ updateStatus(stillPending);
+ }
}).catch((_err) => {
// 错误处理
+ const stillPending = cardList.value.filter(item => {
+ const isParsing = item.parse_status == 'pending' || item.parse_status == 'processing';
+ const isSummaryPending = item.parse_status == 'completed' &&
+ (item.summary_status == 'pending' || item.summary_status == 'processing');
+ return isParsing || isSummaryPending;
+ });
+ if (stillPending.length > 0) {
+ updateStatus(stillPending);
+ }
});
}, 1500);
};
diff --git a/internal/utils/security.go b/internal/utils/security.go
index 28bc2666..139434f5 100644
--- a/internal/utils/security.go
+++ b/internal/utils/security.go
@@ -162,8 +162,8 @@ func IsValidURL(url string) bool {
return false
}
- // 检查协议, 只允许 http, https, local, minio, cos, tos 协议
- allowedProtocols := []string{"http://", "https://", "local://", "minio://", "cos://", "tos://"}
+ // 检查协议, 只允许 http, https, local, minio, cos, tos, oss 协议
+ allowedProtocols := []string{"http://", "https://", "local://", "minio://", "cos://", "tos://", "oss://"}
isAllowed := false
for _, protocol := range allowedProtocols {
if strings.HasPrefix(strings.ToLower(url), protocol) {