Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
feat: 增强租户选择器功能,支持保存和显示选中租户名称
wizardchen46d41954bd5f
diff --git a/frontend/src/components/TenantSelector.vue b/frontend/src/components/TenantSelector.vueindex c4852e009..c49defac6 100644--- a/frontend/src/components/TenantSelector.vue+++ b/frontend/src/components/TenantSelector.vue@@ -109,8 +109,14 @@ const currentTenantId = computed(() => {const currentTenantName = computed(() => {if (!currentTenantId.value) return t('tenant.unknown')+ // 首先从当前加载的租户列表中查找const tenant = tenants.value.find(t => t.id === currentTenantId.value)if (tenant) return tenant.name+ // 如果是选中的租户,使用保存的租户名称+ if (selectedTenantId.value && authStore.selectedTenantName) {+ return authStore.selectedTenantName+ }+ // 最后使用默认租户名称return authStore.tenant?.name || t('tenant.unknown')})@@ -153,10 +159,13 @@ const clearSearch = () => {}const selectTenant = (tenantId: number) => {+ // 找到选中的租户信息+ const selectedTenant = tenants.value.find(t => t.id === tenantId)+if (tenantId === defaultTenantId.value) {- authStore.setSelectedTenant(null)+ authStore.setSelectedTenant(null, null)} else {- authStore.setSelectedTenant(tenantId)+ authStore.setSelectedTenant(tenantId, selectedTenant?.name || null)}closeDropdown()MessagePlugin.success(t('tenant.switchSuccess'))diff --git a/frontend/src/stores/auth.ts b/frontend/src/stores/auth.tsindex 48ef88bba..d52e6d162 100644--- a/frontend/src/stores/auth.ts+++ b/frontend/src/stores/auth.ts@@ -13,6 +13,7 @@ export const useAuthStore = defineStore('auth', () => {const knowledgeBases = ref<KnowledgeBaseInfo[]>([])const currentKnowledgeBase = ref<KnowledgeBaseInfo | null>(null)const selectedTenantId = ref<number | null>(null)+ const selectedTenantName = ref<string | null>(null)const allTenants = ref<TenantInfoFromAPI[]>([])// 计算属性@@ -79,12 +80,17 @@ export const useAuthStore = defineStore('auth', () => {}}- const setSelectedTenant = (tenantId: number | null) => {+ const setSelectedTenant = (tenantId: number | null, tenantName: string | null = null) => {selectedTenantId.value = tenantId+ selectedTenantName.value = tenantNameif (tenantId !== null) {localStorage.setItem('weknora_selected_tenant_id', String(tenantId))+ if (tenantName) {+ localStorage.setItem('weknora_selected_tenant_name', tenantName)+ }} else {localStorage.removeItem('weknora_selected_tenant_id')+ localStorage.removeItem('weknora_selected_tenant_name')}}@@ -106,6 +112,7 @@ export const useAuthStore = defineStore('auth', () => {knowledgeBases.value = []currentKnowledgeBase.value = nullselectedTenantId.value = null+ selectedTenantName.value = nullallTenants.value = []// 清空localStorage@@ -115,6 +122,8 @@ export const useAuthStore = defineStore('auth', () => {localStorage.removeItem('weknora_refresh_token')localStorage.removeItem('weknora_knowledge_bases')localStorage.removeItem('weknora_current_kb')+ localStorage.removeItem('weknora_selected_tenant_id')+ localStorage.removeItem('weknora_selected_tenant_name')}@@ -127,6 +136,7 @@ export const useAuthStore = defineStore('auth', () => {const storedKnowledgeBases = localStorage.getItem('weknora_knowledge_bases')const storedCurrentKb = localStorage.getItem('weknora_current_kb')const storedSelectedTenantId = localStorage.getItem('weknora_selected_tenant_id')+ const storedSelectedTenantName = localStorage.getItem('weknora_selected_tenant_name')if (storedUser) {try {@@ -173,9 +183,13 @@ export const useAuthStore = defineStore('auth', () => {if (storedSelectedTenantId) {try {selectedTenantId.value = Number(storedSelectedTenantId)+ if (storedSelectedTenantName) {+ selectedTenantName.value = storedSelectedTenantName+ }} catch (e) {console.error('Failed to parse selected tenant ID', e)selectedTenantId.value = null+ selectedTenantName.value = null}}}@@ -192,6 +206,7 @@ export const useAuthStore = defineStore('auth', () => {knowledgeBases,currentKnowledgeBase,selectedTenantId,+ selectedTenantName,allTenants,// 计算属性