feat: 添加对话应用选择和知识库切换功能

- 新增对话应用管理模块(dify-chat-apps),支持获取和切换对话应用
- 优化对话应用切换后自动刷新会话列表功能
- 知识库管理页面新增下拉选择器,支持切换不同知识库
- API 层支持 app_id 参数传递,实现多应用会话隔离

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-08 01:44:34 +08:00
parent 27aff59152
commit 3f5c23123b
27 changed files with 925 additions and 167 deletions
+11 -2
View File
@@ -51,6 +51,7 @@ const baseOptions: RequestInit = {
/**
* 获取用户的会话列表
*
* @param appId - 对话应用 ID(可选,用于获取特定应用的会话列表)
* @returns 包含会话列表的响应对象
* @throws {Error} 当获取会话列表失败时抛出错误
*
@@ -59,15 +60,23 @@ const baseOptions: RequestInit = {
* const response = await fetchConversations();
* const conversations = response.data;
* console.log('会话数量:', conversations.length);
*
* // 获取指定应用的会话列表
* const appConversations = await fetchConversations('app-123');
* ```
*/
export async function fetchConversations(): Promise<ConversationsResponse> {
export async function fetchConversations(appId?: string): Promise<ConversationsResponse> {
const params = new URLSearchParams({
limit: '100',
});
// 如果指定了 appId,添加到查询参数中
if (appId) {
params.append('app_id', appId);
}
const url = `${API_URL}/conversations?${params}`;
console.log('📋 [Dify Client] 获取会话列表:', { url });
console.log('📋 [Dify Client] 获取会话列表:', { url, appId });
try {
const response = await axios.get<ConversationsResponse>(url, {