feat: enhance URL validation and timeout handling in knowledge base components

- Added isValidURL function to validate URLs before rendering links in the document content component, preventing invalid links from being clickable.
- Refactored timeout handling in KnowledgeBase.vue to use setTimeout instead of setInterval, improving performance and resource management.
- Ensured that timeouts are cleared appropriately to avoid memory leaks and unnecessary polling.

This update improves the robustness of URL handling and optimizes the component's performance.
This commit is contained in:
wizardchen
2026-04-16 12:24:57 +08:00
parent a78182cfc7
commit 7c40fb6ac9
3 changed files with 49 additions and 11 deletions
+2 -2
View File
@@ -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) {