Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

fix(ui): 优化资源卡片、标签分组与共享空间创建布局

wizardcheneec236b27f96
diff --git a/frontend/src/components/ResourceListToolbar.vue b/frontend/src/components/ResourceListToolbar.vue
new file mode 100644
index 000000000..c010fd90f
--- /dev/null
+++ b/frontend/src/components/ResourceListToolbar.vue
@@ -0,0 +1,91 @@
+<template>
+ <div class="resource-toolbar">
+ <div v-if="!hideScopes" class="scope-filters">
+ <div class="category-tabs" role="group" :aria-label="$t('listSpaceSidebar.all')">
+ <button v-for="item in scopes" :key="item.value" type="button"
+ :aria-pressed="modelValue === item.value" @click="$emit('update:modelValue', item.value)">
+ {{ item.label }}
+ <span v-if="item.count !== undefined" class="scope-count">{{ item.count }}</span>
+ </button>
+ </div>
+ <t-select v-if="mode === 'resource' && spaceOptions.length" class="space-filter"
+ :value="selectedSpace" :options="spaceOptions" :placeholder="$t('listSpaceSidebar.spaces')"
+ :aria-label="$t('listSpaceSidebar.spaces')" filterable clearable
+ @change="(value: unknown) => $emit('update:modelValue', String(value || 'all'))" />
+ </div>
+ <t-input :model-value="query" class="search-input" :placeholder="$t('menu.search')"
+ :aria-label="$t('menu.search')" clearable @update:model-value="(value: unknown) => $emit('update:query', String(value ?? ''))">
+ <template #prefix-icon><t-icon name="search" size="16px" /></template>
+ </t-input>
+ </div>
+</template>
+
+<script setup lang="ts">
+import { computed, onMounted } from 'vue'
+import { useI18n } from 'vue-i18n'
+import { useOrganizationStore } from '@/stores/organization'
+
+const props = withDefaults(defineProps<{
+ modelValue: string
+ query: string
+ mode?: 'resource' | 'organization'
+ hideScopes?: boolean
+ countAll?: number
+ countMine?: number
+ countFavorites?: number
+ countRecents?: number
+ countCreated?: number
+ countJoined?: number
+ countByOrg?: Record<string, number>
+}>(), { mode: 'resource', hideScopes: false, countByOrg: () => ({}) })
+defineEmits<{
+ 'update:modelValue': [value: string]
+ 'update:query': [value: string]
+}>()
+const { t } = useI18n()
+const orgStore = useOrganizationStore()
+const scopes = computed(() => props.mode === 'organization' ? [
+ { value: 'all', label: t('listSpaceSidebar.all'), count: props.countAll },
+ { value: 'created', label: t('organization.createdByMe'), count: props.countCreated },
+ { value: 'joined', label: t('organization.joinedByMe'), count: props.countJoined },
+] : [
+ { value: 'all', label: t('listSpaceSidebar.all'), count: props.countAll },
+ { value: 'favorites', label: t('listSpaceSidebar.favorites'), count: props.countFavorites },
+ { value: 'recents', label: t('listSpaceSidebar.recents'), count: props.countRecents },
+ { value: 'mine', label: t('listSpaceSidebar.workspace'), count: props.countMine },
+])
+const selectedSpace = computed(() => scopes.value.some(s => s.value === props.modelValue) ? '' : props.modelValue)
+const spaceOptions = computed(() => (orgStore.organizations || [])
+ .filter(org => (props.countByOrg[org.id] ?? 0) > 0 || org.id === selectedSpace.value)
+ .map(org => ({ label: org.name, value: org.id })))
+onMounted(() => { if (!props.hideScopes) orgStore.fetchOrganizations() })
+</script>
+
+<style scoped lang="less">
+@import (reference) '@/components/css/artifact-filter-tabs.less';
+.resource-toolbar {
+ flex-shrink: 0;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ flex-wrap: wrap;
+ gap: var(--app-space-3);
+ padding-bottom: var(--app-space-3);
+ border-bottom: 1px solid var(--td-component-stroke);
+}
+.scope-filters {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: var(--app-space-3);
+ min-width: 0;
+}
+.category-tabs { .artifact-filter-tabs(); }
+.scope-count { margin-left: 5px; font-size: var(--app-text-xs); opacity: 0.65; font-variant-numeric: tabular-nums; }
+.space-filter { width: 180px; }
+.search-input { width: 260px; max-width: 100%; margin-left: auto; }
+@media (max-width: 720px) {
+ .search-input { width: 100%; }
+ .space-filter { max-width: 100%; }
+}
+</style>
diff --git a/frontend/src/components/css/resource-card.less b/frontend/src/components/css/resource-card.less
index ca6733b09..dc2aed11d 100644
--- a/frontend/src/components/css/resource-card.less
+++ b/frontend/src/components/css/resource-card.less
@@ -1,18 +1,10 @@
-// 列表页资源卡片(知识库 / 智能体 / 共享空间)共用的视觉规范。
-// 以 mixin 形式提供,消费方保留自己的根 class(.kb-card / .agent-card / .org-card)
-// 与特有变体(类型渐变、收藏星标、装饰图案),基础尺寸、hover、更多按钮、徽标由这里统一。
-//
-// 用法(在消费方 <style lang="less" scoped> 内):
-// @import (reference) '@/components/css/resource-card.less';
-// .kb-card-wrap { .resource-card-grid(); }
-// .kb-card { .resource-card(); /* 变体… */ }
-// .feature-badge { .resource-feature-badge(); /* 语义色变体… */ }
-
+// Resource cards share the artifact page's toolbar, with their own compact grid.
+// Page-specific classes retain existing actions and permission gates.
.resource-card-grid() {
display: grid;
- gap: 12px;
- grid-template-columns: 1fr;
- animation: contentFadeIn 0.32s ease-out;
+ grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
+ gap: 10px;
+ align-items: stretch;
}
.resource-card() {
@@ -20,212 +12,219 @@
display: flex;
flex-direction: column;
box-sizing: border-box;
- height: 136px;
- min-height: 136px;
- padding: 12px 14px;
+ min-width: 0;
+ min-height: 132px;
+ padding: 12px;
border: 1px solid var(--td-component-stroke);
border-radius: var(--app-radius-md);
background: var(--td-bg-color-container);
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
- overflow: hidden;
cursor: pointer;
- transition: border-color var(--app-motion-base) ease, box-shadow var(--app-motion-base) ease, background var(--app-motion-base) ease;
+ transition: border-color var(--app-motion-fast) ease, box-shadow var(--app-motion-fast) ease;
&:hover {
- border-color: var(--td-brand-color);
- box-shadow: 0 4px 12px color-mix(in srgb, var(--td-brand-color) 12%, transparent);
- }
-
- &.is-skeleton {
- cursor: default;
-
- .card-header {
- margin-bottom: 12px;
- }
-
- .card-content {
- flex: 1;
- }
-
- .card-bottom {
- margin-top: auto;
- }
+ border-color: color-mix(in srgb, var(--td-brand-color) 40%, var(--td-component-stroke));
+ box-shadow: 0 3px 12px color-mix(in srgb, var(--td-text-color-primary) 6%, transparent);
}
-
- // 内容永远压在装饰图案之上
- .card-header,
- .card-content,
- .card-bottom {
- position: relative;
- z-index: 1;
+ &:focus-visible {
+ outline: 2px solid var(--td-brand-color);
+ outline-offset: -2px;
}
.card-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- gap: 4px;
- margin-bottom: 6px;
- }
-
- .card-header-left {
display: flex;
align-items: center;
gap: 8px;
- flex: 1;
- min-width: 0;
- }
-
- .card-title-block {
- display: flex;
- flex-direction: column;
- gap: 2px;
- flex: 1;
min-width: 0;
+ min-height: 28px;
+ padding-right: 28px;
+ margin-bottom: 6px;
}
-
+ &:has(.kb-favorite-star, .agent-favorite-star) .card-header { padding-right: 60px; }
+ .card-header-left,
+ .card-title-block { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.card-title {
- display: flex;
- align-items: center;
- gap: 6px;
+ display: block;
flex: 1;
min-width: 0;
color: var(--td-text-color-primary);
- font-size: var(--app-text-lg);
+ font-size: var(--app-text-base);
font-weight: 600;
- line-height: 22px;
- letter-spacing: 0.01em;
+ line-height: 20px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
-
- .card-title-text {
- min-width: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
-
- .permission-tag {
- flex-shrink: 0;
- }
-
- // 「更多」按钮:hover 卡片时半透明出现,hover 自身时完全不透明
- .more-wrap,
- .card-more-btn {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 28px;
- height: 28px;
- flex-shrink: 0;
- border-radius: var(--app-radius-sm);
- color: var(--td-text-color-placeholder);
- cursor: pointer;
- opacity: 0;
- transition: background var(--app-motion-base) ease, opacity var(--app-motion-base) ease, color var(--app-motion-base) ease;
-
- &:hover,
- &.active-more {
- background: var(--td-bg-color-container-hover);
- color: var(--td-text-color-secondary);
- opacity: 1;
- }
-
- .more-icon {
- width: 16px;
- height: 16px;
- }
- }
-
- &:hover .more-wrap,
- &:hover .card-more-btn {
- opacity: 0.6;
- }
-
- &:hover .more-wrap:hover,
- &:hover .more-wrap.active-more,
- &:hover .card-more-btn:hover,
- &:hover .card-more-btn.active-more {
- opacity: 1;
- }
-
- // 触屏没有 hover,保持可见
- @media (hover: none) {
- .more-wrap,
- .card-more-btn {
- opacity: 0.6;
- }
- }
-
+ .card-title:has(.card-title-text) { display: flex; align-items: center; gap: 6px; }
+ .card-title-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
+ .permission-tag { flex-shrink: 0; }
.card-content {
flex: 1;
- min-height: 0;
- margin-bottom: 6px;
+ min-width: 0;
+ min-height: 36px;
+ margin-bottom: 8px;
overflow: hidden;
- display: flex;
- flex-direction: column;
- gap: 6px;
}
-
.card-description {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
line-clamp: 2;
- overflow: hidden;
color: var(--td-text-color-secondary);
font-size: var(--app-text-sm);
- font-weight: 400;
- line-height: 17px;
+ line-height: 18px;
+ overflow: hidden;
}
-
.card-bottom {
display: flex;
align-items: center;
justify-content: space-between;
+ flex-wrap: wrap;
+ gap: 8px;
+ min-width: 0;
margin-top: auto;
padding-top: 6px;
- border-top: 0.5px solid var(--td-component-stroke);
+ border-top: 1px solid color-mix(in srgb, var(--td-component-stroke) 60%, transparent);
}
+ .feature-badges { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
+ .card-time { color: var(--td-text-color-placeholder); font-size: var(--app-text-sm); }
- .card-time {
- color: var(--td-text-color-placeholder);
- font-size: var(--app-text-sm);
- font-weight: 400;
+ .builtin-avatar,
+ .org-avatar,
+ :deep(.agent-avatar) {
+ flex-shrink: 0;
+ width: 28px;
+ height: 28px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
}
- .feature-badges {
+ .more-wrap,
+ .card-more-btn,
+ .shared-detail-trigger {
+ position: absolute;
+ right: 8px;
+ top: 12px;
display: flex;
align-items: center;
- gap: 4px;
+ justify-content: center;
+ width: 28px;
+ height: 28px;
+ padding: 0;
+ border: 0;
+ border-radius: var(--app-radius-sm);
+ background: transparent;
+ color: var(--td-text-color-secondary);
+ cursor: pointer;
+ &:hover, &.active-more { background: var(--td-bg-color-secondarycontainer); }
+ &:focus-visible { outline: 2px solid var(--td-brand-color); outline-offset: 1px; }
+ .more-icon { width: 16px; height: 16px; }
}
+ &.is-skeleton {
+ cursor: default;
+ &:hover { border-color: var(--td-component-stroke); box-shadow: none; }
+ .card-header { padding-right: 0; }
+ }
+ @media (prefers-reduced-motion: reduce) { transition: none; }
}
-// 卡片底部的小徽标:图标独占时 22×22,带计数时自适应宽度
.resource-feature-badge() {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 3px;
- height: 22px;
- min-width: 22px;
+ height: 20px;
+ min-width: 20px;
padding: 0 5px;
box-sizing: border-box;
border-radius: 5px;
font-size: var(--app-text-xs);
font-weight: 500;
+ font-variant-numeric: tabular-nums;
cursor: default;
- transition: background var(--app-motion-base) ease;
+ .t-icon { flex-shrink: 0; }
+ .badge-count { font-size: var(--app-text-xs); font-weight: 500; line-height: 1; }
+}
- .t-icon {
- flex-shrink: 0;
- }
+.resource-section-header() {
+ grid-column: 1 / -1;
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ margin-top: 8px;
+ padding: 4px 4px 2px;
+ color: var(--td-text-color-secondary);
+ font-size: var(--app-text-sm);
+ font-weight: 500;
+ line-height: 20px;
+ cursor: pointer;
+ user-select: none;
+ &:first-child { margin-top: 0; }
+ &:hover { color: var(--td-text-color-primary); }
+ &:focus-visible { outline: 2px solid var(--td-brand-color); outline-offset: -2px; border-radius: 4px; }
+ [class$='-section-count'] { font-variant-numeric: tabular-nums; color: var(--td-text-color-placeholder); }
+ [class$='-section-toggle'] { margin-left: 2px; opacity: 0.6; }
+ [class$='-section-subicon'] { margin-left: -4px; }
+}
- .badge-count {
- font-size: var(--app-text-xs);
- font-weight: 500;
- line-height: 1;
+.resource-list-content() {
+ flex: 1;
+ min-width: 0;
+ min-height: 0;
+ height: 100%;
+ box-sizing: border-box;
+ display: flex;
+ flex-direction: column;
+ margin: 0 16px 0 0;
+ padding: 20px 28px 0;
+ @media (max-width: 720px) { margin: 0; padding: var(--app-space-4) var(--app-space-4) 0; }
+}
+.resource-list-main() {
+ flex: 1;
+ min-height: 0;
+ min-width: 0;
+ overflow-y: auto;
+ overflow-x: hidden;
+ padding: var(--app-space-3) 0 var(--app-space-6);
+}
+.resource-list-header() {
+ .header {
+ margin-bottom: 16px;
+ padding-right: 0;
+ flex-shrink: 0;
+ .header-title { width: 100%; gap: 4px; }
+ .title-row { flex-wrap: wrap; gap: 12px; }
+ h2 { margin-right: auto; }
+ .header-subtitle { color: var(--td-text-color-secondary); font-size: var(--app-text-base); }
+ .header-action-btn {
+ width: auto;
+ min-height: 32px;
+ padding: 0 12px;
+ gap: 6px;
+ box-shadow: none;
+ color: var(--td-text-color-primary);
+ background: var(--td-bg-color-container);
+ &:hover:not(:disabled) { background: var(--td-bg-color-container-hover); }
+ &:focus-visible { outline: 2px solid var(--td-brand-color); outline-offset: 2px; }
+ }
}
}
+.resource-favorite-button() {
+ position: absolute;
+ top: 12px;
+ right: 38px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 28px;
+ height: 28px;
+ padding: 0;
+ border: 0;
+ border-radius: var(--app-radius-sm);
+ background: transparent;
+ color: var(--td-text-color-placeholder);
+ cursor: pointer;
+ &:hover { background: var(--td-bg-color-secondarycontainer); color: var(--td-warning-color); }
+ &.is-favorited { color: var(--td-warning-color); }
+ &:focus-visible { outline: 2px solid var(--td-brand-color); outline-offset: 1px; }
+}
diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts
index 1a60b716f..c0ebdd421 100755
--- a/frontend/src/i18n/locales/en-US.ts
+++ b/frontend/src/i18n/locales/en-US.ts
@@ -575,6 +575,8 @@ export default {
tagManageListSection: 'Tags',
tagManageDocCount: '{count} documents',
tagManageFaqCount: '{count} FAQ entries',
+ tagPickerSelected: 'Selected',
+ tagPickerUnselected: 'Not selected',
tagSelectedCount: '{count} selected',
tagPickerSearch: "Search or create a tag",
tagPickerInUse: "This tag is in use. Remove its document associations before deleting it.",
diff --git a/frontend/src/i18n/locales/ja-JP.ts b/frontend/src/i18n/locales/ja-JP.ts
index 2ccf3af38..85424eaba 100644
--- a/frontend/src/i18n/locales/ja-JP.ts
+++ b/frontend/src/i18n/locales/ja-JP.ts
@@ -575,6 +575,8 @@ export default {
tagManageListSection: 'タグ',
tagManageDocCount: '{count}件のドキュメント',
tagManageFaqCount: '{count}件のFAQ',
+ tagPickerSelected: '選択済み',
+ tagPickerUnselected: '未選択',
tagSelectedCount: '{count}件選択中',
tagPickerSearch: "タグを検索または作成",
tagPickerInUse: "使用中のタグです。先にドキュメントとの関連付けを解除してください。",
diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.ts
index 2cf4c98eb..3d2c3f064 100755
--- a/frontend/src/i18n/locales/ko-KR.ts
+++ b/frontend/src/i18n/locales/ko-KR.ts
@@ -6778,6 +6778,8 @@ export default {
tagManageListSection: '태그 목록',
tagManageDocCount: '문서 {count}개',
tagManageFaqCount: 'FAQ {count}개',
+ tagPickerSelected: '선택됨',
+ tagPickerUnselected: '선택 안 됨',
tagSelectedCount: '{count}개 선택됨',
tagPickerSearch: "태그 검색 또는 만들기",
tagPickerInUse: "사용 중인 태그입니다. 먼저 문서 연결을 해제하세요.",
diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts
index 51f709490..a758e4d59 100755
--- a/frontend/src/i18n/locales/ru-RU.ts
+++ b/frontend/src/i18n/locales/ru-RU.ts
@@ -6778,6 +6778,8 @@ export default {
tagManageListSection: 'Список тегов',
tagManageDocCount: '{count} документов',
tagManageFaqCount: '{count} записей FAQ',
+ tagPickerSelected: 'Выбранные',
+ tagPickerUnselected: 'Не выбранные',
tagSelectedCount: 'Выбрано: {count}',
tagPickerSearch: "Найти или создать тег",
tagPickerInUse: "Тег используется. Сначала удалите его связи с документами.",
diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts
index 434de9f2c..225744533 100755
--- a/frontend/src/i18n/locales/zh-CN.ts
+++ b/frontend/src/i18n/locales/zh-CN.ts
@@ -6780,6 +6780,8 @@ export default {
tagManageListSection: '标签列表',
tagManageDocCount: '{count} 个文档',
tagManageFaqCount: '{count} 个 FAQ',
+ tagPickerSelected: '已选择',
+ tagPickerUnselected: '未选择',
tagSelectedCount: '已选 {count} 个标签',
tagPickerSearch: "搜索或新建标签",
tagPickerInUse: "此标签仍被使用,请先移除文档上的关联再删除",
diff --git a/frontend/src/utils/resourceListSearch.test.ts b/frontend/src/utils/resourceListSearch.test.ts
new file mode 100644
index 000000000..68720632a
--- /dev/null
+++ b/frontend/src/utils/resourceListSearch.test.ts
@@ -0,0 +1,24 @@
+import assert from 'node:assert/strict'
+import test from 'node:test'
+import { matchesResourceQuery } from './resourceListSearch'
+
+test('search accepts empty queries and resources without descriptions', () => {
+ assert.equal(matchesResourceQuery({ name: '知识库' }, ' '), true)
+ assert.equal(matchesResourceQuery({ name: '知识库' }, '知识'), true)
+ assert.equal(matchesResourceQuery(undefined, '知识'), false)
+})
+
+test('search matches all terms across the visible name and description', () => {
+ const resource = { name: 'Wiki 数据分析', description: 'Sales REPORT' }
+ assert.equal(matchesResourceQuery(resource, ' wiki report '), true)
+ assert.equal(matchesResourceQuery(resource, '数据 分析'), true)
+ assert.equal(matchesResourceQuery(resource, 'wiki missing'), false)
+})
+
+test('filtering preserves references and ordering used by pins and row actions', () => {
+ const rows = [{ name: 'Pinned FAQ' }, { name: 'Wiki' }, { name: 'Other FAQ' }]
+ const result = rows.filter(row => matchesResourceQuery(row, 'faq'))
+ assert.deepEqual(result, [rows[0], rows[2]])
+ assert.equal(result[0], rows[0])
+ assert.equal(result[1], rows[2])
+})
diff --git a/frontend/src/utils/resourceListSearch.ts b/frontend/src/utils/resourceListSearch.ts
new file mode 100644
index 000000000..b94829299
--- /dev/null
+++ b/frontend/src/utils/resourceListSearch.ts
@@ -0,0 +1,7 @@
+/** Match only visible resource metadata; preserve source order and object identity. */
+export function matchesResourceQuery(resource: { name?: string; description?: string } | null | undefined, query: string): boolean {
+ const terms = query.trim().toLocaleLowerCase().split(/\s+/).filter(Boolean)
+ if (!terms.length) return true
+ const text = `${resource?.name ?? ''} ${resource?.description ?? ''}`.toLocaleLowerCase()
+ return terms.every(term => text.includes(term))
+}
diff --git a/frontend/src/views/agent/AgentList.vue b/frontend/src/views/agent/AgentList.vue
index 0391d282e..523c71d46 100644
--- a/frontend/src/views/agent/AgentList.vue
+++ b/frontend/src/views/agent/AgentList.vue
@@ -1,8 +1,5 @@
<template>
<div class="agent-list-container">
- <ListSpaceSidebar v-if="!authStore.isLiteMode" v-model="spaceSelection" :count-all="allAgentsCount"
- :count-mine="agents.length" :count-by-org="effectiveSharedCountByOrg" :count-favorites="agentFavoritesCount"
- :count-recents="agentRecentsCount" />
<div class="agent-list-content">
<div class="header" style="--wails-draggable: drag">
<div class="header-title" style="--wails-draggable: drag">
@@ -30,13 +27,21 @@
</svg>
</span>
</template>
+ {{ $t('agent.createAgent') }}
</t-button>
</t-tooltip>
</div>
<p class="header-subtitle" style="--wails-draggable: drag">{{ $t('agent.subtitle') }}</p>
</div>
</div>
+ <ResourceListToolbar :hide-scopes="authStore.isLiteMode" v-model="spaceSelection" v-model:query="keyword" :count-all="allAgentsCount"
+ :count-mine="agents.length" :count-by-org="effectiveSharedCountByOrg" :count-favorites="agentFavoritesCount"
+ :count-recents="agentRecentsCount" />
<div class="agent-list-main">
+ <EmptyState v-if="keyword.trim() && !(loading || spaceAgentsLoading) && visibleResultCount === 0" icon="search"
+ :title="$t('common.noResult')">
+ <t-button variant="outline" @click="keyword = ''">{{ $t('common.clear') }}</t-button>
+ </EmptyState>
<!-- creator filter removed; see KnowledgeBaseList for rationale.
Card-level creator display + URL-state field are retained. -->
@@ -74,7 +79,7 @@
&& (index === 0
|| !filteredAgents[index - 1].isMine
|| !(filteredAgents[index - 1] as AgentWithUI).is_builtin)" class="agent-section-header" role="button"
- tabindex="0" @click="toggleAgentSection('builtin')"
+ tabindex="0" :aria-expanded="!isAgentSectionCollapsed('builtin')" @click="toggleAgentSection('builtin')"
@keydown.enter.prevent="toggleAgentSection('builtin')"
@keydown.space.prevent="toggleAgentSection('builtin')">
<t-icon name="app" size="14px" />
@@ -94,7 +99,7 @@
|| !filteredAgents[index - 1].isMine
|| (filteredAgents[index - 1] as AgentWithUI).is_builtin
|| !isMyAgent(filteredAgents[index - 1] as AgentWithUI))" class="agent-section-header" role="button"
- tabindex="0" @click="toggleAgentSection('mine')"
+ tabindex="0" :aria-expanded="!isAgentSectionCollapsed('mine')" @click="toggleAgentSection('mine')"
@keydown.enter.prevent="toggleAgentSection('mine')"
@keydown.space.prevent="toggleAgentSection('mine')">
<t-icon name="user" size="14px" />
@@ -112,7 +117,7 @@
|| !filteredAgents[index - 1].isMine
|| (filteredAgents[index - 1] as AgentWithUI).is_builtin
|| isMyAgent(filteredAgents[index - 1] as AgentWithUI))" class="agent-section-header" role="button"
- tabindex="0" @click="toggleAgentSection('tenantOthers')"
+ tabindex="0" :aria-expanded="!isAgentSectionCollapsed('tenantOthers')" @click="toggleAgentSection('tenantOthers')"
@keydown.enter.prevent="toggleAgentSection('tenantOthers')"
@keydown.space.prevent="toggleAgentSection('tenantOthers')">
<t-icon :name="tenantSectionIconName" size="14px" />
@@ -126,7 +131,7 @@
&& !agent.isMine
&& isSharedAgentEditable((agent as any).permission)
&& (index === 0 || filteredAgents[index - 1].isMine)" class="agent-section-header" role="button"
- tabindex="0" @click="toggleAgentSection('sharedEditable')"
+ tabindex="0" :aria-expanded="!isAgentSectionCollapsed('sharedEditable')" @click="toggleAgentSection('sharedEditable')"
@keydown.enter.prevent="toggleAgentSection('sharedEditable')"
@keydown.space.prevent="toggleAgentSection('sharedEditable')">
<t-icon name="usergroup-add" size="14px" />
@@ -143,7 +148,7 @@
&& (index === 0
|| filteredAgents[index - 1].isMine
|| isSharedAgentEditable((filteredAgents[index - 1] as any).permission))" class="agent-section-header"
- role="button" tabindex="0" @click="toggleAgentSection('sharedReadonly')"
+ role="button" tabindex="0" :aria-expanded="!isAgentSectionCollapsed('sharedReadonly')" @click="toggleAgentSection('sharedReadonly')"
@keydown.enter.prevent="toggleAgentSection('sharedReadonly')"
@keydown.space.prevent="toggleAgentSection('sharedReadonly')">
<t-icon name="usergroup-add" size="14px" />
@@ -158,29 +163,11 @@
'agent-mode-normal': agent.config?.agent_mode === 'quick-answer',
'agent-mode-agent': agent.config?.agent_mode === 'smart-reasoning',
'shared-agent-card': !agent.isMine
- }" @click="handleCardClick(agent)">
- <!-- 装饰星星 -->
- <div class="card-decoration">
- <svg class="star-icon" width="24" height="24" viewBox="0 0 20 20" fill="none"
- xmlns="http://www.w3.org/2000/svg">
- <path
- d="M10 3L10.8 6.2C10.9 6.7 11.3 7.1 11.8 7.2L15 8L11.8 8.8C11.3 8.9 10.9 9.3 10.8 9.8L10 13L9.2 9.8C9.1 9.3 8.7 8.9 8.2 8.8L5 8L8.2 7.2C8.7 7.1 9.1 6.7 9.2 6.2L10 3Z"
- stroke="currentColor" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round"
- fill="currentColor" fill-opacity="0.15" />
- </svg>
- <svg class="star-icon small" width="14" height="14" viewBox="0 0 20 20" fill="none"
- xmlns="http://www.w3.org/2000/svg">
- <path
- d="M10 3L10.8 6.2C10.9 6.7 11.3 7.1 11.8 7.2L15 8L11.8 8.8C11.3 8.9 10.9 9.3 10.8 9.8L10 13L9.2 9.8C9.1 9.3 8.7 8.9 8.2 8.8L5 8L8.2 7.2C8.7 7.1 9.1 6.7 9.2 6.2L10 3Z"
- stroke="currentColor" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round"
- fill="currentColor" fill-opacity="0.15" />
- </svg>
- </div>
- <!-- 收藏按钮:浮在卡片右上角;.card-header padding-right 已为
- "更多"按钮腾出空间,避免重叠。 -->
+ }" role="link" tabindex="0" @keydown.enter.self.prevent="handleCardClick(agent)" @keydown.space.self.prevent="handleCardClick(agent)" @click="handleCardClick(agent)">
+ <!-- 行尾收藏操作,与更多菜单分开。 -->
<button type="button" class="agent-favorite-star"
:class="{ 'is-favorited': isAgentFavorited(agent.id) }"
- @click.stop="toggleFavoriteAgent(agent.id, $event)">
+ :aria-label="$t('listSpaceSidebar.favorites')" :aria-pressed="isAgentFavorited(agent.id)" @click.stop="toggleFavoriteAgent(agent.id, $event)">
<t-icon :name="isAgentFavorited(agent.id) ? 'star-filled' : 'star'" size="14px" />
</button>
<div class="card-header">
@@ -196,13 +183,13 @@
</div>
<t-popup
v-if="agent.isMine && (canManageAgent(agent) || authStore.hasRole('contributor') || authStore.hasRole('admin'))"
- :visible="openMoreAgentId === agent.id" trigger="hover" overlayClassName="card-more-popup"
- destroy-on-close placement="bottom-right" @visible-change="onVisibleChange"
- @update:visible="(v: boolean) => { if (!v) openMoreAgentId = null }">
- <div class="more-wrap" :class="{ 'active-more': openMoreAgentId === agent.id }"
- @click="toggleMore($event, agent.id)">
+ :visible="openMoreAgentId === agent.id" trigger="click" overlayClassName="card-more-popup"
+ destroy-on-close placement="bottom-right"
+ @update:visible="(v: boolean) => { openMoreAgentId = v ? agent.id : null }">
+ <button type="button" :aria-label="$t('common.expand')" class="more-wrap" :class="{ 'active-more': openMoreAgentId === agent.id }"
+ @click.stop>
<img class="more-icon" src="@/assets/img/more.png" alt="" />
- </div>
+ </button>
<template #content>
<div class="popup-menu">
<div v-if="canManageAgent(agent)" class="popup-menu-item" @click="handleEdit(agent)"><t-icon
@@ -222,13 +209,13 @@
</template>
</t-popup>
<t-popup v-else-if="!agent.isMine && authStore.hasRole('admin')"
- :visible="openMoreAgentId === 'shared-' + agent.share_id" trigger="hover"
+ :visible="openMoreAgentId === 'shared-' + agent.share_id" trigger="click"
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)">
+ @update:visible="(v: boolean) => { openMoreAgentId = v ? 'shared-' + agent.share_id : null }">
+ <button type="button" :aria-label="$t('common.expand')" class="more-wrap" :class="{ 'active-more': openMoreAgentId === 'shared-' + agent.share_id }"
+ @click.stop>
<img class="more-icon" src="@/assets/img/more.png" alt="" />
- </div>
+ </button>
<template #content>
<div class="popup-menu">
<div class="popup-menu-item" @click="handleToggleSharedDisabled(agent)">
@@ -240,7 +227,8 @@
</t-popup>
</div>
<div class="card-content">
- <div class="card-description">{{ agent.description || $t('agent.noDescription') }}</div>
+ <div class="card-description" :title="agent.description || $t('agent.noDescription')">
+ {{ agent.description || $t('agent.noDescription') }}</div>
</div>
<div class="card-bottom">
<div class="bottom-left">
@@ -314,7 +302,7 @@
<div v-if="showShareGroupHeaders
&& agent.is_builtin
&& (index === 0 || !sortedMineAgents[index - 1].is_builtin)" class="agent-section-header" role="button"
- tabindex="0" @click="toggleAgentSection('builtin')"
+ tabindex="0" :aria-expanded="!isAgentSectionCollapsed('builtin')" @click="toggleAgentSection('builtin')"
@keydown.enter.prevent="toggleAgentSection('builtin')"
@keydown.space.prevent="toggleAgentSection('builtin')">
<t-icon name="app" size="14px" />
@@ -330,7 +318,7 @@
&& (index === 0
|| sortedMineAgents[index - 1].is_builtin
|| !isMyAgent(sortedMineAgents[index - 1]))" class="agent-section-header" role="button"
- tabindex="0" @click="toggleAgentSection('mine')"
+ tabindex="0" :aria-expanded="!isAgentSectionCollapsed('mine')" @click="toggleAgentSection('mine')"
@keydown.enter.prevent="toggleAgentSection('mine')"
@keydown.space.prevent="toggleAgentSection('mine')">
<t-icon name="user" size="14px" />
@@ -346,7 +334,7 @@
&& (index === 0
|| sortedMineAgents[index - 1].is_builtin
|| isMyAgent(sortedMineAgents[index - 1]))" class="agent-section-header" role="button"
- tabindex="0" @click="toggleAgentSection('tenantOthers')"
+ tabindex="0" :aria-expanded="!isAgentSectionCollapsed('tenantOthers')" @click="toggleAgentSection('tenantOthers')"
@keydown.enter.prevent="toggleAgentSection('tenantOthers')"
@keydown.space.prevent="toggleAgentSection('tenantOthers')">
<t-icon :name="tenantSectionIconName" size="14px" />
@@ -359,28 +347,11 @@
'is-builtin': agent.is_builtin,
'agent-mode-normal': agent.config?.agent_mode === 'quick-answer',
'agent-mode-agent': agent.config?.agent_mode === 'smart-reasoning'
- }" @click="handleCardClick(agent)">
- <!-- 装饰星星 -->
- <div class="card-decoration">
- <svg class="star-icon" width="24" height="24" viewBox="0 0 20 20" fill="none"
- xmlns="http://www.w3.org/2000/svg">
- <path
- d="M10 3L10.8 6.2C10.9 6.7 11.3 7.1 11.8 7.2L15 8L11.8 8.8C11.3 8.9 10.9 9.3 10.8 9.8L10 13L9.2 9.8C9.1 9.3 8.7 8.9 8.2 8.8L5 8L8.2 7.2C8.7 7.1 9.1 6.7 9.2 6.2L10 3Z"
- stroke="currentColor" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round"
- fill="currentColor" fill-opacity="0.15" />
- </svg>
- <svg class="star-icon small" width="14" height="14" viewBox="0 0 20 20" fill="none"
- xmlns="http://www.w3.org/2000/svg">
- <path
- d="M10 3L10.8 6.2C10.9 6.7 11.3 7.1 11.8 7.2L15 8L11.8 8.8C11.3 8.9 10.9 9.3 10.8 9.8L10 13L9.2 9.8C9.1 9.3 8.7 8.9 8.2 8.8L5 8L8.2 7.2C8.7 7.1 9.1 6.7 9.2 6.2L10 3Z"
- stroke="currentColor" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round"
- fill="currentColor" fill-opacity="0.15" />
- </svg>
- </div>
+ }" role="link" tabindex="0" @keydown.enter.self.prevent="handleCardClick(agent)" @keydown.space.self.prevent="handleCardClick(agent)" @click="handleCardClick(agent)">
<button type="button" class="agent-favorite-star"
:class="{ 'is-favorited': isAgentFavorited(agent.id) }"
- @click.stop="toggleFavoriteAgent(agent.id, $event)">
+ :aria-label="$t('listSpaceSidebar.favorites')" :aria-pressed="isAgentFavorited(agent.id)" @click.stop="toggleFavoriteAgent(agent.id, $event)">
<t-icon :name="isAgentFavorited(agent.id) ? 'star-filled' : 'star'" size="14px" />
</button>
<!-- 卡片头部 -->
@@ -397,13 +368,13 @@
<span class="card-title" :title="agent.name">{{ agent.name }}</span>
</div>
<t-popup v-if="canManageAgent(agent) || authStore.hasRole('contributor') || authStore.hasRole('admin')"
- :visible="openMoreAgentId === agent.id" trigger="hover" overlayClassName="card-more-popup"
- destroy-on-close placement="bottom-right" @visible-change="onVisibleChange"
- @update:visible="(v: boolean) => { if (!v) openMoreAgentId = null }">
- <div class="more-wrap" :class="{ 'active-more': openMoreAgentId === agent.id }"
- @click="toggleMore($event, agent.id)">
+ :visible="openMoreAgentId === agent.id" trigger="click" overlayClassName="card-more-popup"
+ destroy-on-close placement="bottom-right"
+ @update:visible="(v: boolean) => { openMoreAgentId = v ? agent.id : null }">
+ <button type="button" :aria-label="$t('common.expand')" class="more-wrap" :class="{ 'active-more': openMoreAgentId === agent.id }"
+ @click.stop>
<img class="more-icon" src="@/assets/img/more.png" alt="" />
- </div>
+ </button>
<template #content>
<div class="popup-menu">
<div v-if="canManageAgent(agent)" class="popup-menu-item" @click="handleEdit(agent)">
@@ -431,7 +402,7 @@
<!-- 卡片内容 -->
<div class="card-content">
- <div class="card-description">
+ <div class="card-description" :title="agent.description || $t('agent.noDescription')">
{{ agent.description || $t('agent.noDescription') }}
</div>
</div>
@@ -502,7 +473,7 @@
<template v-for="(shared, index) in sortedSpaceAgentsList" :key="'shared-' + shared.share_id">
<!-- 我共享的:当前用户共享进本空间的智能体,只在首条 is_mine 上挂标题 -->
<div v-if="showShareGroupHeaders && shared.is_mine && index === 0" class="agent-section-header"
- role="button" tabindex="0" @click="toggleAgentSection('sharedByMe')"
+ role="button" tabindex="0" :aria-expanded="!isAgentSectionCollapsed('sharedByMe')" @click="toggleAgentSection('sharedByMe')"
@keydown.enter.prevent="toggleAgentSection('sharedByMe')"
@keydown.space.prevent="toggleAgentSection('sharedByMe')">
<t-icon name="share" size="14px" />
@@ -516,7 +487,7 @@
&& !shared.is_mine
&& isSharedAgentEditable(shared.permission)
&& (index === 0 || sortedSpaceAgentsList[index - 1].is_mine)" class="agent-section-header" role="button"
- tabindex="0" @click="toggleAgentSection('sharedEditable')"
+ tabindex="0" :aria-expanded="!isAgentSectionCollapsed('sharedEditable')" @click="toggleAgentSection('sharedEditable')"
@keydown.enter.prevent="toggleAgentSection('sharedEditable')"
@keydown.space.prevent="toggleAgentSection('sharedEditable')">
<t-icon name="usergroup-add" size="14px" />
@@ -533,7 +504,7 @@
&& (index === 0
|| sortedSpaceAgentsList[index - 1].is_mine
|| isSharedAgentEditable(sortedSpaceAgentsList[index - 1].permission))" class="agent-section-header"
- role="button" tabindex="0" @click="toggleAgentSection('sharedReadonly')"
+ role="button" tabindex="0" :aria-expanded="!isAgentSectionCollapsed('sharedReadonly')" @click="toggleAgentSection('sharedReadonly')"
@keydown.enter.prevent="toggleAgentSection('sharedReadonly')"
@keydown.space.prevent="toggleAgentSection('sharedReadonly')">
<t-icon name="usergroup-add" size="14px" />
@@ -546,23 +517,7 @@
<div v-show="!isSpaceAgentCollapsed(shared)" class="agent-card shared-agent-card" :class="{
'agent-mode-normal': shared.agent?.config?.agent_mode === 'quick-answer',
'agent-mode-agent': shared.agent?.config?.agent_mode === 'smart-reasoning'
- }" @click="handleSpaceAgentCardClick(shared)">
- <div class="card-decoration">
- <svg class="star-icon" width="24" height="24" viewBox="0 0 20 20" fill="none"
- xmlns="http://www.w3.org/2000/svg">
- <path
- d="M10 3L10.8 6.2C10.9 6.7 11.3 7.1 11.8 7.2L15 8L11.8 8.8C11.3 8.9 10.9 9.3 10.8 9.8L10 13L9.2 9.8C9.1 9.3 8.7 8.9 8.2 8.8L5 8L8.2 7.2C8.7 7.1 9.1 6.7 9.2 6.2L10 3Z"
- stroke="currentColor" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round"
- fill="currentColor" fill-opacity="0.15" />
- </svg>
- <svg class="star-icon small" width="14" height="14" viewBox="0 0 20 20" fill="none"
- xmlns="http://www.w3.org/2000/svg">
- <path
- d="M10 3L10.8 6.2C10.9 6.7 11.3 7.1 11.8 7.2L15 8L11.8 8.8C11.3 8.9 10.9 9.3 10.8 9.8L10 13L9.2 9.8C9.1 9.3 8.7 8.9 8.2 8.8L5 8L8.2 7.2C8.7 7.1 9.1 6.7 9.2 6.2L10 3Z"
- stroke="currentColor" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round"
- fill="currentColor" fill-opacity="0.15" />
- </svg>
- </div>
+ }" role="link" tabindex="0" @keydown.enter.self.prevent="handleSpaceAgentCardClick(shared)" @keydown.space.self.prevent="handleSpaceAgentCardClick(shared)" @click="handleSpaceAgentCardClick(shared)">
<div class="card-header">
<div class="card-header-left">
<div v-if="shared.agent?.avatar" class="builtin-avatar agent-emoji">{{ shared.agent.avatar }}</div>
@@ -570,13 +525,13 @@
<span class="card-title" :title="shared.agent?.name">{{ shared.agent?.name }}</span>
</div>
<t-popup v-if="!shared.is_mine && authStore.hasRole('admin')"
- :visible="openMoreAgentId === 'shared-tab-' + shared.share_id" trigger="hover"
+ :visible="openMoreAgentId === 'shared-tab-' + shared.share_id" trigger="click"
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)">
+ @update:visible="(v: boolean) => { openMoreAgentId = v ? 'shared-tab-' + shared.share_id : null }">
+ <button type="button" :aria-label="$t('common.expand')" class="more-wrap" :class="{ 'active-more': openMoreAgentId === 'shared-tab-' + shared.share_id }"
+ @click.stop>
<img class="more-icon" src="@/assets/img/more.png" alt="" />
- </div>
+ </button>
<template #content>
<div class="popup-menu">
<div class="popup-menu-item" @click="handleToggleSharedDisabledFromShared(shared)">
@@ -588,7 +543,8 @@
</t-popup>
</div>
<div class="card-content">
- <div class="card-description">{{ shared.agent?.description || $t('agent.noDescription') }}</div>
+ <div class="card-description" :title="shared.agent?.description || $t('agent.noDescription')">
+ {{ shared.agent?.description || $t('agent.noDescription') }}</div>
</div>
<div class="card-bottom">
<div class="bottom-left">
@@ -637,7 +593,7 @@
</div>
<!-- 空状态:全部(保留创建 CTA) -->
- <EmptyState v-if="spaceSelection === 'all' && filteredAgents.length === 0 && !loading" icon="chat-bubble-1" :title="$t('agent.empty.title')"
+ <EmptyState v-if="!keyword.trim() && spaceSelection === 'all' && filteredAgents.length === 0 && !loading" icon="chat-bubble-1" :title="$t('agent.empty.title')"
:description="$t('agent.empty.description')">
<t-button v-if="authStore.hasRole('contributor')" theme="primary" class="agent-create-btn"
data-guide="agent-list-create" @click="handleCreateAgent">
@@ -665,12 +621,12 @@
</EmptyState>
<!-- 空状态:收藏 / 最近 — 不放创建按钮,参见 KnowledgeBaseList 的同处理由 -->
- <EmptyState v-if="spaceSelection === 'favorites' && filteredAgents.length === 0 && !loading" icon="star" :title="$t('agent.empty.favoritesTitle')"
+ <EmptyState v-if="!keyword.trim() && spaceSelection === 'favorites' && filteredAgents.length === 0 && !loading" icon="star" :title="$t('agent.empty.favoritesTitle')"
:description="$t('agent.empty.favoritesDescription')" />
- <EmptyState v-if="spaceSelection === 'recents' && filteredAgents.length === 0 && !loading" icon="history" :title="$t('agent.empty.recentsTitle')"
+ <EmptyState v-if="!keyword.trim() && spaceSelection === 'recents' && filteredAgents.length === 0 && !loading" icon="history" :title="$t('agent.empty.recentsTitle')"
:description="$t('agent.empty.recentsDescription')" />
<!-- 空状态:我的 -->
- <EmptyState v-if="spaceSelection === 'mine' && agents.length === 0 && !loading" icon="chat-bubble-1" :title="$t('agent.empty.title')"
+ <EmptyState v-if="!keyword.trim() && spaceSelection === 'mine' && agents.length === 0 && !loading" icon="chat-bubble-1" :title="$t('agent.empty.title')"
:description="$t('agent.empty.description')">
<t-button v-if="authStore.hasRole('contributor')" theme="primary" class="agent-create-btn"
@click="handleCreateAgent">
@@ -697,7 +653,7 @@
</t-button>
</EmptyState>
<!-- 空状态:空间下 -->
- <EmptyState v-if="spaceSelectionOrgId && !spaceAgentsLoading && spaceAgentsList.length === 0" icon="chat-bubble-1" :title="$t('agent.empty.sharedTitle')"
+ <EmptyState v-if="!keyword.trim() && spaceSelectionOrgId && !spaceAgentsLoading && spaceAgentsList.length === 0" icon="chat-bubble-1" :title="$t('agent.empty.sharedTitle')"
:description="$t('agent.empty.sharedDescription')" />
</div>
</div>
@@ -803,7 +759,8 @@ import { focusAgentEditorSection, markContextualGuideDone } from '@/config/conte
import { useTenantModelReadiness } from '@/composables/useTenantModelReadiness'
import { useUIStore } from '@/stores/ui'
import AgentAvatar from '@/components/AgentAvatar.vue'
-import ListSpaceSidebar from '@/components/ListSpaceSidebar.vue'
+import ResourceListToolbar from '@/components/ResourceListToolbar.vue'
+import { matchesResourceQuery } from '@/utils/resourceListSearch'
import ResourceOriginBadge from '@/components/ResourceOriginBadge.vue'
import { shouldShowResourceOriginBadge } from '@/utils/card-list-badge'
import { useAuthStore } from '@/stores/auth'
@@ -836,9 +793,9 @@ type DisplayAgent = (AgentWithUI & { isMine: true }) | (CustomAgent & { isMine:
// 默认落到 "all" 才能看到内置 + 共享给我的;Contributor 以上仍默认 "mine"。
// State synced to `?scope=` so links are shareable. The "mine" value is
// retained for back-compat with existing links; its display label is
-// rebranded to the active tenant name inside ListSpaceSidebar.
+// shown as the current workspace in ResourceListToolbar.
const defaultScope: 'all' | 'mine' = authStore.hasRole('contributor') ? 'mine' : 'all'
-const { scope: spaceSelection, creator: creatorFilter } = useListUrlState({
+const { scope: spaceSelection, creator: creatorFilter, query: keyword } = useListUrlState({
defaultScope,
defaultCreator: 'all',
})
@@ -856,7 +813,7 @@ const sharedAgents = computed<SharedAgentInfo[]>(() => orgStore.sharedAgents ||
const allAgentsCount = computed(() => agents.value.length + sharedAgents.value.length)
// Same gotcha as KnowledgeBaseList: keep the reserved-scope set in sync
-// with ListSpaceSidebar's pseudo-scopes (favorites / recents / shared /
+// with ResourceListToolbar's pseudo-scopes (favorites / recents / shared /
// mine / all). Anything not in here is treated as an org/space id, which
// is what triggers the per-space fetch + "no shared agents" empty state.
const RESERVED_SCOPES = new Set(['all', 'mine', 'shared', 'favorites', 'recents'])
@@ -950,7 +907,7 @@ const recentsAgentList = computed<DisplayAgent[]>(() => {
.filter((x): x is DisplayAgent => x !== null)
})
-const filteredAgents = computed<DisplayAgent[]>(() => {
+const unsearchedFilteredAgents = computed<DisplayAgent[]>(() => {
if (spaceSelection.value === 'favorites') return favoritesAgentList.value
if (spaceSelection.value === 'recents') return recentsAgentList.value
if (spaceSelection.value === 'mine') {
@@ -997,10 +954,11 @@ const filteredAgents = computed<DisplayAgent[]>(() => {
})
return list
})
+const filteredAgents = computed(() => unsearchedFilteredAgents.value.filter(item => matchesResourceQuery(item, keyword.value)))
// 「工作空间」视图下的稳定排序:本空间内「我创建」在前、「同事创建 / 内建」
// 在后。给 contributor 视图把「本空间 · 仅查看」分组标题正好插在过渡处。
-const sortedMineAgents = computed(() => {
+const unsearchedSortedMineAgents = computed(() => {
// 内置 → 我创建 → 同事创建。与 filteredAgents 的"全部"视图保持同序。
const builtin: AgentWithUI[] = []
const own: AgentWithUI[] = []
@@ -1012,9 +970,10 @@ const sortedMineAgents = computed(() => {
})
return [...builtin, ...own, ...teammate]
})
+const sortedMineAgents = computed(() => unsearchedSortedMineAgents.value.filter(item => matchesResourceQuery(item, keyword.value)))
// 空间视角下的稳定排序:我自己创建的(is_mine)放前面,其余按 permission 切分。
-const sortedSpaceAgentsList = computed(() => {
+const unsearchedSortedSpaceAgentsList = computed(() => {
return [...spaceAgentsList.value].sort((a, b) => {
const aMine = a.is_mine ? 0 : 1
const bMine = b.is_mine ? 0 : 1
@@ -1024,6 +983,7 @@ const sortedSpaceAgentsList = computed(() => {
return aE - bE
})
})
+const sortedSpaceAgentsList = computed(() => unsearchedSortedSpaceAgentsList.value.filter(item => matchesResourceQuery(item.agent, keyword.value)))
const loading = ref(false)
const confirmDelete = useConfirmDelete()
const sharedDetailVisible = ref(false)
@@ -1056,7 +1016,7 @@ const editorInitialHighlightField = ref<string>('')
const openMoreAgentId = ref<string | null>(null)
const showAgentListEmpty = computed(() => {
- if (loading.value) return false
+ if (loading.value || keyword.value.trim()) return false
if (!authStore.hasRole('contributor')) return false
if (spaceSelection.value === 'all' && filteredAgents.value.length === 0) return true
if (spaceSelection.value === 'mine' && agents.value.length === 0) return true
@@ -1217,16 +1177,6 @@ onUnmounted(() => {
window.removeEventListener('openAgentEditor', handleOpenAgentEditor as EventListener)
})
-const onVisibleChange = (visible: boolean) => {
- if (!visible) {
- openMoreAgentId.value = null
- }
-}
-
-const toggleMore = (e: Event, agentId: string) => {
- e.stopPropagation()
- openMoreAgentId.value = openMoreAgentId.value === agentId ? null : agentId
-}
const handleCardClick = (agent: DisplayAgent | AgentWithUI) => {
if (openMoreAgentId.value === agent.id) return
@@ -1575,40 +1525,25 @@ const handleCreateAgent = () => {
defineExpose({
openCreateModal
})
+const visibleResultCount = computed(() => spaceSelection.value === 'mine' ? sortedMineAgents.value.length : spaceSelectionOrgId.value ? sortedSpaceAgentsList.value.length : filteredAgents.value.length)
+// A new search reveals matching rows even if their group was previously collapsed.
+watch(keyword, () => { collapsedAgentSections.value = new Set() })
</script>
<style scoped lang="less">
@import (reference) '@/components/css/resource-card.less';
.agent-list-container {
- margin: 0;
- height: 100%;
- box-sizing: border-box;
flex: 1;
- display: flex;
- position: relative;
+ min-width: 0;
min-height: 0;
-}
-
-.agent-list-content {
- flex: 1;
+ height: 100%;
display: flex;
- flex-direction: column;
- min-width: 0;
- // 右侧不留 padding,让滚动条贴到内容区最右缘;内边距改到 header / main 内部
- padding: 20px 0 0 28px;
}
-.agent-list-main {
- flex: 1;
- min-width: 0;
- overflow-y: auto;
- overflow-x: hidden;
- // 同 KB 列表:顶部去掉 padding,让 sticky 分组标题贴到容器最顶。
- padding: 0 28px 8px 0;
- scrollbar-width: auto;
- scrollbar-color: auto;
-}
+.agent-list-content { .resource-list-content(); }
+
+.agent-list-main { .resource-list-main(); }
.agent-list-main-loading {
display: flex;
@@ -1780,74 +1715,7 @@ defineExpose({
// 共享给我 · 可编辑 / 仅查看 分组标题,与 KB 列表 .kb-section-header 对齐。
.agent-section-header {
- grid-column: 1 / -1;
- display: flex;
- align-items: center;
- gap: 6px;
- // 整行只用来铺背景;点击靠子元素冒泡,避免点到标题右侧空白误折叠。
- pointer-events: none;
-
- & > * {
- pointer-events: auto;
- }
- // 同 KB 列表:下滑到当前分组时标题吸顶到滚动容器顶部,box-shadow 向上/
- // 向下延伸背景以封掉 sticky 边缘的 subpixel 残缝。
- position: sticky;
- top: 0;
- z-index: 5;
- background: var(--td-bg-color-container);
- box-shadow: 0 -8px 0 0 var(--td-bg-color-container),
- 0 4px 0 0 var(--td-bg-color-container);
- padding: 6px 4px 6px 0;
- color: var(--td-text-color-secondary);
- font-family: var(--app-font-family);
- font-size: var(--app-text-md);
- font-weight: 600;
- line-height: 20px;
- cursor: pointer;
- user-select: none;
- outline: none;
-
- &:hover {
- color: var(--td-text-color-primary);
- }
-
- &:focus-visible {
- box-shadow: 0 0 0 2px var(--td-brand-color-focus);
- }
-
- .t-icon {
- color: inherit;
- }
-
- .agent-section-toggle {
- margin-left: 4px;
- opacity: 0.7;
- transition: opacity var(--app-motion-fast) ease;
- }
-
- // 共享给我的两个子分组:主图标 usergroup-add 表达"共享"语义,
- // 子图标 (edit / browse) 紧挨主图标用来区分权限。
- .agent-section-subicon {
- margin-left: -4px;
- opacity: 0.75;
- }
-
- // 与 KB 列表口径一致:组里的卡片数量徽标。
- .agent-section-count {
- margin-left: 2px;
- padding: 0 6px;
- border-radius: var(--app-radius-md);
- background: var(--td-bg-color-secondarycontainer);
- color: var(--td-text-color-secondary);
- font-size: var(--app-text-xs);
- line-height: 16px;
- font-weight: 500;
- }
-
- &:hover .agent-section-toggle {
- opacity: 1;
- }
+ .resource-section-header();
}
@@ -1867,85 +1735,15 @@ defineExpose({
.resource-card-grid();
}
-/* 与知识库列表卡片统一尺寸:紧凑行高、148px 卡片高 */
+// 共享卡片尺寸与交互。
.agent-card {
.resource-card();
- .agent-favorite-star {
- // 浮在卡片右上角顶角。卡片自身有 padding,"更多"按钮在 header flex
- // 末端自然落在 padding 内部,与零位的 star 错开。
- position: absolute;
- top: 0;
- right: 0;
- z-index: 3;
- width: 24px;
- height: 24px;
- display: flex;
- align-items: center;
- justify-content: center;
- background: transparent;
- border: none;
- border-radius: var(--app-radius-sm);
- color: var(--td-text-color-secondary);
- cursor: pointer;
- opacity: 0;
- transition: opacity var(--app-motion-fast) ease, background var(--app-motion-fast) ease, color var(--app-motion-fast) ease;
-
- &:hover {
- background: var(--td-bg-color-secondarycontainer);
- color: var(--td-warning-color);
- }
-
- &.is-favorited {
- opacity: 1;
- color: var(--td-warning-color);
- }
- }
-
- &:hover .agent-favorite-star {
- opacity: 1;
- }
-
- // 普通模式样式
- &.agent-mode-normal {
- background: linear-gradient(135deg, var(--td-bg-color-container) 0%, color-mix(in srgb, var(--td-brand-color) 4%, transparent) 100%);
-
- &:hover {
- border-color: var(--td-brand-color);
- background: linear-gradient(135deg, var(--td-bg-color-container) 0%, color-mix(in srgb, var(--td-brand-color) 8%, transparent) 100%);
- }
-
- .card-decoration {
- color: color-mix(in srgb, var(--td-brand-color) 35%, transparent);
- }
-
- &:hover .card-decoration {
- color: color-mix(in srgb, var(--td-brand-color) 50%, transparent);
- }
- }
-
- // Agent 模式样式
- &.agent-mode-agent {
- background: linear-gradient(135deg, var(--td-bg-color-container) 0%, color-mix(in srgb, var(--app-accent-purple) 4%, transparent) 100%);
-
- &:hover {
- border-color: var(--td-brand-color);
- box-shadow: 0 4px 12px color-mix(in srgb, var(--app-accent-purple) 12%, transparent);
- background: linear-gradient(135deg, var(--td-bg-color-container) 0%, color-mix(in srgb, var(--app-accent-purple) 8%, transparent) 100%);
- }
-
- .card-decoration {
- color: color-mix(in srgb, var(--app-accent-purple) 35%, transparent);
- }
-
- &:hover .card-decoration {
- color: color-mix(in srgb, var(--app-accent-purple) 50%, transparent);
- }
- }
+ .agent-favorite-star { .resource-favorite-button(); }
.builtin-avatar {
- width: 32px;
- height: 32px;
+ width: 28px;
+ height: 28px;
border-radius: var(--app-radius-md);
}
@@ -1956,26 +1754,7 @@ defineExpose({
}
}
-.card-decoration {
- position: absolute;
- top: 12px;
- right: 44px;
- display: flex;
- align-items: flex-start;
- gap: 4px;
- pointer-events: none;
- z-index: 0;
- transition: color 0.25s ease;
-
- .star-icon {
- opacity: 0.9;
- &.small {
- margin-top: 10px;
- opacity: 0.7;
- }
- }
-}
.builtin-badge {
display: inline-flex;
@@ -2074,11 +1853,11 @@ defineExpose({
}
&.knowledge {
- background: color-mix(in srgb, var(--td-brand-color) 8%, transparent);
- color: var(--td-brand-color-active);
+ background: var(--td-bg-color-secondarycontainer);
+ color: var(--td-text-color-secondary);
&:hover {
- background: color-mix(in srgb, var(--td-brand-color) 12%, transparent);
+ background: var(--td-bg-color-container-hover);
}
}
@@ -2101,42 +1880,18 @@ defineExpose({
}
}
-// 响应式布局
-@media (min-width: 900px) {
- .agent-card-wrap {
- grid-template-columns: repeat(2, 1fr);
- }
-}
-
-@media (min-width: 1250px) {
- .agent-card-wrap {
- grid-template-columns: repeat(3, 1fr);
- }
-}
-
-@media (min-width: 1600px) {
- .agent-card-wrap {
- grid-template-columns: repeat(4, 1fr);
- }
-}
-
-@media (min-width: 1900px) {
- .agent-card-wrap {
- grid-template-columns: repeat(5, 1fr);
- }
-}
-
-@media (min-width: 2200px) {
- .agent-card-wrap {
- grid-template-columns: repeat(6, 1fr);
- }
-}
// 删除确认对话框样式
:deep(.t-dialog__position.t-dialog--top) {
padding-top: 40vh !important;
}
+
+.resource-list-header();
+@media (prefers-reduced-motion: reduce) {
+ .agent-card-wrap { animation: none; }
+}
+
</style>
<style lang="less">
diff --git a/frontend/src/views/knowledge/KnowledgeBaseList.vue b/frontend/src/views/knowledge/KnowledgeBaseList.vue
index 792be2260..9057958a0 100644
--- a/frontend/src/views/knowledge/KnowledgeBaseList.vue
+++ b/frontend/src/views/knowledge/KnowledgeBaseList.vue
@@ -1,8 +1,5 @@
<template>
<div class="kb-list-container">
- <ListSpaceSidebar v-if="!authStore.isLiteMode" v-model="spaceSelection" :count-all="allKnowledgeBases"
- :count-mine="kbs.length" :count-by-org="effectiveSharedCountByOrg" :count-favorites="kbFavoritesCount"
- :count-recents="kbRecentsCount" />
<div class="kb-list-content">
<div class="header" style="--wails-draggable: drag">
<div class="header-title" style="--wails-draggable: drag">
@@ -12,13 +9,21 @@
<t-button variant="text" theme="default" size="small" class="header-action-btn"
data-guide="kb-list-create" style="--wails-draggable: no-drag" @click="handleCreateKnowledgeBase">
<template #icon><t-icon name="folder-add" size="16px" /></template>
+ {{ $t('knowledgeList.create') }}
</t-button>
</t-tooltip>
</div>
<p class="header-subtitle" style="--wails-draggable: drag">{{ $t('knowledgeList.subtitle') }}</p>
</div>
</div>
+ <ResourceListToolbar :hide-scopes="authStore.isLiteMode" v-model="spaceSelection" v-model:query="keyword" :count-all="allKnowledgeBases"
+ :count-mine="kbs.length" :count-by-org="effectiveSharedCountByOrg" :count-favorites="kbFavoritesCount"
+ :count-recents="kbRecentsCount" />
<div class="kb-list-main">
+ <EmptyState v-if="keyword.trim() && !(loading || spaceKbsLoading) && visibleResultCount === 0" icon="search"
+ :title="$t('common.noResult')">
+ <t-button variant="outline" @click="keyword = ''">{{ $t('common.clear') }}</t-button>
+ </EmptyState>
<!-- creator filter intentionally removed from chrome: every card
already shows its creator via ResourceOriginBadge / avatar, so
a dedicated horizontal switch added more noise than signal.
@@ -58,7 +63,7 @@
<div
v-if="filteredKnowledgeBases[0] && filteredKnowledgeBases[0].isMine && filteredKnowledgeBases[0].is_pinned"
class="kb-section-header kb-section-header-pinned" role="button" tabindex="0"
- @click="toggleKbSection('pinned')"
+ :aria-expanded="!isKbSectionCollapsed('pinned')" @click="toggleKbSection('pinned')"
@keydown.enter.prevent="toggleKbSection('pinned')"
@keydown.space.prevent="toggleKbSection('pinned')">
<t-icon name="pin-filled" size="14px" />
@@ -82,7 +87,7 @@
&& !kb.is_pinned
&& (index === 0
|| (filteredKnowledgeBases[index - 1] as any).is_pinned)" class="kb-section-header" role="button"
- tabindex="0" @click="toggleKbSection('mine')"
+ tabindex="0" :aria-expanded="!isKbSectionCollapsed('mine')" @click="toggleKbSection('mine')"
@keydown.enter.prevent="toggleKbSection('mine')"
@keydown.space.prevent="toggleKbSection('mine')">
<t-icon name="user" size="14px" />
@@ -103,7 +108,7 @@
|| !filteredKnowledgeBases[index - 1].isMine
|| isMyKb(filteredKnowledgeBases[index - 1] as KB)
|| (filteredKnowledgeBases[index - 1] as any).is_pinned)" class="kb-section-header" role="button"
- tabindex="0" @click="toggleKbSection('tenantOthers')"
+ tabindex="0" :aria-expanded="!isKbSectionCollapsed('tenantOthers')" @click="toggleKbSection('tenantOthers')"
@keydown.enter.prevent="toggleKbSection('tenantOthers')"
@keydown.space.prevent="toggleKbSection('tenantOthers')">
<t-icon :name="tenantSectionIconName" size="14px" />
@@ -117,7 +122,7 @@
&& !kb.isMine
&& isSharedKbEditable((kb as any).permission)
&& (index === 0 || filteredKnowledgeBases[index - 1].isMine)" class="kb-section-header" role="button"
- tabindex="0" @click="toggleKbSection('sharedEditable')"
+ tabindex="0" :aria-expanded="!isKbSectionCollapsed('sharedEditable')" @click="toggleKbSection('sharedEditable')"
@keydown.enter.prevent="toggleKbSection('sharedEditable')"
@keydown.space.prevent="toggleKbSection('sharedEditable')">
<t-icon name="usergroup-add" size="14px" />
@@ -134,7 +139,7 @@
&& (index === 0
|| filteredKnowledgeBases[index - 1].isMine
|| isSharedKbEditable((filteredKnowledgeBases[index - 1] as any).permission))"
- class="kb-section-header" role="button" tabindex="0" @click="toggleKbSection('sharedReadonly')"
+ class="kb-section-header" role="button" tabindex="0" :aria-expanded="!isKbSectionCollapsed('sharedReadonly')" @click="toggleKbSection('sharedReadonly')"
@keydown.enter.prevent="toggleKbSection('sharedReadonly')"
@keydown.space.prevent="toggleKbSection('sharedReadonly')">
<t-icon name="usergroup-add" size="14px" />
@@ -152,11 +157,10 @@
'highlight-flash': highlightedKbId !== null && highlightedKbId === kb.id
}"
:ref="el => { if (highlightedKbId !== null && highlightedKbId === kb.id && el) highlightedCardRef = el as HTMLElement }"
- @click="handleCardClick(kb)">
- <!-- 收藏按钮:右上角浮动;通过 .card-header 的 padding-right
- 给「更多」按钮腾出空间,避免两个按钮叠在一起。 -->
+ role="link" tabindex="0" @keydown.enter.self.prevent="handleCardClick(kb)" @keydown.space.self.prevent="handleCardClick(kb)" @click="handleCardClick(kb)">
+ <!-- 行尾收藏操作,与更多菜单分开。 -->
<button type="button" class="kb-favorite-star" :class="{ 'is-favorited': isKbFavorited(kb.id) }"
- @click.stop="toggleFavoriteKb(kb.id, $event)">
+ :aria-label="$t('listSpaceSidebar.favorites')" :aria-pressed="isKbFavorited(kb.id)" @click.stop="toggleFavoriteKb(kb.id, $event)">
<t-icon :name="isKbFavorited(kb.id) ? 'star-filled' : 'star'" size="14px" />
</button>
<!-- 卡片头部 -->
@@ -171,9 +175,9 @@
Delete are mutations, so they stay behind canManageKBCard. -->
<t-popup overlayClassName="card-more-popup" trigger="click" destroy-on-close
placement="bottom-right">
- <div class="more-wrap" @click.stop>
+ <button type="button" :aria-label="$t('common.expand')" class="more-wrap" @click.stop>
<img class="more-icon" src="@/assets/img/more.png" alt="" />
- </div>
+ </button>
<template #content>
<div class="popup-menu" @click.stop>
<div class="popup-menu-item" @click.stop="handleTogglePinById(kb.id)">
@@ -202,7 +206,7 @@
<!-- 卡片内容 -->
<div class="card-content">
- <div class="card-description">
+ <div class="card-description" :title="kb.description || $t('knowledgeBase.noDescription')">
{{ kb.description || $t('knowledgeBase.noDescription') }}
</div>
</div>
@@ -258,9 +262,9 @@
<div v-else v-show="!isKbSectionCollapsed(kbSectionOf(kb))" class="kb-card shared-kb-card" :class="{
'kb-type-document': (kb.type || 'document') === 'document',
'kb-type-faq': kb.type === 'faq'
- }" @click="handleSharedKbClickFromAll(kb)">
+ }" role="link" tabindex="0" @keydown.enter.self.prevent="handleSharedKbClickFromAll(kb)" @keydown.space.self.prevent="handleSharedKbClickFromAll(kb)" @click="handleSharedKbClickFromAll(kb)">
<button type="button" class="kb-favorite-star" :class="{ 'is-favorited': isKbFavorited(kb.id) }"
- @click.stop="toggleFavoriteKb(kb.id, $event)">
+ :aria-label="$t('listSpaceSidebar.favorites')" :aria-pressed="isKbFavorited(kb.id)" @click.stop="toggleFavoriteKb(kb.id, $event)">
<t-icon :name="isKbFavorited(kb.id) ? 'star-filled' : 'star'" size="14px" />
</button>
<!-- 卡片头部 -->
@@ -279,7 +283,7 @@
<!-- 卡片内容 -->
<div class="card-content">
- <div class="card-description">
+ <div class="card-description" :title="kb.description || $t('knowledgeBase.noDescription')">
{{ kb.description || $t('knowledgeBase.noDescription') }}
</div>
</div>
@@ -337,7 +341,7 @@
<div v-if="spaceSelection === 'mine' && sortedMineKbs.length > 0" class="kb-card-wrap">
<!-- 置顶分组标题 -->
<div v-if="sortedMineKbs[0] && sortedMineKbs[0].is_pinned" class="kb-section-header kb-section-header-pinned"
- role="button" tabindex="0" @click="toggleKbSection('pinned')"
+ role="button" tabindex="0" :aria-expanded="!isKbSectionCollapsed('pinned')" @click="toggleKbSection('pinned')"
@keydown.enter.prevent="toggleKbSection('pinned')"
@keydown.space.prevent="toggleKbSection('pinned')">
<t-icon name="pin-filled" size="14px" />
@@ -356,7 +360,7 @@
&& isMyKb(kb)
&& !kb.is_pinned
&& (index === 0 || sortedMineKbs[index - 1].is_pinned)" class="kb-section-header" role="button"
- tabindex="0" @click="toggleKbSection('mine')"
+ tabindex="0" :aria-expanded="!isKbSectionCollapsed('mine')" @click="toggleKbSection('mine')"
@keydown.enter.prevent="toggleKbSection('mine')"
@keydown.space.prevent="toggleKbSection('mine')">
<t-icon name="user" size="14px" />
@@ -373,7 +377,7 @@
&& (index === 0
|| isMyKb(sortedMineKbs[index - 1])
|| sortedMineKbs[index - 1].is_pinned)" class="kb-section-header" role="button" tabindex="0"
- @click="toggleKbSection('tenantOthers')"
+ :aria-expanded="!isKbSectionCollapsed('tenantOthers')" @click="toggleKbSection('tenantOthers')"
@keydown.enter.prevent="toggleKbSection('tenantOthers')"
@keydown.space.prevent="toggleKbSection('tenantOthers')">
<t-icon :name="tenantSectionIconName" size="14px" />
@@ -389,9 +393,9 @@
'highlight-flash': highlightedKbId !== null && highlightedKbId === kb.id
}"
:ref="el => { if (highlightedKbId !== null && highlightedKbId === kb.id && el) highlightedCardRef = el as HTMLElement }"
- @click="handleCardClick(kb)">
+ role="link" tabindex="0" @keydown.enter.self.prevent="handleCardClick(kb)" @keydown.space.self.prevent="handleCardClick(kb)" @click="handleCardClick(kb)">
<button type="button" class="kb-favorite-star" :class="{ 'is-favorited': isKbFavorited(kb.id) }"
- @click.stop="toggleFavoriteKb(kb.id, $event)">
+ :aria-label="$t('listSpaceSidebar.favorites')" :aria-pressed="isKbFavorited(kb.id)" @click.stop="toggleFavoriteKb(kb.id, $event)">
<t-icon :name="isKbFavorited(kb.id) ? 'star-filled' : 'star'" size="14px" />
</button>
<!-- 卡片头部 -->
@@ -404,10 +408,10 @@
this is no longer gated by canManageKBCard. -->
<t-popup v-model="kb.showMore" overlayClassName="card-more-popup"
:on-visible-change="onVisibleChange" trigger="click" destroy-on-close placement="bottom-right">
- <div variant="outline" class="more-wrap" @click.stop="openMore(index)"
+ <button type="button" :aria-label="$t('common.expand')" class="more-wrap" @click.stop="openMore(index)"
:class="{ 'active-more': currentMoreIndex === index }">
<img class="more-icon" src="@/assets/img/more.png" alt="" />
- </div>
+ </button>
<template #content>
<div class="popup-menu" @click.stop>
<div class="popup-menu-item" @click.stop="handleTogglePin(kb)">
@@ -435,7 +439,7 @@
<!-- 卡片内容 -->
<div class="card-content">
- <div class="card-description">
+ <div class="card-description" :title="kb.description || $t('knowledgeBase.noDescription')">
{{ kb.description || $t('knowledgeBase.noDescription') }}
</div>
</div>
@@ -502,7 +506,7 @@
:key="'shared-' + (shared.share_id || `agent-${shared.knowledge_base?.id}-${shared.source_from_agent?.agent_id || ''}`)">
<!-- 我共享的:本空间下我自己创建并共享进来的条目,只在第一条 is_mine 上挂标题 -->
<div v-if="showShareGroupHeaders && shared.is_mine && index === 0" class="kb-section-header"
- role="button" tabindex="0" @click="toggleKbSection('sharedByMe')"
+ role="button" tabindex="0" :aria-expanded="!isKbSectionCollapsed('sharedByMe')" @click="toggleKbSection('sharedByMe')"
@keydown.enter.prevent="toggleKbSection('sharedByMe')"
@keydown.space.prevent="toggleKbSection('sharedByMe')">
<t-icon name="share" size="14px" />
@@ -516,7 +520,7 @@
&& !shared.is_mine
&& isSharedKbEditable(shared.permission)
&& (index === 0 || sortedSpaceKbsList[index - 1].is_mine)" class="kb-section-header"
- role="button" tabindex="0" @click="toggleKbSection('sharedEditable')"
+ role="button" tabindex="0" :aria-expanded="!isKbSectionCollapsed('sharedEditable')" @click="toggleKbSection('sharedEditable')"
@keydown.enter.prevent="toggleKbSection('sharedEditable')"
@keydown.space.prevent="toggleKbSection('sharedEditable')">
<t-icon name="usergroup-add" size="14px" />
@@ -533,7 +537,7 @@
&& (index === 0
|| sortedSpaceKbsList[index - 1].is_mine
|| isSharedKbEditable(sortedSpaceKbsList[index - 1].permission))" class="kb-section-header"
- role="button" tabindex="0" @click="toggleKbSection('sharedReadonly')"
+ role="button" tabindex="0" :aria-expanded="!isKbSectionCollapsed('sharedReadonly')" @click="toggleKbSection('sharedReadonly')"
@keydown.enter.prevent="toggleKbSection('sharedReadonly')"
@keydown.space.prevent="toggleKbSection('sharedReadonly')">
<t-icon name="usergroup-add" size="14px" />
@@ -546,7 +550,7 @@
<div v-show="!isSpaceKbCollapsed(shared)" class="kb-card shared-kb-card" :class="{
'kb-type-document': (shared.knowledge_base.type || 'document') === 'document',
'kb-type-faq': shared.knowledge_base.type === 'faq'
- }" @click="handleSharedKbClick(shared)">
+ }" role="link" tabindex="0" @keydown.enter.self.prevent="handleSharedKbClick(shared)" @keydown.space.self.prevent="handleSharedKbClick(shared)" @click="handleSharedKbClick(shared)">
<!-- 卡片头部 -->
<div class="card-header">
<span class="card-title" :title="shared.knowledge_base.name">
@@ -563,7 +567,7 @@
<!-- 卡片内容 -->
<div class="card-content">
- <div class="card-description">
+ <div class="card-description" :title="shared.knowledge_base.description || $t('knowledgeBase.noDescription')">
{{ shared.knowledge_base.description || $t('knowledgeBase.noDescription') }}
</div>
</div>
@@ -592,7 +596,7 @@
</div>
<!-- 全部空状态:保留「新建知识库」CTA,因为是空间没有任何 KB 的真空场景 -->
- <EmptyState v-if="spaceSelection === 'all' && filteredKnowledgeBases.length === 0 && !loading" icon="folder-open" :title="$t('knowledgeList.empty.title')"
+ <EmptyState v-if="!keyword.trim() && spaceSelection === 'all' && filteredKnowledgeBases.length === 0 && !loading" icon="folder-open" :title="$t('knowledgeList.empty.title')"
:description="$t('knowledgeList.empty.description')">
<t-button v-if="authStore.hasRole('contributor')" theme="primary" class="kb-create-btn"
data-guide="kb-list-create" @click="handleCreateKnowledgeBase">
@@ -603,15 +607,15 @@
<!-- 收藏空状态:不放创建按钮——「没有收藏」 ≠ 「没有知识库」,
正确引导是「去星标一下」,不是「再建一个」。 -->
- <EmptyState v-if="spaceSelection === 'favorites' && filteredKnowledgeBases.length === 0 && !loading" icon="star" :title="$t('knowledgeList.empty.favoritesTitle')"
+ <EmptyState v-if="!keyword.trim() && spaceSelection === 'favorites' && filteredKnowledgeBases.length === 0 && !loading" icon="star" :title="$t('knowledgeList.empty.favoritesTitle')"
:description="$t('knowledgeList.empty.favoritesDescription')" />
<!-- 最近空状态:同理,引导是「去打开一个」。 -->
- <EmptyState v-if="spaceSelection === 'recents' && filteredKnowledgeBases.length === 0 && !loading" icon="history" :title="$t('knowledgeList.empty.recentsTitle')"
+ <EmptyState v-if="!keyword.trim() && spaceSelection === 'recents' && filteredKnowledgeBases.length === 0 && !loading" icon="history" :title="$t('knowledgeList.empty.recentsTitle')"
:description="$t('knowledgeList.empty.recentsDescription')" />
<!-- 我的知识库空状态 -->
- <EmptyState v-if="spaceSelection === 'mine' && kbs.length === 0 && !loading" icon="folder-open" :title="$t('knowledgeList.empty.title')"
+ <EmptyState v-if="!keyword.trim() && spaceSelection === 'mine' && kbs.length === 0 && !loading" icon="folder-open" :title="$t('knowledgeList.empty.title')"
:description="$t('knowledgeList.empty.description')">
<t-button v-if="authStore.hasRole('contributor')" theme="primary" class="kb-create-btn"
data-guide="kb-list-create" @click="handleCreateKnowledgeBase">
@@ -621,7 +625,7 @@
</EmptyState>
<!-- 空间下知识库空状态 -->
- <EmptyState v-if="spaceSelectionOrgId && !spaceKbsLoading && spaceKbsList.length === 0" icon="folder-open" :title="$t('knowledgeList.empty.sharedTitle')"
+ <EmptyState v-if="!keyword.trim() && spaceSelectionOrgId && !spaceKbsLoading && spaceKbsList.length === 0" icon="folder-open" :title="$t('knowledgeList.empty.sharedTitle')"
:description="$t('knowledgeList.empty.sharedDescription')" />
</div>
</div>
@@ -724,7 +728,8 @@ import { mergeAllScopeKnowledgeBases, type OwnedKnowledgeBase, type SharedKnowle
import KnowledgeBaseEditorModal from './KnowledgeBaseEditorModal.vue'
import KbWikiBadge from './components/KbWikiBadge.vue'
import ShareKnowledgeBaseDialog from '@/components/ShareKnowledgeBaseDialog.vue'
-import ListSpaceSidebar from '@/components/ListSpaceSidebar.vue'
+import ResourceListToolbar from '@/components/ResourceListToolbar.vue'
+import { matchesResourceQuery } from '@/utils/resourceListSearch'
import ResourceOriginBadge from '@/components/ResourceOriginBadge.vue'
import { shouldShowResourceOriginBadge } from '@/utils/card-list-badge'
import ContextualGuide from '@/components/ContextualGuide.vue'
@@ -751,10 +756,9 @@ const { t } = useI18n()
// State lives in `?scope=` so links are shareable/bookmarkable; the
// composable handles two-way sync with the URL. We keep "mine" as the
// stored value (not "workspace") for back-compat with any external link
-// that might point at the old query — its display label is rebranded
-// via ListSpaceSidebar's workspaceLabel computed.
+// that might point at the old query; ResourceListToolbar labels it as the current workspace.
const defaultScope: 'all' | 'mine' = authStore.hasRole('contributor') ? 'mine' : 'all'
-const { scope: spaceSelection, creator: creatorFilter } = useListUrlState({
+const { scope: spaceSelection, creator: creatorFilter, query: keyword } = useListUrlState({
defaultScope,
defaultCreator: 'all',
})
@@ -821,7 +825,7 @@ const sharedKbs = computed<SharedKnowledgeBase[]>(() => orgStore.sharedKnowledge
const allKnowledgeBases = computed(() => kbs.value.length + sharedKbs.value.length)
// 当前选中的是空间 ID(非全部、非我的、非收藏/最近这类伪 scope)
-// NB: keep the reserved-scope list in sync with ListSpaceSidebar's
+// NB: keep the reserved-scope list in sync with ResourceListToolbar's
// non-org buckets — otherwise a new pseudo-scope (e.g. "favorites")
// falls through here and triggers the per-space code paths, which
// renders an extra "no shared KB" empty state on top of the real view.
@@ -855,7 +859,7 @@ const spaceKbsLoading = ref(false)
// even though it would otherwise live in the teammate sub-group. The
// previous version only bucketed by isMyKb and silently demoted these
// pinned-but-teammate KBs.
-const sortedMineKbs = computed<KB[]>(() => {
+const unsearchedSortedMineKbs = computed<KB[]>(() => {
return [...kbs.value].sort((a, b) => {
const ap = a.is_pinned ? 0 : 1
const bp = b.is_pinned ? 0 : 1
@@ -873,10 +877,11 @@ const sortedMineKbs = computed<KB[]>(() => {
return bc - ac
})
})
+const sortedMineKbs = computed(() => unsearchedSortedMineKbs.value.filter(item => matchesResourceQuery(item, keyword.value)))
// 空间视角下的稳定排序:我创建的(is_mine)放在前面,剩下的共享部分再按
// 可编辑 / 仅查看 排序——这样空间列表跟「全部」视图的视觉顺序一致。
-const sortedSpaceKbsList = computed(() => {
+const unsearchedSortedSpaceKbsList = computed(() => {
return [...spaceKbsList.value].sort((a, b) => {
const aMine = a.is_mine ? 0 : 1
const bMine = b.is_mine ? 0 : 1
@@ -886,6 +891,7 @@ const sortedSpaceKbsList = computed(() => {
return aE - bE
})
})
+const sortedSpaceKbsList = computed(() => unsearchedSortedSpaceKbsList.value.filter(item => matchesResourceQuery(item.knowledge_base, keyword.value)))
const spaceCountByOrg = ref<Record<string, number>>({})
// 各空间下的共享知识库数量(用于侧栏展示):优先用接口返回的该空间总数,否则用「共享给我」数量
@@ -1083,7 +1089,7 @@ const spaceKbSectionCounts = computed<Record<KbSectionKey, number>>(() => {
// pre-filtered, pre-ordered slices, so the existing kb-card / shared
// kb-card templates render them with zero extra markup. Order is
// preserved via the upstream array (pins order is ts-desc).
-const filteredKnowledgeBases = computed(() => {
+const unsearchedFilteredKnowledgeBases = computed(() => {
if (spaceSelection.value === 'favorites') {
return favoritesList.value
}
@@ -1109,9 +1115,10 @@ const filteredKnowledgeBases = computed(() => {
authStore.user?.id,
) as unknown as Array<(KB & { isMine: true }) | (SharedKnowledgeBase['knowledge_base'] & { isMine: false; permission: string; shared_at: string; share_id: string } & any)>
})
+const filteredKnowledgeBases = computed(() => unsearchedFilteredKnowledgeBases.value.filter(item => matchesResourceQuery(item, keyword.value)))
const showKbListEmpty = computed(() => {
- if (loading.value) return false
+ if (loading.value || keyword.value.trim()) return false
if (!authStore.hasRole('contributor')) return false
if (spaceSelection.value === 'all' && filteredKnowledgeBases.value.length === 0) return true
if (spaceSelection.value === 'mine' && kbs.value.length === 0) return true
@@ -1555,29 +1562,24 @@ const handleUploadFinishedEvent = (event: Event) => {
uploadRefreshTimer = null
}, 800)
}
+const visibleResultCount = computed(() => spaceSelection.value === 'mine' ? sortedMineKbs.value.length : spaceSelectionOrgId.value ? sortedSpaceKbsList.value.length : filteredKnowledgeBases.value.length)
+// A new search reveals matching rows even if their group was previously collapsed.
+watch(keyword, () => { collapsedKbSections.value = new Set() })
</script>
<style scoped lang="less">
@import (reference) '@/components/css/resource-card.less';
.kb-list-container {
- margin: 0;
- height: 100%;
- box-sizing: border-box;
flex: 1;
- display: flex;
- position: relative;
+ min-width: 0;
min-height: 0;
-}
-
-.kb-list-content {
- flex: 1;
+ height: 100%;
display: flex;
- flex-direction: column;
- min-width: 0;
- padding: 20px 0 0 28px;
}
+.kb-list-content { .resource-list-content(); }
+
.header {
display: flex;
align-items: center;
@@ -1608,17 +1610,7 @@ const handleUploadFinishedEvent = (event: Event) => {
}
-.kb-list-main {
- flex: 1;
- min-width: 0;
- overflow-y: auto;
- overflow-x: hidden;
- // 顶部不留 padding,sticky 的分组标题 (top: 0) 才能贴到容器最顶;
- // 底部 padding 保留,避免最后一行卡片紧贴边。
- padding: 0 28px 8px 0;
- scrollbar-width: auto;
- scrollbar-color: auto;
-}
+.kb-list-main { .resource-list-main(); }
.kb-list-main-loading {
display: flex;
@@ -1800,45 +1792,6 @@ const handleUploadFinishedEvent = (event: Event) => {
.shared-kb-card {
position: relative;
- // 共享知识库根据类型显示不同样式
- &.kb-type-document {
- background: linear-gradient(135deg, var(--td-bg-color-container) 0%, color-mix(in srgb, var(--td-brand-color) 4%, transparent) 100%) !important;
-
- &:hover {
- border-color: var(--td-brand-color) !important;
- box-shadow: 0 4px 12px color-mix(in srgb, var(--td-brand-color) 12%, transparent) !important;
- background: linear-gradient(135deg, var(--td-bg-color-container) 0%, color-mix(in srgb, var(--td-brand-color) 8%, transparent) 100%) !important;
- }
-
- &::after {
- background: linear-gradient(135deg, color-mix(in srgb, var(--td-brand-color) 8%, transparent) 0%, transparent 100%) !important;
- }
- }
-
- &.kb-type-faq {
- background: linear-gradient(135deg, var(--td-bg-color-container) 0%, color-mix(in srgb, var(--td-brand-color) 4%, transparent) 100%) !important;
-
- &:hover {
- border-color: var(--td-brand-color) !important;
- box-shadow: 0 4px 12px color-mix(in srgb, var(--td-brand-color) 12%, transparent) !important;
- background: linear-gradient(135deg, var(--td-bg-color-container) 0%, color-mix(in srgb, var(--td-brand-color) 8%, transparent) 100%) !important;
- }
-
- &::after {
- background: linear-gradient(135deg, color-mix(in srgb, var(--td-brand-color) 8%, transparent) 0%, transparent 100%) !important;
- }
-
- // FAQ 类型共享标识使用蓝色
- .shared-badge {
- background: color-mix(in srgb, var(--td-brand-color) 10%, transparent);
- color: var(--td-brand-color);
-
- .t-icon {
- color: var(--td-brand-color);
- }
- }
- }
-
.org-tag {
display: inline-flex;
align-items: center;
@@ -1890,85 +1843,7 @@ const handleUploadFinishedEvent = (event: Event) => {
}
.kb-section-header {
- grid-column: 1 / -1;
- display: flex;
- align-items: center;
- gap: 6px;
- // 整行只用来铺背景实现 sticky;点击事件靠子元素冒泡触发,避免点到
- // 标题右侧大片空白时误折叠。键盘 tab/enter 不受 pointer-events 影响。
- pointer-events: none;
-
- & > * {
- pointer-events: auto;
- }
- // 下滑时吸顶到滚动容器(.kb-list-main)顶部。z-index 要高于卡片自身的
- // hover 阴影 / 装饰层;背景必须不透明,否则卡片会从下方透出来。
- position: sticky;
- top: 0;
- z-index: 5;
- background: var(--td-bg-color-container);
- // 用 box-shadow 把背景再往上"延伸"8px,封掉 sticky 与容器顶之间任何
- // subpixel 残缝(border-radius 的圆角三角、滚动时浏览器子像素渲染等
- // 都会让卡片从这里漏出 1-2px)。第二条 shadow 在下方也再补一点,避免
- // grid-gap 区域里卡片穿插过来。
- box-shadow: 0 -8px 0 0 var(--td-bg-color-container),
- 0 4px 0 0 var(--td-bg-color-container);
- padding: 6px 4px 6px 0;
- color: var(--td-text-color-secondary);
- font-family: var(--app-font-family);
- font-size: var(--app-text-md);
- font-weight: 600;
- line-height: 20px;
- cursor: pointer;
- user-select: none;
- outline: none;
-
- &:hover {
- color: var(--td-text-color-primary);
- }
-
- &:focus-visible {
- box-shadow: 0 0 0 2px var(--td-brand-color-focus);
- }
-
- // Icons inherit the section header's text color so the whole row
- // (icon + label) reads as one muted secondary tone. The pinned
- // modifier no longer overrides this either — uniform appearance
- // is intentional; the icon shape alone is enough to flag which
- // section the user is looking at.
- .t-icon {
- color: inherit;
- }
-
- .kb-section-toggle {
- margin-left: 4px;
- opacity: 0.7;
- transition: opacity var(--app-motion-fast) ease;
- }
-
- // 共享给我的两个子分组共用一个主图标 usergroup-add,再用子图标
- // (edit / browse) 区分权限。子图标向左挤靠主图标,整体读起来还是一个"组"。
- .kb-section-subicon {
- margin-left: -4px;
- opacity: 0.75;
- }
-
- // 组里实际有多少张卡片。用 13px 主字号同色降透明度,避免抢标题视觉,
- // 同时给个轻底色保证在浅色容器上仍可读。
- .kb-section-count {
- margin-left: 2px;
- padding: 0 6px;
- border-radius: var(--app-radius-md);
- background: var(--td-bg-color-secondarycontainer);
- color: var(--td-text-color-secondary);
- font-size: var(--app-text-xs);
- line-height: 16px;
- font-weight: 500;
- }
-
- &:hover .kb-section-toggle {
- opacity: 1;
- }
+ .resource-section-header();
}
.kb-card {
@@ -1978,90 +1853,7 @@ const handleUploadFinishedEvent = (event: Event) => {
opacity: 0.9;
}
- // 文档类型样式
- &.kb-type-document {
- background: linear-gradient(135deg, var(--td-bg-color-container) 0%, color-mix(in srgb, var(--td-brand-color) 4%, transparent) 100%);
-
- &:hover {
- border-color: var(--td-brand-color);
- background: linear-gradient(135deg, var(--td-bg-color-container) 0%, color-mix(in srgb, var(--td-brand-color) 8%, transparent) 100%);
- }
-
- // 右上角装饰
- &::after {
- content: '';
- position: absolute;
- top: 0;
- right: 0;
- width: 60px;
- height: 60px;
- background: linear-gradient(135deg, color-mix(in srgb, var(--td-brand-color) 8%, transparent) 0%, transparent 100%);
- border-radius: 0 12px 0 100%;
- pointer-events: none;
- z-index: 0;
- }
- }
-
- // 问答类型样式
- &.kb-type-faq {
- background: linear-gradient(135deg, var(--td-bg-color-container) 0%, color-mix(in srgb, var(--td-brand-color) 4%, transparent) 100%);
-
- &:hover {
- border-color: var(--td-brand-color);
- box-shadow: 0 4px 12px color-mix(in srgb, var(--td-brand-color) 12%, transparent);
- background: linear-gradient(135deg, var(--td-bg-color-container) 0%, color-mix(in srgb, var(--td-brand-color) 8%, transparent) 100%);
- }
-
- // 右上角装饰
- &::after {
- content: '';
- position: absolute;
- top: 0;
- right: 0;
- width: 60px;
- height: 60px;
- background: linear-gradient(135deg, color-mix(in srgb, var(--td-brand-color) 8%, transparent) 0%, transparent 100%);
- border-radius: 0 12px 0 100%;
- pointer-events: none;
- z-index: 0;
- }
- }
-
- .kb-favorite-star {
- // 浮在卡片右上角顶角。卡片自身有 padding,"更多"按钮在 header flex 末端
- // 自然落在 padding 内部,与零位的 star 错开一段距离。
- position: absolute;
- top: 0;
- right: 0;
- z-index: 3;
- width: 24px;
- height: 24px;
- display: flex;
- align-items: center;
- justify-content: center;
- background: transparent;
- border: none;
- border-radius: var(--app-radius-sm);
- color: var(--td-text-color-secondary);
- cursor: pointer;
- opacity: 0;
- transition: opacity var(--app-motion-fast) ease, background var(--app-motion-fast) ease, color var(--app-motion-fast) ease;
-
- &:hover {
- background: var(--td-bg-color-secondarycontainer);
- color: var(--td-warning-color);
- }
-
- &.is-favorited {
- opacity: 1;
- color: var(--td-warning-color);
- }
- }
-
- // Reveal the star on card hover; favorited state forces it visible.
- &:hover .kb-favorite-star {
- opacity: 1;
- }
+ .kb-favorite-star { .resource-favorite-button(); }
}
@@ -2090,14 +1882,14 @@ const handleUploadFinishedEvent = (event: Event) => {
.resource-feature-badge();
&.type-document {
- background: color-mix(in srgb, var(--td-brand-color) 8%, transparent);
- color: var(--td-brand-color-active);
+ background: var(--td-bg-color-secondarycontainer);
+ color: var(--td-text-color-secondary);
width: auto;
padding: 0 6px;
gap: 3px;
&:hover {
- background: color-mix(in srgb, var(--td-brand-color) 12%, transparent);
+ background: var(--td-bg-color-container-hover);
}
.badge-count {
@@ -2111,14 +1903,14 @@ const handleUploadFinishedEvent = (event: Event) => {
}
&.type-faq {
- background: color-mix(in srgb, var(--td-brand-color) 8%, transparent);
- color: var(--td-brand-color);
+ background: var(--td-bg-color-secondarycontainer);
+ color: var(--td-text-color-secondary);
width: auto;
padding: 0 6px;
gap: 3px;
&:hover {
- background: color-mix(in srgb, var(--td-brand-color) 12%, transparent);
+ background: var(--td-bg-color-container-hover);
}
.badge-count {
@@ -2221,42 +2013,18 @@ const handleUploadFinishedEvent = (event: Event) => {
box-shadow: 0 0 12px color-mix(in srgb, var(--td-brand-color) 30%, transparent) !important;
}
-// 响应式布局
-@media (min-width: 900px) {
- .kb-card-wrap {
- grid-template-columns: repeat(2, 1fr);
- }
-}
-
-@media (min-width: 1250px) {
- .kb-card-wrap {
- grid-template-columns: repeat(3, 1fr);
- }
-}
-
-@media (min-width: 1600px) {
- .kb-card-wrap {
- grid-template-columns: repeat(4, 1fr);
- }
-}
-
-@media (min-width: 1900px) {
- .kb-card-wrap {
- grid-template-columns: repeat(5, 1fr);
- }
-}
-
-@media (min-width: 2200px) {
- .kb-card-wrap {
- grid-template-columns: repeat(6, 1fr);
- }
-}
// 删除确认对话框样式
:deep(.t-dialog__position.t-dialog--top) {
padding-top: 40vh !important;
}
+
+.resource-list-header();
+@media (prefers-reduced-motion: reduce) {
+ .kb-card-wrap { animation: none; }
+}
+
</style>
<style lang="less">
diff --git a/frontend/src/views/knowledge/components/DocumentCardView.vue b/frontend/src/views/knowledge/components/DocumentCardView.vue
index d839d6400..bfe36451a 100644
--- a/frontend/src/views/knowledge/components/DocumentCardView.vue
+++ b/frontend/src/views/knowledge/components/DocumentCardView.vue
@@ -332,7 +332,7 @@ const handleAction = (action: 'download' | 'edit' | 'view-trace' | 'reparse' | '
>
<div class="card-content">
<div class="card-content-nav">
- <div class="card-file-icon">
+ <div class="card-file-icon" :title="[getKnowledgeType(item), formatFileSize(Number(item.file_size))].filter(Boolean).join(' · ')">
<DocumentFileIcon :source-type="item.type"
:file-name="item.file_type ? `document.${item.file_type.toLowerCase()}` : (item.original_file_name || item.file_name || '')" />
</div>
@@ -365,7 +365,7 @@ const handleAction = (action: 'download' | 'edit' | 'view-trace' | 'reparse' | '
@click.stop
:class="[activeMenuIndex === index ? 'active-more' : '']"
>
- <t-icon name="more" size="18px" />
+ <t-icon name="more" size="16px" />
</button>
<template #content>
<!-- Move: folder picker (must win over the normal menu while open) -->
@@ -541,36 +541,31 @@ const handleAction = (action: 'download' | 'edit' | 'view-trace' | 'reparse' | '
</div>
</div>
- <KnowledgeTagPopover :kb-id="kbId" :knowledge-id="item.id" :tags="item.tags || []" :disabled="!canEdit"
- :visible="tagEditorId === item.id"
- @update:visible="(visible: boolean) => { if (visible) tagEditorId = item.id; else if (tagEditorId === item.id) tagEditorId = null }"
- @changed="emit('tags-changed', $event)">
- <div class="card-tags">
- <template v-if="item.tags?.length">
- <button v-for="tag in item.tags.slice(0, 3)" :key="tag.id" type="button" class="card-tag-chip"
- :disabled="!canEdit" :title="tag.name">{{ tag.name }}</button>
- <button v-if="item.tags.length > 3" type="button" class="card-tag-overflow" :disabled="!canEdit"
- :title="item.tags.slice(3).map(tag => tag.name).join('、')">+{{ item.tags.length - 3 }}</button>
- </template>
- <button v-else-if="canEdit" type="button" class="card-tag-add">
- <t-icon name="add" size="12px" />{{ t('knowledgeBase.tagAddAction') }}
- </button>
- </div>
- </KnowledgeTagPopover>
-
<div class="card-bottom">
+ <KnowledgeTagPopover v-if="canEdit || item.tags?.length" class="card-tags-anchor"
+ :kb-id="kbId" :knowledge-id="item.id" :tags="item.tags || []" :disabled="!canEdit"
+ :visible="tagEditorId === item.id"
+ @update:visible="(visible: boolean) => { if (visible) tagEditorId = item.id; else if (tagEditorId === item.id) tagEditorId = null }"
+ @changed="emit('tags-changed', $event)">
+ <div class="card-tags">
+ <template v-if="item.tags?.length">
+ <button v-for="tag in item.tags.slice(0, 1)" :key="tag.id" type="button" class="card-tag-chip"
+ :disabled="!canEdit" :title="tag.name">{{ tag.name }}</button>
+ <button v-if="item.tags.length > 1" type="button" class="card-tag-overflow" :disabled="!canEdit"
+ :title="item.tags.slice(1).map(tag => tag.name).join('、')">+{{ item.tags.length - 1 }}</button>
+ </template>
+ <button v-else-if="canEdit" type="button" class="card-tag-add">
+ <t-icon name="add" size="12px" />{{ t('knowledgeBase.tagAddAction') }}
+ </button>
+ </div>
+ </KnowledgeTagPopover>
+
<button v-if="showFolderPath && item.folder_path" type="button" class="card-folder"
:title="item.folder_path" @click.stop="onOpenFolder(item.folder_path)">
<t-icon name="folder" />
<span>{{ item.folder_path }}</span>
</button>
<span v-else class="card-time" :title="t('knowledgeBase.columnUpdatedAt')">{{ formatDocTime(item.updated_at) }}</span>
- <span class="card-type">
- {{ getKnowledgeType(item) }}
- <template v-if="item.type !== 'manual' && item.type !== 'url' && Number(item.file_size) > 0">
- <span class="card-meta-separator">·</span>{{ formatFileSize(Number(item.file_size)) }}
- </template>
- </span>
</div>
</div>
</div>
@@ -664,7 +659,7 @@ const handleAction = (action: 'download' | 'edit' | 'view-trace' | 'reparse' | '
.knowledge-card {
min-width: 0;
- height: 164px;
+ min-height: 120px;
display: flex;
flex-direction: column;
padding: 10px;
@@ -682,7 +677,7 @@ const handleAction = (action: 'download' | 'edit' | 'view-trace' | 'reparse' | '
&.is-selected { border-color: var(--app-selection-border); background: var(--td-bg-color-container); box-shadow: none; }
.card-content { min-width: 0; }
- .card-content-nav { display: flex; align-items: flex-start; gap: 8px; height: 40px; margin-bottom: 6px; }
+ .card-content-nav { display: flex; align-items: flex-start; gap: 7px; height: 36px; margin-bottom: 4px; }
.card-content-title {
flex: 1;
min-width: 0;
@@ -698,7 +693,7 @@ const handleAction = (action: 'download' | 'edit' | 'view-trace' | 'reparse' | '
font: inherit;
font-size: var(--app-text-base);
font-weight: 600;
- line-height: 20px;
+ line-height: 18px;
text-align: left;
cursor: pointer;
}
@@ -716,13 +711,22 @@ const handleAction = (action: 'download' | 'edit' | 'view-trace' | 'reparse' | '
background: transparent;
color: var(--td-text-color-placeholder);
cursor: pointer;
- &:hover, &.active-more { background: var(--td-bg-color-component-hover); color: var(--td-text-color-primary); }
+ transition: background-color var(--app-motion-fast) ease, color var(--app-motion-fast) ease;
+ &:hover, &.active-more {
+ background: var(--td-bg-color-container-hover);
+ color: var(--td-text-color-secondary);
+ }
+ &:focus-visible {
+ outline: 2px solid var(--app-focus-border);
+ outline-offset: 2px;
+ }
}
.card-file-icon {
position: relative;
- flex: 0 0 32px;
- width: 32px;
- height: 38px;
+ flex: 0 0 26px;
+ width: 26px;
+ height: 31px;
+ > :deep(*) { transform: scale(0.8125); transform-origin: top left; }
}
.card-nav-check {
flex-shrink: 0;
@@ -735,7 +739,7 @@ const handleAction = (action: 'download' | 'edit' | 'view-trace' | 'reparse' | '
.card-select-checkbox { display: flex; margin: 0; padding: 0; line-height: 1; }
:deep(.t-checkbox__label) { display: none; }
}
- .card-preview { height: 40px; }
+ .card-preview { min-height: 32px; }
.card-content-txt {
display: -webkit-box;
-webkit-box-orient: vertical;
@@ -744,7 +748,7 @@ const handleAction = (action: 'download' | 'edit' | 'view-trace' | 'reparse' | '
overflow-wrap: anywhere;
color: var(--td-text-color-secondary);
font-size: var(--app-text-sm);
- line-height: 20px;
+ line-height: 16px;
&.is-empty { color: var(--td-text-color-placeholder); }
}
.card-bottom {
@@ -753,19 +757,20 @@ const handleAction = (action: 'download' | 'edit' | 'view-trace' | 'reparse' | '
justify-content: space-between;
gap: 8px;
margin-top: auto;
+ padding-top: 6px;
color: var(--td-text-color-placeholder);
font-size: var(--app-text-xs);
line-height: 18px;
}
- .card-time { flex-shrink: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
- .card-type { display: flex; align-items: center; gap: 5px; min-width: 0; white-space: nowrap; }
- .card-meta-separator { opacity: 0.6; }
+ .card-time { flex-shrink: 0; margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
+ .card-tags-anchor { flex: 1; min-width: 0; width: auto; }
.card-folder {
display: inline-flex;
align-items: center;
gap: 4px;
min-width: 0;
- max-width: 60%;
+ max-width: 50%;
+ margin-left: auto;
padding: 0;
border: 0;
background: transparent;
@@ -785,13 +790,12 @@ const handleAction = (action: 'download' | 'edit' | 'view-trace' | 'reparse' | '
flex-wrap: nowrap;
gap: 5px;
height: 20px;
- margin-top: 6px;
overflow: hidden;
button {
display: inline-flex;
align-items: center;
gap: 4px;
- max-width: min(90px, calc((100% - 40px) / 3));
+ max-width: 100%;
height: 20px;
padding: 0 6px;
border: 1px solid var(--td-component-stroke);
@@ -808,8 +812,8 @@ const handleAction = (action: 'download' | 'edit' | 'view-trace' | 'reparse' | '
&:disabled { cursor: default; }
&:not(:disabled):hover { color: var(--td-brand-color); border-color: var(--app-selection-border); background: var(--app-selection-bg); }
}
- .card-tag-chip { display: block; }
- .card-tag-add { max-width: none; border-style: dashed; color: var(--td-text-color-placeholder); background: transparent; }
+ .card-tag-chip { display: block; min-width: 0; }
+ .card-tag-add { max-width: none; padding: 0; border-color: transparent; color: var(--td-text-color-placeholder); background: transparent; }
.card-tag-overflow { flex-shrink: 0; }
}
.card-tag-menu-action { width: 100%; border: 0; background: transparent; font-family: inherit; text-align: left; }
diff --git a/frontend/src/views/knowledge/components/KnowledgeTagPicker.test.ts b/frontend/src/views/knowledge/components/KnowledgeTagPicker.test.ts
index 61d7a5491..519a961a7 100644
--- a/frontend/src/views/knowledge/components/KnowledgeTagPicker.test.ts
+++ b/frontend/src/views/knowledge/components/KnowledgeTagPicker.test.ts
@@ -118,6 +118,26 @@ test('rename saves in place without changing selection', async t => {
assert.ok(textOf(f.root).includes('Renamed'))
})
+test('selected tags move above unselected tags and search preserves selection', async t => {
+ const f = await fixture(); t.after(f.close)
+ const headings = () => all(f.root, el => hasClass(el, 'tag-picker-group-title')).map(textOf)
+ const labels = () => all(f.root, el => el.type === 'checkbox').map(textOf)
+ assert.deepEqual(headings(), ['knowledgeBase.tagPickerUnselected2'])
+ await f.fire(f.find(el => el.type === 'checkbox' && textOf(el) === 'Free'), 'onChange', true)
+ assert.deepEqual(headings(), ['knowledgeBase.tagPickerSelected1', 'knowledgeBase.tagPickerUnselected1'])
+ assert.deepEqual(labels(), ['Free', 'Used'])
+ await f.search('Used')
+ assert.deepEqual(headings(), ['knowledgeBase.tagPickerUnselected1'])
+ assert.deepEqual([...f.selectedIds.value], ['free'])
+ await f.search('')
+ assert.deepEqual(labels(), ['Free', 'Used'])
+ await f.fire(f.find(el => el.type === 'checkbox' && textOf(el) === 'Used'), 'onChange', true)
+ assert.deepEqual(headings(), ['knowledgeBase.tagPickerSelected2'])
+ await f.fire(f.find(el => el.type === 'checkbox' && textOf(el) === 'Free'), 'onChange', false)
+ assert.deepEqual(headings(), ['knowledgeBase.tagPickerSelected1', 'knowledgeBase.tagPickerUnselected1'])
+ assert.deepEqual(labels(), ['Used', 'Free'])
+})
+
test('used tags cannot be deleted; unused deletion never requests cascading content removal', async t => {
const f = await fixture(); t.after(f.close)
await f.fire(f.find(el => el.type === 'popup'), 'onOpen')
diff --git a/frontend/src/views/knowledge/components/KnowledgeTagPicker.vue b/frontend/src/views/knowledge/components/KnowledgeTagPicker.vue
index bb0ca914e..7fd4fd236 100644
--- a/frontend/src/views/knowledge/components/KnowledgeTagPicker.vue
+++ b/frontend/src/views/knowledge/components/KnowledgeTagPicker.vue
@@ -5,36 +5,42 @@
</t-input>
<div class="tag-picker-list" :aria-label="$t('knowledgeBase.columnTag')">
<t-loading v-if="loading && !tags.length" size="small" />
- <div v-for="tag in tags" :key="tag.id" class="tag-picker-row">
- <template v-if="editingId === tag.id">
- <t-input v-model="editingName" autofocus :maxlength="40" size="small" :disabled="busy"
- :aria-label="$t('knowledgeBase.tagEditAction')" @enter="saveName(tag)"
- @keydown="(_v: string, ctx: { e: KeyboardEvent }) => { if (ctx.e.key === 'Escape') cancelEdit() }" />
- <t-button variant="text" shape="square" size="small" :loading="busy" :aria-label="$t('common.save')" @click="saveName(tag)"><t-icon name="check" size="14px" /></t-button>
- <t-button theme="default" variant="text" shape="square" size="small" :disabled="busy" :aria-label="$t('common.cancel')" @click="cancelEdit"><t-icon name="close" size="14px" /></t-button>
- </template>
- <template v-else>
- <t-checkbox :checked="selectedIds.includes(tag.id)" :disabled="busy" @change="toggle(tag.id)"><span :title="tag.name">{{ tag.name }}</span></t-checkbox>
- <t-popup attach="body" trigger="click" placement="bottom-right" :visible="menuTagId === tag.id"
- @visible-change="(visible: boolean) => { if (visible) menuTagId = tag.id; else if (menuTagId === tag.id) menuTagId = '' }">
- <button type="button" class="tag-picker-more" :class="{ 'is-open': menuTagId === tag.id }" :disabled="busy"
- :aria-label="`${tag.name} · ${$t('knowledgeBase.columnActions')}`" :aria-expanded="menuTagId === tag.id"><t-icon name="ellipsis" size="16px" /></button>
- <template #content>
- <div class="tag-picker-menu">
- <button type="button" @click="startEdit(tag)">{{ $t('knowledgeBase.tagEditAction') }}</button>
- <t-tooltip v-if="isUsed(tag)" :content="$t('knowledgeBase.tagPickerInUse')">
- <span><button type="button" disabled>{{ $t('knowledgeBase.tagDeleteAction') }}</button></span>
- </t-tooltip>
- <t-popconfirm v-else attach="body" :content="$t('knowledgeBase.tagPickerDeleteConfirm', { name: tag.name })"
- :confirm-btn="{ content: $t('common.delete'), theme: 'danger', loading: busy }"
- :cancel-btn="{ content: $t('common.cancel') }" @confirm="removeTag(tag)">
- <button type="button" class="tag-picker-delete" :disabled="busy">{{ $t('knowledgeBase.tagDeleteAction') }}</button>
- </t-popconfirm>
- </div>
- </template>
- </t-popup>
- </template>
- </div>
+ <template v-for="(tag, index) in orderedTags" :key="tag.id">
+ <div v-if="index === 0 || index === selectedTags.length" class="tag-picker-group-title" role="heading" aria-level="3">
+ <span>{{ $t(selectedIds.includes(tag.id) ? 'knowledgeBase.tagPickerSelected' : 'knowledgeBase.tagPickerUnselected') }}</span>
+ <span class="tag-picker-group-count">{{ selectedIds.includes(tag.id) ? selectedTags.length : unselectedTags.length }}</span>
+ </div>
+ <div class="tag-picker-row">
+ <template v-if="editingId === tag.id">
+ <t-input v-model="editingName" autofocus :maxlength="40" size="small" :disabled="busy"
+ :aria-label="$t('knowledgeBase.tagEditAction')" @enter="saveName(tag)"
+ @keydown="(_v: string, ctx: { e: KeyboardEvent }) => { if (ctx.e.key === 'Escape') cancelEdit() }" />
+ <t-button variant="text" shape="square" size="small" :loading="busy" :aria-label="$t('common.save')" @click="saveName(tag)"><t-icon name="check" size="14px" /></t-button>
+ <t-button theme="default" variant="text" shape="square" size="small" :disabled="busy" :aria-label="$t('common.cancel')" @click="cancelEdit"><t-icon name="close" size="14px" /></t-button>
+ </template>
+ <template v-else>
+ <t-checkbox :checked="selectedIds.includes(tag.id)" :disabled="busy" @change="toggle(tag.id)"><span :title="tag.name">{{ tag.name }}</span></t-checkbox>
+ <t-popup attach="body" trigger="click" placement="bottom-right" :visible="menuTagId === tag.id"
+ @visible-change="(visible: boolean) => { if (visible) menuTagId = tag.id; else if (menuTagId === tag.id) menuTagId = '' }">
+ <button type="button" class="tag-picker-more" :class="{ 'is-open': menuTagId === tag.id }" :disabled="busy"
+ :aria-label="`${tag.name} · ${$t('knowledgeBase.columnActions')}`" :aria-expanded="menuTagId === tag.id"><t-icon name="ellipsis" size="16px" /></button>
+ <template #content>
+ <div class="tag-picker-menu">
+ <button type="button" @click="startEdit(tag)">{{ $t('knowledgeBase.tagEditAction') }}</button>
+ <t-tooltip v-if="isUsed(tag)" :content="$t('knowledgeBase.tagPickerInUse')">
+ <span><button type="button" disabled>{{ $t('knowledgeBase.tagDeleteAction') }}</button></span>
+ </t-tooltip>
+ <t-popconfirm v-else attach="body" :content="$t('knowledgeBase.tagPickerDeleteConfirm', { name: tag.name })"
+ :confirm-btn="{ content: $t('common.delete'), theme: 'danger', loading: busy }"
+ :cancel-btn="{ content: $t('common.cancel') }" @confirm="removeTag(tag)">
+ <button type="button" class="tag-picker-delete" :disabled="busy">{{ $t('knowledgeBase.tagDeleteAction') }}</button>
+ </t-popconfirm>
+ </div>
+ </template>
+ </t-popup>
+ </template>
+ </div>
+ </template>
<button v-if="canCreate && !loading" type="button" class="tag-picker-create" :disabled="busy" @click="createTag">
<t-icon :name="busy ? 'loading' : 'add'" size="16px" />
<span :title="query.trim()">{{ $t('knowledgeBase.tagCreateAction') }} “{{ query.trim() }}”</span>
@@ -71,6 +77,10 @@ const editingName = ref('');
let requestVersion = 0;
let debounce: ReturnType<typeof setTimeout> | undefined;
const canCreate = computed(() => query.value.trim() && !tags.value.some(tag => tag.name === query.value.trim()));
+const selectedTagIds = computed(() => new Set(props.selectedIds));
+const selectedTags = computed(() => tags.value.filter(tag => selectedTagIds.value.has(tag.id)));
+const unselectedTags = computed(() => tags.value.filter(tag => !selectedTagIds.value.has(tag.id)));
+const orderedTags = computed(() => [...selectedTags.value, ...unselectedTags.value]);
const isUsed = (tag: Tag) => !!(tag.knowledge_count || tag.chunk_count);
const reportError = (error: any) => MessagePlugin.error(error?.message || t('common.operationFailed'));
watch(busy, value => emit('busy-change', value), { flush: 'sync' });
@@ -154,6 +164,12 @@ async function removeTag(tag: Tag) {
<style scoped lang="less">
.knowledge-tag-picker { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.tag-picker-list { max-height: min(280px, 40vh); overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-gutter: stable; padding: 2px 4px 2px 0; }
+.tag-picker-group-title {
+ display: flex; align-items: center; gap: 6px; padding: 5px 4px;
+ color: var(--td-text-color-secondary); font-size: var(--app-text-xs); line-height: 18px;
+ &:not(:first-child) { margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--td-component-stroke); }
+}
+.tag-picker-group-count { color: var(--td-text-color-placeholder); font-variant-numeric: tabular-nums; }
.tag-picker-row {
display: flex; align-items: center; gap: 4px; min-width: 0; box-sizing: border-box; min-height: 34px; padding: 2px 4px; border-radius: var(--app-radius-xs);
&:hover { background: var(--td-bg-color-container-hover); }
diff --git a/frontend/src/views/organization/OrganizationList.vue b/frontend/src/views/organization/OrganizationList.vue
index 7deffdd99..39d883961 100644
--- a/frontend/src/views/organization/OrganizationList.vue
+++ b/frontend/src/views/organization/OrganizationList.vue
@@ -1,7 +1,5 @@
<template>
<div class="org-list-container">
- <ListSpaceSidebar mode="organization" v-model="spaceSelection" :count-all="organizations.length"
- :count-created="createdCount" :count-joined="joinedCount" />
<div class="org-list-content">
<div class="header" style="--wails-draggable: drag">
<div class="header-title" style="--wails-draggable: drag">
@@ -12,6 +10,7 @@
<t-button variant="text" theme="default" size="small" class="header-action-btn"
style="--wails-draggable: no-drag" :disabled="!canManageOrg" @click="handleJoinOrganization">
<template #icon><t-icon name="enter" size="16px" /></template>
+ {{ $t('organization.joinOrg') }}
</t-button>
</t-tooltip>
<t-tooltip :content="canManageOrg ? $t('organization.createOrg') : noPermissionTip" placement="bottom">
@@ -19,6 +18,7 @@
style="--wails-draggable: no-drag" :disabled="!canManageOrg" @click="handleCreateOrganization">
<template #icon><img src="@/assets/img/organization-green.svg" class="org-create-icon" alt=""
aria-hidden="true" /></template>
+ {{ $t('organization.createOrg') }}
</t-button>
</t-tooltip>
</div>
@@ -26,7 +26,13 @@
<p class="header-subtitle" style="--wails-draggable: drag">{{ $t('organization.subtitle') }}</p>
</div>
</div>
+ <ResourceListToolbar mode="organization" :model-value="spaceSelection" @update:model-value="value => spaceSelection = value === 'created' || value === 'joined' ? value : 'all'" v-model:query="keyword" :count-all="organizations.length"
+ :count-created="createdCount" :count-joined="joinedCount" />
<div class="org-list-main">
+ <EmptyState v-if="keyword.trim() && !(loading) && visibleResultCount === 0" icon="search"
+ :title="$t('common.noResult')">
+ <t-button variant="outline" @click="keyword = ''">{{ $t('common.clear') }}</t-button>
+ </EmptyState>
<!-- 骨架屏占位 -->
<div v-if="loading && filteredOrganizations.length === 0" class="org-card-wrap">
<div v-for="n in 4" :key="'skel-' + n" class="org-card org-card-skeleton is-skeleton">
@@ -51,7 +57,7 @@
<!-- 我创建的:仅在 all 视图下出现;created/joined 子视图自身已经
隐含了语义,再加标题反而冗余。-->
<div v-if="spaceSelection === 'all' && org.is_owner && index === 0" class="org-section-header"
- role="button" tabindex="0" @click="toggleOrgSection('created')"
+ role="button" tabindex="0" :aria-expanded="!isOrgSectionCollapsed('created')" @click="toggleOrgSection('created')"
@keydown.enter.prevent="toggleOrgSection('created')"
@keydown.space.prevent="toggleOrgSection('created')">
<t-icon name="user" size="14px" />
@@ -63,7 +69,7 @@
<!-- 我加入的:第一张非 owner 卡片前打标题(all 视图下) -->
<div v-if="spaceSelection === 'all' && !org.is_owner
&& (index === 0 || filteredOrganizations[index - 1].is_owner)" class="org-section-header" role="button"
- tabindex="0" @click="toggleOrgSection('joined')"
+ tabindex="0" :aria-expanded="!isOrgSectionCollapsed('joined')" @click="toggleOrgSection('joined')"
@keydown.enter.prevent="toggleOrgSection('joined')"
@keydown.space.prevent="toggleOrgSection('joined')">
<t-icon name="usergroup" size="14px" />
@@ -73,21 +79,8 @@
:name="isOrgSectionCollapsed('joined') ? 'chevron-right' : 'chevron-down'" size="14px" />
</div>
<div v-show="!isOrgRowHidden(org)" class="org-card"
- :class="{ 'joined-org': !org.is_owner }" @click="handleCardClick(org)">
- <!-- 装饰:协作网络感图形 -->
- <div class="card-decoration">
- <svg class="card-deco-svg" width="56" height="40" viewBox="0 0 56 40" fill="none"
- xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
- <circle cx="10" cy="12" r="4" stroke="currentColor" stroke-width="1.5" fill="none" opacity="0.5" />
- <circle cx="28" cy="8" r="5" stroke="currentColor" stroke-width="1.8" fill="none" opacity="0.7" />
- <circle cx="46" cy="14" r="4" stroke="currentColor" stroke-width="1.5" fill="none" opacity="0.5" />
- <path d="M14 13 L24 10 M32 10 L42 13" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"
- opacity="0.4" />
- <circle cx="28" cy="28" r="6" stroke="currentColor" stroke-width="1.2" fill="none" opacity="0.35" />
- <path d="M28 14 L28 22 M20 18 L26 24 M36 18 L30 24" stroke="currentColor" stroke-width="1"
- stroke-linecap="round" opacity="0.3" />
- </svg>
- </div>
+ :class="{ 'joined-org': !org.is_owner }" role="link" tabindex="0" @keydown.enter.self.prevent="handleCardClick(org)" @keydown.space.self.prevent="handleCardClick(org)" @click="handleCardClick(org)">
+
<!-- 卡片头部 -->
<div class="card-header">
@@ -102,9 +95,9 @@
<t-popup v-model="organizationMenuVisibility[org.id]" overlayClassName="card-more-popup"
:on-visible-change="(visible: boolean) => onVisibleChange(visible, org)" trigger="click"
destroy-on-close placement="bottom-right">
- <div class="more-wrap" @click.stop :class="{ 'active-more': organizationMenuVisibility[org.id] }">
+ <button type="button" :aria-label="$t('common.expand')" class="more-wrap" @click.stop :class="{ 'active-more': organizationMenuVisibility[org.id] }">
<img class="more-icon" src="@/assets/img/more.png" alt="" />
- </div>
+ </button>
<template #content>
<div class="popup-menu" @click.stop>
<div class="popup-menu-item" @click.stop="handleSettings(org)">
@@ -127,8 +120,8 @@
<!-- 卡片内容 -->
<div class="card-content">
- <div class="card-description">
- {{ org.description || $t('organization.noDescription') }}
+ <div class="card-description" :title="org.description || $t('organization.noDescription')">
+ {{ org.description || $t('organization.noDescription') }}
</div>
</div>
@@ -175,7 +168,7 @@
</div>
<!-- 空状态(按筛选显示不同文案) -->
- <EmptyState v-else-if="!loading" icon="usergroup" :title="emptyStateTitle"
+ <EmptyState v-if="!keyword.trim() && !loading && filteredOrganizations.length === 0" icon="usergroup" :title="emptyStateTitle"
:description="emptyStateDesc">
<t-tooltip :content="noPermissionTip" placement="top" :disabled="canManageOrg">
<t-button theme="default" variant="outline" class="org-join-btn" :disabled="!canManageOrg"
@@ -447,7 +440,8 @@ import { useI18n } from 'vue-i18n'
import { copyWithToast } from '@/utils/clipboard'
import OrganizationSettingsModal from './OrganizationSettingsModal.vue'
import SpaceAvatar from '@/components/SpaceAvatar.vue'
-import ListSpaceSidebar from '@/components/ListSpaceSidebar.vue'
+import ResourceListToolbar from '@/components/ResourceListToolbar.vue'
+import { matchesResourceQuery } from '@/utils/resourceListSearch'
import { shouldShowOrgRelationTag } from '@/utils/card-list-badge'
type OrgWithUI = Organization
@@ -658,6 +652,7 @@ const handleOrganizationDialogEvent = ((event: CustomEvent<{ type: 'create' | 'j
// 左侧筛选:'all' | 'created' | 'joined'
const spaceSelection = ref<'all' | 'created' | 'joined'>('all')
+const keyword = ref('')
// Computed
const loading = computed(() => orgStore.loading)
@@ -666,7 +661,7 @@ const organizations = computed<OrgWithUI[]>(() => orgStore.organizations)
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(() => {
+const unsearchedFilteredOrganizations = computed(() => {
if (spaceSelection.value === 'created') return organizations.value.filter(o => o.is_owner)
if (spaceSelection.value === 'joined') return organizations.value.filter(o => !o.is_owner)
// 「全部」视图下把我创建的 owner 排在前面、我加入的排在后面,方便上面的
@@ -676,6 +671,7 @@ const filteredOrganizations = computed(() => {
return a.is_owner ? -1 : 1
})
})
+const filteredOrganizations = computed(() => unsearchedFilteredOrganizations.value.filter(item => matchesResourceQuery(item, keyword.value)))
type OrgSectionKey = 'created' | 'joined'
const collapsedOrgSections = ref<Set<OrgSectionKey>>(new Set())
@@ -1071,36 +1067,25 @@ onUnmounted(() => {
window.removeEventListener('openOrganizationDialog', handleOrganizationDialogEvent)
teardownInviteBodyResizeObserver()
})
+const visibleResultCount = computed(() => filteredOrganizations.value.length)
+// A new search reveals matching rows even if their group was previously collapsed.
+watch(keyword, () => { collapsedOrgSections.value = new Set() })
</script>
<style scoped lang="less">
@import (reference) '@/components/css/resource-card.less';
.org-list-container {
- margin: 0 16px 0 0;
- height: 100%;
- box-sizing: border-box;
flex: 1;
- display: flex;
- position: relative;
+ min-width: 0;
min-height: 0;
-}
-
-.org-list-content {
- flex: 1;
+ height: 100%;
display: flex;
- flex-direction: column;
- min-width: 0;
- padding: 20px 28px 0 28px;
}
-.org-list-main {
- flex: 1;
- min-width: 0;
- overflow-y: auto;
- overflow-x: hidden;
- padding: 8px 0;
-}
+.org-list-content { .resource-list-content(); }
+
+.org-list-main { .resource-list-main(); }
.header {
display: flex;
@@ -1267,110 +1252,15 @@ onUnmounted(() => {
// 共享空间分组标题——与 KB / Agent 列表口径完全一致(图标 + 名称 + 数量 + 折叠 chevron)。
.org-section-header {
- grid-column: 1 / -1;
- display: flex;
- align-items: center;
- gap: 6px;
- // 整行只用来铺背景;点击靠子元素冒泡,避免点到标题右侧空白误折叠。
- pointer-events: none;
-
- & > * {
- pointer-events: auto;
- }
- position: sticky;
- top: 0;
- z-index: 5;
- background: var(--td-bg-color-container);
- box-shadow: 0 -8px 0 0 var(--td-bg-color-container),
- 0 4px 0 0 var(--td-bg-color-container);
- padding: 6px 4px 6px 0;
- color: var(--td-text-color-secondary);
- font-family: var(--app-font-family);
- font-size: var(--app-text-md);
- font-weight: 600;
- line-height: 20px;
- cursor: pointer;
- user-select: none;
- outline: none;
-
- &:hover {
- color: var(--td-text-color-primary);
- }
-
- &:focus-visible {
- box-shadow: 0 0 0 2px var(--td-brand-color-focus);
- }
-
- .t-icon {
- color: inherit;
- }
-
- .org-section-toggle {
- margin-left: 4px;
- opacity: 0.7;
- transition: opacity var(--app-motion-fast) ease;
- }
-
- .org-section-count {
- margin-left: 2px;
- padding: 0 6px;
- border-radius: var(--app-radius-md);
- background: var(--td-bg-color-secondarycontainer);
- color: var(--td-text-color-secondary);
- font-size: var(--app-text-xs);
- line-height: 16px;
- font-weight: 500;
- }
-
- &:hover .org-section-toggle {
- opacity: 1;
- }
+ .resource-section-header();
}
/* 与知识库 / 智能体列表统一:紧凑 + 1px 描边 */
.org-card {
.resource-card();
-
- &::before {
- content: '';
- position: absolute;
- top: 0;
- right: 0;
- width: 120px;
- height: 80px;
- background: radial-gradient(ellipse 60% 50% at 100% 0%, color-mix(in srgb, var(--td-brand-color) 6%, transparent) 0%, transparent 70%);
- pointer-events: none;
- z-index: 0;
- }
-
- .card-decoration {
- color: color-mix(in srgb, var(--td-brand-color) 35%, transparent);
- }
-
- &:hover .card-decoration {
- color: color-mix(in srgb, var(--td-brand-color) 55%, transparent);
- }
-
}
-// 卡片装饰:协作网络图形
-.card-decoration {
- position: absolute;
- top: 8px;
- right: 14px;
- display: flex;
- align-items: flex-start;
- justify-content: flex-end;
- pointer-events: none;
- z-index: 0;
- transition: color var(--app-motion-slow) ease;
- .card-deco-svg {
- display: block;
- width: 56px;
- height: 40px;
- }
-}
// 空间头像容器(SpaceAvatar 自带样式)
.org-avatar {
@@ -1416,15 +1306,15 @@ onUnmounted(() => {
}
&.stat-kb {
- background: color-mix(in srgb, var(--td-brand-color) 8%, transparent);
- color: var(--td-brand-color);
+ background: var(--td-bg-color-secondarycontainer);
+ color: var(--td-text-color-secondary);
.t-icon {
- color: var(--td-brand-color);
+ color: var(--td-text-color-secondary);
}
&:hover {
- background: color-mix(in srgb, var(--td-brand-color) 12%, transparent);
+ background: var(--td-bg-color-container-hover);
}
}
@@ -1522,42 +1412,18 @@ onUnmounted(() => {
}
}
-// 响应式布局
-@media (min-width: 900px) {
- .org-card-wrap {
- grid-template-columns: repeat(2, 1fr);
- }
-}
-
-@media (min-width: 1250px) {
- .org-card-wrap {
- grid-template-columns: repeat(3, 1fr);
- }
-}
-
-@media (min-width: 1600px) {
- .org-card-wrap {
- grid-template-columns: repeat(4, 1fr);
- }
-}
-
-@media (min-width: 1900px) {
- .org-card-wrap {
- grid-template-columns: repeat(5, 1fr);
- }
-}
-
-@media (min-width: 2200px) {
- .org-card-wrap {
- grid-template-columns: repeat(6, 1fr);
- }
-}
// 删除/离开确认对话框样式
:deep(.t-dialog__position.t-dialog--top) {
padding-top: 40vh !important;
}
+
+.resource-list-header();
+@media (prefers-reduced-motion: reduce) {
+ .org-card-wrap { animation: none; }
+}
+
</style>
<style lang="less">
diff --git a/frontend/src/views/organization/OrganizationSettingsModal.vue b/frontend/src/views/organization/OrganizationSettingsModal.vue
index 361dc3f54..4ed7697e6 100644
--- a/frontend/src/views/organization/OrganizationSettingsModal.vue
+++ b/frontend/src/views/organization/OrganizationSettingsModal.vue
@@ -1,12 +1,13 @@
<template>
<SettingsModalShell :visible="visible" :title="modalTitle" v-model="currentSection" :nav-groups="navGroups"
+ :overlay-class="isCreateMode ? 'organization-create-overlay' : ''"
:z-index="2000" @close="modalShell.requestClose">
<template #nav-icon="{ item, active }">
<img v-if="item.key === 'sharedAgents'" :src="active ? agentIconActiveSrc : agentIconSrc"
class="nav-icon nav-icon-img" alt="" aria-hidden="true" />
<t-icon v-else :name="item.icon" class="nav-icon" />
</template>
- <div ref="contentWrapperRef" class="content-wrapper">
+ <div ref="contentWrapperRef" class="content-wrapper" :class="{ 'is-create': isCreateMode }">
<!-- 组织管理员但空间角色不足,给出只读提示 -->
<div v-if="showTenantRoleHint" class="tenant-role-hint">
<t-icon name="info-circle" size="16px" />
@@ -200,61 +201,29 @@
<p class="section-description">{{ $t('organization.editor.permissionsDesc') }}</p>
</div>
- <div class="permissions-info">
- <div class="permission-card">
- <div class="permission-header">
- <div class="permission-icon admin">
- <t-icon name="user-safety" />
- </div>
- <div class="permission-title">
- <span class="role-name">{{ $t('organization.role.admin') }}</span>
- <t-tag size="small" theme="primary">{{ $t('organization.editor.fullAccess') }}</t-tag>
- </div>
- </div>
- <ul class="permission-list">
- <li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.adminPerm1') }}</li>
- <li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.adminPerm2') }}</li>
- <li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.adminPerm3') }}</li>
- <li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.adminPerm4') }}</li>
- <li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.useSharedAgentsPerm') }}</li>
- </ul>
- </div>
- <div class="permission-card">
- <div class="permission-header">
- <div class="permission-icon editor">
- <t-icon name="edit" />
- </div>
- <div class="permission-title">
- <span class="role-name">{{ $t('organization.role.editor') }}</span>
- <t-tag size="small" theme="warning">{{ $t('organization.editor.editAccess') }}</t-tag>
- </div>
- </div>
- <ul class="permission-list">
- <li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.editorPerm1') }}</li>
- <li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.editorPerm2') }}</li>
- <li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.useSharedAgentsPerm') }}</li>
- <li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.shareKBPerm') }}</li>
- <li><t-icon name="close" class="close-icon" />{{ $t('organization.editor.editorPerm3') }}</li>
- </ul>
- </div>
- <div class="permission-card">
- <div class="permission-header">
- <div class="permission-icon viewer">
- <t-icon name="browse" />
- </div>
- <div class="permission-title">
- <span class="role-name">{{ $t('organization.role.viewer') }}</span>
- <t-tag size="small">{{ $t('organization.editor.viewAccess') }}</t-tag>
- </div>
- </div>
- <ul class="permission-list">
- <li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.viewerPerm1') }}</li>
- <li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.useSharedAgentsPerm') }}</li>
- <li><t-icon name="close" class="close-icon" />{{ $t('organization.editor.shareKBPerm') }}</li>
- <li><t-icon name="close" class="close-icon" />{{ $t('organization.editor.viewerPerm2') }}</li>
- <li><t-icon name="close" class="close-icon" />{{ $t('organization.editor.viewerPerm3') }}</li>
- </ul>
- </div>
+ <div class="permission-comparison">
+ <table class="permission-table" :aria-label="$t('organization.editor.permissionsTitle')">
+ <thead>
+ <tr>
+ <th scope="col">{{ $t('organization.editor.permissionFeature') }}</th>
+ <th v-for="role in orgRoleMatrixOrder" :key="role" scope="col">
+ {{ $t(`organization.role.${role}`) }}
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr v-for="permission in orgRoleMatrix.admin" :key="permission.key">
+ <th scope="row">{{ $t(`organization.editor.${permission.key}`) }}</th>
+ <td v-for="role in orgRoleMatrixOrder" :key="role">
+ <span v-if="orgRoleMatrix[role].find(item => item.key === permission.key)?.has"
+ class="permission-allowed" role="img" :aria-label="$t('common.yes')" :title="$t('common.yes')">
+ <t-icon name="check" size="16px" />
+ </span>
+ <span v-else class="permission-unavailable" role="img" :aria-label="$t('common.no')" :title="$t('common.no')">—</span>
+ </td>
+ </tr>
+ </tbody>
+ </table>
</div>
<div class="info-notice">
<t-icon name="info-circle" />
@@ -2094,102 +2063,63 @@ watch(addMemberPopupVisible, (visible) => {
}
}
-// 创建模式权限说明卡片
-.permissions-info {
- display: flex;
- flex-direction: column;
- gap: 16px;
-}
+// 创建模式使用紧凑表单和角色对照,复用成员管理的权限定义。
+.content-wrapper.is-create {
+ padding: 28px 28px 24px;
-.permission-card {
- background: var(--td-bg-color-secondarycontainer);
- border-radius: var(--app-radius-md);
- padding: 16px;
- border: 1px solid var(--td-component-stroke);
-}
-
-.permission-header {
- display: flex;
- align-items: center;
- gap: 12px;
- margin-bottom: 12px;
-}
-
-.permission-icon {
- width: 40px;
- height: 40px;
- border-radius: var(--app-radius-md);
- display: flex;
- align-items: center;
- justify-content: center;
- color: var(--td-text-color-anti);
-
- &.admin {
- background: linear-gradient(135deg, var(--td-brand-color), var(--td-brand-color-active));
- }
-
- &.editor {
- background: linear-gradient(135deg, var(--td-warning-color), var(--td-warning-color-active));
+ .section-header {
+ padding-right: 20px;
+ box-sizing: border-box;
+ margin-bottom: 24px;
+ h2 { font-size: var(--app-text-xl); line-height: 28px; }
+ .section-description { margin-top: 6px; font-size: var(--app-text-sm); }
}
- &.viewer {
- background: var(--td-bg-color-component-disabled);
+ .settings-group { gap: 20px; }
+ .setting-row {
+ flex-direction: column;
+ gap: 8px;
+ padding: 0;
+ border: 0;
+ .setting-info, .setting-control { flex: auto; width: 100%; max-width: 100%; }
+ .setting-info label { font-size: var(--app-text-base); }
+ .setting-info .desc { font-size: var(--app-text-sm); }
+ .setting-control { overflow: visible; }
}
}
-.permission-title {
- display: flex;
- align-items: center;
- gap: 8px;
-
- .role-name {
- font-size: var(--app-text-lg);
- font-weight: 600;
- color: var(--td-text-color-primary);
- }
+.permission-comparison {
+ overflow: hidden;
+ border: 1px solid var(--td-component-stroke);
+ border-radius: var(--app-radius-md);
}
+.permission-table {
+ width: 100%;
+ table-layout: fixed;
+ border-collapse: collapse;
+ font-size: var(--app-text-sm);
+ line-height: 20px;
+ color: var(--td-text-color-secondary);
-.permission-list {
- margin: 0;
- padding: 0;
- list-style: none;
-
- li {
- display: flex;
- align-items: center;
- gap: 8px;
- padding: 6px 0;
- font-size: var(--app-text-md);
- color: var(--td-text-color-secondary);
- }
-
- .check-icon {
- color: var(--td-brand-color);
- font-size: var(--app-text-base);
- }
-
- .close-icon {
- color: var(--td-error-color);
- font-size: var(--app-text-base);
- }
+ th, td { padding: 12px 8px; text-align: center; overflow-wrap: anywhere; }
+ th:first-child { width: 46%; padding-left: 14px; text-align: left; }
+ thead { background: var(--td-bg-color-secondarycontainer); }
+ thead th { font-weight: 500; color: var(--td-text-color-primary); }
+ tbody th { font-weight: 400; }
+ tbody tr { border-top: 1px solid var(--td-component-stroke); }
+ .permission-allowed { display: inline-flex; vertical-align: middle; color: var(--td-brand-color); }
+ .permission-unavailable { color: var(--td-text-color-placeholder); }
}
.info-notice {
display: flex;
align-items: flex-start;
gap: 8px;
- margin-top: 20px;
- padding: 12px 16px;
- background: var(--td-brand-color-light);
- border-radius: var(--app-radius-md);
- color: var(--td-brand-color);
- font-size: var(--app-text-md);
+ margin-top: 16px;
+ color: var(--td-text-color-secondary);
+ font-size: var(--app-text-sm);
line-height: 20px;
-
- .t-icon {
- flex-shrink: 0;
- margin-top: 2px;
- }
+ .t-icon { flex-shrink: 0; margin-top: 2px; }
}
/* 头像 Emoji 弹层内容 */
@@ -2944,6 +2874,30 @@ watch(addMemberPopupVisible, (visible) => {
</style>
<style lang="less">
+// 限定在创建弹窗,保留已有共享空间设置页的布局。
+.settings-modal-shell.organization-create-overlay {
+ .settings-modal { max-width: 860px; height: 560px; }
+ .settings-sidebar { width: 176px; }
+ .sidebar-title { font-size: var(--app-text-base); line-height: 24px; }
+ .settings-footer { padding: 14px 28px; }
+ .settings-footer-actions { gap: 8px; }
+
+ @media (max-width: 640px) {
+ padding: 12px;
+ .settings-modal { height: 680px; max-height: calc(100dvh - 24px); }
+ .settings-container { flex-direction: column; }
+ .settings-sidebar { width: 100%; border-right: 0; border-bottom: 1px solid var(--td-component-stroke); }
+ .sidebar-header { padding-right: 52px; border-bottom: 0; }
+ .settings-nav { display: flex; flex: none; gap: 4px; padding: 0 12px 10px; }
+ .nav-group-title { display: none; }
+ .nav-item { margin: 0; }
+ .content-wrapper.is-create { padding: 20px 16px; }
+ .settings-footer { padding: 12px 16px; }
+ .permission-table th:first-child { width: 40%; padding-left: 10px; }
+ .permission-table th, .permission-table td { padding: 10px 5px; }
+ }
+}
+
/* 权限说明 / 提示弹出层(t-popup 挂到 body,须全局样式) */
.org-permissions-popup-overlay {
z-index: 3050 !important;