refactor: Update chat and knowledge base handling for improved flexibility

- Removed validation for empty knowledge_base_ids in useStream, allowing backend to manage this case.
- Adjusted routing in KnowledgeBase.vue to decouple session creation from knowledge base ID.
- Updated getCurrentKbId function to simplify knowledge base ID retrieval from the route.
- Enhanced comments for clarity regarding knowledge base handling in chat components.
This commit is contained in:
wizardchen
2025-11-07 01:06:25 +08:00
parent 4fb12545c1
commit 288dfbd19e
4 changed files with 15 additions and 40 deletions
+5 -4
View File
@@ -538,12 +538,13 @@ const handleLogout = () => {
}
const getCurrentKbId = async (): Promise<string | null> => {
// Session 不再和知识库绑定,从当前路由获取知识库ID(仅用于知识库详情页)
let kbId = (route.params as any)?.kbId as string
// 新的路由格式:/platform/chat/:kbId/:chatid,直接从路由参数获取
if (!kbId && route.name === 'chat' && (route.params as any)?.kbId) {
kbId = (route.params as any).kbId
// 如果当前在知识库详情页,返回知识库ID
if (route.name === 'knowledgeBaseDetail' && kbId) {
return kbId
}
return kbId || null
return null
}
const gotopage = async (path: string) => {