feat(agent): enhance agent and skill management features
- Updated the API to include disabled agent IDs for better management of user-specific agent visibility. - Introduced a new function to set the disabled state for shared agents, allowing users to manage their shared agent preferences. - Added a new Skills API to retrieve available skills, enhancing the overall agent capabilities. - Improved the AgentSelector and related components to filter out disabled agents, ensuring a cleaner user experience. - Updated localization strings to reflect new features and improve clarity in agent and skill management. This update enhances the user experience by providing better control over agent visibility and introducing new skill management functionalities.
This commit is contained in:
@@ -113,8 +113,9 @@ export const BUILTIN_AGENT_NORMAL_ID = BUILTIN_QUICK_ANSWER_ID;
|
||||
export const BUILTIN_AGENT_AGENT_ID = BUILTIN_SMART_REASONING_ID;
|
||||
|
||||
// 获取智能体列表(包括内置智能体)
|
||||
// disabled_own_agent_ids: 当前租户在对话下拉中停用的「我的」智能体 ID,仅影响本租户
|
||||
export function listAgents() {
|
||||
return get<{ data: CustomAgent[] }>('/api/v1/agents');
|
||||
return get<{ data: CustomAgent[]; disabled_own_agent_ids?: string[] }>('/api/v1/agents');
|
||||
}
|
||||
|
||||
// 获取智能体详情
|
||||
|
||||
@@ -241,6 +241,8 @@ export interface SharedAgentInfo {
|
||||
shared_at: string
|
||||
shared_by_user_id?: string
|
||||
shared_by_username?: string
|
||||
/** 当前用户是否已停用该共享智能体(仅影响本人对话下拉显示) */
|
||||
disabled_by_me?: boolean
|
||||
}
|
||||
|
||||
export interface ListAgentSharesResponse {
|
||||
@@ -610,6 +612,22 @@ export async function listSharedAgents(): Promise<ApiResponse<SharedAgentInfo[]>
|
||||
}
|
||||
}
|
||||
|
||||
/** 设置当前用户对某共享智能体的停用状态(仅影响本人对话下拉显示) */
|
||||
export async function setSharedAgentDisabledByMe(
|
||||
agentId: string,
|
||||
disabled: boolean
|
||||
): Promise<ApiResponse<void>> {
|
||||
try {
|
||||
const response = await post('/api/v1/shared-agents/disabled', {
|
||||
agent_id: agentId,
|
||||
disabled
|
||||
})
|
||||
return response as unknown as ApiResponse<void>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to update preference' }
|
||||
}
|
||||
}
|
||||
|
||||
export async function listOrgAgentShares(orgId: string): Promise<ApiResponse<ListAgentSharesResponse>> {
|
||||
try {
|
||||
const response = await get(`/api/v1/organizations/${orgId}/agent-shares`)
|
||||
|
||||
@@ -301,12 +301,12 @@ const emit = defineEmits<{
|
||||
|
||||
const dropdownStyle = ref<Record<string, string>>({});
|
||||
|
||||
// 使用父组件传入的 agents,避免与父组件重复请求
|
||||
// 父组件已按「当前租户停用」过滤,此处直接使用
|
||||
const agentsList = computed(() => props.agents ?? []);
|
||||
|
||||
// 内置智能体(从 API 获取,对特定 ID 使用本地化名称)
|
||||
const builtinAgents = computed(() => {
|
||||
// 从 API 获取的内置智能体
|
||||
// 从 API 获取的内置智能体(内置无 disabled 概念,全部展示)
|
||||
const apiBuiltins = agentsList.value.filter(a => a.is_builtin);
|
||||
|
||||
// 对特定内置智能体使用本地化名称和描述
|
||||
@@ -334,8 +334,10 @@ const customAgents = computed(() => {
|
||||
return agentsList.value.filter(a => !a.is_builtin);
|
||||
});
|
||||
|
||||
// 共享给我的智能体
|
||||
const sharedAgentsList = computed<SharedAgentInfo[]>(() => orgStore.sharedAgents || []);
|
||||
// 共享给我的智能体(仅展示当前用户未停用的)
|
||||
const sharedAgentsList = computed<SharedAgentInfo[]>(() =>
|
||||
(orgStore.sharedAgents || []).filter(shared => !shared.disabled_by_me)
|
||||
);
|
||||
|
||||
// 当前选中的来源租户(共享智能体时)
|
||||
const currentAgentSourceTenantId = computed(() => settingsStore.selectedAgentSourceTenantId ?? null);
|
||||
|
||||
@@ -32,8 +32,10 @@ const showAgentModeSelector = ref(false);
|
||||
const agentModeButtonRef = ref<HTMLElement>();
|
||||
const agentModeDropdownStyle = ref<Record<string, string>>({});
|
||||
|
||||
// 智能体相关状态
|
||||
// 智能体相关状态(完整列表供选中态解析;对话下拉用 enabledAgents)
|
||||
const agents = ref<CustomAgent[]>([]);
|
||||
/** 当前租户在对话下拉中停用的「我的」智能体 ID(仅影响本租户) */
|
||||
const disabledOwnAgentIds = ref<string[]>([]);
|
||||
const selectedAgentId = computed({
|
||||
get: () => settingsStore.selectedAgentId || BUILTIN_QUICK_ANSWER_ID,
|
||||
set: (val: string) => settingsStore.selectAgent(val)
|
||||
@@ -478,11 +480,18 @@ const loadAgents = async () => {
|
||||
listAgents(),
|
||||
orgStore.fetchSharedAgents(),
|
||||
]);
|
||||
agents.value = agentsRes.data || [];
|
||||
const res = agentsRes as { data?: CustomAgent[]; disabled_own_agent_ids?: string[] }
|
||||
agents.value = res.data || []
|
||||
disabledOwnAgentIds.value = res.disabled_own_agent_ids || []
|
||||
} catch (error) {
|
||||
console.error('Failed to load agents:', error);
|
||||
console.error('Failed to load agents:', error)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// 对话下拉中展示的「我的」智能体(排除当前租户已停用的)
|
||||
const enabledAgents = computed(() =>
|
||||
agents.value.filter(a => !disabledOwnAgentIds.value.includes(a.id))
|
||||
);
|
||||
|
||||
const loadConversationConfig = async () => {
|
||||
try {
|
||||
@@ -1791,7 +1800,7 @@ onBeforeRouteUpdate((to, from, next) => {
|
||||
:visible="showAgentModeSelector"
|
||||
:anchorEl="agentModeButtonRef"
|
||||
:currentAgentId="selectedAgentId"
|
||||
:agents="agents"
|
||||
:agents="enabledAgents"
|
||||
@close="closeAgentModeSelector"
|
||||
@select="handleSelectAgent"
|
||||
/>
|
||||
|
||||
@@ -0,0 +1,320 @@
|
||||
<template>
|
||||
<aside class="list-space-sidebar">
|
||||
<div class="sidebar-header-row">
|
||||
<span class="sidebar-title">{{ $t('listSpaceSidebar.title') }}</span>
|
||||
<div v-if="$slots.actions" class="sidebar-actions">
|
||||
<slot name="actions" />
|
||||
</div>
|
||||
</div>
|
||||
<nav class="sidebar-nav">
|
||||
<!-- 全部 -->
|
||||
<div
|
||||
class="sidebar-item"
|
||||
:class="{ active: selected === 'all' }"
|
||||
@click="select('all')"
|
||||
>
|
||||
<div class="item-left">
|
||||
<t-icon name="layers" class="item-icon" />
|
||||
<span class="item-label">{{ $t('listSpaceSidebar.all') }}</span>
|
||||
</div>
|
||||
<span v-if="countAll !== undefined" class="item-count">{{ countAll }}</span>
|
||||
</div>
|
||||
<!-- 资源列表模式:我的 + 空间列表 -->
|
||||
<template v-if="mode === 'resource'">
|
||||
<div
|
||||
class="sidebar-item"
|
||||
:class="{ active: selected === 'mine' }"
|
||||
@click="select('mine')"
|
||||
>
|
||||
<div class="item-left">
|
||||
<t-icon name="user" class="item-icon" />
|
||||
<span class="item-label">{{ $t('listSpaceSidebar.mine') }}</span>
|
||||
</div>
|
||||
<span v-if="countMine !== undefined" class="item-count">{{ countMine }}</span>
|
||||
</div>
|
||||
<template v-if="organizations.length">
|
||||
<div class="sidebar-section">
|
||||
<span class="section-title">{{ $t('listSpaceSidebar.spaces') }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-for="org in organizations"
|
||||
:key="org.id"
|
||||
class="sidebar-item org-item"
|
||||
:class="{ active: selected === org.id }"
|
||||
@click="select(org.id)"
|
||||
>
|
||||
<div class="item-left">
|
||||
<SpaceAvatar :name="org.name" :avatar="org.avatar" size="small" class="item-avatar" />
|
||||
<span class="item-label" :title="org.name">{{ org.name }}</span>
|
||||
</div>
|
||||
<span v-if="getOrgCount(org.id) !== undefined" class="item-count">{{ getOrgCount(org.id) }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
<!-- 共享空间列表模式:我创建的 + 我加入的 -->
|
||||
<template v-else>
|
||||
<div
|
||||
class="sidebar-item"
|
||||
:class="{ active: selected === 'created' }"
|
||||
@click="select('created')"
|
||||
>
|
||||
<div class="item-left">
|
||||
<t-icon name="usergroup-add" class="item-icon" />
|
||||
<span class="item-label">{{ $t('organization.createdByMe') }}</span>
|
||||
</div>
|
||||
<span v-if="countCreated !== undefined" class="item-count">{{ countCreated }}</span>
|
||||
</div>
|
||||
<div
|
||||
class="sidebar-item"
|
||||
:class="{ active: selected === 'joined' }"
|
||||
@click="select('joined')"
|
||||
>
|
||||
<div class="item-left">
|
||||
<t-icon name="usergroup" class="item-icon" />
|
||||
<span class="item-label">{{ $t('organization.joinedByMe') }}</span>
|
||||
</div>
|
||||
<span v-if="countJoined !== undefined" class="item-count">{{ countJoined }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</nav>
|
||||
</aside>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { Icon as TIcon } from 'tdesign-vue-next'
|
||||
import SpaceAvatar from './SpaceAvatar.vue'
|
||||
import { useOrganizationStore } from '@/stores/organization'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
/** resource = 知识库/智能体(全部+我的+空间列表);organization = 共享空间(全部+我创建的+我加入的) */
|
||||
mode?: 'resource' | 'organization'
|
||||
modelValue: string
|
||||
/** 全部数量(可选) */
|
||||
countAll?: number
|
||||
/** 我的数量(resource 模式) */
|
||||
countMine?: number
|
||||
/** 各空间下的数量(resource 模式),key 为 organization_id */
|
||||
countByOrg?: Record<string, number>
|
||||
/** 我创建的数量(organization 模式) */
|
||||
countCreated?: number
|
||||
/** 我加入的数量(organization 模式) */
|
||||
countJoined?: number
|
||||
}>(),
|
||||
{ mode: 'resource', countAll: undefined, countMine: undefined, countByOrg: () => ({}), countCreated: undefined, countJoined: undefined }
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [value: string]
|
||||
}>()
|
||||
|
||||
const orgStore = useOrganizationStore()
|
||||
const selected = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (v: string) => emit('update:modelValue', v)
|
||||
})
|
||||
|
||||
const organizations = computed(() => orgStore.organizations || [])
|
||||
|
||||
function select(value: string) {
|
||||
selected.value = value
|
||||
}
|
||||
|
||||
function getOrgCount(orgId: string): number | undefined {
|
||||
const n = props.countByOrg?.[orgId]
|
||||
return n === undefined ? undefined : n
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
orgStore.fetchOrganizations()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
// 作为整体内容区左侧一栏,与主内容同属一块区域
|
||||
.list-space-sidebar {
|
||||
width: 176px;
|
||||
flex-shrink: 0;
|
||||
background: #fafbfc;
|
||||
border-right: 1px solid #e7ebf0;
|
||||
padding: 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.sidebar-header-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin-bottom: 8px;
|
||||
flex-shrink: 0;
|
||||
min-height: 28px;
|
||||
|
||||
.sidebar-title {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
color: #1d2129;
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
flex-shrink: 0;
|
||||
|
||||
:deep(.t-button) {
|
||||
padding: 0;
|
||||
min-width: 24px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
font-size: 12px;
|
||||
gap: 0;
|
||||
display: inline-flex !important;
|
||||
align-items: center !important;
|
||||
justify-content: center !important;
|
||||
background: #f2f3f5 !important;
|
||||
border: 1px solid #e5e9f2 !important;
|
||||
color: #4e5969;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s, border-color 0.2s, color 0.2s;
|
||||
&:hover {
|
||||
background: #e5e9f2 !important;
|
||||
border-color: #c9cdd4 !important;
|
||||
color: #1d2129;
|
||||
}
|
||||
}
|
||||
:deep(.t-button .t-button__icon),
|
||||
:deep(.t-button .btn-icon-wrapper) {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
:deep(.t-button .t-icon + .t-button__text:not(:empty)) {
|
||||
margin-left: 0;
|
||||
}
|
||||
:deep(.sidebar-org-icon) {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
filter: brightness(0) saturate(100%) invert(55%);
|
||||
}
|
||||
:deep(.t-button:hover .sidebar-org-icon) {
|
||||
filter: brightness(0) saturate(100%) invert(40%);
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar-nav {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.sidebar-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 6px 8px;
|
||||
border-radius: 6px;
|
||||
color: #4e5969;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
font-size: 12px;
|
||||
|
||||
.item-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.item-icon {
|
||||
flex-shrink: 0;
|
||||
color: #86909c;
|
||||
font-size: 14px;
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
|
||||
.item-avatar {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.item-label {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.item-count {
|
||||
font-size: 12px;
|
||||
color: #86909c;
|
||||
font-weight: 500;
|
||||
padding: 2px 5px;
|
||||
border-radius: 8px;
|
||||
background: #f7f9fc;
|
||||
margin-left: 6px;
|
||||
flex-shrink: 0;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: #f7f9fc;
|
||||
color: #1d2129;
|
||||
|
||||
.item-icon {
|
||||
color: #4e5969;
|
||||
}
|
||||
|
||||
.item-count {
|
||||
background: #e5e9f2;
|
||||
color: #4e5969;
|
||||
}
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: #e6f7ec;
|
||||
color: #00a870;
|
||||
font-weight: 500;
|
||||
|
||||
.item-icon {
|
||||
color: #00a870;
|
||||
}
|
||||
|
||||
.item-count {
|
||||
background: #b8f0d3;
|
||||
color: #00a870;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: #d4f4e3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar-section {
|
||||
padding: 8px 8px 2px;
|
||||
margin-top: 2px;
|
||||
border-top: 1px solid #e7ebf0;
|
||||
|
||||
.section-title {
|
||||
font-size: 12px;
|
||||
color: #86909c;
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -14,6 +14,12 @@ export default {
|
||||
confirmLogout: 'Are you sure you want to logout?',
|
||||
systemInfo: 'System Information'
|
||||
},
|
||||
listSpaceSidebar: {
|
||||
title: 'Filter',
|
||||
all: 'All',
|
||||
mine: 'Mine',
|
||||
spaces: 'Spaces'
|
||||
},
|
||||
knowledgeBase: {
|
||||
title: 'Knowledge Base',
|
||||
list: 'Knowledge Base List',
|
||||
@@ -224,7 +230,11 @@ export default {
|
||||
title: 'Agents',
|
||||
subtitle: 'Configure and manage your agents to customize conversation behavior and capabilities',
|
||||
createAgent: 'Create Agent',
|
||||
createAgentShort: 'New',
|
||||
builtin: 'Built-in',
|
||||
disabled: 'Disabled',
|
||||
disable: 'Disable',
|
||||
enable: 'Enable',
|
||||
noDescription: 'No description',
|
||||
selectAgent: 'Select Agent',
|
||||
noAgents: 'No agents',
|
||||
@@ -309,6 +319,8 @@ export default {
|
||||
builtinReadonly: 'Built-in agents cannot be edited',
|
||||
copied: 'Agent copied successfully',
|
||||
copyFailed: 'Copy failed',
|
||||
disabled: 'Agent disabled',
|
||||
enabled: 'Agent enabled',
|
||||
},
|
||||
editor: {
|
||||
createTitle: 'Create Agent',
|
||||
@@ -329,6 +341,8 @@ export default {
|
||||
name: 'Name',
|
||||
namePlaceholder: 'Enter agent name',
|
||||
nameRequired: 'Agent name is required',
|
||||
disabled: 'Disable',
|
||||
disabledDesc: 'When disabled, this agent will not appear in the conversation agent dropdown',
|
||||
systemPromptRequired: 'System prompt is required',
|
||||
modelRequired: 'Please select a model',
|
||||
rerankModelRequired: 'ReRank model is required when using knowledge bases',
|
||||
@@ -1090,6 +1104,7 @@ export default {
|
||||
},
|
||||
knowledgeList: {
|
||||
create: 'Create Knowledge Base',
|
||||
createShort: 'New',
|
||||
createFAQ: 'Create FAQ Knowledge Base',
|
||||
subtitle: 'Manage and organize your knowledge bases, supporting document-based and FAQ-based knowledge bases',
|
||||
myKnowledgeBases: 'My Knowledge Bases',
|
||||
@@ -1253,6 +1268,7 @@ export default {
|
||||
searchTest: 'Search Test',
|
||||
addFaq: 'Add FAQ',
|
||||
manageFaq: 'FAQ Actions',
|
||||
createGroup: 'New',
|
||||
searchTestTitle: 'FAQ Search Test',
|
||||
queryLabel: 'Query',
|
||||
queryPlaceholder: 'Enter a question to search',
|
||||
@@ -2377,7 +2393,9 @@ export default {
|
||||
title: 'Shared Spaces',
|
||||
subtitle: 'Create or join shared spaces to share knowledge bases and agents with your team',
|
||||
createOrg: 'Create Space',
|
||||
createOrgShort: 'New',
|
||||
joinOrg: 'Join Space',
|
||||
joinOrgShort: 'Join',
|
||||
name: 'Space Name',
|
||||
namePlaceholder: 'Enter space name',
|
||||
nameRequired: 'Please enter space name',
|
||||
|
||||
@@ -14,6 +14,12 @@ export default {
|
||||
confirmLogout: "确定要退出登录吗?",
|
||||
systemInfo: "系统信息",
|
||||
},
|
||||
listSpaceSidebar: {
|
||||
title: "筛选",
|
||||
all: "全部",
|
||||
mine: "我的",
|
||||
spaces: "空间",
|
||||
},
|
||||
knowledgeBase: {
|
||||
title: "知识库",
|
||||
list: "知识库列表",
|
||||
@@ -762,7 +768,11 @@ export default {
|
||||
title: "智能体",
|
||||
subtitle: "配置和管理您的智能体,自定义对话行为和能力",
|
||||
createAgent: "创建智能体",
|
||||
createAgentShort: "新建",
|
||||
builtin: "内置",
|
||||
disabled: "已停用",
|
||||
disable: "停用",
|
||||
enable: "启用",
|
||||
noDescription: "暂无描述",
|
||||
selectAgent: "选择智能体",
|
||||
noAgents: "暂无智能体",
|
||||
@@ -847,6 +857,8 @@ export default {
|
||||
builtinReadonly: "内置智能体不可编辑",
|
||||
copied: "智能体复制成功",
|
||||
copyFailed: "复制失败",
|
||||
disabled: "已停用",
|
||||
enabled: "已启用",
|
||||
},
|
||||
editor: {
|
||||
createTitle: "创建智能体",
|
||||
@@ -867,6 +879,8 @@ export default {
|
||||
name: "名称",
|
||||
namePlaceholder: "请输入智能体名称",
|
||||
nameRequired: "请输入智能体名称",
|
||||
disabled: "停用",
|
||||
disabledDesc: "停用后该智能体将不会在对话窗口的智能体下拉列表中显示",
|
||||
systemPromptRequired: "请输入系统提示词",
|
||||
modelRequired: "请选择模型",
|
||||
rerankModelRequired: "使用知识库时请选择 ReRank 模型",
|
||||
@@ -1482,6 +1496,7 @@ export default {
|
||||
},
|
||||
knowledgeList: {
|
||||
create: "新建知识库",
|
||||
createShort: "新建",
|
||||
createFAQ: "新建 FAQ 知识库",
|
||||
subtitle: "管理和组织您的知识库,支持文档型和问答型知识库",
|
||||
myKnowledgeBases: "我的知识库",
|
||||
@@ -1653,6 +1668,7 @@ export default {
|
||||
searchTest: "检索测试",
|
||||
addFaq: "添加FAQ",
|
||||
manageFaq: "FAQ操作",
|
||||
createGroup: "新建",
|
||||
searchTestTitle: "FAQ 检索测试",
|
||||
queryLabel: "查询内容",
|
||||
queryPlaceholder: "请输入要检索的问题",
|
||||
@@ -2382,7 +2398,9 @@ export default {
|
||||
title: "共享空间",
|
||||
subtitle: "创建或加入共享空间,与团队成员共享知识库与智能体",
|
||||
createOrg: "创建空间",
|
||||
createOrgShort: "新建",
|
||||
joinOrg: "加入空间",
|
||||
joinOrgShort: "加入",
|
||||
name: "空间名称",
|
||||
namePlaceholder: "请输入空间名称",
|
||||
nameRequired: "请输入空间名称",
|
||||
|
||||
@@ -1,54 +1,47 @@
|
||||
<template>
|
||||
<div class="agent-list-container">
|
||||
<!-- 头部 -->
|
||||
<!-- 头部:仅标题与副标题 -->
|
||||
<div class="header">
|
||||
<div class="header-title">
|
||||
<h2>{{ $t('agent.title') }}</h2>
|
||||
<p class="header-subtitle">{{ $t('agent.subtitle') }}</p>
|
||||
</div>
|
||||
<div class="header-actions">
|
||||
<t-button class="agent-create-btn" @click="handleCreateAgent">
|
||||
<template #icon>
|
||||
<span class="btn-icon-wrapper">
|
||||
<svg class="sparkles-icon" width="18" height="18" 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" fill="currentColor" stroke="currentColor" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M15.5 4L15.8 5.2C15.85 5.45 16.05 5.65 16.3 5.7L17.5 6L16.3 6.3C16.05 6.35 15.85 6.55 15.8 6.8L15.5 8L15.2 6.8C15.15 6.55 14.95 6.35 14.7 6.3L13.5 6L14.7 5.7C14.95 5.65 15.15 5.45 15.2 5.2L15.5 4Z" fill="currentColor" stroke="currentColor" stroke-width="0.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M4.5 13L4.8 14.2C4.85 14.45 5.05 14.65 5.3 14.7L6.5 15L5.3 15.3C5.05 15.35 4.85 15.55 4.8 15.8L4.5 17L4.2 15.8C4.15 15.55 3.95 15.35 3.7 15.3L2.5 15L3.7 14.7C3.95 14.65 4.15 14.45 4.2 14.2L4.5 13Z" fill="currentColor" stroke="currentColor" stroke-width="0.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</span>
|
||||
</template>
|
||||
<span>{{ $t('agent.createAgent') }}</span>
|
||||
</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 class="agent-list-body">
|
||||
<ListSpaceSidebar
|
||||
v-model="spaceSelection"
|
||||
:count-all="allAgentsCount"
|
||||
:count-mine="agents.length"
|
||||
:count-by-org="sharedCountByOrg"
|
||||
>
|
||||
<template #actions>
|
||||
<t-tooltip :content="$t('agent.createAgent')" placement="top">
|
||||
<t-button
|
||||
variant="text"
|
||||
theme="default"
|
||||
class="sidebar-action-btn"
|
||||
size="small"
|
||||
:aria-label="$t('agent.createAgent')"
|
||||
@click="handleCreateAgent"
|
||||
>
|
||||
<template #icon>
|
||||
<span class="btn-icon-wrapper">
|
||||
<svg class="sparkles-icon" width="16" height="16" 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" fill="currentColor" stroke="currentColor" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M15.5 4L15.8 5.2C15.85 5.45 16.05 5.65 16.3 5.7L17.5 6L16.3 6.3C16.05 6.35 15.85 6.55 15.8 6.8L15.5 8L15.2 6.8C15.15 6.55 14.95 6.35 14.7 6.3L13.5 6L14.7 5.7C14.95 5.65 15.15 5.45 15.2 5.2L15.5 4Z" fill="currentColor" stroke="currentColor" stroke-width="0.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M4.5 13L4.8 14.2C4.85 14.45 5.05 14.65 5.3 14.7L6.5 15L5.3 15.3C5.05 15.35 4.85 15.55 4.8 15.8L4.5 17L4.2 15.8C4.15 15.55 3.95 15.35 3.7 15.3L2.5 15L3.7 14.7C3.95 14.65 4.15 14.45 4.2 14.2L4.5 13Z" fill="currentColor" stroke="currentColor" stroke-width="0.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</span>
|
||||
</template>
|
||||
</t-button>
|
||||
</t-tooltip>
|
||||
</template>
|
||||
</ListSpaceSidebar>
|
||||
<div class="agent-list-main">
|
||||
<!-- 全部:我的 + 共享 -->
|
||||
<div v-if="activeTab === 'all' && filteredAgents.length > 0" class="agent-card-wrap">
|
||||
<div v-if="spaceSelection === 'all' && filteredAgents.length > 0" class="agent-card-wrap">
|
||||
<div
|
||||
v-for="agent in filteredAgents"
|
||||
:key="agent.isMine ? agent.id : `shared-${agent.share_id}`"
|
||||
@@ -76,7 +69,7 @@
|
||||
<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" />
|
||||
<AgentAvatar v-else :name="agent.name" size="small" />
|
||||
<span class="card-title" :title="agent.name">{{ agent.name }}</span>
|
||||
</div>
|
||||
<t-popup
|
||||
@@ -96,10 +89,35 @@
|
||||
<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" @click="handleToggleDisabled(agent)">
|
||||
<t-icon class="menu-icon" name="poweroff" />
|
||||
<span>{{ agent.disabled_by_me ? $t('agent.enable') : $t('agent.disable') }}</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>
|
||||
<t-popup
|
||||
v-else
|
||||
:visible="openMoreAgentId === 'shared-' + agent.share_id"
|
||||
trigger="hover"
|
||||
overlayClassName="card-more-popup"
|
||||
destroy-on-close
|
||||
placement="bottom-right"
|
||||
@update:visible="(v: boolean) => { if (!v) openMoreAgentId = null }"
|
||||
>
|
||||
<div class="more-wrap" :class="{ 'active-more': openMoreAgentId === 'shared-' + agent.share_id }" @click.stop="toggleMore($event, 'shared-' + agent.share_id)">
|
||||
<img class="more-icon" src="@/assets/img/more.png" alt="" />
|
||||
</div>
|
||||
<template #content>
|
||||
<div class="popup-menu">
|
||||
<div class="popup-menu-item" @click="handleToggleSharedDisabled(agent)">
|
||||
<t-icon class="menu-icon" name="poweroff" />
|
||||
<span>{{ agent.disabled_by_me ? $t('agent.enable') : $t('agent.disable') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</t-popup>
|
||||
</div>
|
||||
<div class="card-content">
|
||||
<div class="card-description">{{ agent.description || $t('agent.noDescription') }}</div>
|
||||
@@ -107,6 +125,8 @@
|
||||
<div class="card-bottom">
|
||||
<div class="bottom-left">
|
||||
<div class="feature-badges">
|
||||
<t-tag v-if="agent.isMine && !agent.is_builtin && agent.disabled_by_me" theme="default" size="small" class="disabled-badge">{{ $t('agent.disabled') }}</t-tag>
|
||||
<t-tag v-if="!agent.isMine && agent.disabled_by_me" theme="default" size="small" class="disabled-badge">{{ $t('agent.disabled') }}</t-tag>
|
||||
<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" />
|
||||
@@ -156,7 +176,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 我的智能体 -->
|
||||
<div v-if="activeTab === 'mine' && agents.length > 0" class="agent-card-wrap">
|
||||
<div v-if="spaceSelection === 'mine' && agents.length > 0" class="agent-card-wrap">
|
||||
<div
|
||||
v-for="agent in agents"
|
||||
:key="agent.id"
|
||||
@@ -186,7 +206,7 @@
|
||||
<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" />
|
||||
<AgentAvatar v-else :name="agent.name" size="small" />
|
||||
<span class="card-title" :title="agent.name">{{ agent.name }}</span>
|
||||
</div>
|
||||
<t-popup
|
||||
@@ -215,6 +235,10 @@
|
||||
<t-icon class="menu-icon" name="file-copy" />
|
||||
<span>{{ $t('common.copy') }}</span>
|
||||
</div>
|
||||
<div v-if="!agent.is_builtin" class="popup-menu-item" @click="handleToggleDisabled(agent)">
|
||||
<t-icon class="menu-icon" name="poweroff" />
|
||||
<span>{{ agent.disabled_by_me ? $t('agent.enable') : $t('agent.disable') }}</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>
|
||||
@@ -235,6 +259,7 @@
|
||||
<div class="card-bottom">
|
||||
<div class="bottom-left">
|
||||
<div class="feature-badges">
|
||||
<t-tag v-if="!agent.is_builtin && agent.disabled_by_me" theme="default" size="small" class="disabled-badge">{{ $t('agent.disabled') }}</t-tag>
|
||||
<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" />
|
||||
@@ -279,10 +304,10 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 共享给我的智能体 -->
|
||||
<div v-if="activeTab === 'shared' && sharedAgents.length > 0" class="agent-card-wrap">
|
||||
<!-- 按空间筛选:该空间下共享给我的智能体 -->
|
||||
<div v-if="spaceSelectionOrgId && sharedAgentsByOrg.length > 0" class="agent-card-wrap">
|
||||
<div
|
||||
v-for="shared in sharedAgents"
|
||||
v-for="shared in sharedAgentsByOrg"
|
||||
:key="'shared-' + shared.share_id"
|
||||
class="agent-card shared-agent-card"
|
||||
:class="{
|
||||
@@ -302,9 +327,29 @@
|
||||
<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" />
|
||||
<AgentAvatar v-else :name="shared.agent?.name" size="small" />
|
||||
<span class="card-title" :title="shared.agent?.name">{{ shared.agent?.name }}</span>
|
||||
</div>
|
||||
<t-popup
|
||||
:visible="openMoreAgentId === 'shared-tab-' + shared.share_id"
|
||||
trigger="hover"
|
||||
overlayClassName="card-more-popup"
|
||||
destroy-on-close
|
||||
placement="bottom-right"
|
||||
@update:visible="(v: boolean) => { if (!v) openMoreAgentId = null }"
|
||||
>
|
||||
<div class="more-wrap" :class="{ 'active-more': openMoreAgentId === 'shared-tab-' + shared.share_id }" @click.stop="toggleMore($event, 'shared-tab-' + shared.share_id)">
|
||||
<img class="more-icon" src="@/assets/img/more.png" alt="" />
|
||||
</div>
|
||||
<template #content>
|
||||
<div class="popup-menu">
|
||||
<div class="popup-menu-item" @click="handleToggleSharedDisabledFromShared(shared)">
|
||||
<t-icon class="menu-icon" name="poweroff" />
|
||||
<span>{{ shared.disabled_by_me ? $t('agent.enable') : $t('agent.disable') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</t-popup>
|
||||
</div>
|
||||
<div class="card-content">
|
||||
<div class="card-description">{{ shared.agent?.description || $t('agent.noDescription') }}</div>
|
||||
@@ -312,6 +357,7 @@
|
||||
<div class="card-bottom">
|
||||
<div class="bottom-left">
|
||||
<div class="feature-badges">
|
||||
<t-tag v-if="shared.disabled_by_me" theme="default" size="small" class="disabled-badge">{{ $t('agent.disabled') }}</t-tag>
|
||||
<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" />
|
||||
@@ -341,23 +387,49 @@
|
||||
</div>
|
||||
|
||||
<!-- 空状态:全部 -->
|
||||
<div v-if="activeTab === 'all' && filteredAgents.length === 0 && !loading" class="empty-state">
|
||||
<div v-if="spaceSelection === '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>
|
||||
<t-button class="agent-create-btn empty-state-btn" @click="handleCreateAgent">
|
||||
<template #icon>
|
||||
<span class="btn-icon-wrapper">
|
||||
<svg class="sparkles-icon" width="18" height="18" 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" fill="currentColor" stroke="currentColor" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M15.5 4L15.8 5.2C15.85 5.45 16.05 5.65 16.3 5.7L17.5 6L16.3 6.3C16.05 6.35 15.85 6.55 15.8 6.8L15.5 8L15.2 6.8C15.15 6.55 14.95 6.35 14.7 6.3L13.5 6L14.7 5.7C14.95 5.65 15.15 5.45 15.2 5.2L15.5 4Z" fill="currentColor" stroke="currentColor" stroke-width="0.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M4.5 13L4.8 14.2C4.85 14.45 5.05 14.65 5.3 14.7L6.5 15L5.3 15.3C5.05 15.35 4.85 15.55 4.8 15.8L4.5 17L4.2 15.8C4.15 15.55 3.95 15.35 3.7 15.3L2.5 15L3.7 14.7C3.95 14.65 4.15 14.45 4.2 14.2L4.5 13Z" fill="currentColor" stroke="currentColor" stroke-width="0.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</span>
|
||||
</template>
|
||||
<span>{{ $t('agent.createAgent') }}</span>
|
||||
</t-button>
|
||||
</div>
|
||||
<!-- 空状态:我的 -->
|
||||
<div v-if="activeTab === 'mine' && agents.length === 0 && !loading" class="empty-state">
|
||||
<div v-if="spaceSelection === '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>
|
||||
<t-button class="agent-create-btn empty-state-btn" @click="handleCreateAgent">
|
||||
<template #icon>
|
||||
<span class="btn-icon-wrapper">
|
||||
<svg class="sparkles-icon" width="18" height="18" 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" fill="currentColor" stroke="currentColor" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M15.5 4L15.8 5.2C15.85 5.45 16.05 5.65 16.3 5.7L17.5 6L16.3 6.3C16.05 6.35 15.85 6.55 15.8 6.8L15.5 8L15.2 6.8C15.15 6.55 14.95 6.35 14.7 6.3L13.5 6L14.7 5.7C14.95 5.65 15.15 5.45 15.2 5.2L15.5 4Z" fill="currentColor" stroke="currentColor" stroke-width="0.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M4.5 13L4.8 14.2C4.85 14.45 5.05 14.65 5.3 14.7L6.5 15L5.3 15.3C5.05 15.35 4.85 15.55 4.8 15.8L4.5 17L4.2 15.8C4.15 15.55 3.95 15.35 3.7 15.3L2.5 15L3.7 14.7C3.95 14.65 4.15 14.45 4.2 14.2L4.5 13Z" fill="currentColor" stroke="currentColor" stroke-width="0.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</span>
|
||||
</template>
|
||||
<span>{{ $t('agent.createAgent') }}</span>
|
||||
</t-button>
|
||||
</div>
|
||||
<!-- 空状态:共享给我 -->
|
||||
<div v-if="activeTab === 'shared' && sharedAgents.length === 0 && !loading" class="empty-state">
|
||||
<!-- 空状态:空间下共享给我 -->
|
||||
<div v-if="spaceSelectionOrgId && sharedAgentsByOrg.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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 删除确认对话框 -->
|
||||
<t-dialog
|
||||
@@ -463,11 +535,13 @@ import { formatStringDate } from '@/utils/index'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { createSessions } from '@/api/chat/index'
|
||||
import { useOrganizationStore } from '@/stores/organization'
|
||||
import { setSharedAgentDisabledByMe } from '@/api/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'
|
||||
import ListSpaceSidebar from '@/components/ListSpaceSidebar.vue'
|
||||
|
||||
const { t } = useI18n()
|
||||
const route = useRoute()
|
||||
@@ -476,17 +550,44 @@ const orgStore = useOrganizationStore()
|
||||
|
||||
interface AgentWithUI extends CustomAgent {
|
||||
showMore?: boolean
|
||||
/** 当前租户在对话下拉中停用(仅影响本租户) */
|
||||
disabled_by_me?: 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 })
|
||||
/** Merged agent for "all" tab: my agents (isMine: true) or shared (isMine: false, org_name, source_tenant_id, share_id, disabled_by_me?) */
|
||||
type DisplayAgent = (AgentWithUI & { isMine: true }) | (CustomAgent & { isMine: false; org_name: string; source_tenant_id: number; share_id: string; showMore?: boolean; disabled_by_me?: boolean })
|
||||
|
||||
const activeTab = ref<'all' | 'mine' | 'shared'>('all')
|
||||
const spaceSelection = ref<'all' | 'mine' | string>('all')
|
||||
const agents = ref<AgentWithUI[]>([])
|
||||
const sharedAgents = computed<SharedAgentInfo[]>(() => orgStore.sharedAgents || [])
|
||||
const allAgentsCount = computed(() => agents.value.length + sharedAgents.value.length)
|
||||
|
||||
const spaceSelectionOrgId = computed(() => {
|
||||
const s = spaceSelection.value
|
||||
return s !== 'all' && s !== 'mine' && !!s
|
||||
})
|
||||
|
||||
const sharedAgentsByOrg = computed(() => {
|
||||
const orgId = spaceSelection.value
|
||||
if (orgId === 'all' || orgId === 'mine') return []
|
||||
return sharedAgents.value.filter(s => s.organization_id === orgId)
|
||||
})
|
||||
|
||||
const sharedCountByOrg = computed<Record<string, number>>(() => {
|
||||
const map: Record<string, number> = {}
|
||||
sharedAgents.value.forEach(s => {
|
||||
const id = s.organization_id
|
||||
if (!id) return
|
||||
map[id] = (map[id] || 0) + 1
|
||||
})
|
||||
return map
|
||||
})
|
||||
|
||||
const filteredAgents = computed<DisplayAgent[]>(() => {
|
||||
if (activeTab.value !== 'all') return []
|
||||
if (spaceSelection.value === 'mine') {
|
||||
return agents.value.map(a => ({ ...a, isMine: true as const }))
|
||||
}
|
||||
if (spaceSelection.value !== 'all') return []
|
||||
const list: DisplayAgent[] = []
|
||||
agents.value.forEach(a => list.push({ ...a, isMine: true as const }))
|
||||
sharedAgents.value.forEach(shared => {
|
||||
@@ -497,6 +598,7 @@ const filteredAgents = computed<DisplayAgent[]>(() => {
|
||||
org_name: shared.org_name,
|
||||
source_tenant_id: shared.source_tenant_id,
|
||||
share_id: shared.share_id,
|
||||
disabled_by_me: shared.disabled_by_me,
|
||||
showMore: false
|
||||
} as DisplayAgent)
|
||||
})
|
||||
@@ -538,7 +640,12 @@ const fetchList = () => {
|
||||
return Promise.all([
|
||||
listAgents().then((res: any) => {
|
||||
const data = res.data || []
|
||||
agents.value = data.map((agent: CustomAgent) => ({ ...agent, showMore: false }))
|
||||
const disabledOwnIds = res.disabled_own_agent_ids || []
|
||||
agents.value = data.map((agent: CustomAgent) => ({
|
||||
...agent,
|
||||
showMore: false,
|
||||
disabled_by_me: disabledOwnIds.includes(agent.id)
|
||||
}))
|
||||
checkAndOpenEditModal()
|
||||
}),
|
||||
orgStore.fetchSharedAgents()
|
||||
@@ -671,6 +778,55 @@ const handleCopy = (agent: AgentWithUI) => {
|
||||
})
|
||||
}
|
||||
|
||||
/** 切换「我的」智能体停用状态(仅影响当前租户对话下拉显示) */
|
||||
const handleToggleDisabled = (agent: AgentWithUI) => {
|
||||
openMoreAgentId.value = null
|
||||
const nextDisabled = !agent.disabled_by_me
|
||||
setSharedAgentDisabledByMe(agent.id, nextDisabled).then((res: any) => {
|
||||
if (res.success) {
|
||||
MessagePlugin.success(nextDisabled ? t('agent.messages.disabled') : t('agent.messages.enabled'))
|
||||
fetchList()
|
||||
} else {
|
||||
MessagePlugin.error(res.message || t('agent.messages.saveFailed'))
|
||||
}
|
||||
}).catch((e: any) => {
|
||||
MessagePlugin.error(e?.message || t('agent.messages.saveFailed'))
|
||||
})
|
||||
}
|
||||
|
||||
/** 切换共享智能体“停用”状态(仅影响当前用户对话下拉显示) */
|
||||
const handleToggleSharedDisabled = (agent: DisplayAgent) => {
|
||||
if (agent.isMine) return
|
||||
openMoreAgentId.value = null
|
||||
const nextDisabled = !agent.disabled_by_me
|
||||
setSharedAgentDisabledByMe(agent.id, nextDisabled).then((res: any) => {
|
||||
if (res.success) {
|
||||
MessagePlugin.success(nextDisabled ? t('agent.messages.disabled') : t('agent.messages.enabled'))
|
||||
orgStore.fetchSharedAgents()
|
||||
} else {
|
||||
MessagePlugin.error(res.message || t('agent.messages.saveFailed'))
|
||||
}
|
||||
}).catch((e: any) => {
|
||||
MessagePlugin.error(e?.message || t('agent.messages.saveFailed'))
|
||||
})
|
||||
}
|
||||
|
||||
const handleToggleSharedDisabledFromShared = (shared: SharedAgentInfo) => {
|
||||
if (!shared.agent) return
|
||||
openMoreAgentId.value = null
|
||||
const nextDisabled = !shared.disabled_by_me
|
||||
setSharedAgentDisabledByMe(shared.agent.id, nextDisabled).then((res: any) => {
|
||||
if (res.success) {
|
||||
MessagePlugin.success(nextDisabled ? t('agent.messages.disabled') : t('agent.messages.enabled'))
|
||||
orgStore.fetchSharedAgents()
|
||||
} else {
|
||||
MessagePlugin.error(res.message || t('agent.messages.saveFailed'))
|
||||
}
|
||||
}).catch((e: any) => {
|
||||
MessagePlugin.error(e?.message || t('agent.messages.saveFailed'))
|
||||
})
|
||||
}
|
||||
|
||||
const confirmDelete = () => {
|
||||
if (!deletingAgent.value) return
|
||||
|
||||
@@ -718,18 +874,37 @@ defineExpose({
|
||||
|
||||
<style scoped lang="less">
|
||||
.agent-list-container {
|
||||
padding: 24px 44px;
|
||||
padding: 24px 10px;
|
||||
margin: 0 20px;
|
||||
height: calc(100vh);
|
||||
overflow-y: auto;
|
||||
box-sizing: border-box;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.agent-list-body {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
background: #fff;
|
||||
border: 1px solid #e7ebf0;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.agent-list-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 16px;
|
||||
|
||||
.header-title {
|
||||
@@ -746,76 +921,67 @@ defineExpose({
|
||||
font-weight: 600;
|
||||
line-height: 32px;
|
||||
}
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: flex;
|
||||
:deep(.agent-create-btn) {
|
||||
--ripple-color: rgba(118, 75, 162, 0.3) !important;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
|
||||
border: none !important;
|
||||
color: #fff !important;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
|
||||
&:hover,
|
||||
&:active,
|
||||
&:focus,
|
||||
&.t-is-active,
|
||||
&[data-state="active"] {
|
||||
background: linear-gradient(135deg, #5a6fd6 0%, #6a4190 100%) !important;
|
||||
border: none !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
--td-button-primary-bg-color: #667eea !important;
|
||||
--td-button-primary-border-color: #667eea !important;
|
||||
--td-button-primary-active-bg-color: #5a6fd6 !important;
|
||||
--td-button-primary-active-border-color: #5a6fd6 !important;
|
||||
|
||||
.btn-icon-wrapper {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
|
||||
:deep(.agent-create-btn) {
|
||||
--ripple-color: rgba(118, 75, 162, 0.3) !important;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
|
||||
border: none !important;
|
||||
color: #fff !important;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
|
||||
&:hover,
|
||||
&:active,
|
||||
&:focus,
|
||||
&.t-is-active,
|
||||
&[data-state="active"] {
|
||||
background: linear-gradient(135deg, #5a6fd6 0%, #6a4190 100%) !important;
|
||||
border: none !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
// 覆盖 TDesign 按钮的 CSS 变量
|
||||
--td-button-primary-bg-color: #667eea !important;
|
||||
--td-button-primary-border-color: #667eea !important;
|
||||
--td-button-primary-active-bg-color: #5a6fd6 !important;
|
||||
--td-button-primary-active-border-color: #5a6fd6 !important;
|
||||
}
|
||||
|
||||
.agent-create-btn {
|
||||
.btn-icon-wrapper {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.sparkles-icon {
|
||||
animation: twinkle 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: -50%;
|
||||
left: -50%;
|
||||
width: 200%;
|
||||
height: 200%;
|
||||
background: linear-gradient(
|
||||
45deg,
|
||||
transparent 30%,
|
||||
rgba(255, 255, 255, 0.1) 50%,
|
||||
transparent 70%
|
||||
);
|
||||
transform: translateX(-100%);
|
||||
transition: transform 0.6s ease;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
&:hover::before {
|
||||
transform: translateX(100%);
|
||||
}
|
||||
}
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
@keyframes twinkle {
|
||||
0%, 100% { opacity: 1; transform: scale(1); }
|
||||
50% { opacity: 0.8; transform: scale(0.95); }
|
||||
|
||||
.sparkles-icon {
|
||||
animation: twinkle 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: -50%;
|
||||
left: -50%;
|
||||
width: 200%;
|
||||
height: 200%;
|
||||
background: linear-gradient(
|
||||
45deg,
|
||||
transparent 30%,
|
||||
rgba(255, 255, 255, 0.1) 50%,
|
||||
transparent 70%
|
||||
);
|
||||
transform: translateX(-100%);
|
||||
transition: transform 0.6s ease;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
&:hover::before {
|
||||
transform: translateX(100%);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes twinkle {
|
||||
0%, 100% { opacity: 1; transform: scale(1); }
|
||||
50% { opacity: 0.8; transform: scale(0.95); }
|
||||
}
|
||||
|
||||
.header-subtitle {
|
||||
@@ -901,13 +1067,13 @@ defineExpose({
|
||||
|
||||
.agent-card-wrap {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
gap: 12px;
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.agent-card {
|
||||
border: 1px solid #f0f0f0;
|
||||
border-radius: 12px;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
|
||||
@@ -915,10 +1081,10 @@ defineExpose({
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
transition: all 0.25s ease;
|
||||
padding: 16px 18px;
|
||||
padding: 12px 14px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 160px;
|
||||
height: 132px;
|
||||
|
||||
&:hover {
|
||||
border-color: #07c05f;
|
||||
@@ -975,8 +1141,8 @@ defineExpose({
|
||||
|
||||
.card-decoration {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
right: 50px;
|
||||
top: 10px;
|
||||
right: 40px;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 4px;
|
||||
@@ -988,7 +1154,7 @@ defineExpose({
|
||||
opacity: 0.9;
|
||||
|
||||
&.small {
|
||||
margin-top: 14px;
|
||||
margin-top: 10px;
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
@@ -998,13 +1164,13 @@ defineExpose({
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 10px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.card-header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
gap: 8px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
@@ -1012,9 +1178,9 @@ defineExpose({
|
||||
.card-title {
|
||||
color: #1a1a1a;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 15px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
line-height: 22px;
|
||||
line-height: 20px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
@@ -1040,13 +1206,13 @@ defineExpose({
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 8px;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border-radius: 6px;
|
||||
flex-shrink: 0;
|
||||
|
||||
&.agent-emoji {
|
||||
font-size: 18px;
|
||||
font-size: 16px;
|
||||
line-height: 1;
|
||||
background: rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
@@ -1064,8 +1230,8 @@ defineExpose({
|
||||
|
||||
.edit-btn {
|
||||
display: flex;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: 6px;
|
||||
@@ -1082,8 +1248,8 @@ defineExpose({
|
||||
|
||||
.more-wrap {
|
||||
display: flex;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: 6px;
|
||||
@@ -1107,14 +1273,14 @@ defineExpose({
|
||||
}
|
||||
|
||||
.more-icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.card-content {
|
||||
flex: 1;
|
||||
margin-bottom: 12px;
|
||||
margin-bottom: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@@ -1126,9 +1292,9 @@ defineExpose({
|
||||
overflow: hidden;
|
||||
color: #666;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 13px;
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
line-height: 20px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.card-bottom {
|
||||
@@ -1136,7 +1302,7 @@ defineExpose({
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: auto;
|
||||
padding-top: 12px;
|
||||
padding-top: 8px;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
@@ -1156,9 +1322,9 @@ defineExpose({
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
border-radius: 6px;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
border-radius: 5px;
|
||||
cursor: default;
|
||||
transition: background 0.2s ease;
|
||||
|
||||
@@ -1253,6 +1419,11 @@ defineExpose({
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
line-height: 22px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.empty-state-btn {
|
||||
margin-top: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1137,6 +1137,27 @@ async function createNewSession(value: string): Promise<void> {
|
||||
<t-icon name="chevron-right" class="breadcrumb-separator" />
|
||||
<span class="breadcrumb-current">{{ $t('knowledgeEditor.document.title') }}</span>
|
||||
</h2>
|
||||
<!-- 身份与最后更新:紧凑单行,置于标题行右侧,悬停显示权限说明 -->
|
||||
<div v-if="kbInfo" class="kb-access-meta">
|
||||
<t-tooltip :content="accessPermissionSummary" placement="top">
|
||||
<span class="kb-access-meta-inner">
|
||||
<t-tag size="small" :theme="isOwner ? 'success' : (currentSharedKb?.permission === 'admin' ? 'primary' : currentSharedKb?.permission === 'editor' ? 'warning' : 'default')" class="kb-access-role-tag">
|
||||
{{ accessRoleLabel }}
|
||||
</t-tag>
|
||||
<template v-if="currentSharedKb">
|
||||
<span class="kb-access-meta-sep">·</span>
|
||||
<span class="kb-access-meta-text">
|
||||
{{ $t('knowledgeBase.accessInfo.fromOrg') }}「{{ currentSharedKb.org_name }}」
|
||||
{{ $t('knowledgeBase.accessInfo.sharedAt') }} {{ formatStringDate(new Date(currentSharedKb.shared_at)) }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-else-if="kbLastUpdated">
|
||||
<span class="kb-access-meta-sep">·</span>
|
||||
<span class="kb-access-meta-text">{{ $t('knowledgeBase.accessInfo.lastUpdated') }} {{ kbLastUpdated }}</span>
|
||||
</template>
|
||||
</span>
|
||||
</t-tooltip>
|
||||
</div>
|
||||
<t-tooltip v-if="canManage" :content="$t('knowledgeBase.settings')" placement="top">
|
||||
<button
|
||||
type="button"
|
||||
@@ -1149,49 +1170,6 @@ async function createNewSession(value: string): Promise<void> {
|
||||
</t-tooltip>
|
||||
</div>
|
||||
<p class="document-subtitle">{{ $t('knowledgeEditor.document.subtitle') }}</p>
|
||||
<!-- 当前知识库权限与来源信息 -->
|
||||
<div v-if="kbInfo" class="kb-access-info">
|
||||
<span class="kb-access-role">
|
||||
<t-icon name="user" class="kb-access-item-icon" />
|
||||
<span class="kb-access-label">{{ $t('knowledgeBase.accessInfo.myRole') }}:</span>
|
||||
<t-tag size="small" :theme="isOwner ? 'success' : (currentSharedKb?.permission === 'admin' ? 'primary' : currentSharedKb?.permission === 'editor' ? 'warning' : 'default')">
|
||||
{{ accessRoleLabel }}
|
||||
</t-tag>
|
||||
<t-tooltip :content="accessPermissionSummary" placement="top">
|
||||
<t-icon name="help-circle" class="kb-access-item-icon kb-access-permission-tip" />
|
||||
</t-tooltip>
|
||||
</span>
|
||||
<template v-if="currentSharedKb">
|
||||
<span class="kb-access-sep">·</span>
|
||||
<span class="kb-access-source">
|
||||
<img src="@/assets/img/organization-green.svg" class="kb-access-org-icon" alt="" aria-hidden="true" />
|
||||
{{ $t('knowledgeBase.accessInfo.fromOrg') }}「{{ currentSharedKb.org_name }}」
|
||||
<t-icon name="time" class="kb-access-item-icon" />
|
||||
{{ $t('knowledgeBase.accessInfo.sharedAt') }} {{ formatStringDate(new Date(currentSharedKb.shared_at)) }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-else-if="kbLastUpdated">
|
||||
<span class="kb-access-sep">·</span>
|
||||
<span class="kb-access-updated">
|
||||
<t-icon name="time" class="kb-access-item-icon" />
|
||||
{{ $t('knowledgeBase.accessInfo.lastUpdated') }} {{ kbLastUpdated }}
|
||||
</span>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="canEdit" class="document-header-actions">
|
||||
<t-dropdown
|
||||
:options="documentActionOptions"
|
||||
trigger="click"
|
||||
placement="bottom-right"
|
||||
@click="handleDocumentActionSelect"
|
||||
>
|
||||
<t-button class="doc-action-btn dropdown-action-btn">
|
||||
<template #icon><t-icon name="file-add" /></template>
|
||||
<span>{{ $t('knowledgeBase.addDocument') }}</span>
|
||||
<t-icon name="chevron-down" size="14px" class="dropdown-arrow" />
|
||||
</t-button>
|
||||
</t-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1375,7 +1353,7 @@ async function createNewSession(value: string): Promise<void> {
|
||||
</aside>
|
||||
<div class="tag-content">
|
||||
<div class="doc-card-area">
|
||||
<!-- 搜索栏和筛选 -->
|
||||
<!-- 搜索栏、筛选与添加文档 -->
|
||||
<div class="doc-filter-bar">
|
||||
<t-input
|
||||
v-model.trim="docSearchKeyword"
|
||||
@@ -1396,6 +1374,20 @@ async function createNewSession(value: string): Promise<void> {
|
||||
class="doc-type-select"
|
||||
clearable
|
||||
/>
|
||||
<div v-if="canEdit" class="doc-filter-actions">
|
||||
<t-tooltip :content="$t('knowledgeBase.addDocument')" placement="top">
|
||||
<t-dropdown
|
||||
:options="documentActionOptions"
|
||||
trigger="click"
|
||||
placement="bottom-right"
|
||||
@click="handleDocumentActionSelect"
|
||||
>
|
||||
<t-button variant="text" theme="default" class="content-bar-icon-btn" size="small">
|
||||
<template #icon><t-icon name="file-add" size="16px" /></template>
|
||||
</t-button>
|
||||
</t-dropdown>
|
||||
</t-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="doc-scroll-container"
|
||||
@@ -1672,23 +1664,26 @@ async function createNewSession(value: string): Promise<void> {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: 24px 44px 32px;
|
||||
padding: 24px 30px 32px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
// 与列表页一致:整体一块白底圆角区,左侧标签栏为内部分区
|
||||
.knowledge-main {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
background: #fff;
|
||||
border: 1px solid #e7ebf0;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.tag-sidebar {
|
||||
width: 230px;
|
||||
background: #fff;
|
||||
border-radius: 12px;
|
||||
border: 1px solid #e7ebf0;
|
||||
padding: 16px;
|
||||
width: 176px;
|
||||
background: #fafbfc;
|
||||
border-right: 1px solid #e7ebf0;
|
||||
padding: 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-shrink: 0;
|
||||
@@ -1699,36 +1694,37 @@ async function createNewSession(value: string): Promise<void> {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 12px;
|
||||
margin-bottom: 8px;
|
||||
color: #1d2129;
|
||||
|
||||
.sidebar-title {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 4px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
|
||||
.sidebar-count {
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
color: #86909c;
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
color: #c9ced6;
|
||||
align-items: center;
|
||||
|
||||
.create-tag-btn {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
padding: 0;
|
||||
border-radius: 6px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 18px;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #00a870;
|
||||
line-height: 1;
|
||||
@@ -1747,7 +1743,7 @@ async function createNewSession(value: string): Promise<void> {
|
||||
}
|
||||
|
||||
.tag-search-bar {
|
||||
margin-bottom: 12px;
|
||||
margin-bottom: 8px;
|
||||
|
||||
:deep(.t-input) {
|
||||
font-size: 12px;
|
||||
@@ -1759,19 +1755,19 @@ async function createNewSession(value: string): Promise<void> {
|
||||
.tag-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
gap: 4px;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
|
||||
.tag-load-more {
|
||||
padding: 8px 0 0;
|
||||
padding: 6px 0 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
:deep(.t-button) {
|
||||
padding: 0;
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
color: #00a870;
|
||||
}
|
||||
}
|
||||
@@ -1780,24 +1776,24 @@ async function createNewSession(value: string): Promise<void> {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 8px 10px;
|
||||
padding: 6px 8px;
|
||||
border-radius: 6px;
|
||||
color: #4e5969;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
font-size: 13px;
|
||||
font-size: 12px;
|
||||
|
||||
.tag-list-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
|
||||
.t-icon {
|
||||
flex-shrink: 0;
|
||||
color: #86909c;
|
||||
font-size: 16px;
|
||||
font-size: 14px;
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
}
|
||||
@@ -1813,17 +1809,17 @@ async function createNewSession(value: string): Promise<void> {
|
||||
.tag-list-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-left: 8px;
|
||||
gap: 5px;
|
||||
margin-left: 6px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.tag-count {
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
color: #86909c;
|
||||
font-weight: 500;
|
||||
padding: 2px 6px;
|
||||
border-radius: 10px;
|
||||
padding: 2px 5px;
|
||||
border-radius: 8px;
|
||||
background: #f7f9fc;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
@@ -1963,8 +1959,8 @@ async function createNewSession(value: string): Promise<void> {
|
||||
}
|
||||
|
||||
.tag-more-btn {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@@ -1983,9 +1979,9 @@ async function createNewSession(value: string): Promise<void> {
|
||||
|
||||
.tag-empty-state {
|
||||
text-align: center;
|
||||
padding: 12px 8px;
|
||||
padding: 10px 6px;
|
||||
color: #a1a7b3;
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2032,9 +2028,12 @@ async function createNewSession(value: string): Promise<void> {
|
||||
|
||||
.tag-content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
padding: 16px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.doc-card-area {
|
||||
@@ -2053,6 +2052,7 @@ async function createNewSession(value: string): Promise<void> {
|
||||
|
||||
.doc-search-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.doc-type-select {
|
||||
@@ -2060,6 +2060,19 @@ async function createNewSession(value: string): Promise<void> {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.doc-filter-actions {
|
||||
flex-shrink: 0;
|
||||
:deep(.content-bar-icon-btn) {
|
||||
color: #86909c;
|
||||
background: transparent;
|
||||
border: none;
|
||||
&:hover {
|
||||
color: #4e5969;
|
||||
background: #f2f3f5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.t-input) {
|
||||
font-size: 13px;
|
||||
background-color: #f7f9fc;
|
||||
@@ -2105,16 +2118,14 @@ async function createNewSession(value: string): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
// Header 样式
|
||||
// Header 样式(无底部分割线,留更多空间给下方内容区)
|
||||
.document-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: 16px;
|
||||
padding: 0 0 16px;
|
||||
gap: 12px;
|
||||
flex-shrink: 0;
|
||||
border-bottom: 1px solid #e7ebf0;
|
||||
|
||||
.document-header-title {
|
||||
display: flex;
|
||||
@@ -2122,34 +2133,6 @@ async function createNewSession(value: string): Promise<void> {
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.document-header-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-shrink: 0;
|
||||
|
||||
.doc-action-btn {
|
||||
background: linear-gradient(135deg, #07c05f 0%, #00a67e 100%);
|
||||
border: none;
|
||||
color: #fff;
|
||||
|
||||
&:hover {
|
||||
background: linear-gradient(135deg, #05a04f 0%, #008a6a 100%);
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.dropdown-action-btn) {
|
||||
.t-button__text {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.dropdown-arrow {
|
||||
margin-left: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.document-title-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -2157,6 +2140,33 @@ async function createNewSession(value: string): Promise<void> {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.kb-access-meta {
|
||||
margin-left: auto;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.kb-access-meta-inner {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 12px;
|
||||
color: #86909c;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.kb-access-role-tag {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.kb-access-meta-sep {
|
||||
color: #c9ced6;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.kb-access-meta-text {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.document-breadcrumb {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -2235,61 +2245,6 @@ async function createNewSession(value: string): Promise<void> {
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.kb-access-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px 12px;
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
color: #86909c;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.kb-access-label {
|
||||
color: #4e5969;
|
||||
}
|
||||
|
||||
.kb-access-role {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.kb-access-permission-tip {
|
||||
cursor: help;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.kb-access-permission-tip:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.kb-access-sep {
|
||||
color: #c9ced6;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.kb-access-source,
|
||||
.kb-access-updated {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
color: #86909c;
|
||||
}
|
||||
|
||||
.kb-access-item-icon {
|
||||
font-size: 14px;
|
||||
color: #86909c;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.kb-access-org-icon {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
flex-shrink: 0;
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2378,7 +2333,7 @@ async function createNewSession(value: string): Promise<void> {
|
||||
|
||||
.faq-manager-wrapper {
|
||||
flex: 1;
|
||||
padding: 24px 44px;
|
||||
padding: 24px 30px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
@@ -2425,7 +2380,7 @@ async function createNewSession(value: string): Promise<void> {
|
||||
.doc-card-list {
|
||||
box-sizing: border-box;
|
||||
display: grid;
|
||||
gap: 20px;
|
||||
gap: 12px;
|
||||
align-content: flex-start;
|
||||
width: 100%;
|
||||
}
|
||||
@@ -2546,18 +2501,18 @@ async function createNewSession(value: string): Promise<void> {
|
||||
.card-draft {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 10px 0;
|
||||
gap: 8px;
|
||||
padding: 6px 0;
|
||||
}
|
||||
|
||||
.card-draft-tip {
|
||||
color: #b05b00;
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.knowledge-card {
|
||||
border: 2px solid #fbfbfb;
|
||||
height: 174px;
|
||||
height: 132px;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
@@ -2567,26 +2522,26 @@ async function createNewSession(value: string): Promise<void> {
|
||||
cursor: pointer;
|
||||
|
||||
.card-content {
|
||||
padding: 10px 20px 23px;
|
||||
padding: 10px 14px 12px;
|
||||
}
|
||||
|
||||
.card-analyze {
|
||||
height: 66px;
|
||||
height: 50px;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.card-analyze-loading {
|
||||
display: block;
|
||||
color: #07c05f;
|
||||
font-size: 15px;
|
||||
font-size: 14px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.card-analyze-txt {
|
||||
color: #07c05f;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 12px;
|
||||
margin-left: 9px;
|
||||
font-size: 11px;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.failure {
|
||||
@@ -2596,27 +2551,27 @@ async function createNewSession(value: string): Promise<void> {
|
||||
.card-content-nav {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 10px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.card-content-title {
|
||||
width: 200px;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
height: 28px;
|
||||
line-height: 28px;
|
||||
display: inline-block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: #000000e6;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.more-wrap {
|
||||
display: flex;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: 3px;
|
||||
@@ -2628,8 +2583,8 @@ async function createNewSession(value: string): Promise<void> {
|
||||
}
|
||||
|
||||
.more {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
|
||||
.active-more {
|
||||
@@ -2639,22 +2594,22 @@ async function createNewSession(value: string): Promise<void> {
|
||||
.card-content-txt {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 3;
|
||||
line-clamp: 3;
|
||||
-webkit-line-clamp: 2;
|
||||
line-clamp: 2;
|
||||
overflow: hidden;
|
||||
color: #00000066;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
line-height: 20px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.card-bottom {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
padding: 0 20px;
|
||||
padding: 0 14px;
|
||||
box-sizing: border-box;
|
||||
height: 32px;
|
||||
height: 28px;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -2665,7 +2620,7 @@ async function createNewSession(value: string): Promise<void> {
|
||||
.card-time {
|
||||
color: #00000066;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
@@ -2744,31 +2699,31 @@ async function createNewSession(value: string): Promise<void> {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* 小屏幕平板 - 2列 */
|
||||
/* 小屏幕平板 - 3列,卡片更窄 */
|
||||
@media (min-width: 900px) {
|
||||
.doc-card-list {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
/* 中等屏幕 - 3列 */
|
||||
@media (min-width: 1250px) {
|
||||
.doc-card-list {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
/* 中等屏幕 - 3列 */
|
||||
@media (min-width: 1600px) {
|
||||
/* 中等屏幕 - 4列 */
|
||||
@media (min-width: 1250px) {
|
||||
.doc-card-list {
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
/* 大屏幕 - 4列 */
|
||||
@media (min-width: 2000px) {
|
||||
/* 宽屏 - 5列 */
|
||||
@media (min-width: 1600px) {
|
||||
.doc-card-list {
|
||||
grid-template-columns: repeat(5, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
/* 大屏幕 - 6列 */
|
||||
@media (min-width: 2000px) {
|
||||
.doc-card-list {
|
||||
grid-template-columns: repeat(6, 1fr);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,43 +1,37 @@
|
||||
<template>
|
||||
<div class="kb-list-container">
|
||||
<!-- 头部 -->
|
||||
<!-- 头部:仅标题与副标题 -->
|
||||
<div class="header">
|
||||
<div class="header-title">
|
||||
<h2>{{ $t('knowledgeBase.title') }}</h2>
|
||||
<p class="header-subtitle">{{ $t('knowledgeList.subtitle') }}</p>
|
||||
</div>
|
||||
<div class="header-actions">
|
||||
<t-button class="kb-create-btn" @click="handleCreateKnowledgeBase">
|
||||
<template #icon><t-icon name="folder-add" /></template>
|
||||
{{ $t('knowledgeList.create') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Tab 切换(下划线式,替代分隔线) -->
|
||||
<div class="kb-tabs">
|
||||
<div
|
||||
class="tab-item"
|
||||
:class="{ 'active': activeTab === 'all' }"
|
||||
@click="activeTab = 'all'"
|
||||
|
||||
<!-- 左侧菜单 + 主内容 -->
|
||||
<div class="kb-list-body">
|
||||
<ListSpaceSidebar
|
||||
v-model="spaceSelection"
|
||||
:count-all="allKnowledgeBases"
|
||||
:count-mine="kbs.length"
|
||||
:count-by-org="sharedCountByOrg"
|
||||
>
|
||||
{{ $t('knowledgeList.tabs.all') }} ({{ allKnowledgeBases }})
|
||||
</div>
|
||||
<div
|
||||
class="tab-item"
|
||||
:class="{ 'active': activeTab === 'mine' }"
|
||||
@click="activeTab = 'mine'"
|
||||
>
|
||||
{{ $t('knowledgeList.tabs.myKnowledgeBases') }} ({{ kbs.length }})
|
||||
</div>
|
||||
<div
|
||||
class="tab-item"
|
||||
:class="{ 'active': activeTab === 'shared' }"
|
||||
@click="activeTab = 'shared'"
|
||||
>
|
||||
{{ $t('knowledgeList.tabs.sharedToMe') }} ({{ sharedKbs.length }})
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #actions>
|
||||
<t-tooltip :content="$t('knowledgeList.create')" placement="top">
|
||||
<t-button
|
||||
variant="text"
|
||||
theme="default"
|
||||
class="sidebar-action-btn"
|
||||
size="small"
|
||||
:aria-label="$t('knowledgeList.create')"
|
||||
@click="handleCreateKnowledgeBase"
|
||||
>
|
||||
<template #icon><t-icon name="folder-add" size="16px" /></template>
|
||||
</t-button>
|
||||
</t-tooltip>
|
||||
</template>
|
||||
</ListSpaceSidebar>
|
||||
<div class="kb-list-main">
|
||||
<!-- 未初始化知识库提示 -->
|
||||
<div v-if="hasUninitializedKbs" class="warning-banner">
|
||||
<t-icon name="info-circle" size="16px" />
|
||||
@@ -86,8 +80,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 卡片网格 -->
|
||||
<div v-if="activeTab === 'all' && filteredKnowledgeBases.length > 0" class="kb-card-wrap">
|
||||
<!-- 卡片网格:全部 -->
|
||||
<div v-if="spaceSelection === 'all' && filteredKnowledgeBases.length > 0" class="kb-card-wrap">
|
||||
<!-- 全部:我的知识库 + 共享给我的知识库 -->
|
||||
<template v-for="kb in filteredKnowledgeBases" :key="kb.id">
|
||||
<!-- 我的知识库卡片 -->
|
||||
@@ -246,7 +240,7 @@
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div v-if="activeTab === 'mine' && kbs.length > 0" class="kb-card-wrap">
|
||||
<div v-if="spaceSelection === 'mine' && kbs.length > 0" class="kb-card-wrap">
|
||||
<!-- 我的知识库 -->
|
||||
<div
|
||||
v-for="(kb, index) in kbs"
|
||||
@@ -346,10 +340,10 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 共享给我的知识库 -->
|
||||
<div v-if="activeTab === 'shared' && sharedKbs.length > 0" class="kb-card-wrap">
|
||||
<!-- 按空间筛选:该空间下共享给我的知识库 -->
|
||||
<div v-if="spaceSelectionOrgId && sharedKbsByOrg.length > 0" class="kb-card-wrap">
|
||||
<div
|
||||
v-for="shared in sharedKbs"
|
||||
v-for="shared in sharedKbsByOrg"
|
||||
:key="'shared-' + shared.share_id"
|
||||
class="kb-card shared-kb-card"
|
||||
:class="{
|
||||
@@ -399,26 +393,36 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 全部 Tab 空状态 -->
|
||||
<div v-if="activeTab === 'all' && filteredKnowledgeBases.length === 0 && !loading" class="empty-state">
|
||||
<!-- 全部空状态 -->
|
||||
<div v-if="spaceSelection === 'all' && filteredKnowledgeBases.length === 0 && !loading" class="empty-state">
|
||||
<img class="empty-img" src="@/assets/img/upload.svg" alt="">
|
||||
<span class="empty-txt">{{ $t('knowledgeList.empty.title') }}</span>
|
||||
<span class="empty-desc">{{ $t('knowledgeList.empty.description') }}</span>
|
||||
<t-button class="kb-create-btn empty-state-btn" @click="handleCreateKnowledgeBase">
|
||||
<template #icon><t-icon name="folder-add" /></template>
|
||||
{{ $t('knowledgeList.create') }}
|
||||
</t-button>
|
||||
</div>
|
||||
|
||||
<!-- 我的知识库空状态 -->
|
||||
<div v-if="activeTab === 'mine' && kbs.length === 0 && !loading" class="empty-state">
|
||||
<div v-if="spaceSelection === 'mine' && kbs.length === 0 && !loading" class="empty-state">
|
||||
<img class="empty-img" src="@/assets/img/upload.svg" alt="">
|
||||
<span class="empty-txt">{{ $t('knowledgeList.empty.title') }}</span>
|
||||
<span class="empty-desc">{{ $t('knowledgeList.empty.description') }}</span>
|
||||
<t-button class="kb-create-btn empty-state-btn" @click="handleCreateKnowledgeBase">
|
||||
<template #icon><t-icon name="folder-add" /></template>
|
||||
{{ $t('knowledgeList.create') }}
|
||||
</t-button>
|
||||
</div>
|
||||
|
||||
<!-- 共享知识库空状态 -->
|
||||
<div v-if="activeTab === 'shared' && sharedKbs.length === 0 && !loading" class="empty-state">
|
||||
<!-- 空间下共享知识库空状态 -->
|
||||
<div v-if="spaceSelectionOrgId && sharedKbsByOrg.length === 0 && !loading" class="empty-state">
|
||||
<img class="empty-img" src="@/assets/img/upload.svg" alt="">
|
||||
<span class="empty-txt">{{ $t('knowledgeList.empty.sharedTitle') || '暂无共享知识库' }}</span>
|
||||
<span class="empty-desc">{{ $t('knowledgeList.empty.sharedDescription') || '您可以加入组织或请求他人共享知识库给您' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 删除确认对话框 -->
|
||||
<t-dialog
|
||||
@@ -521,6 +525,7 @@ import { useOrganizationStore } from '@/stores/organization'
|
||||
import type { SharedKnowledgeBase } from '@/api/organization'
|
||||
import KnowledgeBaseEditorModal from './KnowledgeBaseEditorModal.vue'
|
||||
import ShareKnowledgeBaseDialog from '@/components/ShareKnowledgeBaseDialog.vue'
|
||||
import ListSpaceSidebar from '@/components/ListSpaceSidebar.vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const router = useRouter()
|
||||
@@ -529,8 +534,8 @@ const uiStore = useUIStore()
|
||||
const orgStore = useOrganizationStore()
|
||||
const { t } = useI18n()
|
||||
|
||||
// Tab 状态
|
||||
const activeTab = ref<'all' | 'mine' | 'shared'>('all')
|
||||
// 左侧空间选择:全部 / 我的 / 空间 ID
|
||||
const spaceSelection = ref<'all' | 'mine' | string>('all')
|
||||
|
||||
interface KB {
|
||||
id: string;
|
||||
@@ -575,17 +580,42 @@ const sharedKbs = computed<SharedKnowledgeBase[]>(() => orgStore.sharedKnowledge
|
||||
// All knowledge bases (mine + shared to me)
|
||||
const allKnowledgeBases = computed(() => kbs.value.length + sharedKbs.value.length)
|
||||
|
||||
// Filtered knowledge bases based on active tab
|
||||
// 当前选中的是空间 ID(非全部、非我的)
|
||||
const spaceSelectionOrgId = computed(() => {
|
||||
const s = spaceSelection.value
|
||||
return s !== 'all' && s !== 'mine' && !!s
|
||||
})
|
||||
|
||||
// 当前空间下共享给我的知识库
|
||||
const sharedKbsByOrg = computed(() => {
|
||||
const orgId = spaceSelection.value
|
||||
if (orgId === 'all' || orgId === 'mine') return []
|
||||
return sharedKbs.value.filter(s => s.organization_id === orgId)
|
||||
})
|
||||
|
||||
// 各空间下的共享知识库数量(用于侧栏展示)
|
||||
const sharedCountByOrg = computed<Record<string, number>>(() => {
|
||||
const map: Record<string, number> = {}
|
||||
sharedKbs.value.forEach(s => {
|
||||
const id = s.organization_id
|
||||
if (!id) return
|
||||
map[id] = (map[id] || 0) + 1
|
||||
})
|
||||
return map
|
||||
})
|
||||
|
||||
// Filtered knowledge bases: 全部 = 我的 + 全部共享;我的 = 仅我的
|
||||
const filteredKnowledgeBases = computed(() => {
|
||||
if (activeTab.value === 'mine') return []
|
||||
if (activeTab.value === 'shared') return []
|
||||
// activeTab === 'all'
|
||||
if (spaceSelection.value === 'mine') {
|
||||
return kbs.value.map(kb => ({ ...kb, isMine: true as const }))
|
||||
}
|
||||
if (spaceSelection.value !== 'all') {
|
||||
return []
|
||||
}
|
||||
const result: Array<(KB & { isMine: true }) | (SharedKnowledgeBase['knowledge_base'] & { isMine: false; permission: string; shared_at: string; share_id: string } & any)> = []
|
||||
// Add my knowledge bases
|
||||
kbs.value.forEach(kb => {
|
||||
result.push({ ...kb, isMine: true as const })
|
||||
})
|
||||
// Add shared knowledge bases (skip entries where knowledge_base is null, e.g. deleted KB)
|
||||
sharedKbs.value.forEach(shared => {
|
||||
const kb = shared.knowledge_base
|
||||
if (!kb) return
|
||||
@@ -1000,13 +1030,14 @@ const handleUploadFinishedEvent = (event: Event) => {
|
||||
|
||||
<style scoped lang="less">
|
||||
.kb-list-container {
|
||||
padding: 24px 44px;
|
||||
// background: #fff;
|
||||
padding: 24px 10px;
|
||||
margin: 0 20px;
|
||||
height: calc(100vh);
|
||||
overflow-y: auto;
|
||||
box-sizing: border-box;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.header {
|
||||
@@ -1030,23 +1061,36 @@ const handleUploadFinishedEvent = (event: Event) => {
|
||||
line-height: 32px;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.kb-create-btn {
|
||||
background: linear-gradient(135deg, #07c05f 0%, #00a67e 100%);
|
||||
border: none;
|
||||
color: #fff;
|
||||
.kb-create-btn {
|
||||
background: linear-gradient(135deg, #07c05f 0%, #00a67e 100%);
|
||||
border: none;
|
||||
color: #fff;
|
||||
|
||||
&:hover {
|
||||
background: linear-gradient(135deg, #05a04f 0%, #008a6a 100%);
|
||||
}
|
||||
}
|
||||
&:hover {
|
||||
background: linear-gradient(135deg, #05a04f 0%, #008a6a 100%);
|
||||
}
|
||||
}
|
||||
|
||||
.kb-list-body {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
background: #fff;
|
||||
border: 1px solid #e7ebf0;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.kb-list-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.header-subtitle {
|
||||
margin: 0;
|
||||
color: #00000099;
|
||||
@@ -1056,7 +1100,7 @@ const handleUploadFinishedEvent = (event: Event) => {
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
// Tab 切换样式(下划线式,简洁清晰)
|
||||
// Tab 切换样式(已由左侧菜单替代,保留以备兼容)
|
||||
.kb-tabs {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -1326,13 +1370,13 @@ const handleUploadFinishedEvent = (event: Event) => {
|
||||
|
||||
.kb-card-wrap {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
gap: 12px;
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.kb-card {
|
||||
border: 1px solid #f0f0f0;
|
||||
border-radius: 12px;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
|
||||
@@ -1340,10 +1384,10 @@ const handleUploadFinishedEvent = (event: Event) => {
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
transition: all 0.25s ease;
|
||||
padding: 16px 18px;
|
||||
padding: 12px 14px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 160px;
|
||||
height: 132px;
|
||||
|
||||
&:hover {
|
||||
border-color: #07c05f;
|
||||
@@ -1370,10 +1414,10 @@ const handleUploadFinishedEvent = (event: Event) => {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
background: linear-gradient(135deg, rgba(7, 192, 95, 0.08) 0%, transparent 100%);
|
||||
border-radius: 0 12px 0 100%;
|
||||
border-radius: 0 10px 0 100%;
|
||||
pointer-events: none;
|
||||
z-index: 0;
|
||||
}
|
||||
@@ -1396,10 +1440,10 @@ const handleUploadFinishedEvent = (event: Event) => {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
background: linear-gradient(135deg, rgba(0, 82, 217, 0.08) 0%, transparent 100%);
|
||||
border-radius: 0 12px 0 100%;
|
||||
border-radius: 0 10px 0 100%;
|
||||
pointer-events: none;
|
||||
z-index: 0;
|
||||
}
|
||||
@@ -1418,11 +1462,11 @@ const handleUploadFinishedEvent = (event: Event) => {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 10px;
|
||||
margin-bottom: 8px;
|
||||
|
||||
.card-title {
|
||||
flex: 1;
|
||||
font-size: 16px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #1a1a1a;
|
||||
white-space: nowrap;
|
||||
@@ -1430,13 +1474,13 @@ const handleUploadFinishedEvent = (event: Event) => {
|
||||
text-overflow: ellipsis;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.card-more-btn {
|
||||
flex-shrink: 0;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@@ -1459,9 +1503,9 @@ const handleUploadFinishedEvent = (event: Event) => {
|
||||
.card-title {
|
||||
color: #1a1a1a;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 15px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
line-height: 22px;
|
||||
line-height: 20px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
@@ -1471,8 +1515,8 @@ const handleUploadFinishedEvent = (event: Event) => {
|
||||
|
||||
.more-wrap {
|
||||
display: flex;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: 6px;
|
||||
@@ -1496,18 +1540,18 @@ const handleUploadFinishedEvent = (event: Event) => {
|
||||
}
|
||||
|
||||
.more-icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.card-content {
|
||||
flex: 1;
|
||||
margin-bottom: 12px;
|
||||
margin-bottom: 8px;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.card-description {
|
||||
@@ -1518,9 +1562,9 @@ const handleUploadFinishedEvent = (event: Event) => {
|
||||
overflow: hidden;
|
||||
color: #666;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 13px;
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
line-height: 20px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.card-bottom {
|
||||
@@ -1528,7 +1572,7 @@ const handleUploadFinishedEvent = (event: Event) => {
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: auto;
|
||||
padding-top: 12px;
|
||||
padding-top: 8px;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
@@ -1562,9 +1606,9 @@ const handleUploadFinishedEvent = (event: Event) => {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
border-radius: 6px;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
border-radius: 5px;
|
||||
cursor: default;
|
||||
transition: background 0.2s ease;
|
||||
|
||||
@@ -1572,15 +1616,15 @@ const handleUploadFinishedEvent = (event: Event) => {
|
||||
background: rgba(7, 192, 95, 0.08);
|
||||
color: #059669;
|
||||
width: auto;
|
||||
padding: 0 8px;
|
||||
gap: 4px;
|
||||
padding: 0 6px;
|
||||
gap: 3px;
|
||||
|
||||
&:hover {
|
||||
background: rgba(7, 192, 95, 0.12);
|
||||
}
|
||||
|
||||
.badge-count {
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
@@ -1593,15 +1637,15 @@ const handleUploadFinishedEvent = (event: Event) => {
|
||||
background: rgba(0, 82, 217, 0.08);
|
||||
color: #0052d9;
|
||||
width: auto;
|
||||
padding: 0 8px;
|
||||
gap: 4px;
|
||||
padding: 0 6px;
|
||||
gap: 3px;
|
||||
|
||||
&:hover {
|
||||
background: rgba(0, 82, 217, 0.12);
|
||||
}
|
||||
|
||||
.badge-count {
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
@@ -1744,6 +1788,11 @@ const handleUploadFinishedEvent = (event: Event) => {
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
line-height: 22px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.empty-state-btn {
|
||||
margin-top: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,27 @@
|
||||
<t-icon name="chevron-right" class="breadcrumb-separator" />
|
||||
<span class="breadcrumb-current">{{ $t('knowledgeEditor.faq.title') }}</span>
|
||||
</h2>
|
||||
<!-- 身份与最后更新:紧凑单行,置于标题行右侧,悬停显示权限说明 -->
|
||||
<div v-if="kbInfo" class="faq-access-meta">
|
||||
<t-tooltip :content="accessPermissionSummary" placement="top">
|
||||
<span class="faq-access-meta-inner">
|
||||
<t-tag size="small" :theme="isOwner ? 'success' : (currentSharedKb?.permission === 'admin' ? 'primary' : currentSharedKb?.permission === 'editor' ? 'warning' : 'default')" class="faq-access-role-tag">
|
||||
{{ accessRoleLabel }}
|
||||
</t-tag>
|
||||
<template v-if="currentSharedKb">
|
||||
<span class="faq-access-meta-sep">·</span>
|
||||
<span class="faq-access-meta-text">
|
||||
{{ $t('knowledgeBase.accessInfo.fromOrg') }}「{{ currentSharedKb.org_name }}」
|
||||
{{ $t('knowledgeBase.accessInfo.sharedAt') }} {{ formatImportTime(currentSharedKb.shared_at) }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-else-if="kbLastUpdated">
|
||||
<span class="faq-access-meta-sep">·</span>
|
||||
<span class="faq-access-meta-text">{{ $t('knowledgeBase.accessInfo.lastUpdated') }} {{ kbLastUpdated }}</span>
|
||||
</template>
|
||||
</span>
|
||||
</t-tooltip>
|
||||
</div>
|
||||
<t-tooltip v-if="canManage" :content="$t('knowledgeBase.settings')" placement="top">
|
||||
<button
|
||||
type="button"
|
||||
@@ -50,49 +71,6 @@
|
||||
</t-tooltip>
|
||||
</div>
|
||||
<p class="faq-subtitle">{{ $t('knowledgeEditor.faq.subtitle') }}</p>
|
||||
<!-- 当前知识库权限与来源信息 -->
|
||||
<div v-if="kbInfo" class="faq-access-info">
|
||||
<span class="faq-access-role">
|
||||
<t-icon name="user" class="faq-access-item-icon" />
|
||||
<span class="faq-access-label">{{ $t('knowledgeBase.accessInfo.myRole') }}:</span>
|
||||
<t-tag size="small" :theme="isOwner ? 'success' : (currentSharedKb?.permission === 'admin' ? 'primary' : currentSharedKb?.permission === 'editor' ? 'warning' : 'default')">
|
||||
{{ accessRoleLabel }}
|
||||
</t-tag>
|
||||
<t-tooltip :content="accessPermissionSummary" placement="top">
|
||||
<t-icon name="help-circle" class="faq-access-item-icon faq-access-permission-tip" />
|
||||
</t-tooltip>
|
||||
</span>
|
||||
<template v-if="currentSharedKb">
|
||||
<span class="faq-access-sep">·</span>
|
||||
<span class="faq-access-source">
|
||||
<img src="@/assets/img/organization-green.svg" class="faq-access-org-icon" alt="" aria-hidden="true" />
|
||||
{{ $t('knowledgeBase.accessInfo.fromOrg') }}「{{ currentSharedKb.org_name }}」
|
||||
<t-icon name="time" class="faq-access-item-icon" />
|
||||
{{ $t('knowledgeBase.accessInfo.sharedAt') }} {{ formatImportTime(currentSharedKb.shared_at) }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-else-if="kbLastUpdated">
|
||||
<span class="faq-access-sep">·</span>
|
||||
<span class="faq-access-updated">
|
||||
<t-icon name="time" class="faq-access-item-icon" />
|
||||
{{ $t('knowledgeBase.accessInfo.lastUpdated') }} {{ kbLastUpdated }}
|
||||
</span>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<div class="faq-header-actions">
|
||||
<t-dropdown
|
||||
:options="faqActionOptions"
|
||||
trigger="click"
|
||||
placement="bottom-right"
|
||||
@click="handleFaqAction"
|
||||
>
|
||||
<t-button class="faq-action-btn dropdown-action-btn">
|
||||
<template #icon><t-icon name="help-circle" /></template>
|
||||
<span>{{ $t('knowledgeEditor.faq.manageFaq') }}</span>
|
||||
<t-icon name="chevron-down" size="14px" class="dropdown-arrow" />
|
||||
</t-button>
|
||||
</t-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -366,12 +344,13 @@
|
||||
</aside>
|
||||
|
||||
<div class="faq-card-area">
|
||||
<!-- 搜索栏 -->
|
||||
<!-- 搜索栏与管理 FAQ -->
|
||||
<div class="faq-search-bar">
|
||||
<t-input
|
||||
v-model.trim="entrySearchKeyword"
|
||||
:placeholder="$t('knowledgeEditor.faq.searchPlaceholder')"
|
||||
clearable
|
||||
class="faq-search-input"
|
||||
@clear="loadEntries()"
|
||||
@keydown.enter="loadEntries()"
|
||||
>
|
||||
@@ -379,6 +358,35 @@
|
||||
<t-icon name="search" size="16px" />
|
||||
</template>
|
||||
</t-input>
|
||||
<div class="faq-search-actions">
|
||||
<!-- 新建:新建条目 / 导入 -->
|
||||
<template v-if="faqCreateOptions.length">
|
||||
<t-tooltip :content="$t('knowledgeEditor.faq.createGroup')" placement="top">
|
||||
<t-dropdown
|
||||
:options="faqCreateOptions"
|
||||
trigger="click"
|
||||
placement="bottom-right"
|
||||
@click="handleFaqAction"
|
||||
>
|
||||
<t-button variant="text" theme="default" class="content-bar-icon-btn" size="small">
|
||||
<template #icon><t-icon name="add" size="16px" /></template>
|
||||
</t-button>
|
||||
</t-dropdown>
|
||||
</t-tooltip>
|
||||
</template>
|
||||
<!-- 导出 -->
|
||||
<t-tooltip :content="$t('knowledgeEditor.faqExport.exportButton')" placement="top">
|
||||
<t-button variant="text" theme="default" class="content-bar-icon-btn" size="small" @click="handleFaqAction({ value: 'export' })">
|
||||
<template #icon><t-icon name="download" size="16px" /></template>
|
||||
</t-button>
|
||||
</t-tooltip>
|
||||
<!-- 检索 -->
|
||||
<t-tooltip :content="$t('knowledgeEditor.faq.searchTest')" placement="top">
|
||||
<t-button variant="text" theme="default" class="content-bar-icon-btn" size="small" @click="handleFaqAction({ value: 'search' })">
|
||||
<template #icon><t-icon name="search" size="16px" /></template>
|
||||
</t-button>
|
||||
</t-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Card List Container with Scroll -->
|
||||
<div ref="scrollContainer" class="faq-scroll-container" @scroll="handleScroll">
|
||||
@@ -1321,25 +1329,13 @@ const kbLastUpdated = computed(() => {
|
||||
return formatImportTime(raw)
|
||||
})
|
||||
|
||||
// FAQ 操作下拉选项
|
||||
const faqActionOptions = computed(() => {
|
||||
const options = []
|
||||
|
||||
// 编辑权限相关操作
|
||||
if (canEdit.value) {
|
||||
options.push(
|
||||
{ content: t('knowledgeEditor.faq.editorCreate'), value: 'create', prefixIcon: () => h(TIcon, { name: 'add', size: '16px' }) },
|
||||
{ content: t('knowledgeEditor.faqImport.importButton'), value: 'import', prefixIcon: () => h(TIcon, { name: 'upload', size: '16px' }) },
|
||||
)
|
||||
}
|
||||
|
||||
// 通用操作
|
||||
options.push(
|
||||
{ content: t('knowledgeEditor.faq.searchTest'), value: 'search', prefixIcon: () => h(TIcon, { name: 'search', size: '16px' }) },
|
||||
{ content: t('knowledgeEditor.faqExport.exportButton'), value: 'export', prefixIcon: () => h(TIcon, { name: 'download', size: '16px' }) },
|
||||
)
|
||||
|
||||
return options
|
||||
// FAQ 操作:新建组(新建条目 + 导入)
|
||||
const faqCreateOptions = computed(() => {
|
||||
if (!canEdit.value) return []
|
||||
return [
|
||||
{ content: t('knowledgeEditor.faq.editorCreate'), value: 'create', prefixIcon: () => h(TIcon, { name: 'add', size: '16px' }) },
|
||||
{ content: t('knowledgeEditor.faqImport.importButton'), value: 'import', prefixIcon: () => h(TIcon, { name: 'upload', size: '16px' }) },
|
||||
]
|
||||
})
|
||||
|
||||
// 处理 FAQ 操作
|
||||
@@ -3329,19 +3325,22 @@ watch(() => entries.value.map(e => ({
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
// 与列表页一致:整体一块白底圆角区,左侧标签栏为内部分区
|
||||
.faq-main {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
background: #fff;
|
||||
border: 1px solid #e7ebf0;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.faq-tag-panel {
|
||||
width: 230px;
|
||||
background: #fff;
|
||||
border: 1px solid #e7ebf0;
|
||||
border-radius: 12px;
|
||||
padding: 16px;
|
||||
width: 176px;
|
||||
background: #fafbfc;
|
||||
border-right: 1px solid #e7ebf0;
|
||||
padding: 12px;
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -3363,35 +3362,36 @@ watch(() => entries.value.map(e => ({
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 12px;
|
||||
margin-bottom: 8px;
|
||||
color: #1d2129;
|
||||
|
||||
.sidebar-title {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 4px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
|
||||
.sidebar-count {
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
color: #86909c;
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
color: #c9ced6;
|
||||
|
||||
.create-tag-btn {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
padding: 0;
|
||||
border-radius: 6px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 18px;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #00a870;
|
||||
line-height: 1;
|
||||
@@ -3408,8 +3408,8 @@ watch(() => entries.value.map(e => ({
|
||||
}
|
||||
|
||||
.sidebar-action-icon {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border-radius: 6px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -3426,26 +3426,34 @@ watch(() => entries.value.map(e => ({
|
||||
}
|
||||
|
||||
.tag-search-bar {
|
||||
margin-bottom: 12px;
|
||||
margin-bottom: 8px;
|
||||
|
||||
:deep(.t-input) {
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
background-color: #f7f9fc;
|
||||
border-color: #e5e9f2;
|
||||
}
|
||||
|
||||
:deep(.t-input__inner) {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
:deep(.t-input__prefix-icon) {
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.faq-tag-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
gap: 4px;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
|
||||
.tag-loading-more {
|
||||
padding: 12px 0;
|
||||
padding: 8px 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
@@ -3455,24 +3463,24 @@ watch(() => entries.value.map(e => ({
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 8px 10px;
|
||||
padding: 6px 8px;
|
||||
border-radius: 6px;
|
||||
color: #4e5969;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
font-size: 13px;
|
||||
font-size: 12px;
|
||||
|
||||
.faq-tag-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
|
||||
.t-icon {
|
||||
flex-shrink: 0;
|
||||
color: #86909c;
|
||||
font-size: 16px;
|
||||
font-size: 14px;
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
}
|
||||
@@ -3489,18 +3497,18 @@ watch(() => entries.value.map(e => ({
|
||||
.faq-tag-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-left: 8px;
|
||||
gap: 5px;
|
||||
margin-left: 6px;
|
||||
min-width: 0;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.faq-tag-count {
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
color: #86909c;
|
||||
font-weight: 500;
|
||||
padding: 2px 6px;
|
||||
border-radius: 10px;
|
||||
padding: 2px 5px;
|
||||
border-radius: 8px;
|
||||
background: #f7f9fc;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
@@ -3639,8 +3647,8 @@ watch(() => entries.value.map(e => ({
|
||||
}
|
||||
|
||||
.tag-more-btn {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@@ -3663,17 +3671,17 @@ watch(() => entries.value.map(e => ({
|
||||
}
|
||||
|
||||
.tag-more-placeholder {
|
||||
width: 24px; // Same width as tag-more-btn
|
||||
height: 24px;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.tag-empty-state {
|
||||
text-align: center;
|
||||
padding: 12px 8px;
|
||||
padding: 10px 6px;
|
||||
color: #a1a7b3;
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3684,11 +3692,37 @@ watch(() => entries.value.map(e => ({
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 16px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.faq-search-bar {
|
||||
padding: 0px 0px 10px 0px;
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
|
||||
.faq-search-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.faq-search-actions {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
:deep(.content-bar-icon-btn) {
|
||||
color: #86909c;
|
||||
background: transparent;
|
||||
border: none;
|
||||
&:hover {
|
||||
color: #4e5969;
|
||||
background: #f2f3f5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.t-input) {
|
||||
font-size: 13px;
|
||||
@@ -3703,6 +3737,10 @@ watch(() => entries.value.map(e => ({
|
||||
border-color: #00a870;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.t-input__prefix-icon) {
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.tag-menu) {
|
||||
@@ -3747,13 +3785,11 @@ watch(() => entries.value.map(e => ({
|
||||
|
||||
.faq-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: 16px;
|
||||
padding: 0 0 16px;
|
||||
margin-bottom: 20px;
|
||||
border-bottom: 1px solid #e7ebf0;
|
||||
gap: 12px;
|
||||
margin-bottom: 12px;
|
||||
flex-shrink: 0;
|
||||
|
||||
.faq-header-title {
|
||||
@@ -3769,6 +3805,32 @@ watch(() => entries.value.map(e => ({
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.faq-access-meta {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.faq-access-meta-inner {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 12px;
|
||||
color: #86909c;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.faq-access-role-tag {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.faq-access-meta-sep {
|
||||
color: #c9ced6;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.faq-access-meta-text {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.faq-breadcrumb {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -3846,91 +3908,8 @@ watch(() => entries.value.map(e => ({
|
||||
font-weight: 400;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.faq-access-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px 12px;
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
color: #86909c;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.faq-access-label {
|
||||
color: #4e5969;
|
||||
}
|
||||
|
||||
.faq-access-role {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.faq-access-permission-tip {
|
||||
cursor: help;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.faq-access-permission-tip:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.faq-access-item-icon {
|
||||
font-size: 14px;
|
||||
color: #86909c;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.faq-access-sep {
|
||||
color: #c9ced6;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.faq-access-source,
|
||||
.faq-access-updated {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
color: #86909c;
|
||||
}
|
||||
|
||||
.faq-access-org-icon {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
flex-shrink: 0;
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
|
||||
.faq-header-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-shrink: 0;
|
||||
|
||||
.faq-action-btn {
|
||||
background: linear-gradient(135deg, #26a69a 0%, #00897b 100%);
|
||||
border: none;
|
||||
color: #fff;
|
||||
|
||||
&:hover {
|
||||
background: linear-gradient(135deg, #00897b 0%, #00796b 100%);
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.dropdown-action-btn) {
|
||||
.t-button__text {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.dropdown-arrow {
|
||||
margin-left: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 导入进度条样式(显示在列表页面顶部)
|
||||
.faq-import-progress-bar {
|
||||
@@ -4237,21 +4216,20 @@ watch(() => entries.value.map(e => ({
|
||||
|
||||
.faq-card {
|
||||
border: 1px solid #E7E7E7;
|
||||
border-radius: 12px;
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
padding: 12px;
|
||||
padding: 10px;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
|
||||
box-sizing: border-box;
|
||||
height: fit-content; // 高度根据内容自适应
|
||||
// 注意:top 和 left 的 transition 由 JS 动态控制,避免与布局动画冲突
|
||||
height: fit-content;
|
||||
|
||||
&:hover {
|
||||
border-color: #07C05F;
|
||||
@@ -4268,8 +4246,8 @@ watch(() => entries.value.map(e => ({
|
||||
.faq-card-header {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
padding-bottom: 12px;
|
||||
gap: 8px;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 1px solid #F3F4F6;
|
||||
position: relative;
|
||||
}
|
||||
@@ -4277,13 +4255,13 @@ watch(() => entries.value.map(e => ({
|
||||
.faq-header-top {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.faq-card-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
margin-left: auto;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
@@ -4292,28 +4270,28 @@ watch(() => entries.value.map(e => ({
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding-top: 6px;
|
||||
gap: 8px;
|
||||
padding-top: 5px;
|
||||
border-top: 1px dashed #F3F4F6;
|
||||
}
|
||||
|
||||
.faq-meta-item {
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: 6px;
|
||||
padding: 4px 10px;
|
||||
gap: 5px;
|
||||
padding: 3px 8px;
|
||||
border-radius: 999px;
|
||||
background: #F9FAFB;
|
||||
border: 1px solid #EEF2F7;
|
||||
|
||||
.meta-label {
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
color: #6B7280;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.meta-value {
|
||||
font-size: 13px;
|
||||
font-size: 12px;
|
||||
color: #111827;
|
||||
font-weight: 600;
|
||||
}
|
||||
@@ -4323,9 +4301,9 @@ watch(() => entries.value.map(e => ({
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
padding: 10px 16px;
|
||||
margin: 0 -16px -12px;
|
||||
gap: 6px;
|
||||
padding: 8px 12px;
|
||||
margin: 0 -10px -10px;
|
||||
background: rgba(48, 50, 54, 0.02);
|
||||
border-top: 1px solid #f5f5f5;
|
||||
flex-wrap: nowrap;
|
||||
@@ -4334,7 +4312,7 @@ watch(() => entries.value.map(e => ({
|
||||
.faq-card-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
gap: 5px;
|
||||
flex-shrink: 0;
|
||||
margin-left: auto;
|
||||
}
|
||||
@@ -4342,17 +4320,17 @@ watch(() => entries.value.map(e => ({
|
||||
.status-item {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 4px 10px;
|
||||
gap: 5px;
|
||||
padding: 3px 8px;
|
||||
border-radius: 999px;
|
||||
background: #F9FAFB;
|
||||
border: 1px solid #EEF2F7;
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
color: #4B5563;
|
||||
font-family: "PingFang SC";
|
||||
|
||||
.status-icon {
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
color: #9CA3AF;
|
||||
|
||||
&.warning {
|
||||
@@ -4409,14 +4387,14 @@ watch(() => entries.value.map(e => ({
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
max-width: 140px;
|
||||
height: 22px;
|
||||
max-width: 120px;
|
||||
height: 20px;
|
||||
border-radius: 4px;
|
||||
border-color: #e5e7eb;
|
||||
color: #00000066;
|
||||
padding: 0 8px;
|
||||
padding: 0 6px;
|
||||
background: #3032360f;
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
font-weight: 400;
|
||||
font-family: "PingFang SC";
|
||||
transition: all 0.2s ease;
|
||||
@@ -4435,11 +4413,11 @@ watch(() => entries.value.map(e => ({
|
||||
cursor: pointer;
|
||||
|
||||
.tag-text {
|
||||
max-width: 120px;
|
||||
max-width: 100px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
font-weight: 400;
|
||||
color: #00000066;
|
||||
}
|
||||
@@ -4531,36 +4509,36 @@ watch(() => entries.value.map(e => ({
|
||||
.faq-card-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
contain: layout; // 优化渲染性能
|
||||
contain: layout;
|
||||
}
|
||||
|
||||
.faq-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
|
||||
.faq-section-label {
|
||||
color: #6B7280;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-bottom: 2px;
|
||||
gap: 5px;
|
||||
margin-bottom: 1px;
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
width: 3px;
|
||||
height: 12px;
|
||||
height: 10px;
|
||||
background: #07C05F;
|
||||
border-radius: 2px;
|
||||
flex-shrink: 0;
|
||||
@@ -4583,7 +4561,7 @@ watch(() => entries.value.map(e => ({
|
||||
}
|
||||
|
||||
.collapse-icon {
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
color: #9CA3AF;
|
||||
flex-shrink: 0;
|
||||
margin-left: auto; // 让箭头靠右对齐
|
||||
@@ -4612,8 +4590,8 @@ watch(() => entries.value.map(e => ({
|
||||
.faq-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
min-height: 20px;
|
||||
gap: 5px;
|
||||
min-height: 18px;
|
||||
min-width: 0;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
@@ -4633,11 +4611,11 @@ watch(() => entries.value.map(e => ({
|
||||
}
|
||||
|
||||
.question-tag {
|
||||
font-size: 12px;
|
||||
padding: 4px 10px;
|
||||
font-size: 11px;
|
||||
padding: 3px 8px;
|
||||
max-width: 100%;
|
||||
min-width: 0;
|
||||
border-radius: 6px;
|
||||
border-radius: 5px;
|
||||
font-family: "PingFang SC";
|
||||
flex: 0 1 auto;
|
||||
|
||||
|
||||
@@ -1,47 +1,50 @@
|
||||
<template>
|
||||
<div class="org-list-container">
|
||||
<!-- 头部 -->
|
||||
<!-- 头部:仅标题与副标题 -->
|
||||
<div class="header">
|
||||
<div class="header-title">
|
||||
<h2>{{ $t('organization.title') }}</h2>
|
||||
<p class="header-subtitle">{{ $t('organization.subtitle') }}</p>
|
||||
</div>
|
||||
<div class="header-actions">
|
||||
<t-button theme="default" variant="outline" class="org-join-btn" @click="handleJoinOrganization">
|
||||
<template #icon><t-icon name="enter" /></template>
|
||||
{{ $t('organization.joinOrg') }}
|
||||
</t-button>
|
||||
<t-button class="org-create-btn" @click="handleCreateOrganization">
|
||||
<template #icon><img src="@/assets/img/organization.svg" class="org-create-icon" alt="" aria-hidden="true" /></template>
|
||||
{{ $t('organization.createOrg') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Tab 切换(下划线式,替代分隔线) -->
|
||||
<div class="org-tabs">
|
||||
<div
|
||||
class="tab-item"
|
||||
:class="{ 'active': activeTab === 'all' }"
|
||||
@click="activeTab = 'all'"
|
||||
>
|
||||
{{ $t('organization.all') }} ({{ organizations.length }})
|
||||
</div>
|
||||
<div
|
||||
class="tab-item"
|
||||
:class="{ 'active': activeTab === 'created' }"
|
||||
@click="activeTab = 'created'"
|
||||
>
|
||||
{{ $t('organization.createdByMe') }} ({{ organizations.filter(o => o.is_owner).length }})
|
||||
</div>
|
||||
<div
|
||||
class="tab-item"
|
||||
:class="{ 'active': activeTab === 'joined' }"
|
||||
@click="activeTab = 'joined'"
|
||||
>
|
||||
{{ $t('organization.joinedByMe') }} ({{ organizations.filter(o => !o.is_owner).length }})
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 左侧筛选 + 主内容 -->
|
||||
<div class="org-list-body">
|
||||
<ListSpaceSidebar
|
||||
mode="organization"
|
||||
v-model="spaceSelection"
|
||||
:count-all="organizations.length"
|
||||
:count-created="createdCount"
|
||||
:count-joined="joinedCount"
|
||||
>
|
||||
<template #actions>
|
||||
<t-tooltip :content="$t('organization.joinOrg')" placement="top">
|
||||
<t-button
|
||||
variant="text"
|
||||
theme="default"
|
||||
class="sidebar-action-btn"
|
||||
size="small"
|
||||
:aria-label="$t('organization.joinOrg')"
|
||||
@click="handleJoinOrganization"
|
||||
>
|
||||
<template #icon><t-icon name="enter" size="16px" /></template>
|
||||
</t-button>
|
||||
</t-tooltip>
|
||||
<t-tooltip :content="$t('organization.createOrg')" placement="top">
|
||||
<t-button
|
||||
variant="text"
|
||||
theme="default"
|
||||
class="sidebar-action-btn"
|
||||
size="small"
|
||||
:aria-label="$t('organization.createOrg')"
|
||||
@click="handleCreateOrganization"
|
||||
>
|
||||
<template #icon><img src="@/assets/img/organization.svg" class="org-create-icon sidebar-org-icon" alt="" aria-hidden="true" /></template>
|
||||
</t-button>
|
||||
</t-tooltip>
|
||||
</template>
|
||||
</ListSpaceSidebar>
|
||||
<div class="org-list-main">
|
||||
<!-- 卡片网格 -->
|
||||
<div v-if="filteredOrganizations.length > 0" class="org-card-wrap">
|
||||
<div
|
||||
@@ -67,14 +70,10 @@
|
||||
<div class="card-header">
|
||||
<div class="card-header-left">
|
||||
<div class="org-avatar">
|
||||
<SpaceAvatar :name="org.name" :avatar="org.avatar" />
|
||||
<SpaceAvatar :name="org.name" :avatar="org.avatar" size="small" />
|
||||
</div>
|
||||
<div class="card-title-block">
|
||||
<span class="card-title" :title="org.name">{{ org.name }}</span>
|
||||
<span class="card-relation" :class="{ 'is-owner': org.is_owner }">
|
||||
<t-icon :name="org.is_owner ? 'usergroup-add' : 'usergroup'" size="10px" />
|
||||
<span>{{ org.is_owner ? $t('organization.createdByMe') : $t('organization.joinedByMe') }}</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<t-popup
|
||||
@@ -118,49 +117,60 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 卡片底部 -->
|
||||
<!-- 卡片底部(与知识库卡片风格统一:小标签、无日期、智能体用主题色) -->
|
||||
<div class="card-bottom">
|
||||
<div class="bottom-left">
|
||||
<div class="card-stats">
|
||||
<div class="feature-badges">
|
||||
<t-tooltip :content="$t('organization.memberCount')" placement="top">
|
||||
<span class="stat-item">
|
||||
<t-icon name="user" size="12px" />
|
||||
<span>{{ org.member_count || 0 }}</span>
|
||||
</span>
|
||||
<div class="feature-badge stat-member">
|
||||
<t-icon name="user" size="14px" />
|
||||
<span class="badge-count">{{ org.member_count || 0 }}</span>
|
||||
</div>
|
||||
</t-tooltip>
|
||||
<t-tooltip :content="$t('organization.invite.knowledgeBases')" placement="top">
|
||||
<span class="stat-item">
|
||||
<t-icon name="folder" size="12px" />
|
||||
<span>{{ org.share_count ?? 0 }}</span>
|
||||
</span>
|
||||
<div class="feature-badge stat-kb">
|
||||
<t-icon name="folder" size="14px" />
|
||||
<span class="badge-count">{{ org.share_count ?? 0 }}</span>
|
||||
</div>
|
||||
</t-tooltip>
|
||||
<t-tooltip :content="$t('organization.invite.agents')" placement="top">
|
||||
<span class="stat-item stat-item-agent">
|
||||
<img src="@/assets/img/agent.svg" class="stat-agent-icon" alt="" aria-hidden="true" />
|
||||
<span>{{ org.agent_share_count ?? 0 }}</span>
|
||||
</span>
|
||||
<div class="feature-badge stat-agent">
|
||||
<img src="@/assets/img/agent-green.svg" class="stat-agent-icon" alt="" aria-hidden="true" />
|
||||
<span class="badge-count">{{ org.agent_share_count ?? 0 }}</span>
|
||||
</div>
|
||||
</t-tooltip>
|
||||
</div>
|
||||
<t-tooltip v-if="(org.pending_join_request_count ?? 0) > 0" :content="$t('organization.settings.pendingJoinRequestsBadge')" placement="top">
|
||||
<span class="pending-requests-badge">{{ org.pending_join_request_count }} {{ $t('organization.settings.pendingReview') }}</span>
|
||||
</t-tooltip>
|
||||
<t-tag v-if="org.is_owner" class="role-tag owner" size="small">
|
||||
{{ $t('organization.owner') }}
|
||||
</t-tag>
|
||||
<t-tag v-else-if="org.my_role" class="role-tag" :class="org.my_role" size="small">
|
||||
{{ $t(`organization.role.${org.my_role}`) }}
|
||||
</t-tag>
|
||||
</div>
|
||||
<span class="card-time">{{ formatDate(org.created_at) }}</span>
|
||||
<div class="bottom-right">
|
||||
<div class="relation-role-tag" :class="org.is_owner ? 'owner' : (org.my_role || '')">
|
||||
<t-icon :name="org.is_owner ? 'usergroup-add' : 'usergroup'" size="14px" />
|
||||
<span>{{ org.is_owner ? $t('organization.owner') : (org.my_role ? $t(`organization.role.${org.my_role}`) : $t('organization.joinedByMe')) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 空状态(按 Tab 显示不同文案) -->
|
||||
<!-- 空状态(按筛选显示不同文案) -->
|
||||
<div v-else-if="!loading" class="empty-state">
|
||||
<img class="empty-img" src="@/assets/img/upload.svg" alt="">
|
||||
<span class="empty-txt">{{ emptyStateTitle }}</span>
|
||||
<span class="empty-desc">{{ emptyStateDesc }}</span>
|
||||
<div class="empty-state-actions">
|
||||
<t-button theme="default" variant="outline" class="org-join-btn" @click="handleJoinOrganization">
|
||||
<template #icon><t-icon name="enter" /></template>
|
||||
{{ $t('organization.joinOrg') }}
|
||||
</t-button>
|
||||
<t-button class="org-create-btn" @click="handleCreateOrganization">
|
||||
<template #icon><img src="@/assets/img/organization.svg" class="org-create-icon" alt="" aria-hidden="true" /></template>
|
||||
{{ $t('organization.createOrg') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Organization Settings Modal (用于创建和编辑组织) -->
|
||||
@@ -566,6 +576,7 @@ import { previewOrganization, joinOrganization, submitJoinRequest, searchSearcha
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import OrganizationSettingsModal from './OrganizationSettingsModal.vue'
|
||||
import SpaceAvatar from '@/components/SpaceAvatar.vue'
|
||||
import ListSpaceSidebar from '@/components/ListSpaceSidebar.vue'
|
||||
|
||||
interface OrgWithUI extends Organization {
|
||||
showMore?: boolean
|
||||
@@ -763,28 +774,31 @@ const handleOrganizationDialogEvent = ((event: CustomEvent<{ type: 'create' | 'j
|
||||
}
|
||||
}) as EventListener
|
||||
|
||||
// Tab: 'all' | 'created' | 'joined'
|
||||
const activeTab = ref<'all' | 'created' | 'joined'>('all')
|
||||
// 左侧筛选:'all' | 'created' | 'joined'
|
||||
const spaceSelection = ref<'all' | 'created' | 'joined'>('all')
|
||||
|
||||
// Computed
|
||||
const loading = computed(() => orgStore.loading)
|
||||
const organizations = ref<OrgWithUI[]>([])
|
||||
|
||||
const createdCount = computed(() => organizations.value.filter(o => o.is_owner).length)
|
||||
const joinedCount = computed(() => organizations.value.filter(o => !o.is_owner).length)
|
||||
|
||||
const filteredOrganizations = computed(() => {
|
||||
if (activeTab.value === 'created') return organizations.value.filter(o => o.is_owner)
|
||||
if (activeTab.value === 'joined') return organizations.value.filter(o => !o.is_owner)
|
||||
if (spaceSelection.value === 'created') return organizations.value.filter(o => o.is_owner)
|
||||
if (spaceSelection.value === 'joined') return organizations.value.filter(o => !o.is_owner)
|
||||
return organizations.value
|
||||
})
|
||||
|
||||
const emptyStateTitle = computed(() => {
|
||||
if (activeTab.value === 'created') return t('organization.emptyCreated')
|
||||
if (activeTab.value === 'joined') return t('organization.emptyJoined')
|
||||
if (spaceSelection.value === 'created') return t('organization.emptyCreated')
|
||||
if (spaceSelection.value === 'joined') return t('organization.emptyJoined')
|
||||
return t('organization.empty')
|
||||
})
|
||||
|
||||
const emptyStateDesc = computed(() => {
|
||||
if (activeTab.value === 'created') return t('organization.emptyCreatedDesc')
|
||||
if (activeTab.value === 'joined') return t('organization.emptyJoinedDesc')
|
||||
if (spaceSelection.value === 'created') return t('organization.emptyCreatedDesc')
|
||||
if (spaceSelection.value === 'joined') return t('organization.emptyJoinedDesc')
|
||||
return t('organization.emptyDesc')
|
||||
})
|
||||
|
||||
@@ -798,15 +812,6 @@ watch(
|
||||
)
|
||||
|
||||
// Methods
|
||||
function formatDate(dateStr: string) {
|
||||
if (!dateStr) return ''
|
||||
const date = new Date(dateStr)
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
return `${year}-${month}-${day}`
|
||||
}
|
||||
|
||||
function getRoleTheme(role: string) {
|
||||
switch (role) {
|
||||
case 'admin': return 'primary'
|
||||
@@ -1196,18 +1201,37 @@ onUnmounted(() => {
|
||||
|
||||
<style scoped lang="less">
|
||||
.org-list-container {
|
||||
padding: 24px 44px;
|
||||
padding: 24px 10px;
|
||||
margin: 0 20px;
|
||||
height: calc(100vh);
|
||||
overflow-y: auto;
|
||||
box-sizing: border-box;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.org-list-body {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
background: #fff;
|
||||
border: 1px solid #e7ebf0;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.org-list-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 16px;
|
||||
|
||||
.header-title {
|
||||
@@ -1220,49 +1244,43 @@ onUnmounted(() => {
|
||||
margin: 0;
|
||||
color: #0f172a;
|
||||
font-family: "PingFang SC", system-ui, sans-serif;
|
||||
font-size: 26px;
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.02em;
|
||||
line-height: 32px;
|
||||
}
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
.org-join-btn {
|
||||
border-color: rgba(7, 192, 95, 0.5);
|
||||
color: #059669;
|
||||
font-weight: 500;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
.org-join-btn {
|
||||
border-color: rgba(7, 192, 95, 0.5);
|
||||
color: #059669;
|
||||
font-weight: 500;
|
||||
transition: all 0.2s ease;
|
||||
&:hover {
|
||||
background: linear-gradient(135deg, rgba(7, 192, 95, 0.06) 0%, rgba(0, 166, 126, 0.06) 100%);
|
||||
border-color: #07c05f;
|
||||
color: #047857;
|
||||
}
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: linear-gradient(135deg, rgba(7, 192, 95, 0.06) 0%, rgba(0, 166, 126, 0.06) 100%);
|
||||
border-color: #07c05f;
|
||||
color: #047857;
|
||||
}
|
||||
}
|
||||
.org-create-btn {
|
||||
background: linear-gradient(135deg, #07c05f 0%, #059669 50%, #047857 100%);
|
||||
border: none;
|
||||
color: #fff;
|
||||
font-weight: 500;
|
||||
box-shadow: 0 2px 8px rgba(7, 192, 95, 0.25);
|
||||
transition: all 0.25s ease;
|
||||
|
||||
.org-create-btn {
|
||||
background: linear-gradient(135deg, #07c05f 0%, #059669 50%, #047857 100%);
|
||||
border: none;
|
||||
color: #fff;
|
||||
font-weight: 500;
|
||||
box-shadow: 0 2px 8px rgba(7, 192, 95, 0.25);
|
||||
transition: all 0.25s ease;
|
||||
&:hover {
|
||||
background: linear-gradient(135deg, #059669 0%, #047857 100%);
|
||||
box-shadow: 0 4px 14px rgba(7, 192, 95, 0.35);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: linear-gradient(135deg, #059669 0%, #047857 100%);
|
||||
box-shadow: 0 4px 14px rgba(7, 192, 95, 0.35);
|
||||
}
|
||||
|
||||
.org-create-icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
filter: brightness(0) invert(1);
|
||||
}
|
||||
}
|
||||
.org-create-icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
filter: brightness(0) invert(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1318,27 +1336,13 @@ onUnmounted(() => {
|
||||
|
||||
.org-card-wrap {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
gap: 12px;
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
// 已加入标识(底部与角色标签同行)
|
||||
.pending-requests-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
height: 22px;
|
||||
padding: 0 8px;
|
||||
border-radius: 6px;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
background: rgba(250, 173, 20, 0.12);
|
||||
color: #d48806;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.org-card {
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 14px;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
|
||||
@@ -1346,10 +1350,10 @@ onUnmounted(() => {
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.2s ease;
|
||||
padding: 18px 20px;
|
||||
padding: 12px 14px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 160px;
|
||||
height: 132px;
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
@@ -1398,8 +1402,8 @@ onUnmounted(() => {
|
||||
// 卡片装饰:协作网络图形
|
||||
.card-decoration {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 16px;
|
||||
top: 6px;
|
||||
right: 12px;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: flex-end;
|
||||
@@ -1409,6 +1413,8 @@ onUnmounted(() => {
|
||||
|
||||
.card-deco-svg {
|
||||
display: block;
|
||||
width: 48px;
|
||||
height: 34px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1416,7 +1422,7 @@ onUnmounted(() => {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 12px;
|
||||
margin-bottom: 8px;
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
}
|
||||
@@ -1424,7 +1430,7 @@ onUnmounted(() => {
|
||||
.card-header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
gap: 8px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
@@ -1448,7 +1454,7 @@ onUnmounted(() => {
|
||||
.card-title {
|
||||
color: #1f2937;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 15px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
line-height: 1.4;
|
||||
overflow: hidden;
|
||||
@@ -1456,45 +1462,10 @@ onUnmounted(() => {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.card-relation {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
margin-top: 2px;
|
||||
font-size: 11px;
|
||||
font-weight: 400;
|
||||
line-height: 1.4;
|
||||
color: #94a3b8;
|
||||
opacity: 0.95;
|
||||
|
||||
.t-icon {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&.is-owner {
|
||||
color: #a78bfa;
|
||||
opacity: 0.9;
|
||||
|
||||
.t-icon {
|
||||
color: #a78bfa;
|
||||
}
|
||||
}
|
||||
|
||||
&:not(.is-owner) {
|
||||
color: #34d399;
|
||||
opacity: 0.9;
|
||||
|
||||
.t-icon {
|
||||
color: #34d399;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.more-wrap {
|
||||
display: flex;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: 6px;
|
||||
@@ -1518,14 +1489,14 @@ onUnmounted(() => {
|
||||
}
|
||||
|
||||
.more-icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.card-content {
|
||||
flex: 1;
|
||||
margin-bottom: 14px;
|
||||
margin-bottom: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@@ -1537,9 +1508,9 @@ onUnmounted(() => {
|
||||
overflow: hidden;
|
||||
color: #64748b;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 13px;
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
line-height: 1.5;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.card-bottom {
|
||||
@@ -1547,128 +1518,139 @@ onUnmounted(() => {
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: auto;
|
||||
padding-top: 12px;
|
||||
padding-top: 8px;
|
||||
border-top: 1px solid rgba(226, 232, 240, 0.8);
|
||||
}
|
||||
|
||||
.bottom-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.card-stats {
|
||||
// 与知识库卡片统一的底部标签:小尺寸、统一圆角
|
||||
.feature-badges {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
.feature-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
height: 22px;
|
||||
padding: 0 8px;
|
||||
border-radius: 6px;
|
||||
font-size: 12px;
|
||||
justify-content: center;
|
||||
gap: 3px;
|
||||
height: 20px;
|
||||
padding: 0 5px;
|
||||
border-radius: 5px;
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
font-family: "PingFang SC", system-ui, sans-serif;
|
||||
cursor: default;
|
||||
background: rgba(100, 116, 139, 0.08);
|
||||
color: #64748b;
|
||||
transition: background 0.2s ease;
|
||||
|
||||
.t-icon {
|
||||
flex-shrink: 0;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
span {
|
||||
.badge-count {
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
&.stat-item-agent {
|
||||
&.stat-member {
|
||||
background: rgba(100, 116, 139, 0.08);
|
||||
color: #64748b;
|
||||
.t-icon { color: #64748b; }
|
||||
&:hover { background: rgba(100, 116, 139, 0.12); }
|
||||
}
|
||||
|
||||
&.stat-kb {
|
||||
background: rgba(7, 192, 95, 0.08);
|
||||
color: #059669;
|
||||
.t-icon { color: #059669; }
|
||||
&:hover { background: rgba(7, 192, 95, 0.12); }
|
||||
}
|
||||
|
||||
&.stat-agent {
|
||||
background: rgba(124, 77, 255, 0.08);
|
||||
color: #7c4dff;
|
||||
.stat-agent-icon {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
flex-shrink: 0;
|
||||
/* 将绿色 icon 着色为紫色,与标签统一 */
|
||||
filter: brightness(0) saturate(100%) invert(48%) sepia(79%) saturate(2476%) hue-rotate(236deg);
|
||||
}
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: rgba(100, 116, 139, 0.12);
|
||||
}
|
||||
|
||||
// 成员数标签 - 绿色主题
|
||||
&:first-child {
|
||||
background: rgba(7, 192, 95, 0.08);
|
||||
color: #07c05f;
|
||||
|
||||
.t-icon {
|
||||
color: #07c05f;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: rgba(7, 192, 95, 0.12);
|
||||
}
|
||||
}
|
||||
|
||||
// 知识库数标签 - 蓝色主题
|
||||
&:last-child {
|
||||
background: rgba(0, 82, 217, 0.08);
|
||||
color: #0052d9;
|
||||
|
||||
.t-icon {
|
||||
color: #0052d9;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: rgba(0, 82, 217, 0.12);
|
||||
}
|
||||
&:hover { background: rgba(124, 77, 255, 0.12); }
|
||||
}
|
||||
}
|
||||
|
||||
.role-tag {
|
||||
// 待审核角标:与 feature-badge 同高
|
||||
.pending-requests-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
height: 22px;
|
||||
padding: 0 8px;
|
||||
padding: 0 6px;
|
||||
border-radius: 6px;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
background: rgba(250, 173, 20, 0.12);
|
||||
color: #d48806;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
// 右下角:创建者/角色 合并标签(带图标)
|
||||
.bottom-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.relation-role-tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
height: 22px;
|
||||
padding: 0 6px;
|
||||
border-radius: 6px;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
font-family: "PingFang SC", system-ui, sans-serif;
|
||||
background: rgba(107, 114, 128, 0.08);
|
||||
color: #6b7280;
|
||||
|
||||
.t-icon {
|
||||
flex-shrink: 0;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
&.owner {
|
||||
background: rgba(124, 77, 255, 0.1);
|
||||
color: #7c4dff;
|
||||
border: none;
|
||||
.t-icon { color: #7c4dff; }
|
||||
}
|
||||
|
||||
&.admin {
|
||||
background: rgba(7, 192, 95, 0.12);
|
||||
color: #07c05f;
|
||||
border: none;
|
||||
.t-icon { color: #07c05f; }
|
||||
}
|
||||
|
||||
&.editor {
|
||||
background: rgba(7, 192, 95, 0.08);
|
||||
color: #059669;
|
||||
border: none;
|
||||
.t-icon { color: #059669; }
|
||||
}
|
||||
|
||||
&.viewer {
|
||||
background: rgba(107, 114, 128, 0.08);
|
||||
color: #6b7280;
|
||||
border: none;
|
||||
.t-icon { color: #6b7280; }
|
||||
}
|
||||
}
|
||||
|
||||
.card-time {
|
||||
color: #9ca3af;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
@@ -1698,6 +1680,14 @@ onUnmounted(() => {
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
line-height: 22px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.empty-state-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"github.com/Tencent/WeKnora/internal/types/interfaces"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type tenantDisabledSharedAgentRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
// NewTenantDisabledSharedAgentRepository creates a new repository
|
||||
func NewTenantDisabledSharedAgentRepository(db *gorm.DB) interfaces.TenantDisabledSharedAgentRepository {
|
||||
return &tenantDisabledSharedAgentRepository{db: db}
|
||||
}
|
||||
|
||||
func (r *tenantDisabledSharedAgentRepository) ListByTenantID(ctx context.Context, tenantID uint64) ([]*types.TenantDisabledSharedAgent, error) {
|
||||
var list []*types.TenantDisabledSharedAgent
|
||||
err := r.db.WithContext(ctx).Where("tenant_id = ?", tenantID).Find(&list).Error
|
||||
return list, err
|
||||
}
|
||||
|
||||
func (r *tenantDisabledSharedAgentRepository) ListDisabledOwnAgentIDs(ctx context.Context, tenantID uint64) ([]string, error) {
|
||||
var ids []string
|
||||
err := r.db.WithContext(ctx).Model(&types.TenantDisabledSharedAgent{}).
|
||||
Where("tenant_id = ? AND source_tenant_id = ?", tenantID, tenantID).
|
||||
Pluck("agent_id", &ids).Error
|
||||
return ids, err
|
||||
}
|
||||
|
||||
func (r *tenantDisabledSharedAgentRepository) Add(ctx context.Context, tenantID uint64, agentID string, sourceTenantID uint64) error {
|
||||
rec := &types.TenantDisabledSharedAgent{
|
||||
TenantID: tenantID,
|
||||
AgentID: agentID,
|
||||
SourceTenantID: sourceTenantID,
|
||||
}
|
||||
return r.db.WithContext(ctx).Where(rec).FirstOrCreate(rec).Error
|
||||
}
|
||||
|
||||
func (r *tenantDisabledSharedAgentRepository) Remove(ctx context.Context, tenantID uint64, agentID string, sourceTenantID uint64) error {
|
||||
return r.db.WithContext(ctx).
|
||||
Where("tenant_id = ? AND agent_id = ? AND source_tenant_id = ?", tenantID, agentID, sourceTenantID).
|
||||
Delete(&types.TenantDisabledSharedAgent{}).Error
|
||||
}
|
||||
@@ -24,24 +24,27 @@ var (
|
||||
|
||||
// agentShareService implements AgentShareService interface
|
||||
type agentShareService struct {
|
||||
shareRepo interfaces.AgentShareRepository
|
||||
orgRepo interfaces.OrganizationRepository
|
||||
agentRepo interfaces.CustomAgentRepository
|
||||
userRepo interfaces.UserRepository
|
||||
shareRepo interfaces.AgentShareRepository
|
||||
disabledRepo interfaces.TenantDisabledSharedAgentRepository
|
||||
orgRepo interfaces.OrganizationRepository
|
||||
agentRepo interfaces.CustomAgentRepository
|
||||
userRepo interfaces.UserRepository
|
||||
}
|
||||
|
||||
// NewAgentShareService creates a new agent share service
|
||||
func NewAgentShareService(
|
||||
shareRepo interfaces.AgentShareRepository,
|
||||
disabledRepo interfaces.TenantDisabledSharedAgentRepository,
|
||||
orgRepo interfaces.OrganizationRepository,
|
||||
agentRepo interfaces.CustomAgentRepository,
|
||||
userRepo interfaces.UserRepository,
|
||||
) interfaces.AgentShareService {
|
||||
return &agentShareService{
|
||||
shareRepo: shareRepo,
|
||||
orgRepo: orgRepo,
|
||||
agentRepo: agentRepo,
|
||||
userRepo: userRepo,
|
||||
shareRepo: shareRepo,
|
||||
disabledRepo: disabledRepo,
|
||||
orgRepo: orgRepo,
|
||||
agentRepo: agentRepo,
|
||||
userRepo: userRepo,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,9 +205,33 @@ func (s *agentShareService) ListSharedAgents(ctx context.Context, userID string,
|
||||
for _, info := range agentInfoMap {
|
||||
result = append(result, info)
|
||||
}
|
||||
|
||||
// Set DisabledByMe from tenant_disabled_shared_agents for current tenant
|
||||
disabledList, err := s.disabledRepo.ListByTenantID(ctx, currentTenantID)
|
||||
if err != nil {
|
||||
return result, nil // non-fatal: return list without DisabledByMe
|
||||
}
|
||||
disabledSet := make(map[string]bool)
|
||||
for _, d := range disabledList {
|
||||
disabledSet[fmt.Sprintf("%s_%d", d.AgentID, d.SourceTenantID)] = true
|
||||
}
|
||||
for _, info := range result {
|
||||
if info.Agent != nil {
|
||||
key := fmt.Sprintf("%s_%d", info.Agent.ID, info.SourceTenantID)
|
||||
info.DisabledByMe = disabledSet[key]
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// SetSharedAgentDisabledByMe adds or removes (tenantID, agentID, sourceTenantID) from tenant_disabled_shared_agents.
|
||||
func (s *agentShareService) SetSharedAgentDisabledByMe(ctx context.Context, tenantID uint64, agentID string, sourceTenantID uint64, disabled bool) error {
|
||||
if disabled {
|
||||
return s.disabledRepo.Add(ctx, tenantID, agentID, sourceTenantID)
|
||||
}
|
||||
return s.disabledRepo.Remove(ctx, tenantID, agentID, sourceTenantID)
|
||||
}
|
||||
|
||||
// GetSharedAgentForUser returns the shared agent by agentID if the user has access; source tenant is resolved from the user's share. One share lookup + one agent lookup.
|
||||
func (s *agentShareService) GetSharedAgentForUser(ctx context.Context, userID string, currentTenantID uint64, agentID string) (*types.CustomAgent, error) {
|
||||
if agentID == "" {
|
||||
@@ -250,3 +277,8 @@ func (s *agentShareService) GetShareByAgentAndOrg(ctx context.Context, agentID s
|
||||
}
|
||||
return share, nil
|
||||
}
|
||||
|
||||
// GetShareByAgentIDForUser returns one share for the given agentID that the user can access (user in org), excluding source_tenant_id == excludeTenantID.
|
||||
func (s *agentShareService) GetShareByAgentIDForUser(ctx context.Context, userID, agentID string, excludeTenantID uint64) (*types.AgentShare, error) {
|
||||
return s.shareRepo.GetShareByAgentIDForUser(ctx, userID, agentID, excludeTenantID)
|
||||
}
|
||||
|
||||
@@ -114,6 +114,7 @@ func BuildContainer(container *dig.Container) *dig.Container {
|
||||
must(container.Provide(repository.NewOrganizationRepository))
|
||||
must(container.Provide(repository.NewKBShareRepository))
|
||||
must(container.Provide(repository.NewAgentShareRepository))
|
||||
must(container.Provide(repository.NewTenantDisabledSharedAgentRepository))
|
||||
must(container.Provide(service.NewWebSearchStateService))
|
||||
|
||||
// MCP manager for managing MCP client connections
|
||||
|
||||
@@ -14,13 +14,15 @@ import (
|
||||
|
||||
// CustomAgentHandler defines the HTTP handler for custom agent operations
|
||||
type CustomAgentHandler struct {
|
||||
service interfaces.CustomAgentService
|
||||
service interfaces.CustomAgentService
|
||||
disabledRepo interfaces.TenantDisabledSharedAgentRepository
|
||||
}
|
||||
|
||||
// NewCustomAgentHandler creates a new custom agent handler instance
|
||||
func NewCustomAgentHandler(service interfaces.CustomAgentService) *CustomAgentHandler {
|
||||
func NewCustomAgentHandler(service interfaces.CustomAgentService, disabledRepo interfaces.TenantDisabledSharedAgentRepository) *CustomAgentHandler {
|
||||
return &CustomAgentHandler{
|
||||
service: service,
|
||||
service: service,
|
||||
disabledRepo: disabledRepo,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,10 +36,10 @@ type CreateAgentRequest struct {
|
||||
|
||||
// UpdateAgentRequest defines the request body for updating an agent
|
||||
type UpdateAgentRequest struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Avatar string `json:"avatar"`
|
||||
Config types.CustomAgentConfig `json:"config"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Avatar string `json:"avatar"`
|
||||
Config types.CustomAgentConfig `json:"config"`
|
||||
}
|
||||
|
||||
// CreateAgent godoc
|
||||
@@ -161,9 +163,14 @@ func (h *CustomAgentHandler) ListAgents(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// Per-tenant "disabled by me" for own agents (only affects this tenant's conversation dropdown)
|
||||
tenantID, _ := c.Get(types.TenantIDContextKey.String())
|
||||
disabledOwnIDs, _ := h.disabledRepo.ListDisabledOwnAgentIDs(ctx, tenantID.(uint64))
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": true,
|
||||
"data": agents,
|
||||
"success": true,
|
||||
"data": agents,
|
||||
"disabled_own_agent_ids": disabledOwnIDs,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -18,12 +18,13 @@ import (
|
||||
|
||||
// OrganizationHandler implements HTTP request handlers for organization management
|
||||
type OrganizationHandler struct {
|
||||
orgService interfaces.OrganizationService
|
||||
shareService interfaces.KBShareService
|
||||
agentShareService interfaces.AgentShareService
|
||||
userService interfaces.UserService
|
||||
knowledgeRepo interfaces.KnowledgeRepository
|
||||
chunkRepo interfaces.ChunkRepository
|
||||
orgService interfaces.OrganizationService
|
||||
shareService interfaces.KBShareService
|
||||
agentShareService interfaces.AgentShareService
|
||||
customAgentService interfaces.CustomAgentService
|
||||
userService interfaces.UserService
|
||||
knowledgeRepo interfaces.KnowledgeRepository
|
||||
chunkRepo interfaces.ChunkRepository
|
||||
}
|
||||
|
||||
// NewOrganizationHandler creates a new organization handler
|
||||
@@ -31,17 +32,19 @@ func NewOrganizationHandler(
|
||||
orgService interfaces.OrganizationService,
|
||||
shareService interfaces.KBShareService,
|
||||
agentShareService interfaces.AgentShareService,
|
||||
customAgentService interfaces.CustomAgentService,
|
||||
userService interfaces.UserService,
|
||||
knowledgeRepo interfaces.KnowledgeRepository,
|
||||
chunkRepo interfaces.ChunkRepository,
|
||||
) *OrganizationHandler {
|
||||
return &OrganizationHandler{
|
||||
orgService: orgService,
|
||||
shareService: shareService,
|
||||
agentShareService: agentShareService,
|
||||
userService: userService,
|
||||
knowledgeRepo: knowledgeRepo,
|
||||
chunkRepo: chunkRepo,
|
||||
orgService: orgService,
|
||||
shareService: shareService,
|
||||
agentShareService: agentShareService,
|
||||
customAgentService: customAgentService,
|
||||
userService: userService,
|
||||
knowledgeRepo: knowledgeRepo,
|
||||
chunkRepo: chunkRepo,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1252,6 +1255,46 @@ func (h *OrganizationHandler) ListSharedAgents(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"success": true, "data": list, "total": len(list)})
|
||||
}
|
||||
|
||||
// SetSharedAgentDisabledByMeRequest is the body for POST /shared-agents/disabled
|
||||
type SetSharedAgentDisabledByMeRequest struct {
|
||||
AgentID string `json:"agent_id" binding:"required"`
|
||||
Disabled bool `json:"disabled"`
|
||||
}
|
||||
|
||||
// SetSharedAgentDisabledByMe sets whether the current tenant has disabled this shared agent for their conversation dropdown
|
||||
func (h *OrganizationHandler) SetSharedAgentDisabledByMe(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
userID, _ := c.Get(types.UserIDContextKey.String())
|
||||
tenantID, _ := c.Get(types.TenantIDContextKey.String())
|
||||
uid := userID.(string)
|
||||
tid := tenantID.(uint64)
|
||||
|
||||
var req SetSharedAgentDisabledByMeRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.Error(apperrors.NewBadRequestError("Invalid request").WithDetails(err.Error()))
|
||||
return
|
||||
}
|
||||
// Derive sourceTenantID: own agent (current tenant) or from shared list
|
||||
var sourceTenantID uint64
|
||||
agent, err := h.customAgentService.GetAgentByID(ctx, req.AgentID)
|
||||
if err == nil && agent != nil && agent.TenantID == tid {
|
||||
sourceTenantID = tid
|
||||
} else {
|
||||
share, err := h.agentShareService.GetShareByAgentIDForUser(ctx, uid, req.AgentID, tid)
|
||||
if err != nil || share == nil {
|
||||
c.Error(apperrors.NewForbiddenError("No access to this agent"))
|
||||
return
|
||||
}
|
||||
sourceTenantID = share.SourceTenantID
|
||||
}
|
||||
if err := h.agentShareService.SetSharedAgentDisabledByMe(ctx, tid, req.AgentID, sourceTenantID, req.Disabled); err != nil {
|
||||
logger.Errorf(ctx, "SetSharedAgentDisabledByMe failed: %v", err)
|
||||
c.Error(apperrors.NewInternalServerError("Failed to update preference"))
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"success": true})
|
||||
}
|
||||
|
||||
// toOrgResponse converts an organization to response format
|
||||
func (h *OrganizationHandler) toOrgResponse(ctx context.Context, org *types.Organization, currentUserID string) types.OrganizationResponse {
|
||||
resp := types.OrganizationResponse{
|
||||
|
||||
@@ -529,4 +529,5 @@ func RegisterOrganizationRoutes(r *gin.RouterGroup, orgHandler *handler.Organiza
|
||||
r.GET("/shared-knowledge-bases", orgHandler.ListSharedKnowledgeBases)
|
||||
// Shared agents route
|
||||
r.GET("/shared-agents", orgHandler.ListSharedAgents)
|
||||
r.POST("/shared-agents/disabled", orgHandler.SetSharedAgentDisabledByMe)
|
||||
}
|
||||
|
||||
@@ -135,10 +135,14 @@ type AgentShareService interface {
|
||||
ListSharesByAgent(ctx context.Context, agentID string) ([]*types.AgentShare, error)
|
||||
ListSharesByOrganization(ctx context.Context, orgID string) ([]*types.AgentShare, error)
|
||||
ListSharedAgents(ctx context.Context, userID string, currentTenantID uint64) ([]*types.SharedAgentInfo, error)
|
||||
// SetSharedAgentDisabledByMe sets whether the current tenant has "disabled" this shared agent for their conversation dropdown (per-user preference).
|
||||
SetSharedAgentDisabledByMe(ctx context.Context, tenantID uint64, agentID string, sourceTenantID uint64, disabled bool) error
|
||||
// GetSharedAgentForUser returns the shared agent by agentID if the user has access (source tenant is resolved from share); used to resolve KB scope for @ mention.
|
||||
GetSharedAgentForUser(ctx context.Context, userID string, currentTenantID uint64, agentID string) (*types.CustomAgent, error)
|
||||
GetShare(ctx context.Context, shareID string) (*types.AgentShare, error)
|
||||
GetShareByAgentAndOrg(ctx context.Context, agentID string, orgID string) (*types.AgentShare, error)
|
||||
// GetShareByAgentIDForUser returns one share for the given agentID that the user can access, excluding source_tenant_id == excludeTenantID (e.g. current tenant to get shared-from-other only).
|
||||
GetShareByAgentIDForUser(ctx context.Context, userID, agentID string, excludeTenantID uint64) (*types.AgentShare, error)
|
||||
}
|
||||
|
||||
// AgentShareRepository defines the agent sharing repository interface
|
||||
@@ -156,3 +160,12 @@ type AgentShareRepository interface {
|
||||
// GetShareByAgentIDForUser returns one share for the given agentID that the user can access (user in org), excluding source_tenant_id == excludeTenantID.
|
||||
GetShareByAgentIDForUser(ctx context.Context, userID, agentID string, excludeTenantID uint64) (*types.AgentShare, error)
|
||||
}
|
||||
|
||||
// TenantDisabledSharedAgentRepository stores per-tenant "disabled" agents (hidden from conversation dropdown; own and shared)
|
||||
type TenantDisabledSharedAgentRepository interface {
|
||||
ListByTenantID(ctx context.Context, tenantID uint64) ([]*types.TenantDisabledSharedAgent, error)
|
||||
// ListDisabledOwnAgentIDs returns agent IDs that this tenant has disabled for their own agents (source_tenant_id = tenant_id)
|
||||
ListDisabledOwnAgentIDs(ctx context.Context, tenantID uint64) ([]string, error)
|
||||
Add(ctx context.Context, tenantID uint64, agentID string, sourceTenantID uint64) error
|
||||
Remove(ctx context.Context, tenantID uint64, agentID string, sourceTenantID uint64) error
|
||||
}
|
||||
|
||||
@@ -241,6 +241,21 @@ type SharedAgentInfo struct {
|
||||
SharedAt time.Time `json:"shared_at"`
|
||||
SharedByUserID string `json:"shared_by_user_id,omitempty"`
|
||||
SharedByUsername string `json:"shared_by_username,omitempty"`
|
||||
// DisabledByMe: current tenant has hidden this shared agent from their conversation dropdown (per-user preference)
|
||||
DisabledByMe bool `json:"disabled_by_me"`
|
||||
}
|
||||
|
||||
// TenantDisabledSharedAgent records that a tenant has "disabled" a shared agent for their own dropdown
|
||||
type TenantDisabledSharedAgent struct {
|
||||
TenantID uint64 `json:"tenant_id" gorm:"primaryKey"`
|
||||
AgentID string `json:"agent_id" gorm:"type:varchar(36);primaryKey"`
|
||||
SourceTenantID uint64 `json:"source_tenant_id" gorm:"primaryKey"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// TableName returns the table name for GORM
|
||||
func (TenantDisabledSharedAgent) TableName() string {
|
||||
return "tenant_disabled_shared_agents"
|
||||
}
|
||||
|
||||
// ----------------------
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
-- Migration: 000012_organizations (down, merged 000012, 000013, 000014)
|
||||
DO $$ BEGIN RAISE NOTICE '[Migration 000012] Rolling back organization and agent_share tables...'; END $$;
|
||||
|
||||
-- Rollback 000014: tenant_disabled_shared_agents first (no FK to organizations)
|
||||
DROP INDEX IF EXISTS idx_tenant_disabled_shared_agents_tenant_id;
|
||||
DROP TABLE IF EXISTS tenant_disabled_shared_agents;
|
||||
|
||||
-- Rollback 000012/000013: organization-related tables (order matters for FK)
|
||||
DROP TABLE IF EXISTS agent_shares;
|
||||
DROP TABLE IF EXISTS organization_join_requests;
|
||||
DROP TABLE IF EXISTS kb_shares;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- Migration: 000012_organizations (merged 000012, 000013, 000014)
|
||||
-- Description: Organization tables, kb_shares, join requests, agent_shares (model_shares omitted/dropped)
|
||||
-- Description: Organization tables, kb_shares, join requests, agent_shares, tenant_disabled_shared_agents
|
||||
DO $$ BEGIN RAISE NOTICE '[Migration 000012] Starting organization tables setup...'; END $$;
|
||||
|
||||
-- Create organizations table
|
||||
@@ -132,4 +132,15 @@ COMMENT ON TABLE agent_shares IS 'Custom agent sharing records to organizations'
|
||||
COMMENT ON COLUMN agent_shares.source_tenant_id IS 'Original tenant ID of the agent';
|
||||
COMMENT ON COLUMN agent_shares.permission IS 'Access permission: viewer or editor';
|
||||
|
||||
DO $$ BEGIN RAISE NOTICE '[Migration 000012] Organization tables and agent_shares setup completed successfully!'; END $$;
|
||||
-- Per-tenant "disabled" list for shared agents (merged from 000014)
|
||||
DO $$ BEGIN RAISE NOTICE '[Migration 000012] Creating table: tenant_disabled_shared_agents'; END $$;
|
||||
CREATE TABLE IF NOT EXISTS tenant_disabled_shared_agents (
|
||||
tenant_id BIGINT NOT NULL,
|
||||
agent_id VARCHAR(36) NOT NULL,
|
||||
source_tenant_id BIGINT NOT NULL,
|
||||
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (tenant_id, agent_id, source_tenant_id)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_tenant_disabled_shared_agents_tenant_id ON tenant_disabled_shared_agents(tenant_id);
|
||||
|
||||
DO $$ BEGIN RAISE NOTICE '[Migration 000012] Organization tables and tenant_disabled_shared_agents setup completed successfully!'; END $$;
|
||||
|
||||
Reference in New Issue
Block a user