refactor(frontend): streamline knowledge base and agent handling with chat resources store
- Updated components to utilize the new `useChatResourcesStore` for managing knowledge bases and agents, improving data fetching and caching mechanisms. - Refactored `AgentSelector`, `IMChannelPanel`, `Input-field`, and `menu` components to replace direct API calls with store methods, enhancing maintainability and performance. - Adjusted knowledge base loading logic to ensure consistency across components and reduce redundant API requests. - Improved session state handling in `settings` store to prevent overwriting user selections during state restoration.
This commit is contained in:
@@ -14,15 +14,18 @@ import { useMenuStore } from '@/stores/menu';
|
||||
import { useUIStore } from '@/stores/ui';
|
||||
import { useOrganizationStore } from '@/stores/organization';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { useChatResourcesStore } from '@/stores/chatResources';
|
||||
import { useEditorResourcesStore } from '@/stores/editorResources';
|
||||
import KnowledgeBaseEditorModal from './KnowledgeBaseEditorModal.vue';
|
||||
const usemenuStore = useMenuStore();
|
||||
const uiStore = useUIStore();
|
||||
const orgStore = useOrganizationStore();
|
||||
const authStore = useAuthStore();
|
||||
const chatResources = useChatResourcesStore();
|
||||
const editorResources = useEditorResourcesStore();
|
||||
const router = useRouter();
|
||||
import {
|
||||
batchQueryKnowledge,
|
||||
getKnowledgeBaseById,
|
||||
listKnowledgeTags,
|
||||
updateKnowledgeTagBatch,
|
||||
createKnowledgeBaseTag,
|
||||
@@ -30,7 +33,6 @@ import {
|
||||
deleteKnowledgeBaseTag,
|
||||
uploadKnowledgeFile,
|
||||
createKnowledgeFromURL,
|
||||
listKnowledgeBases,
|
||||
reparseKnowledge,
|
||||
cancelKnowledgeParse,
|
||||
batchDeleteKnowledge,
|
||||
@@ -51,7 +53,7 @@ import { listMoveTargets, moveKnowledge, getKnowledgeMoveProgress } from '@/api/
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { formatStringDate, kbFileTypeVerification } from '@/utils';
|
||||
import { formatFileSize } from '@/utils/files';
|
||||
import { getParserEngines, type ParserEngineInfo } from '@/api/system';
|
||||
import type { ParserEngineInfo } from '@/api/system';
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
const kbId = computed(() => (route.params as any).kbId as string || '');
|
||||
@@ -153,7 +155,7 @@ const missingStorageEngine = computed(() => {
|
||||
const spc = kbInfo.value.storage_provider_config
|
||||
return !spc || !spc.provider
|
||||
})
|
||||
const parserEngines = ref<ParserEngineInfo[]>([]);
|
||||
const parserEngines = computed<ParserEngineInfo[]>(() => editorResources.parserEngines);
|
||||
|
||||
const supportedFileTypes = computed<Set<string>>(() => {
|
||||
const engines = parserEngines.value
|
||||
@@ -811,7 +813,7 @@ const handleKnowledgeTagChange = async (knowledgeId: string, tagValue: string) =
|
||||
}
|
||||
};
|
||||
|
||||
const loadKnowledgeBaseInfo = async (targetKbId: string) => {
|
||||
const loadKnowledgeBaseInfo = async (targetKbId: string, force = false) => {
|
||||
if (!targetKbId) {
|
||||
kbInfo.value = null;
|
||||
cardList.value = [];
|
||||
@@ -820,10 +822,10 @@ const loadKnowledgeBaseInfo = async (targetKbId: string) => {
|
||||
}
|
||||
kbLoading.value = true;
|
||||
try {
|
||||
const res: any = await getKnowledgeBaseById(targetKbId);
|
||||
const data = await chatResources.fetchKnowledgeBaseById(targetKbId, force);
|
||||
if (!isCurrentKb(targetKbId)) return;
|
||||
|
||||
kbInfo.value = res?.data || null;
|
||||
kbInfo.value = data;
|
||||
selectedTagId.value = '';
|
||||
// 重置store中的标签选择状态,避免上传文档时自动带上之前选择的标签
|
||||
uiStore.setSelectedTagId('');
|
||||
@@ -851,8 +853,8 @@ const loadKnowledgeBaseInfo = async (targetKbId: string) => {
|
||||
|
||||
const loadKnowledgeList = async () => {
|
||||
try {
|
||||
const res: any = await listKnowledgeBases();
|
||||
const myKbs = (res?.data || []).map((item: any) => ({
|
||||
await chatResources.ensureKnowledgeBases();
|
||||
const myKbs = chatResources.rawKnowledgeBases.map((item: any) => ({
|
||||
id: String(item.id),
|
||||
name: item.name,
|
||||
type: item.type || 'document',
|
||||
@@ -890,7 +892,15 @@ watch(activeKbTab, (tab) => {
|
||||
})
|
||||
|
||||
watch(() => kbId.value, (newKbId, oldKbId) => {
|
||||
if (newKbId && newKbId !== oldKbId) {
|
||||
if (!newKbId) {
|
||||
kbInfo.value = null;
|
||||
cardList.value = [];
|
||||
total.value = 0;
|
||||
return;
|
||||
}
|
||||
if (newKbId === oldKbId && kbInfo.value) return;
|
||||
|
||||
if (newKbId !== oldKbId) {
|
||||
clearTraceAvailabilityCache();
|
||||
cardList.value = [];
|
||||
total.value = 0;
|
||||
@@ -898,11 +908,10 @@ watch(() => kbId.value, (newKbId, oldKbId) => {
|
||||
resetPage();
|
||||
tagSearchQuery.value = '';
|
||||
tagPage.value = 1;
|
||||
// 重置标签选择状态,避免在不同知识库间保持标签选择
|
||||
uiStore.setSelectedTagId('');
|
||||
loadKnowledgeBaseInfo(newKbId);
|
||||
}
|
||||
}, { immediate: false });
|
||||
loadKnowledgeBaseInfo(newKbId);
|
||||
}, { immediate: true });
|
||||
|
||||
watch(selectedTagId, (newVal, oldVal) => {
|
||||
if (oldVal === undefined) return
|
||||
@@ -1027,13 +1036,8 @@ const handleOpenKnowledgeEvent = (e: Event) => {
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
loadKnowledgeBaseInfo(kbId.value);
|
||||
loadKnowledgeList();
|
||||
orgStore.fetchSharedKnowledgeBases();
|
||||
|
||||
getParserEngines()
|
||||
.then(res => { parserEngines.value = res?.data || [] })
|
||||
.catch(() => { parserEngines.value = [] })
|
||||
editorResources.ensureParserEngines();
|
||||
|
||||
window.addEventListener('knowledgeFileUploaded', handleFileUploaded as EventListener);
|
||||
window.addEventListener('openURLImportDialog', handleOpenURLImportDialog as EventListener);
|
||||
@@ -2022,8 +2026,11 @@ watch(cardList, () => {
|
||||
|
||||
// 处理知识库编辑成功后的回调
|
||||
const handleKBEditorSuccess = (kbIdValue: string) => {
|
||||
chatResources.invalidateKnowledgeBaseDetail(kbIdValue);
|
||||
chatResources.invalidate('knowledgeBases');
|
||||
loadKnowledgeList();
|
||||
if (kbIdValue === kbId.value) {
|
||||
loadKnowledgeBaseInfo(kbIdValue);
|
||||
loadKnowledgeBaseInfo(kbIdValue, true);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 解析引擎 -->
|
||||
<div v-if="!isFAQ && formData" v-show="currentSection === 'parser'" class="section">
|
||||
<div v-if="!isFAQ && formData && currentSection === 'parser'" class="section">
|
||||
<KBParserSettings
|
||||
:parser-engine-rules="formData.chunkingConfig.parserEngineRules"
|
||||
@update:parser-engine-rules="handleParserEngineRulesUpdate"
|
||||
@@ -227,7 +227,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 存储引擎 -->
|
||||
<div v-if="!isFAQ && formData" v-show="currentSection === 'storage'" class="section">
|
||||
<div v-if="!isFAQ && formData && currentSection === 'storage'" class="section">
|
||||
<KBStorageSettings
|
||||
:storage-provider="formData.storageProvider"
|
||||
:has-files="mode === 'edit' && hasFiles"
|
||||
@@ -335,7 +335,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 知识图谱 -->
|
||||
<div v-if="!isFAQ" v-show="currentSection === 'graph'" class="section">
|
||||
<div v-if="!isFAQ && currentSection === 'graph'" class="section">
|
||||
<GraphSettings
|
||||
v-if="formData"
|
||||
:graph-extract="formData.nodeExtractConfig"
|
||||
@@ -358,12 +358,12 @@
|
||||
</div>
|
||||
|
||||
<!-- 数据源管理(仅编辑模式) -->
|
||||
<div v-if="mode === 'edit' && kbId" v-show="currentSection === 'datasource'" class="section">
|
||||
<div v-if="mode === 'edit' && kbId && currentSection === 'datasource'" class="section">
|
||||
<DataSourceSettings :kb-id="kbId" @count="dsCount = $event" />
|
||||
</div>
|
||||
|
||||
<!-- 共享设置(仅编辑模式) -->
|
||||
<div v-if="mode === 'edit' && kbId" v-show="currentSection === 'share'" class="section">
|
||||
<div v-if="mode === 'edit' && kbId && currentSection === 'share'" class="section">
|
||||
<KBShareSettings :kb-id="kbId" :can-share="canShareKB" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -395,8 +395,9 @@ import { KB_EDITOR_FOCUS_SECTION_EVENT, markContextualGuideDone } from '@/config
|
||||
import { MessagePlugin, DialogPlugin } from 'tdesign-vue-next'
|
||||
import { createKnowledgeBase, getKnowledgeBaseById, listKnowledgeFiles, updateKnowledgeBase, rebuildKBIndex } from '@/api/knowledge-base'
|
||||
import { updateKBConfig, type KBModelConfigRequest } from '@/api/initialization'
|
||||
import { listModels, type ModelConfig } from '@/api/model'
|
||||
import { getStorageEngineConfig } from '@/api/system'
|
||||
import { type ModelConfig } from '@/api/model'
|
||||
import { useChatResourcesStore } from '@/stores/chatResources'
|
||||
import { useEditorResourcesStore } from '@/stores/editorResources'
|
||||
import { useUIStore } from '@/stores/ui'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import KBModelConfig from './settings/KBModelConfig.vue'
|
||||
@@ -413,6 +414,8 @@ import { useI18n } from 'vue-i18n'
|
||||
|
||||
const uiStore = useUIStore()
|
||||
const authStore = useAuthStore()
|
||||
const chatResources = useChatResourcesStore()
|
||||
const editorResources = useEditorResourcesStore()
|
||||
const { t } = useI18n()
|
||||
|
||||
// Props
|
||||
@@ -676,10 +679,10 @@ const initFormData = (type: 'document' | 'faq' = 'document') => {
|
||||
}
|
||||
|
||||
// 加载所有模型
|
||||
const loadAllModels = async () => {
|
||||
const loadAllModels = async (force = false) => {
|
||||
try {
|
||||
const models = await listModels()
|
||||
allModels.value = models || []
|
||||
await chatResources.ensureModels(force)
|
||||
allModels.value = chatResources.allModels || []
|
||||
} catch (error) {
|
||||
console.error('Failed to load model list:', error)
|
||||
MessagePlugin.error(t('knowledgeEditor.messages.loadModelsFailed'))
|
||||
@@ -693,9 +696,8 @@ const loadKBData = async () => {
|
||||
|
||||
loading.value = true
|
||||
try {
|
||||
const [kbInfo, models, filesResult] = await Promise.all([
|
||||
const [kbInfo, filesResult] = await Promise.all([
|
||||
getKnowledgeBaseById(props.kbId),
|
||||
loadAllModels(),
|
||||
listKnowledgeFiles(props.kbId, { page: 1, page_size: 1 })
|
||||
])
|
||||
|
||||
@@ -923,10 +925,10 @@ const handleStorageProviderUpdate = (value: string) => {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadTenantDefaultStorageProvider() {
|
||||
async function loadTenantDefaultStorageProvider(force = false) {
|
||||
try {
|
||||
const res = await getStorageEngineConfig()
|
||||
tenantDefaultStorageProvider.value = res?.data?.default_provider || 'local'
|
||||
await editorResources.ensureStorageEngine(force)
|
||||
tenantDefaultStorageProvider.value = editorResources.storageConfig?.default_provider || 'local'
|
||||
} catch {
|
||||
tenantDefaultStorageProvider.value = 'local'
|
||||
}
|
||||
@@ -1379,7 +1381,7 @@ watch(
|
||||
() => uiStore.showSettingsModal,
|
||||
async (visible, previous) => {
|
||||
if (!visible && previous && props.visible) {
|
||||
await loadAllModels()
|
||||
await loadAllModels(true)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -772,7 +772,8 @@
|
||||
import { onMounted, onUnmounted, ref, computed, watch, nextTick } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import { MessagePlugin, Icon as TIcon } from 'tdesign-vue-next'
|
||||
import { listKnowledgeBases, deleteKnowledgeBase, togglePinKnowledgeBase } from '@/api/knowledge-base'
|
||||
import { deleteKnowledgeBase, togglePinKnowledgeBase } from '@/api/knowledge-base'
|
||||
import { useChatResourcesStore } from '@/stores/chatResources'
|
||||
import { formatStringDate } from '@/utils/index'
|
||||
import { useUIStore } from '@/stores/ui'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
@@ -797,6 +798,7 @@ const uiStore = useUIStore()
|
||||
const authStore = useAuthStore()
|
||||
const { loaded: modelsReadyLoaded, isReadyForDocumentKb } = useTenantModelReadiness()
|
||||
const orgStore = useOrganizationStore()
|
||||
const chatResources = useChatResourcesStore()
|
||||
const { t } = useI18n()
|
||||
|
||||
// 左侧空间选择:默认根据当前角色决定。
|
||||
@@ -1202,27 +1204,26 @@ interface UploadSummary {
|
||||
hasError: boolean
|
||||
}
|
||||
|
||||
const fetchList = () => {
|
||||
const applyKbListData = (data: any[]) => {
|
||||
kbs.value = data.map((kb: any) => ({
|
||||
...kb,
|
||||
updated_at: kb.updated_at ? formatStringDate(new Date(kb.updated_at)) : '',
|
||||
showMore: false,
|
||||
isProcessing: kb.is_processing || false,
|
||||
processing_count: kb.processing_count || 0
|
||||
}))
|
||||
}
|
||||
|
||||
const fetchList = (force = false) => {
|
||||
loading.value = true
|
||||
// The creator filter only applies to the caller's own tenant KBs (the
|
||||
// first call). Shared KBs are inherently "not mine" so we don't filter
|
||||
// them server-side; the segmented control is also hidden whenever the
|
||||
// user is browsing the shared / per-space scopes.
|
||||
return Promise.all([
|
||||
listKnowledgeBases({ creator: creatorFilter.value }).then((res: any) => {
|
||||
const data = res.data || []
|
||||
// 格式化时间,并初始化 showMore 状态
|
||||
// is_processing 字段由后端返回
|
||||
kbs.value = data.map((kb: any) => ({
|
||||
...kb,
|
||||
updated_at: kb.updated_at ? formatStringDate(new Date(kb.updated_at)) : '',
|
||||
showMore: false,
|
||||
isProcessing: kb.is_processing || false,
|
||||
processing_count: kb.processing_count || 0
|
||||
}))
|
||||
}),
|
||||
orgStore.fetchSharedKnowledgeBases(),
|
||||
orgStore.fetchOrganizations()
|
||||
chatResources.fetchKnowledgeBasesForList({ creator: creatorFilter.value }, force).then(applyKbListData),
|
||||
orgStore.fetchSharedKnowledgeBases({ force }),
|
||||
orgStore.fetchOrganizations({ force }),
|
||||
]).finally(() => { loading.value = false }).then(() => {
|
||||
// 各空间知识库数量已由 GET /organizations 的 resource_counts 带回,存于 orgStore.resourceCounts
|
||||
const counts = orgStore.resourceCounts?.knowledge_bases?.by_organization
|
||||
@@ -1261,7 +1262,7 @@ watch(spaceSelection, (val) => {
|
||||
// than filtering in-memory so the server stays the single source of truth
|
||||
// (and we don't need to worry about stale share_count or pagination later).
|
||||
watch(creatorFilter, () => {
|
||||
fetchList()
|
||||
fetchList(true)
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
@@ -1388,7 +1389,7 @@ const handleTogglePin = async (kb: KB) => {
|
||||
MessagePlugin.success(
|
||||
res.data.is_pinned ? t('knowledgeList.pin.pinSuccess') : t('knowledgeList.pin.unpinSuccess')
|
||||
)
|
||||
fetchList()
|
||||
fetchList(true)
|
||||
}
|
||||
} catch {
|
||||
MessagePlugin.error(t('knowledgeList.pin.failed'))
|
||||
@@ -1402,7 +1403,7 @@ const handleTogglePinById = async (id: string) => {
|
||||
MessagePlugin.success(
|
||||
res.data.is_pinned ? t('knowledgeList.pin.pinSuccess') : t('knowledgeList.pin.unpinSuccess')
|
||||
)
|
||||
fetchList()
|
||||
fetchList(true)
|
||||
}
|
||||
} catch {
|
||||
MessagePlugin.error(t('knowledgeList.pin.failed'))
|
||||
@@ -1419,7 +1420,7 @@ const handleShare = (kb: KB) => {
|
||||
|
||||
const handleShareSuccess = () => {
|
||||
// 共享成功后可刷新列表
|
||||
fetchList()
|
||||
fetchList(true)
|
||||
}
|
||||
|
||||
const handleSharedKbClick = (sharedKb: SharedKnowledgeBase) => {
|
||||
@@ -1489,7 +1490,7 @@ const confirmDelete = () => {
|
||||
MessagePlugin.success(t('knowledgeList.messages.deleted'))
|
||||
deleteVisible.value = false
|
||||
deletingKb.value = null
|
||||
fetchList()
|
||||
fetchList(true)
|
||||
} else {
|
||||
MessagePlugin.error(res.message || t('knowledgeList.messages.deleteFailed'))
|
||||
}
|
||||
@@ -1652,7 +1653,7 @@ const handleCreateKnowledgeBase = () => {
|
||||
const handleKBEditorSuccess = (kbId: string) => {
|
||||
console.log('[KnowledgeBaseList] knowledge operation success:', kbId)
|
||||
const shouldOpenDetailForUploadGuide = !isContextualGuideDone('kbDetail')
|
||||
fetchList().then(() => {
|
||||
fetchList(true).then(() => {
|
||||
if (shouldOpenDetailForUploadGuide && kbId) {
|
||||
goDetail(kbId)
|
||||
}
|
||||
@@ -1726,7 +1727,7 @@ const handleUploadFinishedEvent = (event: Event) => {
|
||||
clearTimeout(uploadRefreshTimer)
|
||||
}
|
||||
uploadRefreshTimer = setTimeout(() => {
|
||||
fetchList()
|
||||
fetchList(true)
|
||||
uploadRefreshTimer = null
|
||||
}, 800)
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ import { ref, watch, onMounted, computed } from 'vue'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { extractTextRelations, fabriText, fabriTag, type Node, type Relation } from '@/api/initialization'
|
||||
import { getSystemInfo } from '@/api/system'
|
||||
import { useEditorResourcesStore } from '@/stores/editorResources'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
|
||||
const { t } = useI18n()
|
||||
@@ -544,11 +544,13 @@ const clearExtractExample = () => {
|
||||
MessagePlugin.success(t('graphSettings.exampleCleared'))
|
||||
}
|
||||
|
||||
const editorResources = useEditorResourcesStore()
|
||||
|
||||
// 加载系统信息
|
||||
const loadSystemInfo = async () => {
|
||||
const loadSystemInfo = async (force = false) => {
|
||||
try {
|
||||
const response = await getSystemInfo()
|
||||
systemInfo.value = response.data
|
||||
await editorResources.ensureSystemInfo(force)
|
||||
systemInfo.value = editorResources.systemInfo
|
||||
} catch (error: any) {
|
||||
console.error('Failed to load system info:', error)
|
||||
}
|
||||
|
||||
@@ -86,11 +86,13 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, computed, onMounted, onUnmounted } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { getParserEngines, type ParserEngineInfo } from '@/api/system'
|
||||
import { type ParserEngineInfo } from '@/api/system'
|
||||
import { useEditorResourcesStore } from '@/stores/editorResources'
|
||||
import { useUIStore } from '@/stores/ui'
|
||||
import { storeToRefs } from 'pinia'
|
||||
|
||||
const { t } = useI18n()
|
||||
const editorResources = useEditorResourcesStore()
|
||||
|
||||
function getEngineDisplayName(engineName: string): string {
|
||||
const key = `kbSettings.parser.engines.${engineName}.name`
|
||||
@@ -253,13 +255,11 @@ function goToParserSettings() {
|
||||
uiStore.openSettings('parser')
|
||||
}
|
||||
|
||||
async function loadEngines() {
|
||||
async function loadEngines(force = false) {
|
||||
loading.value = true
|
||||
try {
|
||||
const resp = await getParserEngines()
|
||||
if (resp?.data && Array.isArray(resp.data)) {
|
||||
parserEngines.value = resp.data
|
||||
}
|
||||
await editorResources.ensureParserEngines(force)
|
||||
parserEngines.value = editorResources.parserEngines as ParserEngineInfo[]
|
||||
} catch {
|
||||
parserEngines.value = []
|
||||
} finally {
|
||||
@@ -282,7 +282,7 @@ onMounted(loadEngines)
|
||||
const { showSettingsModal } = storeToRefs(uiStore)
|
||||
watch(showSettingsModal, (open, wasOpen) => {
|
||||
if (wasOpen && !open) {
|
||||
loadEngines()
|
||||
loadEngines(true)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch, onMounted } from 'vue'
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useOrganizationStore } from '@/stores/organization'
|
||||
@@ -304,12 +304,6 @@ watch(() => props.kbId, async (newKbId) => {
|
||||
await Promise.all([loadOrganizations(), loadShares()])
|
||||
}
|
||||
}, { immediate: true })
|
||||
|
||||
onMounted(async () => {
|
||||
if (props.kbId) {
|
||||
await Promise.all([loadOrganizations(), loadShares()])
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
|
||||
@@ -53,8 +53,9 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch, onMounted } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { getStorageEngineConfig, getStorageEngineStatus, type StorageEngineStatusItem } from '@/api/system'
|
||||
import { type StorageEngineStatusItem } from '@/api/system'
|
||||
import { useUIStore } from '@/stores/ui'
|
||||
import { useEditorResourcesStore } from '@/stores/editorResources'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
@@ -68,6 +69,7 @@ const emit = defineEmits<{
|
||||
}>()
|
||||
|
||||
const uiStore = useUIStore()
|
||||
const editorResources = useEditorResourcesStore()
|
||||
// Keep empty until tenant default_provider is loaded — do not pre-fill 'local'.
|
||||
const localProvider = ref(props.storageProvider)
|
||||
const loading = ref(true)
|
||||
@@ -176,18 +178,15 @@ function goToStorageSettings() {
|
||||
uiStore.openSettings?.('storage')
|
||||
}
|
||||
|
||||
async function load() {
|
||||
async function load(force = false) {
|
||||
loading.value = true
|
||||
try {
|
||||
const [configRes, statusRes] = await Promise.all([
|
||||
getStorageEngineConfig(),
|
||||
getStorageEngineStatus(),
|
||||
])
|
||||
const engines = statusRes?.data?.engines ?? []
|
||||
await editorResources.ensureStorageEngine(force)
|
||||
const engines = editorResources.storageStatus
|
||||
engineStatus.value = engines
|
||||
allowedProviders.value = statusRes?.data?.allowed_providers ?? []
|
||||
defaultProvider.value = configRes?.data?.default_provider || 'local'
|
||||
const d = configRes?.data
|
||||
allowedProviders.value = editorResources.storageAllowedProviders
|
||||
defaultProvider.value = editorResources.storageConfig?.default_provider || 'local'
|
||||
const d = editorResources.storageConfig
|
||||
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)
|
||||
const parentUnset = !props.storageProvider
|
||||
if (parentUnset) {
|
||||
|
||||
Reference in New Issue
Block a user