fix(chat): 智能体支持配置分级显示
This commit is contained in:
1 parent
a451951e7a
commit
70d7435b5f
27 files changed
+645
-76
No files matched your search
@@ -16,6 +16,12 @@ import {
|
||||
type WorkspaceUser,
|
||||
} from '../types/workspace.types';
|
||||
import type { WorkspaceDeps } from './workspace.deps';
|
||||
import {
|
||||
extractAgentCategories,
|
||||
filterAgentsByQuery,
|
||||
normalizeAgentCategoryFields,
|
||||
sortAgentsByCategory,
|
||||
} from '@/shared/utils/agent-category.utils';
|
||||
|
||||
interface HomeOptions {
|
||||
currentUser: Ref<WorkspaceUser | null>;
|
||||
@@ -41,6 +47,7 @@ export function useWorkspaceHome(deps: WorkspaceDeps, options: HomeOptions) {
|
||||
{ id: 'all_agents', visible: true, collapsed: false, title: 'workspace.availableAgents' },
|
||||
]);
|
||||
const searchQuery = ref('');
|
||||
const selectedCategory = ref<string | null>(null);
|
||||
const showAnnouncementModal = ref(false);
|
||||
const selectedAnnouncement = ref<WorkspaceAnnouncement | null>(null);
|
||||
const userReport = ref<unknown>(null);
|
||||
@@ -53,13 +60,18 @@ export function useWorkspaceHome(deps: WorkspaceDeps, options: HomeOptions) {
|
||||
|
||||
const favoriteAgents = computed(() => agents.value.filter((a) => favoriteAgentIds.value.includes(a.id)));
|
||||
|
||||
const chatflowAgents = computed(() =>
|
||||
sortAgentsByCategory(agents.value.filter((a) => (a.dify_app_type || 'chatflow') === 'chatflow')),
|
||||
);
|
||||
|
||||
const agentCategories = computed(() => extractAgentCategories(chatflowAgents.value));
|
||||
|
||||
const otherAgents = computed(() => {
|
||||
const chatflowAgents = agents.value.filter((a) => (a.dify_app_type || 'chatflow') === 'chatflow');
|
||||
if (!searchQuery.value.trim()) return chatflowAgents;
|
||||
const q = searchQuery.value.toLowerCase();
|
||||
return chatflowAgents.filter(
|
||||
(a) => a.name.toLowerCase().includes(q) || a.description.toLowerCase().includes(q),
|
||||
);
|
||||
let list = chatflowAgents.value;
|
||||
if (selectedCategory.value) {
|
||||
list = list.filter((a) => normalizeAgentCategoryFields(a).category === selectedCategory.value);
|
||||
}
|
||||
return filterAgentsByQuery(list, searchQuery.value);
|
||||
});
|
||||
|
||||
const filteredQuickQuestions = computed(() => {
|
||||
@@ -85,6 +97,7 @@ export function useWorkspaceHome(deps: WorkspaceDeps, options: HomeOptions) {
|
||||
favoriteAgentIds.value = [];
|
||||
embeddedAgents.value = [];
|
||||
userReport.value = null;
|
||||
selectedCategory.value = null;
|
||||
};
|
||||
|
||||
const fetchHome = async () => {
|
||||
@@ -322,6 +335,8 @@ export function useWorkspaceHome(deps: WorkspaceDeps, options: HomeOptions) {
|
||||
SECTION_TITLE_KEY_MAP,
|
||||
layoutSections,
|
||||
searchQuery,
|
||||
selectedCategory,
|
||||
agentCategories,
|
||||
showAnnouncementModal,
|
||||
selectedAnnouncement,
|
||||
userReport,
|
||||
|
||||
@@ -161,6 +161,26 @@ const ws = inject(WORKSPACE_KEY)! as any;
|
||||
|
||||
<!-- Content: All Agents -->
|
||||
<div v-if="section.id === 'all_agents'">
|
||||
<div class="mb-4 flex flex-wrap gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full px-3 py-1.5 text-xs font-medium transition-colors"
|
||||
:class="!ws.selectedCategory ? 'bg-brand-600 text-white' : 'bg-surface-soft text-secondary hover:bg-slate-100'"
|
||||
@click="ws.selectedCategory = null"
|
||||
>
|
||||
{{ $t('workspace.agentCategory.all') }}
|
||||
</button>
|
||||
<button
|
||||
v-for="category in ws.agentCategories"
|
||||
:key="category"
|
||||
type="button"
|
||||
class="rounded-full px-3 py-1.5 text-xs font-medium transition-colors"
|
||||
:class="ws.selectedCategory === category ? 'bg-brand-600 text-white' : 'bg-surface-soft text-secondary hover:bg-slate-100'"
|
||||
@click="ws.selectedCategory = category"
|
||||
>
|
||||
{{ category }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="mb-6">
|
||||
<input v-model="ws.searchQuery" type="text" :placeholder="$t('workspace.search')" class="input-field max-w-md shadow-sm" />
|
||||
</div>
|
||||
|
||||
@@ -29,6 +29,9 @@ export interface WorkspaceAgent {
|
||||
description: string;
|
||||
icon_url?: string;
|
||||
dify_app_type?: 'chatflow' | 'workflow';
|
||||
category?: string | null;
|
||||
sub_category?: string | null;
|
||||
sort_order?: number;
|
||||
}
|
||||
|
||||
export interface WorkspaceQuickQuestion {
|
||||
|
||||
Reference in new issue
Block a user