diff --git a/frontend/src/api/agent/index.ts b/frontend/src/api/agent/index.ts index 9a783693..e40a713a 100644 --- a/frontend/src/api/agent/index.ts +++ b/frontend/src/api/agent/index.ts @@ -99,6 +99,8 @@ export interface CustomAgent { is_builtin: boolean; tenant_id?: number; created_by?: string; + // creator_name 由后端 list 接口批量回填,仅用于列表卡片来源徽章。 + creator_name?: string; config: CustomAgentConfig; created_at?: string; updated_at?: string; diff --git a/frontend/src/api/auth/index.ts b/frontend/src/api/auth/index.ts index 5a28361a..e6b86d5a 100644 --- a/frontend/src/api/auth/index.ts +++ b/frontend/src/api/auth/index.ts @@ -115,6 +115,9 @@ export interface KnowledgeBaseInfo { // Set by PR 5 of the multi-tenant RBAC series; nullable for legacy // KBs created before that migration backfilled the column. creator_id?: string + // creator_name 由后端 list 接口批量回填(username 优先,退化到 email), + // 仅用于列表卡片来源徽章;缺失代表无法解析(已删除 / 老数据)。 + creator_name?: string created_at: string updated_at: string document_count?: number diff --git a/frontend/src/components/ResourceOriginBadge.vue b/frontend/src/components/ResourceOriginBadge.vue index 0e52080a..e41e39a3 100644 --- a/frontend/src/components/ResourceOriginBadge.vue +++ b/frontend/src/components/ResourceOriginBadge.vue @@ -15,23 +15,30 @@ import { useAuthStore } from '@/stores/auth' * ResourceOriginBadge – a unified, compact label that explains *where* a * KB or Agent comes from. Replaces the ad-hoc "我的" / "shared-by-me-badge" * / org_name pills scattered across KnowledgeBaseList and AgentList. The - * variants below cover the four origin shapes the list views actually + * variants below cover the five origin shapes the list views actually * surface; future origins (e.g. "system" / "imported") should add a new * variant rather than re-using one of these. * * Variants: * - mine : created by the current user in the current tenant * - tenant : owned by the current tenant but created by someone else + * — label shows tenant name; use when context doesn't say + * - creator : same data shape as `tenant`, but the surrounding section + * header already names the tenant ("本空间 · 仅查看"), so + * the badge only carries the creator name to avoid the + * duplicated "本空间 / wizardchen's Workspace" pill on + * every card. Falls back to the i18n label when the + * creator name is unknown. * - space : reached through a cross-tenant space (organization) * - shared : cross-tenant share without a useful org name to show * * Pass `creatorName` to surface "by 张三" in the tooltip for the `tenant` - * variant; omit it for the `mine` / `space` / `shared` variants where the - * subject is implicit. + * variant, or to drive the visible label of the `creator` variant; omit it + * for the `mine` / `space` / `shared` variants where the subject is implicit. */ const props = withDefaults( defineProps<{ - variant: 'mine' | 'tenant' | 'space' | 'shared' + variant: 'mine' | 'tenant' | 'creator' | 'space' | 'shared' /** Used in `space` variant — the organization (space) display name. */ spaceName?: string /** Optional creator display name, surfaces in tooltip for `tenant` variant. */ @@ -51,6 +58,8 @@ const iconName = computed(() => { return 'user' case 'tenant': return 'usergroup' + case 'creator': + return 'user' case 'space': return 'building' case 'shared': @@ -70,6 +79,11 @@ const displayText = computed(() => { // Prefer the tenant name when known so the badge says where the // resource lives, not a vague "tenant" label. Falls back to i18n. return authStore.currentTenantName || t('resourceOrigin.tenant') + case 'creator': + // Section header already provides the「本空间」context, so we just + // show who created it. Fall back to a generic label when the user + // can't be resolved (creator_name 缺失,例如已删除账号 / 老数据)。 + return props.creatorName || t('resourceOrigin.tenant') case 'space': return props.spaceName || t('resourceOrigin.space') case 'shared': @@ -88,6 +102,12 @@ const tooltipText = computed(() => { return t('resourceOrigin.tenantTooltipWithCreator', { creator: props.creatorName }) } return t('resourceOrigin.tenantTooltip') + case 'creator': + // 卡片标签只露名字;tooltip 把完整含义补回来。 + if (props.creatorName) { + return t('resourceOrigin.tenantTooltipWithCreator', { creator: props.creatorName }) + } + return t('resourceOrigin.tenantTooltip') case 'space': if (props.sourceTenantName) { return t('resourceOrigin.spaceTooltipWithTenant', { @@ -136,6 +156,11 @@ const tooltipText = computed(() => { background: var(--td-bg-color-secondarycontainer); } + &.origin-creator { + color: var(--td-text-color-secondary); + background: var(--td-bg-color-secondarycontainer); + } + &.origin-space { color: var(--td-warning-color-7, #b86e02); background: var(--td-warning-color-1, #fff7e6); diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts index 39319ebe..3bcf8f9b 100755 --- a/frontend/src/i18n/locales/en-US.ts +++ b/frontend/src/i18n/locales/en-US.ts @@ -425,6 +425,11 @@ export default { mine: 'My Agents', sharedToMe: 'Shared to Me', }, + sections: { + tenantReadonly: 'Workspace · View only', + sharedEditable: 'Shared with me · Can edit', + sharedReadonly: 'Shared with me · View only', + }, empty: { title: 'No Custom Agents', description: 'Click the button in the top right to create your first agent', @@ -1618,6 +1623,9 @@ export default { sections: { pinned: 'Pinned', others: 'Others', + tenantReadonly: 'Workspace · View only', + sharedEditable: 'Shared with me · Can edit', + sharedReadonly: 'Shared with me · View only', }, messages: { deleted: 'Knowledge base deleted', diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.ts index 798153d2..4c533a4f 100755 --- a/frontend/src/i18n/locales/ko-KR.ts +++ b/frontend/src/i18n/locales/ko-KR.ts @@ -1317,6 +1317,11 @@ export default { mine: "내 에이전트", sharedToMe: "나와 공유됨", }, + sections: { + tenantReadonly: "워크스페이스 · 읽기 전용", + sharedEditable: "공유받음 · 편집 가능", + sharedReadonly: "공유받음 · 읽기 전용", + }, empty: { title: "아직 맞춤 에이전트가 없습니다.", description: "첫 번째 에이전트를 생성하려면 오른쪽 상단에 있는 버튼을 클릭하세요.", @@ -2276,6 +2281,9 @@ export default { sections: { pinned: "고정됨", others: "기타", + tenantReadonly: "워크스페이스 · 읽기 전용", + sharedEditable: "공유받음 · 편집 가능", + sharedReadonly: "공유받음 · 읽기 전용", }, detail: { title: "공유 지식베이스", diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts index 695c0c2d..7ae39fda 100755 --- a/frontend/src/i18n/locales/ru-RU.ts +++ b/frontend/src/i18n/locales/ru-RU.ts @@ -517,6 +517,11 @@ export default { mine: 'My Agents', sharedToMe: 'Shared to Me' }, + sections: { + tenantReadonly: 'Рабочая область · Только просмотр', + sharedEditable: 'Доступно мне · Можно редактировать', + sharedReadonly: 'Доступно мне · Только просмотр' + }, empty: { title: 'No Custom Agents', description: 'Click the button in the top right to create your first agent', @@ -1850,7 +1855,10 @@ export default { }, sections: { pinned: 'Закреплённые', - others: 'Другие' + others: 'Другие', + tenantReadonly: 'Рабочая область · Только просмотр', + sharedEditable: 'Доступно мне · Можно редактировать', + sharedReadonly: 'Доступно мне · Только просмотр' }, messages: { deleted: 'База знаний удалена', diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts index e19fa4a1..c4878b0a 100755 --- a/frontend/src/i18n/locales/zh-CN.ts +++ b/frontend/src/i18n/locales/zh-CN.ts @@ -1311,6 +1311,11 @@ export default { mine: "我的智能体", sharedToMe: "共享给我", }, + sections: { + tenantReadonly: "本空间 · 仅查看", + sharedEditable: "共享给我 · 可编辑", + sharedReadonly: "共享给我 · 仅查看", + }, empty: { title: "暂无自定义智能体", description: "点击右上角按钮创建您的第一个智能体", @@ -2252,6 +2257,9 @@ export default { sections: { pinned: "置顶", others: "其他", + tenantReadonly: "本空间 · 仅查看", + sharedEditable: "共享给我 · 可编辑", + sharedReadonly: "共享给我 · 仅查看", }, detail: { title: "共享知识库", diff --git a/frontend/src/views/agent/AgentList.vue b/frontend/src/views/agent/AgentList.vue index 3d1ed05d..6bc604ab 100644 --- a/frontend/src/views/agent/AgentList.vue +++ b/frontend/src/views/agent/AgentList.vue @@ -64,402 +64,457 @@
-