feat(agent): enhance agent sharing and selection features
- Updated the AgentSelector component to improve agent selection logic, ensuring accurate representation of selected agents. - Introduced new AgentShareSettings component for managing agent sharing with organizations, including UI for selecting organizations and displaying shared agents. - Enhanced API interactions for sharing agents, including new methods for listing and managing agent shares. - Improved localization support for agent sharing features across multiple languages. - Updated various components to reflect changes in agent capabilities and sharing status, enhancing user experience and clarity. This update strengthens the agent management features, providing users with better tools for sharing and selecting agents within organizations.
This commit is contained in:
@@ -1017,6 +1017,11 @@
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 共享管理(仅编辑模式且非内置智能体) -->
|
||||
<div v-if="props.mode === 'edit' && props.agent?.id && !props.agent?.is_builtin" v-show="currentSection === 'share'" class="section">
|
||||
<AgentShareSettings :agent-id="props.agent.id" :agent="props.agent" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 底部操作栏 -->
|
||||
@@ -1046,6 +1051,7 @@ import { useUIStore } from '@/stores/ui';
|
||||
import AgentAvatar from '@/components/AgentAvatar.vue';
|
||||
import PromptTemplateSelector from '@/components/PromptTemplateSelector.vue';
|
||||
import ModelSelector from '@/components/ModelSelector.vue';
|
||||
import AgentShareSettings from '@/components/AgentShareSettings.vue';
|
||||
|
||||
const uiStore = useUIStore();
|
||||
|
||||
@@ -1252,6 +1258,10 @@ const navItems = computed(() => {
|
||||
if (!isAgentMode.value) {
|
||||
items.push({ key: 'conversation', icon: 'chat', label: t('agent.editor.conversationSettings') || '多轮对话' });
|
||||
}
|
||||
// 共享管理(仅编辑模式且非内置智能体)
|
||||
if (props.mode === 'edit' && props.agent?.id && !props.agent?.is_builtin) {
|
||||
items.push({ key: 'share', icon: 'share', label: t('knowledgeEditor.sidebar.share') || '共享管理' });
|
||||
}
|
||||
return items;
|
||||
});
|
||||
|
||||
|
||||
@@ -21,10 +21,142 @@
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Tab 切换 -->
|
||||
<div class="agent-tabs">
|
||||
<div
|
||||
class="tab-item"
|
||||
:class="{ 'active': activeTab === 'all' }"
|
||||
@click="activeTab = 'all'"
|
||||
>
|
||||
{{ $t('agent.tabs.all') }} ({{ allAgentsCount }})
|
||||
</div>
|
||||
<div
|
||||
class="tab-item"
|
||||
:class="{ 'active': activeTab === 'mine' }"
|
||||
@click="activeTab = 'mine'"
|
||||
>
|
||||
{{ $t('agent.tabs.mine') }} ({{ agents.length }})
|
||||
</div>
|
||||
<div
|
||||
class="tab-item"
|
||||
:class="{ 'active': activeTab === 'shared' }"
|
||||
@click="activeTab = 'shared'"
|
||||
>
|
||||
{{ $t('agent.tabs.sharedToMe') }} ({{ sharedAgents.length }})
|
||||
</div>
|
||||
</div>
|
||||
<div class="header-divider"></div>
|
||||
|
||||
<!-- 卡片网格 -->
|
||||
<div v-if="agents.length > 0" class="agent-card-wrap">
|
||||
<!-- 全部:我的 + 共享 -->
|
||||
<div v-if="activeTab === 'all' && filteredAgents.length > 0" class="agent-card-wrap">
|
||||
<div
|
||||
v-for="agent in filteredAgents"
|
||||
:key="agent.isMine ? agent.id : `shared-${agent.share_id}`"
|
||||
class="agent-card"
|
||||
:class="{
|
||||
'is-builtin': agent.is_builtin,
|
||||
'agent-mode-normal': agent.config?.agent_mode === 'quick-answer',
|
||||
'agent-mode-agent': agent.config?.agent_mode === 'smart-reasoning',
|
||||
'shared-agent-card': !agent.isMine
|
||||
}"
|
||||
@click="handleCardClick(agent)"
|
||||
>
|
||||
<!-- 装饰星星 -->
|
||||
<div class="card-decoration">
|
||||
<svg class="star-icon" width="24" height="24" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M10 3L10.8 6.2C10.9 6.7 11.3 7.1 11.8 7.2L15 8L11.8 8.8C11.3 8.9 10.9 9.3 10.8 9.8L10 13L9.2 9.8C9.1 9.3 8.7 8.9 8.2 8.8L5 8L8.2 7.2C8.7 7.1 9.1 6.7 9.2 6.2L10 3Z" stroke="currentColor" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round" fill="currentColor" fill-opacity="0.15"/>
|
||||
</svg>
|
||||
<svg class="star-icon small" width="14" height="14" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M10 3L10.8 6.2C10.9 6.7 11.3 7.1 11.8 7.2L15 8L11.8 8.8C11.3 8.9 10.9 9.3 10.8 9.8L10 13L9.2 9.8C9.1 9.3 8.7 8.9 8.2 8.8L5 8L8.2 7.2C8.7 7.1 9.1 6.7 9.2 6.2L10 3Z" stroke="currentColor" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round" fill="currentColor" fill-opacity="0.15"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="card-header">
|
||||
<div class="card-header-left">
|
||||
<div v-if="agent.is_builtin" class="builtin-avatar" :class="agent.config?.agent_mode === 'smart-reasoning' ? 'agent' : 'normal'">
|
||||
<t-icon :name="agent.config?.agent_mode === 'smart-reasoning' ? 'control-platform' : 'chat'" size="18px" />
|
||||
</div>
|
||||
<div v-else-if="agent.avatar" class="builtin-avatar agent-emoji">{{ agent.avatar }}</div>
|
||||
<AgentAvatar v-else :name="agent.name" size="medium" />
|
||||
<span class="card-title" :title="agent.name">{{ agent.name }}</span>
|
||||
</div>
|
||||
<t-popup
|
||||
v-if="agent.isMine"
|
||||
:visible="openMoreAgentId === agent.id"
|
||||
trigger="hover"
|
||||
overlayClassName="card-more-popup"
|
||||
destroy-on-close
|
||||
placement="bottom-right"
|
||||
@visible-change="onVisibleChange"
|
||||
@update:visible="(v: boolean) => { if (!v) openMoreAgentId = null }"
|
||||
>
|
||||
<div class="more-wrap" :class="{ 'active-more': openMoreAgentId === agent.id }" @click="toggleMore($event, agent.id)">
|
||||
<img class="more-icon" src="@/assets/img/more.png" alt="" />
|
||||
</div>
|
||||
<template #content>
|
||||
<div class="popup-menu">
|
||||
<div class="popup-menu-item" @click="handleEdit(agent)"><t-icon class="menu-icon" name="edit" /><span>{{ $t('common.edit') }}</span></div>
|
||||
<div class="popup-menu-item" @click="handleCopy(agent)"><t-icon class="menu-icon" name="file-copy" /><span>{{ $t('common.copy') }}</span></div>
|
||||
<div v-if="!agent.is_builtin" class="popup-menu-item delete" @click="handleDelete(agent)"><t-icon class="menu-icon" name="delete" /><span>{{ $t('common.delete') }}</span></div>
|
||||
</div>
|
||||
</template>
|
||||
</t-popup>
|
||||
</div>
|
||||
<div class="card-content">
|
||||
<div class="card-description">{{ agent.description || $t('agent.noDescription') }}</div>
|
||||
</div>
|
||||
<div class="card-bottom">
|
||||
<div class="bottom-left">
|
||||
<div class="feature-badges">
|
||||
<t-tooltip :content="agent.config?.agent_mode === 'smart-reasoning' ? $t('agent.mode.agent') : $t('agent.mode.normal')" placement="top">
|
||||
<div class="feature-badge" :class="{ 'mode-normal': agent.config?.agent_mode === 'quick-answer', 'mode-agent': agent.config?.agent_mode === 'smart-reasoning' }">
|
||||
<t-icon :name="agent.config?.agent_mode === 'smart-reasoning' ? 'control-platform' : 'chat'" size="14px" />
|
||||
</div>
|
||||
</t-tooltip>
|
||||
<t-tooltip v-if="agent.config?.web_search_enabled" :content="$t('agent.features.webSearch')" placement="top">
|
||||
<div class="feature-badge web-search">
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="8" cy="8" r="6" stroke="currentColor" stroke-width="1.2" fill="none"/>
|
||||
<ellipse cx="8" cy="8" rx="2.5" ry="6" stroke="currentColor" stroke-width="1.2" fill="none"/>
|
||||
<line x1="2" y1="6" x2="14" y2="6" stroke="currentColor" stroke-width="1.2"/>
|
||||
<line x1="2" y1="10" x2="14" y2="10" stroke="currentColor" stroke-width="1.2"/>
|
||||
</svg>
|
||||
</div>
|
||||
</t-tooltip>
|
||||
<t-tooltip v-if="agent.config?.knowledge_bases?.length || agent.config?.kb_selection_mode === 'all'" :content="$t('agent.features.knowledgeBase')" placement="top">
|
||||
<div class="feature-badge knowledge">
|
||||
<t-icon name="folder" size="16px" />
|
||||
</div>
|
||||
</t-tooltip>
|
||||
<t-tooltip v-if="agent.config?.mcp_services?.length || agent.config?.mcp_selection_mode === 'all'" :content="$t('agent.features.mcp')" placement="top">
|
||||
<div class="feature-badge mcp">
|
||||
<t-icon name="extension" size="16px" />
|
||||
</div>
|
||||
</t-tooltip>
|
||||
<t-tooltip v-if="agent.config?.multi_turn_enabled" :content="$t('agent.features.multiTurn')" placement="top">
|
||||
<div class="feature-badge multi-turn">
|
||||
<t-icon name="chat-bubble" size="16px" />
|
||||
</div>
|
||||
</t-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 右下角:内置 / 自定义 / 空间图标+名称 -->
|
||||
<div v-if="!agent.isMine" class="card-bottom-source">
|
||||
<img src="@/assets/img/organization-green.svg" class="org-icon" alt="" aria-hidden="true" />
|
||||
<span class="org-source-text">{{ agent.org_name }}</span>
|
||||
</div>
|
||||
<div v-else-if="agent.is_builtin" class="builtin-badge">
|
||||
<t-icon name="lock-on" size="12px" />
|
||||
<span>{{ $t('agent.builtin') }}</span>
|
||||
</div>
|
||||
<div v-else class="custom-badge">
|
||||
<span>{{ $t('agent.type.custom') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 我的智能体 -->
|
||||
<div v-if="activeTab === 'mine' && agents.length > 0" class="agent-card-wrap">
|
||||
<div
|
||||
v-for="agent in agents"
|
||||
:key="agent.id"
|
||||
@@ -53,22 +185,23 @@
|
||||
<div v-if="agent.is_builtin" class="builtin-avatar" :class="agent.config?.agent_mode === 'smart-reasoning' ? 'agent' : 'normal'">
|
||||
<t-icon :name="agent.config?.agent_mode === 'smart-reasoning' ? 'control-platform' : 'chat'" size="18px" />
|
||||
</div>
|
||||
<!-- 自定义智能体使用 AgentAvatar -->
|
||||
<div v-else-if="agent.avatar" class="builtin-avatar agent-emoji">{{ agent.avatar }}</div>
|
||||
<AgentAvatar v-else :name="agent.name" size="medium" />
|
||||
<span class="card-title" :title="agent.name">{{ agent.name }}</span>
|
||||
</div>
|
||||
<t-popup
|
||||
v-model="agent.showMore"
|
||||
<t-popup
|
||||
:visible="openMoreAgentId === agent.id"
|
||||
trigger="hover"
|
||||
overlayClassName="card-more-popup"
|
||||
:on-visible-change="(visible: boolean) => onVisibleChange(visible, agent)"
|
||||
trigger="click"
|
||||
destroy-on-close
|
||||
destroy-on-close
|
||||
placement="bottom-right"
|
||||
@visible-change="onVisibleChange"
|
||||
@update:visible="(v: boolean) => { if (!v) openMoreAgentId = null }"
|
||||
>
|
||||
<div
|
||||
class="more-wrap"
|
||||
@click.stop
|
||||
:class="{ 'active-more': agent.showMore }"
|
||||
<div
|
||||
class="more-wrap"
|
||||
:class="{ 'active-more': openMoreAgentId === agent.id }"
|
||||
@click="toggleMore($event, agent.id)"
|
||||
>
|
||||
<img class="more-icon" src="@/assets/img/more.png" alt="" />
|
||||
</div>
|
||||
@@ -134,21 +267,97 @@
|
||||
</t-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 右下角:内置 / 自定义 -->
|
||||
<div v-if="agent.is_builtin" class="builtin-badge">
|
||||
<t-icon name="lock-on" size="12px" />
|
||||
<span>{{ $t('agent.builtin') }}</span>
|
||||
</div>
|
||||
<span v-else-if="agent.updated_at" class="card-time">{{ formatDate(agent.updated_at) }}</span>
|
||||
<div v-else class="custom-badge">
|
||||
<span>{{ $t('agent.type.custom') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<div v-else-if="!loading" class="empty-state">
|
||||
<!-- 共享给我的智能体 -->
|
||||
<div v-if="activeTab === 'shared' && sharedAgents.length > 0" class="agent-card-wrap">
|
||||
<div
|
||||
v-for="shared in sharedAgents"
|
||||
:key="'shared-' + shared.share_id"
|
||||
class="agent-card shared-agent-card"
|
||||
:class="{
|
||||
'agent-mode-normal': shared.agent?.config?.agent_mode === 'quick-answer',
|
||||
'agent-mode-agent': shared.agent?.config?.agent_mode === 'smart-reasoning'
|
||||
}"
|
||||
@click="openSharedAgentDetail(shared)"
|
||||
>
|
||||
<div class="card-decoration">
|
||||
<svg class="star-icon" width="24" height="24" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M10 3L10.8 6.2C10.9 6.7 11.3 7.1 11.8 7.2L15 8L11.8 8.8C11.3 8.9 10.9 9.3 10.8 9.8L10 13L9.2 9.8C9.1 9.3 8.7 8.9 8.2 8.8L5 8L8.2 7.2C8.7 7.1 9.1 6.7 9.2 6.2L10 3Z" stroke="currentColor" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round" fill="currentColor" fill-opacity="0.15"/>
|
||||
</svg>
|
||||
<svg class="star-icon small" width="14" height="14" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M10 3L10.8 6.2C10.9 6.7 11.3 7.1 11.8 7.2L15 8L11.8 8.8C11.3 8.9 10.9 9.3 10.8 9.8L10 13L9.2 9.8C9.1 9.3 8.7 8.9 8.2 8.8L5 8L8.2 7.2C8.7 7.1 9.1 6.7 9.2 6.2L10 3Z" stroke="currentColor" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round" fill="currentColor" fill-opacity="0.15"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="card-header">
|
||||
<div class="card-header-left">
|
||||
<div v-if="shared.agent?.avatar" class="builtin-avatar agent-emoji">{{ shared.agent.avatar }}</div>
|
||||
<AgentAvatar v-else :name="shared.agent?.name" size="medium" />
|
||||
<span class="card-title" :title="shared.agent?.name">{{ shared.agent?.name }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-content">
|
||||
<div class="card-description">{{ shared.agent?.description || $t('agent.noDescription') }}</div>
|
||||
</div>
|
||||
<div class="card-bottom">
|
||||
<div class="bottom-left">
|
||||
<div class="feature-badges">
|
||||
<t-tooltip :content="shared.agent?.config?.agent_mode === 'smart-reasoning' ? $t('agent.mode.agent') : $t('agent.mode.normal')" placement="top">
|
||||
<div class="feature-badge" :class="{ 'mode-normal': shared.agent?.config?.agent_mode === 'quick-answer', 'mode-agent': shared.agent?.config?.agent_mode === 'smart-reasoning' }">
|
||||
<t-icon :name="shared.agent?.config?.agent_mode === 'smart-reasoning' ? 'control-platform' : 'chat'" size="14px" />
|
||||
</div>
|
||||
</t-tooltip>
|
||||
<t-tooltip v-if="shared.agent?.config?.web_search_enabled" :content="$t('agent.features.webSearch')" placement="top">
|
||||
<div class="feature-badge web-search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="8" cy="8" r="6" stroke="currentColor" stroke-width="1.2" fill="none"/><ellipse cx="8" cy="8" rx="2.5" ry="6" stroke="currentColor" stroke-width="1.2" fill="none"/><line x1="2" y1="6" x2="14" y2="6" stroke="currentColor" stroke-width="1.2"/><line x1="2" y1="10" x2="14" y2="10" stroke="currentColor" stroke-width="1.2"/></svg></div>
|
||||
</t-tooltip>
|
||||
<t-tooltip v-if="shared.agent?.config?.knowledge_bases?.length || shared.agent?.config?.kb_selection_mode === 'all'" :content="$t('agent.features.knowledgeBase')" placement="top">
|
||||
<div class="feature-badge knowledge"><t-icon name="folder" size="16px" /></div>
|
||||
</t-tooltip>
|
||||
<t-tooltip v-if="shared.agent?.config?.mcp_services?.length || shared.agent?.config?.mcp_selection_mode === 'all'" :content="$t('agent.features.mcp')" placement="top">
|
||||
<div class="feature-badge mcp"><t-icon name="extension" size="16px" /></div>
|
||||
</t-tooltip>
|
||||
<t-tooltip v-if="shared.agent?.config?.multi_turn_enabled" :content="$t('agent.features.multiTurn')" placement="top">
|
||||
<div class="feature-badge multi-turn"><t-icon name="chat-bubble" size="16px" /></div>
|
||||
</t-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 右下角:空间图标+名称 -->
|
||||
<div class="card-bottom-source">
|
||||
<img src="@/assets/img/organization-green.svg" class="org-icon" alt="" aria-hidden="true" />
|
||||
<span class="org-source-text">{{ shared.org_name }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 空状态:全部 -->
|
||||
<div v-if="activeTab === 'all' && filteredAgents.length === 0 && !loading" class="empty-state">
|
||||
<img class="empty-img" src="@/assets/img/upload.svg" alt="">
|
||||
<span class="empty-txt">{{ $t('agent.empty.title') }}</span>
|
||||
<span class="empty-desc">{{ $t('agent.empty.description') }}</span>
|
||||
</div>
|
||||
<!-- 空状态:我的 -->
|
||||
<div v-if="activeTab === 'mine' && agents.length === 0 && !loading" class="empty-state">
|
||||
<img class="empty-img" src="@/assets/img/upload.svg" alt="">
|
||||
<span class="empty-txt">{{ $t('agent.empty.title') }}</span>
|
||||
<span class="empty-desc">{{ $t('agent.empty.description') }}</span>
|
||||
</div>
|
||||
<!-- 空状态:共享给我 -->
|
||||
<div v-if="activeTab === 'shared' && sharedAgents.length === 0 && !loading" class="empty-state">
|
||||
<img class="empty-img" src="@/assets/img/upload.svg" alt="">
|
||||
<span class="empty-txt">{{ $t('agent.empty.sharedTitle') }}</span>
|
||||
<span class="empty-desc">{{ $t('agent.empty.sharedDescription') }}</span>
|
||||
</div>
|
||||
|
||||
<!-- 删除确认对话框 -->
|
||||
<t-dialog
|
||||
@@ -173,6 +382,66 @@
|
||||
</div>
|
||||
</t-dialog>
|
||||
|
||||
<!-- 共享智能体详情侧边栏 -->
|
||||
<Transition name="shared-detail-drawer">
|
||||
<div v-if="sharedDetailVisible && currentSharedAgent" class="shared-detail-drawer-overlay" @click.self="closeSharedAgentDetail">
|
||||
<div class="shared-detail-drawer">
|
||||
<div class="shared-detail-drawer-header">
|
||||
<h3 class="shared-detail-drawer-title">{{ $t('agent.detail.title') || '智能体详情' }}</h3>
|
||||
<button type="button" class="shared-detail-drawer-close" @click="closeSharedAgentDetail" :aria-label="$t('general.close')">
|
||||
<t-icon name="close" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="shared-detail-drawer-body">
|
||||
<div class="shared-detail-row">
|
||||
<span class="shared-detail-label">{{ $t('agent.editor.name') || '名称' }}</span>
|
||||
<span class="shared-detail-value">{{ currentSharedAgent.agent?.name }}</span>
|
||||
</div>
|
||||
<div class="shared-detail-row">
|
||||
<span class="shared-detail-label">{{ $t('knowledgeList.detail.sourceOrg') || '来源空间' }}</span>
|
||||
<span class="shared-detail-value shared-detail-org">
|
||||
<img src="@/assets/img/organization-green.svg" class="shared-detail-org-icon" alt="" aria-hidden="true" />
|
||||
<span>{{ currentSharedAgent.org_name }}</span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="shared-detail-row">
|
||||
<span class="shared-detail-label">{{ $t('knowledgeList.detail.myPermission') || '我的权限' }}</span>
|
||||
<span class="shared-detail-value">{{ $t('organization.share.permissionReadonly') }}</span>
|
||||
</div>
|
||||
<!-- 能力范围(与共享范围说明一致) -->
|
||||
<template v-if="currentSharedAgent.agent?.config">
|
||||
<div class="shared-detail-section-title">{{ $t('agent.shareScope.title') }}</div>
|
||||
<div class="shared-detail-row">
|
||||
<span class="shared-detail-label">{{ $t('agent.shareScope.knowledgeBase') }}</span>
|
||||
<span class="shared-detail-value">{{ sharedAgentKbScopeText }}</span>
|
||||
</div>
|
||||
<div class="shared-detail-row">
|
||||
<span class="shared-detail-label">{{ $t('agent.shareScope.chatModel') }}</span>
|
||||
<span class="shared-detail-value">{{ currentSharedAgent.agent.config.model_id ? $t('agent.shareScope.modelConfigured') : $t('agent.shareScope.modelNotSet') }}</span>
|
||||
</div>
|
||||
<div v-if="sharedAgentUsesKb" class="shared-detail-row">
|
||||
<span class="shared-detail-label">{{ $t('agent.shareScope.rerankModel') }}</span>
|
||||
<span class="shared-detail-value">{{ currentSharedAgent.agent.config.rerank_model_id ? $t('agent.shareScope.modelConfigured') : $t('agent.shareScope.modelNotSet') }}</span>
|
||||
</div>
|
||||
<div class="shared-detail-row">
|
||||
<span class="shared-detail-label">{{ $t('agent.shareScope.webSearch') }}</span>
|
||||
<span class="shared-detail-value">{{ currentSharedAgent.agent.config.web_search_enabled ? $t('agent.shareScope.enabled') : $t('agent.shareScope.disabled') }}</span>
|
||||
</div>
|
||||
<div class="shared-detail-row">
|
||||
<span class="shared-detail-label">{{ $t('agent.shareScope.mcp') }}</span>
|
||||
<span class="shared-detail-value">{{ sharedAgentMcpScopeText }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div class="shared-detail-drawer-footer">
|
||||
<t-button theme="primary" block @click="handleUseSharedAgentInChat(currentSharedAgent)">
|
||||
{{ $t('agent.detail.useInChat') || '在对话中使用' }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
|
||||
<!-- 智能体编辑器弹窗 -->
|
||||
<AgentEditorModal
|
||||
:visible="editorVisible"
|
||||
@@ -186,45 +455,94 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onUnmounted, ref } from 'vue'
|
||||
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { MessagePlugin, Icon as TIcon } from 'tdesign-vue-next'
|
||||
import { listAgents, deleteAgent, copyAgent, type CustomAgent } from '@/api/agent'
|
||||
import { formatStringDate } from '@/utils/index'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { createSessions } from '@/api/chat/index'
|
||||
import { useOrganizationStore } from '@/stores/organization'
|
||||
import { useSettingsStore } from '@/stores/settings'
|
||||
import { useMenuStore } from '@/stores/menu'
|
||||
import type { SharedAgentInfo } from '@/api/organization'
|
||||
import AgentEditorModal from './AgentEditorModal.vue'
|
||||
import AgentAvatar from '@/components/AgentAvatar.vue'
|
||||
|
||||
const { t } = useI18n()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const orgStore = useOrganizationStore()
|
||||
|
||||
interface AgentWithUI extends CustomAgent {
|
||||
showMore?: boolean
|
||||
}
|
||||
|
||||
/** Merged agent for "all" tab: my agents (isMine: true) or shared (isMine: false, org_name, source_tenant_id, share_id) */
|
||||
type DisplayAgent = (AgentWithUI & { isMine: true }) | (CustomAgent & { isMine: false; org_name: string; source_tenant_id: number; share_id: string; showMore?: boolean })
|
||||
|
||||
const activeTab = ref<'all' | 'mine' | 'shared'>('all')
|
||||
const agents = ref<AgentWithUI[]>([])
|
||||
const sharedAgents = computed<SharedAgentInfo[]>(() => orgStore.sharedAgents || [])
|
||||
const allAgentsCount = computed(() => agents.value.length + sharedAgents.value.length)
|
||||
const filteredAgents = computed<DisplayAgent[]>(() => {
|
||||
if (activeTab.value !== 'all') return []
|
||||
const list: DisplayAgent[] = []
|
||||
agents.value.forEach(a => list.push({ ...a, isMine: true as const }))
|
||||
sharedAgents.value.forEach(shared => {
|
||||
if (!shared.agent) return
|
||||
list.push({
|
||||
...shared.agent,
|
||||
isMine: false as const,
|
||||
org_name: shared.org_name,
|
||||
source_tenant_id: shared.source_tenant_id,
|
||||
share_id: shared.share_id,
|
||||
showMore: false
|
||||
} as DisplayAgent)
|
||||
})
|
||||
return list
|
||||
})
|
||||
const loading = ref(false)
|
||||
const deleteVisible = ref(false)
|
||||
const deletingAgent = ref<AgentWithUI | null>(null)
|
||||
const sharedDetailVisible = ref(false)
|
||||
const currentSharedAgent = ref<SharedAgentInfo | null>(null)
|
||||
const sharedAgentUsesKb = computed(() => {
|
||||
const c = currentSharedAgent.value?.agent?.config
|
||||
if (!c) return false
|
||||
return c.kb_selection_mode !== 'none' && c.kb_selection_mode !== undefined
|
||||
})
|
||||
const sharedAgentKbScopeText = computed(() => {
|
||||
const c = currentSharedAgent.value?.agent?.config
|
||||
if (!c) return t('agent.shareScope.kbNone')
|
||||
if (c.kb_selection_mode === 'all') return t('agent.shareScope.kbAll')
|
||||
if (c.kb_selection_mode === 'selected' && c.knowledge_bases?.length) return t('agent.shareScope.kbSelected', { count: c.knowledge_bases.length })
|
||||
return t('agent.shareScope.kbNone')
|
||||
})
|
||||
const sharedAgentMcpScopeText = computed(() => {
|
||||
const c = currentSharedAgent.value?.agent?.config
|
||||
if (!c) return t('agent.shareScope.mcpNone')
|
||||
if (c.mcp_selection_mode === 'all') return t('agent.shareScope.mcpAll')
|
||||
if (c.mcp_selection_mode === 'selected' && c.mcp_services?.length) return t('agent.shareScope.mcpSelected', { count: c.mcp_services.length })
|
||||
return t('agent.shareScope.mcpNone')
|
||||
})
|
||||
const editorVisible = ref(false)
|
||||
const editorMode = ref<'create' | 'edit'>('create')
|
||||
const editingAgent = ref<CustomAgent | null>(null)
|
||||
const editorInitialSection = ref<string>('basic')
|
||||
/** 当前打开三点菜单的卡片 agent.id(用于受控弹出层,避免 computed 项无持久引用导致菜单不响应) */
|
||||
const openMoreAgentId = ref<string | null>(null)
|
||||
|
||||
const fetchList = () => {
|
||||
loading.value = true
|
||||
return listAgents().then((res: any) => {
|
||||
const data = res.data || []
|
||||
// 显示所有智能体(包括内置智能体)
|
||||
agents.value = data.map((agent: CustomAgent) => ({
|
||||
...agent,
|
||||
showMore: false
|
||||
}))
|
||||
|
||||
// 检查 URL 中是否有 edit 参数,如果有则打开对应智能体的编辑模态框
|
||||
checkAndOpenEditModal()
|
||||
}).finally(() => loading.value = false)
|
||||
return Promise.all([
|
||||
listAgents().then((res: any) => {
|
||||
const data = res.data || []
|
||||
agents.value = data.map((agent: CustomAgent) => ({ ...agent, showMore: false }))
|
||||
checkAndOpenEditModal()
|
||||
}),
|
||||
orgStore.fetchSharedAgents()
|
||||
]).finally(() => loading.value = false)
|
||||
}
|
||||
|
||||
// 检查 URL 参数并打开编辑模态框
|
||||
@@ -260,36 +578,87 @@ onUnmounted(() => {
|
||||
window.removeEventListener('openAgentEditor', handleOpenAgentEditor as EventListener)
|
||||
})
|
||||
|
||||
const onVisibleChange = (visible: boolean, agent: AgentWithUI) => {
|
||||
const onVisibleChange = (visible: boolean) => {
|
||||
if (!visible) {
|
||||
agent.showMore = false
|
||||
openMoreAgentId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
const handleCardClick = (agent: AgentWithUI) => {
|
||||
// 如果弹窗正在显示,不触发编辑
|
||||
if (agent.showMore) {
|
||||
const toggleMore = (e: Event, agentId: string) => {
|
||||
e.stopPropagation()
|
||||
openMoreAgentId.value = openMoreAgentId.value === agentId ? null : agentId
|
||||
}
|
||||
|
||||
const handleCardClick = (agent: DisplayAgent | AgentWithUI) => {
|
||||
if (openMoreAgentId.value === agent.id) return
|
||||
if ('isMine' in agent && !agent.isMine) {
|
||||
const shared = sharedAgents.value.find(s => s.agent?.id === agent.id && s.source_tenant_id === agent.source_tenant_id)
|
||||
if (shared) openSharedAgentDetail(shared)
|
||||
return
|
||||
}
|
||||
// 点击卡片编辑(包括内置智能体)
|
||||
handleEdit(agent)
|
||||
handleEdit(agent as AgentWithUI)
|
||||
}
|
||||
|
||||
function openSharedAgentDetail(shared: SharedAgentInfo) {
|
||||
currentSharedAgent.value = shared
|
||||
sharedDetailVisible.value = true
|
||||
}
|
||||
|
||||
function closeSharedAgentDetail() {
|
||||
sharedDetailVisible.value = false
|
||||
currentSharedAgent.value = null
|
||||
}
|
||||
|
||||
/** 在对话中使用共享智能体:创建新会话并跳转 */
|
||||
async function handleUseSharedAgentInChat(shared: SharedAgentInfo) {
|
||||
if (!shared.agent?.id) return
|
||||
closeSharedAgentDetail()
|
||||
const settingsStore = useSettingsStore()
|
||||
const menuStore = useMenuStore()
|
||||
settingsStore.selectAgent(shared.agent.id, String(shared.source_tenant_id))
|
||||
try {
|
||||
const res = await createSessions({})
|
||||
if (res?.data?.id) {
|
||||
const sessionId = res.data.id
|
||||
const now = new Date().toISOString()
|
||||
menuStore.updataMenuChildren({
|
||||
title: t('createChat.newSessionTitle'),
|
||||
path: `chat/${sessionId}`,
|
||||
id: sessionId,
|
||||
isMore: false,
|
||||
isNoTitle: true,
|
||||
created_at: now,
|
||||
updated_at: now
|
||||
})
|
||||
menuStore.changeIsFirstSession(false)
|
||||
router.push({
|
||||
path: `/platform/chat/${sessionId}`,
|
||||
query: { agent_id: shared.agent.id, source_tenant_id: String(shared.source_tenant_id) }
|
||||
})
|
||||
} else {
|
||||
MessagePlugin.error(t('createChat.messages.createFailed') || '创建会话失败')
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Create session for shared agent failed', e)
|
||||
MessagePlugin.error(t('createChat.messages.createError') || '创建会话出错')
|
||||
}
|
||||
}
|
||||
|
||||
const handleEdit = (agent: AgentWithUI) => {
|
||||
agent.showMore = false
|
||||
openMoreAgentId.value = null
|
||||
editingAgent.value = agent
|
||||
editorMode.value = 'edit'
|
||||
editorVisible.value = true
|
||||
}
|
||||
|
||||
const handleDelete = (agent: AgentWithUI) => {
|
||||
agent.showMore = false
|
||||
openMoreAgentId.value = null
|
||||
deletingAgent.value = agent
|
||||
deleteVisible.value = true
|
||||
}
|
||||
|
||||
const handleCopy = (agent: AgentWithUI) => {
|
||||
agent.showMore = false
|
||||
openMoreAgentId.value = null
|
||||
copyAgent(agent.id).then((res: any) => {
|
||||
if (res.data) {
|
||||
MessagePlugin.success(t('agent.messages.copied'))
|
||||
@@ -458,12 +827,78 @@ defineExpose({
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.header-divider {
|
||||
height: 1px;
|
||||
background: #e7ebf0;
|
||||
.agent-tabs {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 24px;
|
||||
border-bottom: 1px solid #e7ebf0;
|
||||
margin-bottom: 20px;
|
||||
|
||||
.tab-item {
|
||||
padding: 12px 0;
|
||||
cursor: pointer;
|
||||
color: #666;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
transition: color 0.2s;
|
||||
|
||||
&:hover {
|
||||
color: #1a1a1a;
|
||||
}
|
||||
|
||||
&.active {
|
||||
color: #07c05f;
|
||||
font-weight: 600;
|
||||
border-bottom: 2px solid #07c05f;
|
||||
margin-bottom: -1px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.shared-badge {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.card-bottom-source {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 2px 8px;
|
||||
border-radius: 10px;
|
||||
background: rgba(0, 0, 0, 0.04);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.card-bottom-source .org-icon {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.org-source-text {
|
||||
color: #666;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.custom-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
padding: 2px 8px;
|
||||
border-radius: 10px;
|
||||
background: rgba(0, 0, 0, 0.04);
|
||||
color: #666;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
|
||||
.agent-card-wrap {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
@@ -609,6 +1044,12 @@ defineExpose({
|
||||
height: 32px;
|
||||
border-radius: 8px;
|
||||
flex-shrink: 0;
|
||||
|
||||
&.agent-emoji {
|
||||
font-size: 18px;
|
||||
line-height: 1;
|
||||
background: rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
&.normal {
|
||||
background: linear-gradient(135deg, rgba(7, 192, 95, 0.15) 0%, rgba(7, 192, 95, 0.08) 100%);
|
||||
@@ -980,4 +1421,137 @@ defineExpose({
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 共享智能体详情侧边栏
|
||||
.shared-detail-drawer-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.4);
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.shared-detail-drawer {
|
||||
width: 360px;
|
||||
max-width: 90vw;
|
||||
height: 100%;
|
||||
background: #fff;
|
||||
box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
font-family: "PingFang SC", sans-serif;
|
||||
}
|
||||
|
||||
.shared-detail-drawer-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 20px 24px;
|
||||
border-bottom: 1px solid #e7ebf0;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.shared-detail-drawer-title {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #1d2129;
|
||||
}
|
||||
|
||||
.shared-detail-drawer-close {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
background: #f5f6f8;
|
||||
color: #86909c;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: background 0.2s ease, color 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
background: #e7ebf0;
|
||||
color: #1d2129;
|
||||
}
|
||||
}
|
||||
|
||||
.shared-detail-drawer-body {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 24px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.shared-detail-drawer-body .shared-detail-row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.shared-detail-drawer-body .shared-detail-section-title {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #1d2129;
|
||||
margin: 20px 0 12px 0;
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid #e7ebf0;
|
||||
}
|
||||
|
||||
.shared-detail-drawer-body .shared-detail-label {
|
||||
font-size: 12px;
|
||||
color: #86909c;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.shared-detail-drawer-body .shared-detail-value {
|
||||
font-size: 14px;
|
||||
color: #1d2129;
|
||||
line-height: 1.5;
|
||||
word-break: break-word;
|
||||
|
||||
&.shared-detail-org {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
.shared-detail-drawer-body .shared-detail-org-icon {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.shared-detail-drawer-footer {
|
||||
padding: 16px 24px;
|
||||
border-top: 1px solid #e7ebf0;
|
||||
flex-shrink: 0;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.shared-detail-drawer-enter-active,
|
||||
.shared-detail-drawer-leave-active {
|
||||
transition: opacity 0.25s ease;
|
||||
|
||||
.shared-detail-drawer {
|
||||
transition: transform 0.25s ease;
|
||||
}
|
||||
}
|
||||
|
||||
.shared-detail-drawer-enter-from,
|
||||
.shared-detail-drawer-leave-to {
|
||||
opacity: 0;
|
||||
|
||||
.shared-detail-drawer {
|
||||
transform: translateX(100%);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user