diff --git a/frontend/src/components/AgentEmbedChannelPanel.vue b/frontend/src/components/AgentEmbedChannelPanel.vue index a28337e5..041199af 100644 --- a/frontend/src/components/AgentEmbedChannelPanel.vue +++ b/frontend/src/components/AgentEmbedChannelPanel.vue @@ -427,13 +427,15 @@ import { validateAllowedOrigins, type AllowedOriginsValidationError, } from '@/utils/embedAllowedOrigins' -import { listAgents, type CustomAgent } from '@/api/agent' +import type { CustomAgent } from '@/api/agent' +import { useChatResourcesStore } from '@/stores/chatResources' import IntegrationsAgentFilter from '@/components/IntegrationsAgentFilter.vue' const filterAgentId = defineModel('filterAgentId', { default: '' }) const { t } = useI18n() const authStore = useAuthStore() +const chatResources = useChatResourcesStore() const isAdmin = computed(() => authStore.hasRole('admin')) const loading = ref(false) @@ -680,12 +682,12 @@ function mergeChannelDetail(detail: EmbedChannel) { const load = async () => { loading.value = true try { - const [res, agentRes] = await Promise.all([ + const [res] = await Promise.all([ listAllEmbedChannels(), - listAgents(), + chatResources.ensureAgents(), ]) allChannels.value = res?.data || [] - agents.value = agentRes?.data || [] + agents.value = chatResources.agents as CustomAgent[] await Promise.all(allChannels.value.map(async (ch) => { try { const statsRes = await getEmbedChannelStats(ch.id) diff --git a/frontend/src/components/AttachmentUpload.vue b/frontend/src/components/AttachmentUpload.vue index b575a771..a24bfd6f 100644 --- a/frontend/src/components/AttachmentUpload.vue +++ b/frontend/src/components/AttachmentUpload.vue @@ -3,7 +3,7 @@ import { ref, computed, onMounted, onUnmounted } from 'vue'; import { MessagePlugin } from 'tdesign-vue-next'; import { useI18n } from 'vue-i18n'; import { MAX_FILE_SIZE_MB } from '@/utils'; -import { getParserEngines } from '@/api/system'; +import { useEditorResourcesStore } from '@/stores/editorResources'; import { deleteTemporaryAttachment, getTemporaryAttachment, @@ -12,6 +12,7 @@ import { } from '@/api/chat/temporary-attachments'; const { t } = useI18n(); +const editorResources = useEditorResourcesStore(); export interface AttachmentFile { file: File; @@ -61,8 +62,8 @@ const supportedTypes = ref([ onMounted(async () => { try { - const response = await getParserEngines(); - const discovered = (response.data || []) + await editorResources.ensureParserEngines(); + const discovered = editorResources.parserEngines .filter(engine => engine.Available !== false) .flatMap(engine => engine.FileTypes || []) .filter(type => type && type.toLowerCase() !== 'url') diff --git a/frontend/src/components/IMChannelPanel.vue b/frontend/src/components/IMChannelPanel.vue index 7fbc468a..77e956f8 100644 --- a/frontend/src/components/IMChannelPanel.vue +++ b/frontend/src/components/IMChannelPanel.vue @@ -594,7 +594,7 @@ import { copyWithToast } from '@/utils/clipboard'; import { normalizeOptionalString } from '@/utils/optionalString'; import { listIMChannels, createIMChannel, updateIMChannel, deleteIMChannel, toggleIMChannel, - getWeChatQRCode, pollWeChatQRCodeStatus, listAllIMChannels, listAgents, + getWeChatQRCode, pollWeChatQRCodeStatus, listAllIMChannels, type IMChannelOverview, type CustomAgent, } from '@/api/agent'; import { useChatResourcesStore } from '@/stores/chatResources'; @@ -940,13 +940,13 @@ async function loadChannels() { loading.value = true; try { const chatResources = useChatResourcesStore(); - const [channelRes, agentRes] = await Promise.all([ + const [channelRes] = await Promise.all([ listAllIMChannels(), - listAgents(), + chatResources.ensureAgents(), chatResources.ensureKnowledgeBases(), ]); allChannels.value = channelRes.data || []; - agents.value = agentRes?.data || []; + agents.value = chatResources.agents as CustomAgent[]; knowledgeBases.value = chatResources.rawKnowledgeBases.map((kb: any) => ({ id: kb.id, name: kb.name })); } catch { allChannels.value = []; diff --git a/frontend/src/components/Input-field.focus.test.mjs b/frontend/src/components/Input-field.focus.test.mjs index 560c2a3c..7ad4751d 100644 --- a/frontend/src/components/Input-field.focus.test.mjs +++ b/frontend/src/components/Input-field.focus.test.mjs @@ -21,7 +21,7 @@ for (const mode of ['normal', 'embedded', 'after', 'inject']) { uploadedAttachments: { value: [] }, uploadedImages: { value: [] }, allSelectedItems: { value: [] }, selectedModelId: { value: 'model' }, selectedAgent: { value: { config: {} } }, - settingsStore: {}, chatResources: { isFresh: () => true }, + settingsStore: {}, chatResources: { isLoaded: () => true }, collectAgentNotReadyReasons: () => ({ keys: [], labels: [] }), attachmentUploadRef: { value: null }, emit: name => effects.push([name]), diff --git a/frontend/src/components/Input-field.vue b/frontend/src/components/Input-field.vue index 9152d5b6..d41f7f03 100644 --- a/frontend/src/components/Input-field.vue +++ b/frontend/src/components/Input-field.vue @@ -1980,18 +1980,12 @@ watch(() => route.params.kbId, (newKbId) => { } }); +// 模型 / 联网搜索列表由设置页在写操作后直接写回 chatResources +// (replaceModels / ensureWebSearchProviders(true)),这里读的是同一份快照, +// 不再靠「设置弹窗关闭」「离开设置路由」两个信号各强刷一次。 watch(() => uiStore.showSettingsModal, (visible, prevVisible) => { - if (prevVisible && !visible) { - loadWebSearchConfig(true); - loadChatModels(true); - if (!props.embeddedMode) void browserConnection.refresh(); - } -}); - -watch(() => route.path, (path, prev) => { - if (prev === '/platform/settings' && path !== '/platform/settings') { - loadWebSearchConfig(true); - loadChatModels(true); + if (prevVisible && !visible && !props.embeddedMode) { + void browserConnection.refresh(); } }); @@ -2099,7 +2093,7 @@ const createSession = async ( return; } - if (!chatResources.isFresh('models')) { + if (!chatResources.isLoaded('models')) { await loadChatModels() } @@ -2248,7 +2242,7 @@ const toggleAgentModeSelector = () => { showAgentModeSelector.value = !showAgentModeSelector.value; if (showAgentModeSelector.value) { - if (!chatResources.isFresh('agents')) { + if (!chatResources.isLoaded('agents')) { void loadAgents(true); } // 多次更新位置确保准确 @@ -2265,7 +2259,7 @@ const toggleAgentModeSelector = () => { } const selectAgentMode = async (mode: 'quick-answer' | 'smart-reasoning') => { - if (!chatResources.isFresh('models')) { + if (!chatResources.isLoaded('models')) { await loadChatModels() } @@ -2305,7 +2299,7 @@ const handleAgentNotReady = ( }; const handleSelectAgent = async (agent: CustomAgent, sourceTenantId?: string) => { - if (!chatResources.isFresh('models')) { + if (!chatResources.isLoaded('models')) { await loadChatModels() } diff --git a/frontend/src/components/KnowledgeBaseSelector.vue b/frontend/src/components/KnowledgeBaseSelector.vue index ef55f06d..82f2476b 100644 --- a/frontend/src/components/KnowledgeBaseSelector.vue +++ b/frontend/src/components/KnowledgeBaseSelector.vue @@ -65,7 +65,7 @@