feat: implement tenant default storage provider handling in Knowledge Base creation

This commit introduces functionality to utilize the tenant's default storage provider when creating a Knowledge Base. It includes updates to the frontend to load the default provider from settings and apply it during Knowledge Base initialization. Additionally, the backend has been enhanced to ensure that the storage provider is set correctly based on tenant configuration, improving consistency across the application. Tests have been added to verify the correct application of the default storage provider in various scenarios.
This commit is contained in:
wizardchen
2026-05-29 13:36:06 +08:00
committed by lyingbug
parent e0823eff31
commit 48381fbaf5
4 changed files with 86 additions and 10 deletions
@@ -68,7 +68,8 @@ const emit = defineEmits<{
}>()
const uiStore = useUIStore()
const localProvider = ref(props.storageProvider || 'local')
// Keep empty until tenant default_provider is loaded — do not pre-fill 'local'.
const localProvider = ref(props.storageProvider)
const loading = ref(true)
const engineStatus = ref<StorageEngineStatusItem[]>([])
const defaultProvider = ref('local')
@@ -188,9 +189,12 @@ async function load() {
defaultProvider.value = configRes?.data?.default_provider || 'local'
const d = configRes?.data
hasAnyConfig.value = !!(d?.local?.path_prefix || d?.minio?.bucket_name || d?.cos?.bucket_name || d?.tos?.bucket_name || d?.s3?.bucket_name || d?.oss?.bucket_name || d?.ks3?.bucket_name || d?.obs?.bucket_name)
if (!localProvider.value || localProvider.value === '') {
const parentUnset = !props.storageProvider
if (parentUnset) {
localProvider.value = defaultProvider.value
emit('update:storageProvider', localProvider.value)
} else {
localProvider.value = props.storageProvider
}
ensureAllowedProvider()
} catch {
@@ -200,9 +204,13 @@ async function load() {
}
}
// Sync only when parent sets an explicit provider (edit mode). Create mode leaves
// storageProvider empty until load() applies tenant default_provider.
watch(() => props.storageProvider, (v) => {
localProvider.value = v || defaultProvider.value || 'local'
}, { immediate: true })
if (v) {
localProvider.value = v
}
})
onMounted(load)
</script>