fix(chat): 智能体支持配置分级显示
This commit is contained in:
1 parent
a451951e7a
commit
70d7435b5f
27 files changed
+645
-76
No files matched your search
@@ -6,6 +6,7 @@ import { computed, ref, watch, type ComputedRef } from 'vue';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { getUserAgent, listUserAgents } from '@/features/auth/api/user.api';
|
||||
import { setLastChatAgentId } from '@/shared/utils/lastChatAgent';
|
||||
import { sortAgentsByCategory } from '@/shared/utils/agent-category.utils';
|
||||
import type { ChatDeps } from './chat.deps';
|
||||
import type { UseChatGuidesReturn } from './useChatGuides';
|
||||
|
||||
@@ -75,7 +76,16 @@ export function useChatAgent(options: UseChatAgentOptions) {
|
||||
const { t, msg, router } = deps;
|
||||
|
||||
const currentAgent = ref<any>(null);
|
||||
const userAgents = ref<Array<{ id: number; name: string; description: string; icon_url?: string; dify_app_type?: 'chatflow' | 'workflow' }>>([]);
|
||||
const userAgents = ref<Array<{
|
||||
id: number;
|
||||
name: string;
|
||||
description: string;
|
||||
icon_url?: string;
|
||||
dify_app_type?: 'chatflow' | 'workflow';
|
||||
category?: string | null;
|
||||
sub_category?: string | null;
|
||||
sort_order?: number;
|
||||
}>>([]);
|
||||
const showAgentPanel = ref(true);
|
||||
const selectedKb = ref(DEFAULT_KB);
|
||||
const kbOptions = [DEFAULT_KB, ERP_KB];
|
||||
@@ -162,12 +172,12 @@ export function useChatAgent(options: UseChatAgentOptions) {
|
||||
const loadUserAgents = async () => {
|
||||
try {
|
||||
const agents = await listUserAgents();
|
||||
userAgents.value = Array.isArray(agents)
|
||||
const filtered = Array.isArray(agents)
|
||||
? agents.filter((a: any) => a.id !== currentAgentId.value && (a.dify_app_type || 'chatflow') === 'chatflow')
|
||||
: [];
|
||||
if (userAgents.value.length === 0) {
|
||||
showAgentPanel.value = false;
|
||||
}
|
||||
userAgents.value = sortAgentsByCategory(filtered);
|
||||
// [STEP 1] 有可切换智能体时默认展开面板;避免切换 Agent 后列表「消失」
|
||||
showAgentPanel.value = userAgents.value.length > 0;
|
||||
} catch {
|
||||
userAgents.value = [];
|
||||
showAgentPanel.value = false;
|
||||
|
||||
Reference in new issue
Block a user