fix(agent): 调整agent显示样式
This commit is contained in:
1 parent
b2fa2688a3
commit
42de6c02d3
3 files changed
+101
-43
No files matched your search
@@ -24,7 +24,7 @@ const props = withDefaults(defineProps<{
|
||||
activeAgentId: null,
|
||||
compact: false,
|
||||
showSearch: true,
|
||||
defaultExpanded: true,
|
||||
defaultExpanded: false,
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -64,7 +64,7 @@ const matchesQuery = (agent: AgentWithCategory, query: string) => {
|
||||
const filteredAgents = computed(() => {
|
||||
const q = searchQuery.value.trim();
|
||||
return props.agents.filter((agent) => {
|
||||
if (directoryMemberIds.value.has(agent.id)) return false;
|
||||
if (directoryMemberIds.value.has(agent.id) && !isAggregateAgent(agent)) return false;
|
||||
return matchesQuery(agent, q);
|
||||
});
|
||||
});
|
||||
@@ -134,18 +134,29 @@ const onSelect = (agent: AgentWithCategory) => {
|
||||
|
||||
/**
|
||||
* 统一 Agent 行的激活/默认样式类。
|
||||
* 核心逻辑:选中态用浅蓝底 + 品牌色文字,比实心 brand-600 更轻,与侧栏历史选中风格一致。
|
||||
* @param active - 是否为当前选中项
|
||||
* @param dense - 是否为目录成员等更紧凑的行
|
||||
*/
|
||||
const agentRowClass = (active: boolean, dense = false) => {
|
||||
const base = dense
|
||||
? 'group relative flex w-full min-w-0 items-center gap-2 rounded-lg px-2 py-1.5 text-left text-[11px] font-medium transition-all duration-150'
|
||||
: 'group relative flex w-full min-w-0 items-center gap-2 rounded-xl px-2.5 py-2 text-left text-xs font-medium transition-all duration-150';
|
||||
? 'group relative flex w-full min-w-0 items-center gap-2 rounded-lg px-2 py-1.5 text-left text-[11px] font-medium transition-colors duration-150'
|
||||
: 'group relative flex w-full min-w-0 items-center gap-2 rounded-xl px-2.5 py-2 text-left text-xs font-medium transition-colors duration-150';
|
||||
if (active) {
|
||||
return `${base} cursor-default bg-brand-50 text-brand-700 shadow-sm ring-1 ring-brand-100/80 dark:bg-brand-900/25 dark:text-brand-300 dark:ring-brand-800/40`;
|
||||
return `${base} cursor-default bg-brand-50 text-brand-700`;
|
||||
}
|
||||
return `${base} text-secondary hover:bg-surface hover:text-primary hover:shadow-sm`;
|
||||
return `${base} text-secondary hover:bg-surface hover:text-primary`;
|
||||
};
|
||||
|
||||
/**
|
||||
* 聚合应用作为一级入口时选中态需要更强,避免与浅色未选中卡片混在一起。
|
||||
* 核心逻辑:浅蓝底 + 浅品牌描边表达选中,不用实心深蓝。
|
||||
*/
|
||||
const aggregateCardClass = (active: boolean) => (
|
||||
active
|
||||
? 'border-brand-200 bg-brand-50 text-brand-700'
|
||||
: 'border-subtle bg-surface'
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -170,12 +181,16 @@ const agentRowClass = (active: boolean, dense = false) => {
|
||||
<div
|
||||
v-for="agent in aggregateAgents"
|
||||
:key="agent.id"
|
||||
class="overflow-hidden rounded-2xl border border-subtle bg-surface shadow-sm"
|
||||
class="overflow-hidden rounded-2xl border transition-all duration-150"
|
||||
:class="aggregateCardClass(isActiveAgent(agent))"
|
||||
>
|
||||
<div class="flex min-w-0 items-stretch">
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-7 shrink-0 items-center justify-center text-muted transition-colors hover:bg-surface-soft hover:text-brand-600"
|
||||
class="flex w-7 shrink-0 items-center justify-center transition-colors"
|
||||
:class="isActiveAgent(agent)
|
||||
? 'text-brand-600 hover:bg-brand-100/60'
|
||||
: 'text-muted hover:bg-surface-soft hover:text-brand-600'"
|
||||
:title="isDirectoryCollapsed(agent.id) ? t('chat.expandAgents') : t('chat.collapseAgents')"
|
||||
@click.stop="toggleDirectory(agent.id)"
|
||||
>
|
||||
@@ -189,7 +204,7 @@ const agentRowClass = (active: boolean, dense = false) => {
|
||||
type="button"
|
||||
class="flex min-w-0 flex-1 items-center gap-1.5 py-1.5 pr-2.5 text-left transition-colors"
|
||||
:class="isActiveAgent(agent)
|
||||
? 'cursor-default bg-brand-50/80'
|
||||
? 'cursor-default bg-brand-50 text-brand-700'
|
||||
: 'hover:bg-surface-soft/80'"
|
||||
:aria-current="isActiveAgent(agent) ? 'page' : undefined"
|
||||
@click="onSelect(agent)"
|
||||
@@ -197,57 +212,55 @@ const agentRowClass = (active: boolean, dense = false) => {
|
||||
<span
|
||||
class="flex h-5 w-5 shrink-0 items-center justify-center rounded-md"
|
||||
:class="isActiveAgent(agent)
|
||||
? 'bg-brand-100 text-brand-600 dark:bg-brand-900/40 dark:text-brand-300'
|
||||
? 'bg-brand-100 text-brand-600'
|
||||
: 'bg-surface-strong text-brand-500'"
|
||||
>
|
||||
<FolderTree class="h-3 w-3" />
|
||||
</span>
|
||||
<span
|
||||
class="min-w-0 truncate text-xs font-semibold tracking-tight"
|
||||
:class="isActiveAgent(agent) ? 'text-brand-700 dark:text-brand-300' : 'text-primary'"
|
||||
:class="isActiveAgent(agent) ? 'text-brand-700' : 'text-primary'"
|
||||
>
|
||||
{{ agent.name }}
|
||||
</span>
|
||||
<span
|
||||
v-if="visibleDirectoryMembers(agent).length"
|
||||
class="ml-auto shrink-0 rounded px-1 py-px text-[10px] font-medium tabular-nums text-muted"
|
||||
class="ml-auto shrink-0 rounded px-1 py-px text-[10px] font-medium tabular-nums"
|
||||
:class="isActiveAgent(agent) ? 'text-brand-500' : 'text-muted'"
|
||||
>
|
||||
{{ visibleDirectoryMembers(agent).length }}
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-show="!isDirectoryCollapsed(agent.id)"
|
||||
class="border-t border-subtle bg-surface-soft/40 px-2 py-2"
|
||||
>
|
||||
<div v-show="!isDirectoryCollapsed(agent.id)" class="border-t border-subtle bg-surface-soft/40 px-2 py-2">
|
||||
<div class="grid grid-cols-2 gap-1">
|
||||
<button
|
||||
<template
|
||||
v-for="member in visibleDirectoryMembers(agent)"
|
||||
:key="`${agent.id}-${member.id}`"
|
||||
type="button"
|
||||
:class="agentRowClass(isActiveAgent(member), true)"
|
||||
:title="member.name"
|
||||
:aria-current="isActiveAgent(member) ? 'page' : undefined"
|
||||
@click="onSelect(member)"
|
||||
>
|
||||
<span
|
||||
v-if="isActiveAgent(member)"
|
||||
class="absolute inset-y-1 left-0 w-0.5 rounded-full bg-brand-500"
|
||||
/>
|
||||
<div
|
||||
v-if="member.icon_url"
|
||||
class="h-5 w-5 shrink-0 rounded-md bg-contain bg-center bg-no-repeat ring-1 ring-black/5"
|
||||
:style="{ backgroundImage: `url(${member.icon_url})` }"
|
||||
/>
|
||||
<div
|
||||
v-else
|
||||
class="flex h-5 w-5 shrink-0 items-center justify-center rounded-md bg-brand-50 text-[10px] font-bold text-brand-600 ring-1 ring-brand-100/60 dark:bg-brand-900/30 dark:text-brand-300 dark:ring-brand-800/40"
|
||||
<button
|
||||
type="button"
|
||||
:class="agentRowClass(isActiveAgent(member), true)"
|
||||
:title="member.name"
|
||||
:aria-current="isActiveAgent(member) ? 'page' : undefined"
|
||||
@click="onSelect(member)"
|
||||
>
|
||||
{{ member.name.charAt(0) }}
|
||||
</div>
|
||||
<span class="min-w-0 truncate leading-tight">{{ member.name }}</span>
|
||||
</button>
|
||||
<span v-if="isActiveAgent(member)" class="absolute inset-y-1 left-0 w-0.5 rounded-full bg-brand-500" />
|
||||
<div
|
||||
v-if="member.icon_url"
|
||||
class="h-5 w-5 shrink-0 rounded-md bg-contain bg-center bg-no-repeat ring-1 ring-black/5"
|
||||
:style="{ backgroundImage: `url(${member.icon_url})` }"
|
||||
/>
|
||||
<div
|
||||
v-else
|
||||
class="flex h-5 w-5 shrink-0 items-center justify-center rounded-md bg-brand-50 text-[10px] font-bold text-brand-600 ring-1 ring-brand-100/60 dark:bg-brand-900/30 dark:text-brand-300 dark:ring-brand-800/40"
|
||||
>
|
||||
{{ member.name.charAt(0) }}
|
||||
</div>
|
||||
<span class="min-w-0 truncate leading-tight">{{ member.name }}</span>
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user