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:
wizardchen
2026-06-08 20:55:54 +08:00
committed by lyingbug
parent dc8d4f686a
commit 815c72c964
22 changed files with 994 additions and 501 deletions
@@ -1,20 +1,23 @@
import { computed, onMounted, ref, watch } from 'vue'
import { useUIStore } from '@/stores/ui'
import { useChatResourcesStore } from '@/stores/chatResources'
import {
fetchTenantModelReadiness,
evaluateTenantModelReadiness,
type TenantModelReadiness,
} from '@/utils/tenantModelReadiness'
export function useTenantModelReadiness() {
const uiStore = useUIStore()
const chatResources = useChatResourcesStore()
const readiness = ref<TenantModelReadiness | null>(null)
const loaded = ref(false)
const loading = ref(false)
const refresh = async () => {
const refresh = async (force = false) => {
loading.value = true
try {
readiness.value = await fetchTenantModelReadiness()
await chatResources.ensureModels(force)
readiness.value = evaluateTenantModelReadiness(chatResources.allModels)
} finally {
loading.value = false
loaded.value = true
@@ -29,7 +32,7 @@ export function useTenantModelReadiness() {
() => uiStore.showSettingsModal,
(open, wasOpen) => {
if (wasOpen && !open) {
refresh()
refresh(true)
}
},
)