fix(chat): 智能体支持配置分级显示
This commit is contained in:
1 parent
a451951e7a
commit
70d7435b5f
27 files changed
+645
-76
No files matched your search
@@ -20,13 +20,11 @@ import {
|
||||
X,
|
||||
} from 'lucide-vue-next';
|
||||
import LocaleToggleButton from '@/shared/components/LocaleToggleButton.vue';
|
||||
import AgentCategoryList from '@/shared/components/AgentCategoryList.vue';
|
||||
import type { AgentWithCategory } from '@/shared/utils/agent-category.utils';
|
||||
import type { DisplayHistoryItem } from '../types/chat.types';
|
||||
|
||||
export interface ChatSidebarAgent {
|
||||
id: number;
|
||||
name: string;
|
||||
icon_url?: string;
|
||||
}
|
||||
export interface ChatSidebarAgent extends AgentWithCategory {}
|
||||
|
||||
const collapsed = defineModel<boolean>('collapsed', { required: true });
|
||||
const agentPanelOpen = defineModel<boolean>('agentPanelOpen', { required: true });
|
||||
@@ -227,29 +225,26 @@ const userInitial = (fallback: string) => {
|
||||
</div>
|
||||
|
||||
<div class="mt-auto flex flex-col p-4">
|
||||
<div v-if="userAgents.length > 0 && agentPanelOpen" class="chat-agent-panel">
|
||||
<div class="mb-2 flex items-center gap-1.5 text-xs font-semibold text-muted">
|
||||
<LayoutGrid class="h-3.5 w-3.5" /> {{ $t('chat.agents') }}
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-x-2 gap-y-1.5">
|
||||
<div v-if="userAgents.length > 0" class="chat-agent-panel">
|
||||
<div class="mb-2 flex items-center justify-between gap-2">
|
||||
<div class="flex items-center gap-1.5 text-xs font-semibold text-muted">
|
||||
<LayoutGrid class="h-3.5 w-3.5" /> {{ $t('chat.agents') }}
|
||||
<span class="font-normal opacity-70">({{ userAgents.length }})</span>
|
||||
</div>
|
||||
<button
|
||||
v-for="agent in userAgents"
|
||||
:key="agent.id"
|
||||
type="button"
|
||||
class="grid w-full min-w-0 grid-cols-[1rem_1fr] items-center gap-1.5 rounded-xl px-2 py-2 text-left text-xs font-medium text-secondary transition-colors hover-surface-soft hover:shadow-sm"
|
||||
@click="emit('switch-agent', agent)"
|
||||
class="text-[10px] font-medium text-brand-600 hover:text-brand-700"
|
||||
@click="agentPanelOpen = !agentPanelOpen"
|
||||
>
|
||||
<div
|
||||
v-if="agent.icon_url"
|
||||
class="h-4 w-4 shrink-0 rounded bg-contain bg-center bg-no-repeat"
|
||||
:style="{ backgroundImage: `url(${agent.icon_url})` }"
|
||||
/>
|
||||
<div v-else class="flex h-4 w-4 shrink-0 items-center justify-center rounded bg-brand-100 text-[9px] font-bold text-brand-600">
|
||||
{{ agent.name.charAt(0) }}
|
||||
</div>
|
||||
<span class="min-w-0 truncate">{{ agent.name }}</span>
|
||||
{{ agentPanelOpen ? $t('chat.collapseAgents') : $t('chat.expandAgents') }}
|
||||
</button>
|
||||
</div>
|
||||
<AgentCategoryList
|
||||
v-show="agentPanelOpen"
|
||||
:agents="userAgents"
|
||||
compact
|
||||
@select="emit('switch-agent', $event)"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div ref="userMenuRef" class="relative flex items-center justify-between text-muted">
|
||||
|
||||
Reference in new issue
Block a user