Skip to content

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

feat(gallery): rework the gallery toolbar, header tabs and image viewer

wizardchenebbcf96fabb6
diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts
index 5c0d877a5..ff9675d05 100755
--- a/frontend/src/i18n/locales/en-US.ts
+++ b/frontend/src/i18n/locales/en-US.ts
@@ -3463,52 +3463,58 @@ export default {
pageActions: 'Page actions',
tabDocuments: 'Documents',
tabGallery: 'Gallery',
+ tabDocumentsTip: 'Upload and manage the source documents',
+ tabWikiTip: 'Wiki pages compiled automatically from the documents',
+ tabGalleryTip: 'Browse every image extracted from the documents',
+ viewTabs: 'Knowledge base views',
gallery: {
- panelFilter: 'Filter',
- panelSearch: 'Search',
- enableFilter: 'Enable filter',
- searchAll: 'Search all fields',
- verdictDefault: '-',
- verdictOff: 'off',
- verdictOn: 'on',
- searchScope: 'Search scope',
- scopeAll: 'All',
- scopeCustom: 'Custom',
- filterScope: 'Filter',
- filterOff: 'Show all',
- filterOn: 'Custom',
- editSearch: 'Open search settings',
- editFilter: 'Open filter settings',
- pin: 'Pin to the right',
- unpin: 'Unpin',
title: 'Gallery',
- searchPlaceholder: 'Search image content',
- sortByLabel: 'Sort by',
- orderAsc: 'Ascending',
- orderDesc: 'Descending',
- filtersTitle: 'Filters',
- searchFields: 'Search fields',
- modeAll: 'All fields',
- modeCustom: 'Custom',
- keywordsPlaceholder: 'Separate keywords with commas',
- applyAll: 'Apply to all attributes',
+ allImages: 'All images',
count: '{count} images',
- empty: 'No images in this knowledge base yet',
- emptyFiltered: 'No images match the current filters',
+ countFiltered: '{count} matching',
+ searchPlaceholder: 'Search captions or image text',
+ filters: 'Filters',
+ clearFilters: 'Clear filters',
+ searchIn: 'Search in',
+ searchInHint: 'Keywords only match the ticked content',
attrSection: 'Image attributes',
- noAttrs: 'No image attributes available',
- attributes: 'Attributes',
- caption: 'Caption',
- ocr: 'OCR text',
- source: 'Source',
+ attrHint: '"Hide" removes images with that value; "Always show" keeps them even when another rule hides them',
+ verdictDefault: 'Any',
+ verdictOff: 'Hide',
+ verdictOn: 'Always show',
+ keywordsPlaceholder: 'Separate keywords with commas',
+ noAttrs: 'No attributes to filter by',
+ sort: 'Sort',
+ sortField: 'Sort by',
+ sortOrder: 'Order',
+ orderAsc: 'Ascending',
+ orderDesc: 'Descending',
+ empty: 'No images to browse yet',
+ emptyHint: 'Images in your documents appear here once parsing finishes',
+ emptyFiltered: 'No images match these filters',
+ imageLoadError: 'Image failed to load',
noCaption: 'No caption',
- noOcr: 'No OCR text',
- chunkType: 'Type',
- viewerClose: 'Close',
- prev: 'Previous',
- next: 'Next',
+ noOcr: 'No text recognized',
+ caption: 'Caption',
+ ocr: 'Text in image (OCR)',
+ attributes: 'Attributes',
+ source: 'Source document',
+ details: 'Details',
+ dimensions: 'Size',
+ status: 'Status',
openSource: 'Open source document',
- imageLoadError: 'Image failed to load',
+ copy: 'Copy',
+ zoomIn: 'Zoom in (+)',
+ zoomOut: 'Zoom out (-)',
+ zoomReset: 'Fit to window (0)',
+ actualSize: 'Actual size',
+ rotate: 'Rotate (R)',
+ download: 'Download',
+ openOriginal: 'Open in new tab',
+ toggleInfo: 'Image info (I)',
+ viewerClose: 'Close (Esc)',
+ prev: 'Previous (←)',
+ next: 'Next (→)',
// Display names for the builtin attributes the gallery itself
// declares. Attributes contributed by other sources fall back to the
// pipeline's own wording (see the imageAttr namespace).
diff --git a/frontend/src/i18n/locales/ja-JP.ts b/frontend/src/i18n/locales/ja-JP.ts
index cb3c6938d..df0c1562d 100644
--- a/frontend/src/i18n/locales/ja-JP.ts
+++ b/frontend/src/i18n/locales/ja-JP.ts
@@ -3463,52 +3463,58 @@ export default {
pageActions: 'ページ操作',
tabDocuments: 'ドキュメント',
tabGallery: 'ギャラリー',
+ tabDocumentsTip: '元のドキュメントをアップロード・管理',
+ tabWikiTip: 'ドキュメントから自動で整理された Wiki ページ',
+ tabGalleryTip: 'ドキュメントから抽出されたすべての画像を閲覧',
+ viewTabs: 'ナレッジベースのビュー',
gallery: {
- panelFilter: 'フィルター設定',
- panelSearch: '検索設定',
- enableFilter: 'フィルター有効',
- searchAll: '全フィールド検索',
- verdictDefault: '-',
- verdictOff: 'off',
- verdictOn: 'on',
- searchScope: '検索範囲',
- scopeAll: 'すべて',
- scopeCustom: 'カスタム',
- filterScope: 'フィルター',
- filterOff: 'すべて表示',
- filterOn: 'カスタム',
- editSearch: '検索設定を開く',
- editFilter: 'フィルター設定を開く',
- pin: '右側に固定',
- unpin: '固定を解除',
title: 'ギャラリー',
- searchPlaceholder: '画像の内容を検索',
- sortByLabel: '並べ替え',
+ allImages: 'すべての画像',
+ count: '{count} 枚',
+ countFiltered: '{count} 枚が該当',
+ searchPlaceholder: '説明や画像内の文字を検索',
+ filters: 'フィルター',
+ clearFilters: 'フィルターをクリア',
+ searchIn: '検索対象',
+ searchInHint: 'キーワードはチェックした内容だけで照合します',
+ attrSection: '画像属性',
+ attrHint: '「非表示」はその値を持つ画像を除外し、「常に表示」は他の条件で非表示になっても残します',
+ verdictDefault: '指定なし',
+ verdictOff: '非表示',
+ verdictOn: '常に表示',
+ keywordsPlaceholder: 'キーワードはカンマで区切る',
+ noAttrs: '絞り込める属性はありません',
+ sort: '並べ替え',
+ sortField: '並べ替え基準',
+ sortOrder: '順序',
orderAsc: '昇順',
orderDesc: '降順',
- filtersTitle: 'フィルター',
- searchFields: '検索フィールド',
- modeAll: 'すべてのフィールド',
- modeCustom: 'カスタム',
- keywordsPlaceholder: 'キーワードはカンマで区切る',
- applyAll: '全属性に一括設定',
- count: '{count} 枚の画像',
- empty: 'このナレッジベースに画像はまだありません',
- emptyFiltered: '現在のフィルターに一致する画像はありません',
- attrSection: '画像属性',
- noAttrs: '画像属性はありません',
- attributes: '属性',
- caption: '説明',
- ocr: 'OCR テキスト',
- source: 'ソース',
- noCaption: '説明なし',
- noOcr: 'OCR テキストなし',
- chunkType: '種類',
- viewerClose: '閉じる',
- prev: '前へ',
- next: '次へ',
- openSource: 'ソース文書を開く',
+ empty: '閲覧できる画像はまだありません',
+ emptyHint: 'ドキュメント内の画像は解析完了後にここに表示されます',
+ emptyFiltered: '条件に一致する画像はありません',
imageLoadError: '画像の読み込みに失敗しました',
+ noCaption: '説明なし',
+ noOcr: '文字は認識されませんでした',
+ caption: '説明',
+ ocr: '画像内の文字(OCR)',
+ attributes: '属性',
+ source: '元のドキュメント',
+ details: '詳細',
+ dimensions: 'サイズ',
+ status: '状態',
+ openSource: '元のドキュメントを開く',
+ copy: 'コピー',
+ zoomIn: '拡大 (+)',
+ zoomOut: '縮小 (-)',
+ zoomReset: 'ウィンドウに合わせる (0)',
+ actualSize: '実寸',
+ rotate: '回転 (R)',
+ download: 'ダウンロード',
+ openOriginal: '新しいタブで開く',
+ toggleInfo: '画像情報 (I)',
+ viewerClose: '閉じる (Esc)',
+ prev: '前へ (←)',
+ next: '次へ (→)',
// Display names for the builtin attributes the gallery itself
// declares. Attributes contributed by other sources fall back to the
// pipeline's own wording (see the imageAttr namespace).
diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.ts
index 32256a356..7d3a5f4ac 100755
--- a/frontend/src/i18n/locales/ko-KR.ts
+++ b/frontend/src/i18n/locales/ko-KR.ts
@@ -4443,52 +4443,58 @@ export default {
pageActions: '페이지 작업',
tabDocuments: '문서',
tabGallery: '갤러리',
+ tabDocumentsTip: '원본 문서를 업로드하고 관리합니다',
+ tabWikiTip: '문서에서 자동으로 정리된 Wiki 페이지',
+ tabGalleryTip: '문서에서 추출한 모든 이미지를 둘러봅니다',
+ viewTabs: '지식베이스 보기',
gallery: {
- panelFilter: '필터 설정',
- panelSearch: '검색 설정',
- enableFilter: '필터 사용',
- searchAll: '전체 필드 검색',
- verdictDefault: '-',
- verdictOff: 'off',
- verdictOn: 'on',
- searchScope: '검색 범위',
- scopeAll: '전체',
- scopeCustom: '사용자 지정',
- filterScope: '필터',
- filterOff: '전체 표시',
- filterOn: '사용자 지정',
- editSearch: '검색 설정 열기',
- editFilter: '필터 설정 열기',
- pin: '오른쪽에 고정',
- unpin: '고정 해제',
title: '갤러리',
- searchPlaceholder: '이미지 내용 검색',
- sortByLabel: '정렬',
+ allImages: '모든 이미지',
+ count: '{count}장',
+ countFiltered: '{count}장 일치',
+ searchPlaceholder: '설명 또는 이미지 속 텍스트 검색',
+ filters: '필터',
+ clearFilters: '필터 지우기',
+ searchIn: '검색 범위',
+ searchInHint: '키워드는 체크한 내용에서만 일치 여부를 확인합니다',
+ attrSection: '이미지 속성',
+ attrHint: '"숨기기"는 해당 값을 가진 이미지를 제외하고, "항상 표시"는 다른 조건으로 숨겨져도 유지합니다',
+ verdictDefault: '전체',
+ verdictOff: '숨기기',
+ verdictOn: '항상 표시',
+ keywordsPlaceholder: '키워드는 쉼표로 구분',
+ noAttrs: '필터링할 속성이 없습니다',
+ sort: '정렬',
+ sortField: '정렬 기준',
+ sortOrder: '순서',
orderAsc: '오름차순',
orderDesc: '내림차순',
- filtersTitle: '필터',
- searchFields: '검색 필드',
- modeAll: '전체 필드',
- modeCustom: '사용자 지정',
- keywordsPlaceholder: '쉼표로 키워드 구분',
- applyAll: '모든 속성에 일괄 적용',
- count: '{count}개의 이미지',
- empty: '이 지식 베이스에는 아직 이미지가 없습니다',
- emptyFiltered: '현재 필터와 일치하는 이미지가 없습니다',
- attrSection: '이미지 속성',
- noAttrs: '사용 가능한 이미지 속성이 없습니다',
- attributes: '속성',
- caption: '설명',
- ocr: 'OCR 텍스트',
- source: '출처',
- noCaption: '설명 없음',
- noOcr: 'OCR 텍스트 없음',
- chunkType: '유형',
- viewerClose: '닫기',
- prev: '이전',
- next: '다음',
- openSource: '출처 문서 열기',
+ empty: '아직 볼 수 있는 이미지가 없습니다',
+ emptyHint: '문서 속 이미지는 파싱이 끝나면 여기에 표시됩니다',
+ emptyFiltered: '조건에 맞는 이미지가 없습니다',
imageLoadError: '이미지를 불러오지 못했습니다',
+ noCaption: '설명 없음',
+ noOcr: '인식된 텍스트 없음',
+ caption: '설명',
+ ocr: '이미지 속 텍스트(OCR)',
+ attributes: '속성',
+ source: '원본 문서',
+ details: '상세 정보',
+ dimensions: '크기',
+ status: '상태',
+ openSource: '원본 문서 열기',
+ copy: '복사',
+ zoomIn: '확대 (+)',
+ zoomOut: '축소 (-)',
+ zoomReset: '창에 맞추기 (0)',
+ actualSize: '원본 크기',
+ rotate: '회전 (R)',
+ download: '다운로드',
+ openOriginal: '새 탭에서 열기',
+ toggleInfo: '이미지 정보 (I)',
+ viewerClose: '닫기 (Esc)',
+ prev: '이전 (←)',
+ next: '다음 (→)',
// Display names for the builtin attributes the gallery itself
// declares. Attributes contributed by other sources fall back to the
// pipeline's own wording (see the imageAttr namespace).
diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts
index b05603bf4..916776d35 100755
--- a/frontend/src/i18n/locales/ru-RU.ts
+++ b/frontend/src/i18n/locales/ru-RU.ts
@@ -4443,52 +4443,58 @@ export default {
pageActions: 'Действия со страницей',
tabDocuments: 'Документы',
tabGallery: 'Галерея',
+ tabDocumentsTip: 'Загрузка исходных документов и управление ими',
+ tabWikiTip: 'Wiki-страницы, автоматически составленные из документов',
+ tabGalleryTip: 'Все изображения, извлечённые из документов',
+ viewTabs: 'Представления базы знаний',
gallery: {
- panelFilter: 'Фильтр',
- panelSearch: 'Поиск',
- enableFilter: 'Включить фильтр',
- searchAll: 'Искать во всех полях',
- verdictDefault: '-',
- verdictOff: 'off',
- verdictOn: 'on',
- searchScope: 'Область поиска',
- scopeAll: 'Все',
- scopeCustom: 'Вручную',
- filterScope: 'Фильтр',
- filterOff: 'Показывать все',
- filterOn: 'Вручную',
- editSearch: 'Открыть настройки поиска',
- editFilter: 'Открыть настройки фильтра',
- pin: 'Закрепить справа',
- unpin: 'Открепить',
title: 'Галерея',
- searchPlaceholder: 'Поиск по содержимому изображений',
- sortByLabel: 'Сортировка',
+ allImages: 'Все изображения',
+ count: 'Изображений: {count}',
+ countFiltered: 'Найдено: {count}',
+ searchPlaceholder: 'Поиск по описанию или тексту на изображении',
+ filters: 'Фильтры',
+ clearFilters: 'Сбросить фильтры',
+ searchIn: 'Где искать',
+ searchInHint: 'Ключевые слова ищутся только в отмеченных полях',
+ attrSection: 'Атрибуты изображений',
+ attrHint: '«Скрыть» убирает изображения с этим значением; «Всегда показывать» оставляет их, даже если другое правило их скрывает',
+ verdictDefault: 'Любое',
+ verdictOff: 'Скрыть',
+ verdictOn: 'Всегда показывать',
+ keywordsPlaceholder: 'Ключевые слова через запятую',
+ noAttrs: 'Нет атрибутов для фильтрации',
+ sort: 'Сортировка',
+ sortField: 'Сортировать по',
+ sortOrder: 'Порядок',
orderAsc: 'По возрастанию',
orderDesc: 'По убыванию',
- filtersTitle: 'Фильтры',
- searchFields: 'Поля поиска',
- modeAll: 'Все поля',
- modeCustom: 'Свои поля',
- keywordsPlaceholder: 'Разделяйте ключевые слова запятыми',
- applyAll: 'Применить ко всем атрибутам',
- count: '{count} изображений',
- empty: 'В этой базе знаний пока нет изображений',
- emptyFiltered: 'Нет изображений, соответствующих фильтрам',
- attrSection: 'Атрибуты изображения',
- noAttrs: 'Атрибуты изображения отсутствуют',
- attributes: 'Атрибуты',
- caption: 'Описание',
- ocr: 'OCR-текст',
- source: 'Источник',
+ empty: 'Изображений пока нет',
+ emptyHint: 'Изображения из документов появятся здесь после завершения разбора',
+ emptyFiltered: 'Нет изображений, подходящих под фильтры',
+ imageLoadError: 'Не удалось загрузить изображение',
noCaption: 'Нет описания',
- noOcr: 'Нет OCR-текста',
- chunkType: 'Тип',
- viewerClose: 'Закрыть',
- prev: 'Назад',
- next: 'Вперёд',
+ noOcr: 'Текст не распознан',
+ caption: 'Описание',
+ ocr: 'Текст на изображении (OCR)',
+ attributes: 'Атрибуты',
+ source: 'Исходный документ',
+ details: 'Подробности',
+ dimensions: 'Размер',
+ status: 'Статус',
openSource: 'Открыть исходный документ',
- imageLoadError: 'Не удалось загрузить изображение',
+ copy: 'Копировать',
+ zoomIn: 'Увеличить (+)',
+ zoomOut: 'Уменьшить (-)',
+ zoomReset: 'По размеру окна (0)',
+ actualSize: 'Исходный размер',
+ rotate: 'Повернуть (R)',
+ download: 'Скачать',
+ openOriginal: 'Открыть в новой вкладке',
+ toggleInfo: 'Сведения (I)',
+ viewerClose: 'Закрыть (Esc)',
+ prev: 'Назад (←)',
+ next: 'Вперёд (→)',
// Display names for the builtin attributes the gallery itself
// declares. Attributes contributed by other sources fall back to the
// pipeline's own wording (see the imageAttr namespace).
diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts
index 504cf33a0..79fc6b967 100755
--- a/frontend/src/i18n/locales/zh-CN.ts
+++ b/frontend/src/i18n/locales/zh-CN.ts
@@ -4444,53 +4444,59 @@ export default {
editingBadge: '编辑中',
pageActions: '页面操作',
tabDocuments: '文档',
- tabGallery: '图库',
+ tabGallery: '画廊',
+ tabDocumentsTip: '上传和管理原始文档',
+ tabWikiTip: '由文档自动整理生成的 Wiki 页面',
+ tabGalleryTip: '浏览从文档中解析出的全部图片',
+ viewTabs: '知识库视图',
gallery: {
- panelFilter: '筛选设置',
- panelSearch: '搜索设置',
- enableFilter: '开启筛选',
- searchAll: '搜索全部字段',
- verdictDefault: '-',
- verdictOff: 'off',
- verdictOn: 'on',
- searchScope: '搜索范围',
- scopeAll: '全部',
- scopeCustom: '自定义',
- filterScope: '筛选',
- filterOff: '全显示',
- filterOn: '自定义',
- editSearch: '打开搜索设置',
- editFilter: '打开筛选设置',
- pin: '固定到右侧',
- unpin: '取消固定',
- title: '图库',
- searchPlaceholder: '搜索图片内容',
- sortByLabel: '排序',
+ title: '画廊',
+ allImages: '全部图片',
+ count: '共 {count} 张',
+ countFiltered: '筛选出 {count} 张',
+ searchPlaceholder: '搜索图片描述或文字',
+ filters: '筛选',
+ clearFilters: '清除筛选',
+ searchIn: '搜索范围',
+ searchInHint: '关键词只在勾选的内容中匹配',
+ attrSection: '图片属性',
+ attrHint: '「隐藏」不显示带该属性的图片;「始终显示」即使被其他条件隐藏也保留',
+ verdictDefault: '不限',
+ verdictOff: '隐藏',
+ verdictOn: '始终显示',
+ keywordsPlaceholder: '多个关键词用逗号分隔',
+ noAttrs: '暂无可筛选的属性',
+ sort: '排序',
+ sortField: '排序依据',
+ sortOrder: '顺序',
orderAsc: '升序',
orderDesc: '降序',
- filtersTitle: '筛选',
- searchFields: '搜索字段',
- modeAll: '全部字段',
- modeCustom: '自定义',
- keywordsPlaceholder: '多个关键词用逗号分隔',
- applyAll: '全部属性统一设置',
- count: '{count} 张图片',
- empty: '该知识库暂无可浏览的图片',
- emptyFiltered: '没有符合当前筛选条件的图片',
- attrSection: '图片属性',
- noAttrs: '暂无图片属性',
- attributes: '属性',
+ empty: '还没有可浏览的图片',
+ emptyHint: '文档中的图片在解析完成后会出现在这里',
+ emptyFiltered: '没有符合条件的图片',
+ imageLoadError: '图片加载失败',
+ noCaption: '暂无描述',
+ noOcr: '未识别到文字',
caption: '描述',
- ocr: 'OCR 文本',
- source: '来源',
- noCaption: '无描述',
- noOcr: '无 OCR 文本',
- chunkType: '类型',
- viewerClose: '关闭',
- prev: '上一张',
- next: '下一张',
+ ocr: '图中文字(OCR)',
+ attributes: '属性',
+ source: '来源文档',
+ details: '详细信息',
+ dimensions: '尺寸',
+ status: '状态',
openSource: '打开来源文档',
- imageLoadError: '图片加载失败',
+ copy: '复制',
+ zoomIn: '放大 (+)',
+ zoomOut: '缩小 (-)',
+ zoomReset: '适应窗口 (0)',
+ actualSize: '原始尺寸',
+ rotate: '旋转 (R)',
+ download: '下载',
+ openOriginal: '在新标签页打开',
+ toggleInfo: '图片信息 (I)',
+ viewerClose: '关闭 (Esc)',
+ prev: '上一张 (←)',
+ next: '下一张 (→)',
// Display names for the builtin attributes the gallery itself
// declares. Attributes contributed by other sources fall back to the
// pipeline's own wording (see the imageAttr namespace).
diff --git a/frontend/src/views/knowledge/KnowledgeBase.vue b/frontend/src/views/knowledge/KnowledgeBase.vue
index d8170d671..116a26546 100644
--- a/frontend/src/views/knowledge/KnowledgeBase.vue
+++ b/frontend/src/views/knowledge/KnowledgeBase.vue
@@ -109,6 +109,27 @@ const wikiIndexingTip = computed(() => {
if (!wikiIsIndexing.value) return ''
return t('knowledgeEditor.wikiBrowser.queueStatus', { count: wikiStatus.value.pendingTasks || 0 })
})
+// The views of this knowledge base, in header order. Wiki and graph only
+// exist on wiki KBs; a stale wiki/graph tab on another KB renders documents,
+// so the header marks documents active then too.
+const kbViewTabs = computed(() => {
+ const w = 'knowledgeEditor.wikiBrowser'
+ const tabs: Array<{ key: KbTab; icon: string; label: string; tip: string; indexing?: boolean }> = [
+ { key: 'documents', icon: 'file', label: t(`${w}.tabDocuments`), tip: t(`${w}.tabDocumentsTip`) },
+ ]
+ if (isWiki.value) {
+ const indexing = wikiIsIndexing.value
+ tabs.push(
+ { key: 'wiki', icon: 'book-open', label: 'Wiki', tip: indexing ? wikiIndexingTip.value : t(`${w}.tabWikiTip`), indexing },
+ { key: 'graph', icon: 'relation', label: t(`${w}.tabGraph`), tip: indexing ? wikiIndexingTip.value : t(`${w}.tabGraphTip`), indexing },
+ )
+ }
+ tabs.push({ key: 'gallery', icon: 'image', label: t(`${w}.tabGallery`), tip: t(`${w}.tabGalleryTip`) })
+ return tabs
+})
+const shownKbTab = computed<KbTab>(() =>
+ kbViewTabs.value.some((tab) => tab.key === activeKbTab.value) ? activeKbTab.value : 'documents',
+)
const onWikiStatusChange = (payload: { pendingTasks: number; isActive: boolean; pendingIssues: number }) => {
wikiStatus.value = payload
}
@@ -2258,33 +2279,17 @@ const handleKBEditorSuccess = (kbIdValue: string) => {
</template>
</button>
<t-icon name="chevron-right" class="breadcrumb-separator" />
- <span :class="['breadcrumb-tab', { active: activeKbTab === 'documents' }]"
- @click="activeKbTab = 'documents'">{{ $t('knowledgeEditor.wikiBrowser.tabDocuments') }}</span>
- <template v-if="isWiki">
- <span class="breadcrumb-tab-sep">/</span>
- <span :class="['breadcrumb-tab', { active: activeKbTab === 'wiki', indexing: wikiIsIndexing }]"
- @click="activeKbTab = 'wiki'">
- Wiki
- <t-tooltip v-if="wikiIsIndexing" :content="wikiIndexingTip" placement="bottom">
- <t-loading size="small" class="breadcrumb-tab-indicator" />
- </t-tooltip>
- </span>
- <span class="breadcrumb-tab-sep">/</span>
- <t-tooltip :content="$t('knowledgeEditor.wikiBrowser.tabGraphTip')" placement="bottom">
- <span :class="['breadcrumb-tab', { active: activeKbTab === 'graph', indexing: wikiIsIndexing }]"
- @click="activeKbTab = 'graph'">
- {{ $t('knowledgeEditor.wikiBrowser.tabGraph') }}
- <t-tooltip v-if="wikiIsIndexing" :content="wikiIndexingTip" placement="bottom">
- <t-loading size="small" class="breadcrumb-tab-indicator" />
- </t-tooltip>
- </span>
+ <div class="kb-view-tabs" role="tablist" :aria-label="$t('knowledgeEditor.wikiBrowser.viewTabs')">
+ <t-tooltip v-for="tab in kbViewTabs" :key="tab.key" :content="tab.tip" placement="bottom">
+ <button type="button" role="tab" class="kb-view-tab"
+ :class="{ active: shownKbTab === tab.key, indexing: tab.indexing }"
+ :aria-selected="shownKbTab === tab.key" @click="activeKbTab = tab.key">
+ <t-loading v-if="tab.indexing" size="small" class="kb-view-tab__indicator" />
+ <t-icon v-else :name="tab.icon" size="16px" />
+ <span>{{ tab.label }}</span>
+ </button>
</t-tooltip>
- <span class="breadcrumb-tab-sep">/</span>
- </template>
- <span :class="['breadcrumb-tab', { active: activeKbTab === 'gallery' }]"
- @click="activeKbTab = 'gallery'">
- {{ $t('knowledgeEditor.wikiBrowser.tabGallery') }}
- </span>
+ </div>
</h2>
<!-- 标题行右侧的动作锚点:聚拢"信息"和"设置"两个圆形按钮。 -->
<div class="kb-title-actions">
@@ -2322,7 +2327,7 @@ const handleKBEditorSuccess = (kbIdValue: string) => {
</div>
<!-- Image Gallery (4th tab) -->
- <ImageGallery v-if="activeKbTab === 'gallery' && kbId" :knowledge-base-id="kbId" />
+ <ImageGallery v-if="activeKbTab === 'gallery' && kbId" :knowledge-base-id="kbId" @open-source-doc="openSourceDoc" />
<!-- wiki/graph tabs only exist on wiki KBs; a stale tab (?tab= or one
carried over from a previous KB) falls back to documents. -->
@@ -2643,42 +2648,57 @@ const handleKBEditorSuccess = (kbIdValue: string) => {
box-sizing: border-box;
}
-// Breadcrumb tab switch (文档/Wiki in breadcrumb)
-.breadcrumb-tab {
- cursor: pointer;
- color: var(--td-text-color-placeholder);
- font-weight: 400;
- transition: color var(--app-motion-fast);
+// View switch (文档 / Wiki / 图谱 / 画廊): a segmented control after the
+// breadcrumb, drawn like the documents tab's view toggle so the four views
+// read as siblings rather than as another breadcrumb level.
+.kb-view-tabs {
display: inline-flex;
align-items: center;
- gap: 4px;
+ gap: 2px;
+ margin-left: 2px;
+ padding: 3px;
+ border-radius: var(--app-radius-lg);
+ background: var(--td-bg-color-secondarycontainer);
+}
+
+.kb-view-tab {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ height: 28px;
+ padding: 0 12px;
+ border: 0;
+ border-radius: var(--app-radius-md);
+ background: transparent;
+ color: var(--td-text-color-secondary);
+ font-family: var(--app-font-family);
+ font-size: var(--app-text-base);
+ font-weight: 500;
+ line-height: 1;
+ white-space: nowrap;
+ cursor: pointer;
+ transition: color var(--app-motion-fast) ease, background-color var(--app-motion-fast) ease;
&:hover {
color: var(--td-text-color-primary);
}
&.active {
+ background: var(--td-bg-color-container);
color: var(--td-brand-color);
font-weight: 600;
+ box-shadow: 0 1px 3px rgb(0 0 0 / 8%);
}
- &.indexing {
- color: var(--td-brand-color);
+ &:focus-visible {
+ outline: 2px solid var(--app-focus-border);
+ outline-offset: 1px;
}
-}
-.breadcrumb-tab-indicator {
- display: inline-flex;
- align-items: center;
- color: var(--td-brand-color);
- font-size: var(--app-text-sm);
- line-height: 1;
-}
-
-.breadcrumb-tab-sep {
- margin: 0 6px;
- color: var(--td-text-color-disabled);
- font-weight: 400;
+ &__indicator {
+ display: inline-flex;
+ color: var(--td-brand-color);
+ }
}
.wiki-main-area {
@@ -3102,7 +3122,9 @@ const handleKBEditorSuccess = (kbIdValue: string) => {
.document-breadcrumb {
display: flex;
align-items: center;
+ flex-wrap: wrap;
gap: 6px;
+ row-gap: 8px;
margin: 0;
font-size: var(--app-text-3xl);
font-weight: 600;
@@ -3120,6 +3142,7 @@ const handleKBEditorSuccess = (kbIdValue: string) => {
display: inline-flex;
align-items: center;
gap: 4px;
+ white-space: nowrap;
border-radius: var(--app-radius-sm);
transition: all var(--app-motion-instant) ease;
diff --git a/frontend/src/views/knowledge/gallery/GalleryViewer.vue b/frontend/src/views/knowledge/gallery/GalleryViewer.vue
new file mode 100644
index 000000000..48c6f8e3e
--- /dev/null
+++ b/frontend/src/views/knowledge/gallery/GalleryViewer.vue
@@ -0,0 +1,816 @@
+<script setup lang="ts">
+import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
+import { useI18n } from 'vue-i18n'
+import type { ImageAsset } from '@/api/image-gallery'
+import { copyWithToast } from '@/utils/clipboard'
+
+export interface GalleryAttrRow {
+ key: string
+ label: string
+ value: string
+}
+
+const props = defineProps<{
+ /** The images of the page on screen; the viewer walks them in order. */
+ items: ImageAsset[]
+ index: number
+ /** Position of items[0] in the whole result set, so the counter and the
+ * prev/next bounds speak about every image, not just this page. */
+ offset: number
+ total: number
+ /** A neighbouring page is being fetched; navigation waits for it. */
+ loading: boolean
+ thumbUrls: Record<string, string>
+ resolveSrc: (url: string) => Promise<string>
+ attrRows: (img: ImageAsset) => GalleryAttrRow[]
+}>()
+
+const emit = defineEmits<{
+ (e: 'close'): void
+ (e: 'select', index: number): void
+ /** Step past the page edge; the gallery loads the neighbouring page. */
+ (e: 'step', delta: 1 | -1): void
+ (e: 'open-source', knowledgeId: string): void
+}>()
+
+const NS = 'knowledgeEditor.wikiBrowser.gallery'
+const { t, locale } = useI18n()
+
+const current = computed<ImageAsset | null>(() => props.items[props.index] ?? null)
+const position = computed(() => props.offset + props.index + 1)
+const hasPrev = computed(() => position.value > 1)
+const hasNext = computed(() => position.value < props.total)
+
+function prev(): void {
+ if (props.loading || !hasPrev.value) return
+ if (props.index > 0) emit('select', props.index - 1)
+ else emit('step', -1)
+}
+
+function next(): void {
+ if (props.loading || !hasNext.value) return
+ if (props.index < props.items.length - 1) emit('select', props.index + 1)
+ else emit('step', 1)
+}
+
+// ---------------------------------------------------------------------------
+// Zoom, pan and rotation. Scale 1 is "fit to the stage"; the translation is
+// kept relative to the stage centre so zooming can anchor on the cursor.
+// ---------------------------------------------------------------------------
+const MIN_SCALE = 0.2
+const MAX_SCALE = 8
+const scale = ref(1)
+const rotation = ref(0)
+const tx = ref(0)
+const ty = ref(0)
+const dragging = ref(false)
+
+function resetView(): void {
+ scale.value = 1
+ rotation.value = 0
+ tx.value = 0
+ ty.value = 0
+}
+
+function zoomTo(target: number, anchor?: { x: number; y: number }): void {
+ const next = Math.min(MAX_SCALE, Math.max(MIN_SCALE, target))
+ const k = next / scale.value
+ const ax = anchor?.x ?? 0
+ const ay = anchor?.y ?? 0
+ tx.value = ax - (ax - tx.value) * k
+ ty.value = ay - (ay - ty.value) * k
+ scale.value = next
+ // Nothing to pan once the image fits again; re-centre it.
+ if (next <= fitScale()) {
+ tx.value = 0
+ ty.value = 0
+ }
+}
+
+/** The scale at which the (possibly rotated) image fits the stage. */
+function fitScale(): number {
+ const img = imgEl.value
+ const stage = stageEl.value
+ if (!img || !stage || rotation.value % 180 === 0) return 1
+ const w = img.clientWidth
+ const h = img.clientHeight
+ if (!w || !h) return 1
+ const style = getComputedStyle(stage)
+ const boxW = stage.clientWidth - parseFloat(style.paddingLeft) - parseFloat(style.paddingRight)
+ const boxH = stage.clientHeight - parseFloat(style.paddingTop) - parseFloat(style.paddingBottom)
+ return Math.min(1, boxW / h, boxH / w)
+}
+
+/** The scale at which one image pixel is one screen pixel. */
+function actualScale(): number {
+ const img = imgEl.value
+ if (!img || !natural.value || !img.clientWidth) return 1
+ return natural.value.w / img.clientWidth
+}
+
+function anchorOf(e: { clientX: number; clientY: number }): { x: number; y: number } {
+ const rect = stageEl.value?.getBoundingClientRect()
+ if (!rect) return { x: 0, y: 0 }
+ return { x: e.clientX - rect.left - rect.width / 2, y: e.clientY - rect.top - rect.height / 2 }
+}
+
+const zoomIn = () => zoomTo(scale.value * 1.25)
+const zoomOut = () => zoomTo(scale.value / 1.25)
+const zoomActual = () => zoomTo(actualScale())
+
+function rotate(): void {
+ rotation.value = (rotation.value + 90) % 360
+ tx.value = 0
+ ty.value = 0
+ scale.value = fitScale()
+}
+
+function onWheel(e: WheelEvent): void {
+ if (!loaded.value) return
+ zoomTo(scale.value * Math.exp(-e.deltaY * 0.002), anchorOf(e))
+}
+
+function onDblClick(e: MouseEvent): void {
+ if (!loaded.value) return
+ if (Math.abs(scale.value - fitScale()) > 0.01) {
+ resetView()
+ scale.value = fitScale()
+ } else {
+ zoomTo(Math.max(2, actualScale()), anchorOf(e))
+ }
+}
+
+let dragStart: { x: number; y: number; tx: number; ty: number } | null = null
+
+function onPointerDown(e: PointerEvent): void {
+ if (e.button !== 0 || !loaded.value || scale.value <= fitScale()) return
+ dragStart = { x: e.clientX, y: e.clientY, tx: tx.value, ty: ty.value }
+ dragging.value = true
+ ;(e.currentTarget as HTMLElement).setPointerCapture(e.pointerId)
+}
+
+function onPointerMove(e: PointerEvent): void {
+ if (!dragStart) return
+ tx.value = dragStart.tx + e.clientX - dragStart.x
+ ty.value = dragStart.ty + e.clientY - dragStart.y
+}
+
+function onPointerUp(): void {
+ dragStart = null
+ dragging.value = false
+}
+
+// ---------------------------------------------------------------------------
+// Source resolution. The <img> is rendered only once a displayable source is
+// in hand: a raw storage handle would fire the error handler and mask the
+// image that is still being fetched. The token keeps a slow fetch from
+// overwriting a faster one that navigated past it.
+// ---------------------------------------------------------------------------
+const src = ref('')
+const loaded = ref(false)
+const failed = ref(false)
+const natural = ref<{ w: number; h: number } | null>(null)
+let srcToken = 0
+
+watch(
+ () => current.value?.url,
+ async (url) => {
+ const token = ++srcToken
+ resetView()
+ src.value = ''
+ loaded.value = false
+ failed.value = false
+ natural.value = null
+ if (!url) return
+ const resolved = await props.resolveSrc(url)
+ if (token !== srcToken) return
+ src.value = resolved
+ },
+ { immediate: true },
+)
+
+const imgEl = ref<HTMLImageElement | null>(null)
+const stageEl = ref<HTMLElement | null>(null)
+
+function onImgLoad(): void {
+ loaded.value = true
+ const el = imgEl.value
+ if (el) natural.value = { w: el.naturalWidth, h: el.naturalHeight }
+}
+
+function onImgError(): void {
+ failed.value = true
+}
+
+const canPan = computed(() => loaded.value && scale.value > 1)
+const zoomPercent = computed(() => `${Math.round(scale.value * 100)}%`)
+const imgStyle = computed(() => ({
+ transform: `translate(${tx.value}px, ${ty.value}px) rotate(${rotation.value}deg) scale(${scale.value})`,
+}))
+
+// ---------------------------------------------------------------------------
+// Actions
+// ---------------------------------------------------------------------------
+const EXT_BY_TYPE: Record<string, string> = {
+ 'image/png': 'png',
+ 'image/jpeg': 'jpg',
+ 'image/gif': 'gif',
+ 'image/webp': 'webp',
+ 'image/svg+xml': 'svg',
+ 'image/bmp': 'bmp',
+}
+
+function downloadName(img: ImageAsset, type: string): string {
+ const base = (img.source_name || 'image').replace(/\.[^./\\]+$/, '').replace(/[\\/:*?"<>|]+/g, '_')
+ const fromUrl = /\.([a-z0-9]{2,5})(?:$|[?#])/i.exec(img.url)?.[1]
+ const ext = EXT_BY_TYPE[type] || fromUrl || 'png'
+ return `${base}-${position.value}.${ext}`
+}
+
+async function download(): Promise<void> {
+ const img = current.value
+ if (!img || !src.value) return
+ try {
+ const blob = await (await fetch(src.value)).blob()
+ const url = URL.createObjectURL(blob)
+ const a = document.createElement('a')
+ a.href = url
+ a.download = downloadName(img, blob.type)
+ a.click()
+ setTimeout(() => URL.revokeObjectURL(url), 1000)
+ } catch {
+ // A cross-origin image the browser may not read back: let it open instead.
+ openOriginal()
+ }
+}
+
+function openOriginal(): void {
+ if (src.value) window.open(src.value, '_blank', 'noopener')
+}
+
+const copyText = (text: string) => copyWithToast(text, 'common.copySuccess')
+
+// The info panel is a per-viewer preference; storage may be unavailable.
+const INFO_KEY = 'weknora_gallery_viewer_info'
+function readInfoPref(): boolean {
+ try {
+ return localStorage.getItem(INFO_KEY) !== '0'
+ } catch {
+ return true
+ }
+}
+const showInfo = ref(readInfoPref())
+function toggleInfo(): void {
+ showInfo.value = !showInfo.value
+ try {
+ localStorage.setItem(INFO_KEY, showInfo.value ? '1' : '0')
+ } catch {
+ // Not remembered this time; the toggle itself still works.
+ }
+}
+
+const attrs = computed(() => (current.value ? props.attrRows(current.value) : []))
+
+function formatTime(iso: string): string {
+ if (!iso) return ''
+ const d = new Date(iso)
+ return Number.isNaN(d.getTime()) ? iso : d.toLocaleString(locale.value)
+}
+
+// ---------------------------------------------------------------------------
+// Filmstrip: keep the current thumbnail in view as the viewer moves.
+// ---------------------------------------------------------------------------
+const stripEl = ref<HTMLElement | null>(null)
+watch(
+ () => [props.index, props.items] as const,
+ async () => {
+ await nextTick()
+ const el = stripEl.value?.querySelector<HTMLElement>('.igv-strip__item.is-current')
+ el?.scrollIntoView({ block: 'nearest', inline: 'center', behavior: 'smooth' })
+ },
+ { immediate: true },
+)
+
+// ---------------------------------------------------------------------------
+// Keyboard. Bound on window while the viewer is mounted: the overlay itself is
+// never focused, so a listener on it would never hear a key.
+// ---------------------------------------------------------------------------
+function onKey(e: KeyboardEvent): void {
+ if (e.defaultPrevented || e.metaKey || e.ctrlKey || e.altKey) return
+ const target = e.target as HTMLElement | null
+ if (target?.closest?.('input, textarea, select, [contenteditable="true"]')) return
+ const actions: Record<string, () => void> = {
+ Escape: () => emit('close'),
+ ArrowLeft: prev,
+ ArrowRight: next,
+ '+': zoomIn,
+ '=': zoomIn,
+ '-': zoomOut,
+ '0': () => resetView(),
+ r: rotate,
+ i: toggleInfo,
+ }
+ const action = actions[e.key]
+ if (!action) return
+ e.preventDefault()
+ action()
+}
+
+onMounted(() => window.addEventListener('keydown', onKey))
+onBeforeUnmount(() => window.removeEventListener('keydown', onKey))
+</script>
+
+<template>
+ <Teleport to="body">
+ <div class="igv" :class="{ 'has-info': showInfo }" role="dialog" aria-modal="true" :aria-label="current?.caption || t(`${NS}.title`)">
+ <div class="igv-main">
+ <header class="igv-topbar">
+ <div class="igv-topbar__title">
+ <span class="igv-counter">{{ position }} / {{ total }}</span>
+ <span class="igv-name" :title="current?.source_name">{{ current?.source_name || current?.knowledge_id }}</span>
+ </div>
+ <div class="igv-tools">
+ <t-tooltip :content="t(`${NS}.zoomOut`)">
+ <button type="button" class="igv-tool" :disabled="!loaded" :aria-label="t(`${NS}.zoomOut`)" @click="zoomOut">
+ <t-icon name="zoom-out" />
+ </button>
+ </t-tooltip>
+ <t-tooltip :content="t(`${NS}.zoomReset`)">
+ <button type="button" class="igv-tool igv-tool--text" :disabled="!loaded" @click="resetView">{{ zoomPercent }}</button>
+ </t-tooltip>
+ <t-tooltip :content="t(`${NS}.zoomIn`)">
+ <button type="button" class="igv-tool" :disabled="!loaded" :aria-label="t(`${NS}.zoomIn`)" @click="zoomIn">
+ <t-icon name="zoom-in" />
+ </button>
+ </t-tooltip>
+ <t-tooltip :content="t(`${NS}.actualSize`)">
+ <button type="button" class="igv-tool igv-tool--text" :disabled="!loaded" @click="zoomActual">1:1</button>
+ </t-tooltip>
+ <t-tooltip :content="t(`${NS}.rotate`)">
+ <button type="button" class="igv-tool" :disabled="!loaded" :aria-label="t(`${NS}.rotate`)" @click="rotate">
+ <t-icon name="rotation" />
+ </button>
+ </t-tooltip>
+ <span class="igv-tools__sep" />
+ <t-tooltip :content="t(`${NS}.download`)">
+ <button type="button" class="igv-tool" :disabled="!src" :aria-label="t(`${NS}.download`)" @click="download">
+ <t-icon name="download" />
+ </button>
+ </t-tooltip>
+ <t-tooltip :content="t(`${NS}.openOriginal`)">
+ <button type="button" class="igv-tool" :disabled="!src" :aria-label="t(`${NS}.openOriginal`)" @click="openOriginal">
+ <t-icon name="jump" />
+ </button>
+ </t-tooltip>
+ <t-tooltip :content="t(`${NS}.toggleInfo`)">
+ <button type="button" class="igv-tool" :class="{ 'is-on': showInfo }" :aria-pressed="showInfo" :aria-label="t(`${NS}.toggleInfo`)" @click="toggleInfo">
+ <t-icon name="info-circle" />
+ </button>
+ </t-tooltip>
+ <span class="igv-tools__sep" />
+ <t-tooltip :content="t(`${NS}.viewerClose`)">
+ <button type="button" class="igv-tool" :aria-label="t(`${NS}.viewerClose`)" @click="emit('close')">
+ <t-icon name="close" />
+ </button>
+ </t-tooltip>
+ </div>
+ </header>
+
+ <div
+ ref="stageEl"
+ class="igv-stage"
+ :class="{ 'can-pan': canPan, 'is-dragging': dragging }"
+ @wheel.prevent="onWheel"
+ @dblclick="onDblClick"
+ @pointerdown="onPointerDown"
+ @pointermove="onPointerMove"
+ @pointerup="onPointerUp"
+ @pointercancel="onPointerUp"
+ @click.self="emit('close')"
+ >
+ <img
+ v-if="src && !failed"
+ ref="imgEl"
+ :src="src"
+ :alt="current?.caption"
+ class="igv-image"
+ :class="{ 'is-loaded': loaded }"
+ :style="imgStyle"
+ draggable="false"
+ @load="onImgLoad"
+ @error="onImgError"
+ />
+ <div v-if="failed" class="igv-state">
+ <t-icon name="image-error" size="32px" />
+ <span>{{ t(`${NS}.imageLoadError`) }}</span>
+ </div>
+ <t-loading v-else-if="!loaded || loading" class="igv-state" size="medium" />
+
+ <button type="button" class="igv-nav igv-nav--prev" :disabled="!hasPrev || loading" :aria-label="t(`${NS}.prev`)" @click.stop="prev">
+ <t-icon name="chevron-left" size="24px" />
+ </button>
+ <button type="button" class="igv-nav igv-nav--next" :disabled="!hasNext || loading" :aria-label="t(`${NS}.next`)" @click.stop="next">
+ <t-icon name="chevron-right" size="24px" />
+ </button>
+ </div>
+
+ <div v-if="items.length > 1" ref="stripEl" class="igv-strip">
+ <button
+ v-for="(img, i) in items"
+ :key="img.id"
+ type="button"
+ class="igv-strip__item"
+ :class="{ 'is-current': i === index }"
+ :aria-label="img.caption || String(offset + i + 1)"
+ @click="emit('select', i)"
+ >
+ <img v-if="thumbUrls[img.id]" :src="thumbUrls[img.id]" alt="" draggable="false" />
+ </button>
+ </div>
+ </div>
+
+ <aside v-if="showInfo && current" class="igv-info">
+ <section class="igv-section">
+ <div class="igv-section__head">
+ <h3>{{ t(`${NS}.caption`) }}</h3>
+ <button v-if="current.caption" type="button" class="igv-copy" @click="copyText(current.caption)">
+ <t-icon name="file-copy" size="14px" />{{ t(`${NS}.copy`) }}
+ </button>
+ </div>
+ <p class="igv-text" :class="{ 'is-muted': !current.caption }">{{ current.caption || t(`${NS}.noCaption`) }}</p>
+ </section>
+
+ <section class="igv-section">
+ <div class="igv-section__head">
+ <h3>{{ t(`${NS}.ocr`) }}</h3>
+ <button v-if="current.ocr_text" type="button" class="igv-copy" @click="copyText(current.ocr_text)">
+ <t-icon name="file-copy" size="14px" />{{ t(`${NS}.copy`) }}
+ </button>
+ </div>
+ <p class="igv-text" :class="{ 'is-muted': !current.ocr_text }">{{ current.ocr_text || t(`${NS}.noOcr`) }}</p>
+ </section>
+
+ <section v-if="attrs.length" class="igv-section">
+ <div class="igv-section__head"><h3>{{ t(`${NS}.attributes`) }}</h3></div>
+ <dl class="igv-props">
+ <template v-for="a in attrs" :key="a.key">
+ <dt>{{ a.label }}</dt>
+ <dd>{{ a.value }}</dd>
+ </template>
+ </dl>
+ </section>
+
+ <section class="igv-section">
+ <div class="igv-section__head"><h3>{{ t(`${NS}.details`) }}</h3></div>
+ <dl class="igv-props">
+ <dt>{{ t(`${NS}.source`) }}</dt>
+ <dd>
+ <button type="button" class="igv-source" :title="t(`${NS}.openSource`)" @click="emit('open-source', current.knowledge_id)">
+ <t-icon name="file" size="14px" />
+ <span>{{ current.source_name || current.knowledge_id }}</span>
+ </button>
+ </dd>
+ <template v-if="natural">
+ <dt>{{ t(`${NS}.dimensions`) }}</dt>
+ <dd>{{ natural.w }} × {{ natural.h }}</dd>
+ </template>
+ <dt>{{ t(`${NS}.status`) }}</dt>
+ <dd>
+ <t-tag size="small" variant="light" :theme="current.is_enabled ? 'success' : 'default'">
+ {{ t(`${NS}.attr.builtin_is_enabled_value_${current.is_enabled ? 'true' : 'false'}`) }}
+ </t-tag>
+ </dd>
+ <template v-if="current.created_at">
+ <dt>{{ t(`${NS}.attr.builtin_created_at`) }}</dt>
+ <dd>{{ formatTime(current.created_at) }}</dd>
+ </template>
+ </dl>
+ </section>
+ </aside>
+ </div>
+ </Teleport>
+</template>
+
+<style scoped lang="less">
+// The stage is always dark, whatever the app theme: images read best on a
+// neutral dark ground, and the controls over it are sized for that.
+.igv {
+ --igv-stage-bg: #111214;
+ --igv-chrome-fg: rgb(255 255 255 / 86%);
+ --igv-chrome-muted: rgb(255 255 255 / 55%);
+ --igv-chrome-hover: rgb(255 255 255 / 12%);
+
+ position: fixed;
+ inset: 0;
+ z-index: var(--z-drawer);
+ display: grid;
+ grid-template-columns: minmax(0, 1fr);
+ background: var(--igv-stage-bg);
+ color: var(--igv-chrome-fg);
+
+ &.has-info {
+ grid-template-columns: minmax(0, 1fr) 360px;
+ }
+}
+
+.igv-main {
+ display: flex;
+ flex-direction: column;
+ min-width: 0;
+ min-height: 0;
+}
+
+.igv-topbar {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 16px;
+ height: 52px;
+ padding: 0 12px 0 20px;
+ flex-shrink: 0;
+
+ &__title {
+ display: flex;
+ align-items: baseline;
+ gap: 12px;
+ min-width: 0;
+ }
+}
+
+.igv-counter {
+ font-size: var(--app-text-md);
+ font-variant-numeric: tabular-nums;
+ color: var(--igv-chrome-muted);
+ white-space: nowrap;
+}
+
+.igv-name {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ font-size: var(--app-text-base);
+}
+
+.igv-tools {
+ display: flex;
+ align-items: center;
+ gap: 2px;
+ flex-shrink: 0;
+
+ &__sep {
+ width: 1px;
+ height: 18px;
+ margin: 0 6px;
+ background: rgb(255 255 255 / 16%);
+ }
+}
+
+.igv-tool {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ min-width: 32px;
+ height: 32px;
+ padding: 0 6px;
+ border: 0;
+ border-radius: var(--app-radius-sm);
+ background: transparent;
+ color: var(--igv-chrome-fg);
+ font: inherit;
+ font-size: var(--app-text-xl);
+ cursor: pointer;
+ transition: background-color var(--app-motion-fast) ease;
+
+ &--text {
+ min-width: 48px;
+ font-size: var(--app-text-sm);
+ font-variant-numeric: tabular-nums;
+ }
+
+ &:hover:not(:disabled),
+ &.is-on {
+ background: var(--igv-chrome-hover);
+ }
+
+ &:disabled {
+ opacity: 0.35;
+ cursor: default;
+ }
+
+ &:focus-visible {
+ outline: 2px solid var(--app-focus-border);
+ outline-offset: 1px;
+ }
+}
+
+.igv-stage {
+ position: relative;
+ flex: 1;
+ min-height: 0;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ overflow: hidden;
+ padding: 16px 72px;
+ user-select: none;
+ touch-action: none;
+
+ &.can-pan { cursor: grab; }
+ &.is-dragging { cursor: grabbing; }
+}
+
+.igv-image {
+ max-width: 100%;
+ max-height: 100%;
+ object-fit: contain;
+ opacity: 0;
+ transition: transform var(--app-motion-fast) ease, opacity var(--app-motion-fast) ease;
+ will-change: transform;
+
+ &.is-loaded { opacity: 1; }
+
+ .is-dragging & { transition: opacity var(--app-motion-fast) ease; }
+}
+
+.igv-state {
+ position: absolute;
+ inset: 0;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ gap: 8px;
+ color: var(--igv-chrome-muted);
+ font-size: var(--app-text-md);
+ pointer-events: none;
+}
+
+.igv-nav {
+ position: absolute;
+ top: 50%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 44px;
+ height: 44px;
+ margin-top: -22px;
+ border: 0;
+ border-radius: var(--app-radius-pill);
+ background: rgb(255 255 255 / 10%);
+ color: var(--igv-chrome-fg);
+ cursor: pointer;
+ transition: background-color var(--app-motion-fast) ease, opacity var(--app-motion-fast) ease;
+
+ &--prev { left: 16px; }
+ &--next { right: 16px; }
+
+ &:hover:not(:disabled) { background: rgb(255 255 255 / 20%); }
+ &:disabled { opacity: 0.2; cursor: default; }
+ &:focus-visible { outline: 2px solid var(--app-focus-border); outline-offset: 2px; }
+}
+
+.igv-strip {
+ display: flex;
+ gap: 6px;
+ flex-shrink: 0;
+ padding: 10px 20px 14px;
+ overflow-x: auto;
+ scrollbar-width: thin;
+ scrollbar-color: rgb(255 255 255 / 20%) transparent;
+
+ &__item {
+ flex: 0 0 auto;
+ width: 56px;
+ height: 42px;
+ padding: 0;
+ border: 2px solid transparent;
+ border-radius: var(--app-radius-xs);
+ overflow: hidden;
+ background: rgb(255 255 255 / 8%);
+ opacity: 0.5;
+ cursor: pointer;
+ transition: opacity var(--app-motion-fast) ease, border-color var(--app-motion-fast) ease;
+
+ img {
+ display: block;
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ }
+
+ &:hover { opacity: 0.85; }
+
+ &.is-current {
+ opacity: 1;
+ border-color: var(--td-brand-color);
+ }
+ }
+}
+
+.igv-info {
+ min-height: 0;
+ overflow-y: auto;
+ padding: 20px;
+ background: var(--td-bg-color-container);
+ color: var(--td-text-color-primary);
+ border-left: 1px solid var(--td-component-stroke);
+}
+
+.igv-section {
+ & + & {
+ margin-top: 20px;
+ padding-top: 16px;
+ border-top: 1px solid var(--td-component-stroke);
+ }
+
+ &__head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 8px;
+ margin-bottom: 8px;
+
+ h3 {
+ margin: 0;
+ font-size: var(--app-text-md);
+ font-weight: 600;
+ color: var(--td-text-color-secondary);
+ }
+ }
+}
+
+.igv-copy {
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ padding: 2px 6px;
+ border: 0;
+ border-radius: var(--app-radius-xs);
+ background: transparent;
+ color: var(--td-text-color-secondary);
+ font: inherit;
+ font-size: var(--app-text-sm);
+ cursor: pointer;
+
+ &:hover {
+ color: var(--td-brand-color);
+ background: var(--td-bg-color-container-hover);
+ }
+}
+
+.igv-text {
+ margin: 0;
+ font-size: var(--app-text-base);
+ line-height: 1.65;
+ white-space: pre-wrap;
+ word-break: break-word;
+
+ &.is-muted { color: var(--td-text-color-placeholder); }
+}
+
+.igv-props {
+ display: grid;
+ grid-template-columns: max-content minmax(0, 1fr);
+ gap: 8px 16px;
+ margin: 0;
+ font-size: var(--app-text-md);
+ line-height: 22px;
+
+ dt { color: var(--td-text-color-secondary); }
+ dd {
+ margin: 0;
+ min-width: 0;
+ text-align: right;
+ word-break: break-word;
+ }
+}
+
+.igv-source {
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ max-width: 100%;
+ padding: 0;
+ border: 0;
+ background: transparent;
+ color: var(--td-brand-color);
+ font: inherit;
+ cursor: pointer;
+
+ span {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ &:hover span { text-decoration: underline; }
+}
+
+@media (max-width: 900px) {
+ .igv.has-info { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 40%; }
+ .igv-info { border-left: 0; border-top: 1px solid var(--td-component-stroke); }
+ .igv-stage { padding: 12px 56px; }
+}
+</style>
diff --git a/frontend/src/views/knowledge/gallery/ImageGallery.vue b/frontend/src/views/knowledge/gallery/ImageGallery.vue
index ba1c34e91..e5eeeabae 100644
--- a/frontend/src/views/knowledge/gallery/ImageGallery.vue
+++ b/frontend/src/views/knowledge/gallery/ImageGallery.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
-import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
+import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import {
listGalleryImages,
@@ -10,12 +10,19 @@ import {
type ImageListParams,
} from '@/api/image-gallery'
import { updateMyPreferences } from '@/api/auth'
+import EmptyState from '@/components/EmptyState.vue'
import { galleryImageRequest } from './galleryImageSrc'
+import GalleryViewer, { type GalleryAttrRow } from './GalleryViewer.vue'
const props = defineProps<{
knowledgeBaseId: string
}>()
+const emit = defineEmits<{
+ (e: 'open-source-doc', knowledgeId: string): void
+}>()
+
+const NS = 'knowledgeEditor.wikiBrowser.gallery'
const { t, te } = useI18n()
// ---------------------------------------------------------------------------
@@ -32,38 +39,23 @@ const keyword = ref('')
const sortBy = ref('')
const sortOrder = ref<'asc' | 'desc'>('desc')
-// The two scope switches in the toolbar row. Each has the same shape: the
-// inclusive position drops the constraint entirely, the custom position
-// opens the panel that edits it. "筛选:全显示" therefore really is a
-// switch — when it reads "全显示", no attribute constraint is sent at all.
-const searchScope = ref<'all' | 'custom'>('all')
-const filterScope = ref<'all' | 'custom'>('all')
-
-// Which settings panel is on screen. A panel opens as a popover under the
-// arrow that summoned it, and a pin moves it into the right-hand rail,
-// where the two panels take turns as tabs instead of both eating space.
-const openPanel = ref<'search' | 'filter' | ''>('')
-const pinnedPanel = ref<'search' | 'filter' | ''>('')
-const panelTab = ref<'search' | 'filter'>('search')
-// Where the floating panel hangs: captured from the arrow that opened it,
-// so it sits directly beneath that control instead of at a guessed spot.
-const panelPos = ref<{ top: number; left: number } | null>(null)
-const rootEl = ref<HTMLElement | null>(null)
-
-// Attribute selections: namespaced attr id -> selected allowed values (OR
-// within the attribute, AND across attributes). Free-text attributes have no
-// value list to pick from, so they carry their own literal selection.
+const filterPanelVisible = ref(false)
+const sortPanelVisible = ref(false)
+const scrollEl = ref<HTMLElement | null>(null)
+
+// Attribute selections for free-text ("keywords") attributes: namespaced attr
+// id -> literal values (OR within the attribute, AND across attributes).
const attrSelections = ref<Record<string, string[]>>({})
// Per-value verdicts, namespaced attr id -> value -> "off" | "on". An absent
-// key is the middle position: an image carrying that value stays exactly as
+// key is the neutral position: an image carrying that value stays exactly as
// visible as it was, which is what makes the default state show everything.
const attrVerdicts = ref<Record<string, Record<string, string>>>({})
// ---------------------------------------------------------------------------
// Gallery contract (self-describing, fetched once per mount)
//
-// Everything the UI offers — filter panel sections, searchable fields, sort
+// Everything the UI offers — filter sections, searchable fields, sort
// options — comes from the contract. No gallery rule is hardcoded here, so
// new backend attributes and runtime policy edits light up on reload.
// ---------------------------------------------------------------------------
@@ -91,17 +83,6 @@ const activeSearchIds = computed(() => {
return searchAttrs.value.filter((a) => searchStatus.value[a.id] === 'on').map((a) => a.id)
})
-// ---------------------------------------------------------------------------
-// Viewer state
-// ---------------------------------------------------------------------------
-const viewerOpen = ref(false)
-const viewerIndex = ref(0)
-const imageFailed = ref(false)
-
-const current = computed<ImageAsset | null>(() =>
- viewerOpen.value && items.value.length ? items.value[viewerIndex.value] ?? null : null,
-)
-
// ---------------------------------------------------------------------------
// Image URL resolution
//
@@ -112,11 +93,13 @@ const current = computed<ImageAsset | null>(() =>
// ---------------------------------------------------------------------------
const thumbUrls = ref<Record<string, string>>({})
const thumbBroken = ref<Record<string, boolean>>({})
-const viewerUrl = ref('')
// Object URLs keyed by the raw storage URL they were fetched for, so a
// thumbnail and the viewer share one blob and a reload reuses what is already
// on screen instead of fetching (and leaking) a fresh copy.
const blobByRawUrl = new Map<string, string>()
+// Fetches in flight, so the grid and the viewer asking for the same image at
+// once share one request.
+const inflight = new Map<string, Promise<string>>()
/** Revoke every cached object URL whose raw URL is not in keep. */
function releaseBlobs(keep: Set<string> = new Set()): void {
@@ -127,19 +110,13 @@ function releaseBlobs(keep: Set<string> = new Set()): void {
}
}
-async function resolveImageSrc(rawUrl: string): Promise<string> {
+async function fetchBlobUrl(rawUrl: string): Promise<string> {
const req = galleryImageRequest(rawUrl, props.knowledgeBaseId)
if (!req) return rawUrl
- const cached = blobByRawUrl.get(rawUrl)
- if (cached) return cached
try {
const resp = await fetch(req.url, { headers: req.headers })
if (!resp.ok) return rawUrl
- const blob = await resp.blob()
- // A concurrent resolve may have cached this URL meanwhile; keep one blob.
- const raced = blobByRawUrl.get(rawUrl)
- if (raced) return raced
- const objectUrl = URL.createObjectURL(blob)
+ const objectUrl = URL.createObjectURL(await resp.blob())
blobByRawUrl.set(rawUrl, objectUrl)
return objectUrl
} catch {
@@ -147,8 +124,15 @@ async function resolveImageSrc(rawUrl: string): Promise<string> {
}
}
-function thumbUrl(img: ImageAsset): string {
- return thumbUrls.value[img.id] || img.url
+function resolveImageSrc(rawUrl: string): Promise<string> {
+ const cached = blobByRawUrl.get(rawUrl)
+ if (cached) return Promise.resolve(cached)
+ let pending = inflight.get(rawUrl)
+ if (!pending) {
+ pending = fetchBlobUrl(rawUrl).finally(() => inflight.delete(rawUrl))
+ inflight.set(rawUrl, pending)
+ }
+ return pending
}
async function resolveThumbnails(token: number) {
@@ -170,30 +154,6 @@ function onThumbError(id: string) {
thumbBroken.value = { ...thumbBroken.value, [id]: true }
}
-let viewerToken = 0
-
-watch(
- () => current.value,
- async (img) => {
- if (!img) {
- viewerUrl.value = ''
- return
- }
- // Opening the viewer renders the <img> at once, while the blob the
- // browser can actually display only exists after the proxy fetch below.
- // In the meantime the element still shows the previous (or empty)
- // source, whose error event flipped the failure flag — and the real
- // image then arrived to a viewer already showing its failure state.
- // The token keeps a stale fetch from winning a fast navigation race,
- // and the flag is reset here, after the real source is in hand.
- const token = ++viewerToken
- const url = await resolveImageSrc(img.url)
- if (token !== viewerToken) return
- imageFailed.value = false
- viewerUrl.value = url
- },
-)
-
// ---------------------------------------------------------------------------
// Label helpers
//
@@ -275,34 +235,14 @@ function findAttrByRawName(name: string): GalleryResolvedAttr | undefined {
return config.value.attributes.find((a) => a.name === name)
}
-const currentAttrs = computed(() => {
- if (!current.value) return [] as Array<{ key: string; label: string; value: string }>
- return Object.entries(current.value.attrs).map(([name, raw]) => {
- const attr = findAttrByRawName(name)
- return {
- key: name,
- label: attr ? attrLabel(attr) : name,
- value: displayObservedValue(attr, raw),
- }
- })
-})
-
// ---------------------------------------------------------------------------
-// Filter verdicts
+// Filters
//
-// One attribute value moves through three positions by click: neutral (leave
-// those images alone), "off" (hide them), "on" (show them whatever else says).
-// The middle position is the one a user starts at and returns to, so a value
-// the user never touched is absent from the map rather than stored as a word,
-// and never reaches the server.
+// One attribute value takes one of three positions: neutral (leave those
+// images alone), "off" (hide them), "on" (keep them even when another rule
+// hides them). A value the user never touched is absent from the map rather
+// than stored as a word, and never reaches the server.
// ---------------------------------------------------------------------------
-// The filter panel's own switch: off means the verdicts are not imposed at
-// all, which is what the toolbar's 全显示 position shows.
-const filterScopeOn = computed({
- get: () => filterScope.value === 'custom',
- set: (on: boolean) => onFilterScopeChange(on ? 'custom' : 'all'),
-})
-
const VERDICTS = ['default', 'off', 'on'] as const
type Verdict = (typeof VERDICTS)[number]
@@ -319,100 +259,126 @@ const activeRules = computed(() => {
return out
})
+const activeSelections = computed(() =>
+ Object.fromEntries(Object.entries(attrSelections.value).filter(([, v]) => v.length)),
+)
+
+/** How many constraints narrow the list; the filter button shows it. */
+const activeFilterCount = computed(() => {
+ let n = Object.keys(activeSelections.value).length
+ for (const perValue of Object.values(activeRules.value)) n += Object.keys(perValue).length
+ if (searchMode.value === 'custom') n += 1
+ return n
+})
+
+const isNarrowed = computed(
+ () =>
+ !!keyword.value.trim() ||
+ Object.keys(activeRules.value).length > 0 ||
+ Object.keys(activeSelections.value).length > 0,
+)
+
function verdictOf(attrId: string, value: string): Verdict {
return (attrVerdicts.value[attrId]?.[value] as Verdict) || 'default'
}
function setVerdict(attrId: string, value: string, verdict: Verdict): void {
+ if (verdictOf(attrId, value) === verdict) return
const perValue = { ...(attrVerdicts.value[attrId] || {}) }
if (verdict === 'default') delete perValue[value]
else perValue[value] = verdict
attrVerdicts.value = { ...attrVerdicts.value, [attrId]: perValue }
- // A verdict the user just expressed must take effect immediately: staying
- // in "全显示" while the panel shows an off/on would silently ignore it.
- // Clearing the last meaningful verdict returns to "全显示", since custom
- // mode with no rules constrains nothing anyway.
- const hasRules = Object.values(attrVerdicts.value).some((perValueInner) =>
- Object.values(perValueInner).some((v) => v === 'off' || v === 'on'),
- )
- filterScope.value = hasRules ? 'custom' : 'all'
resetPageAndReload()
}
function verdictLabel(v: Verdict): string {
- if (v === 'off') return t('knowledgeEditor.wikiBrowser.gallery.verdictOff')
- if (v === 'on') return t('knowledgeEditor.wikiBrowser.gallery.verdictOn')
- return t('knowledgeEditor.wikiBrowser.gallery.verdictDefault')
+ if (v === 'off') return t(`${NS}.verdictOff`)
+ if (v === 'on') return t(`${NS}.verdictOn`)
+ return t(`${NS}.verdictDefault`)
+}
+
+function onKeywordsInput(attrId: string, raw: string) {
+ const values = raw
+ .split(/[,,;;\n]/)
+ .map((s) => s.trim())
+ .filter(Boolean)
+ attrSelections.value = { ...attrSelections.value, [attrId]: values }
+ resetPageAndReload()
+}
+
+function keywordsInputValue(attrId: string): string {
+ return (attrSelections.value[attrId] || []).join(', ')
+}
+
+/** Drop every constraint in the filter panel, search scope included. */
+function clearFilters(): void {
+ attrVerdicts.value = {}
+ attrSelections.value = {}
+ if (searchMode.value === 'custom') {
+ searchMode.value = 'all'
+ persistSearchPrefs()
+ }
+ resetPageAndReload()
+}
+
+/** The empty state's way back: forget the keyword as well. */
+function clearAll(): void {
+ keyword.value = ''
+ clearFilters()
}
// ---------------------------------------------------------------------------
-// Settings panels
+// Search scope (mode + per-field toggles, persisted as the user's own record)
//
-// Both panels answer the same question — what may the gallery show — and both
-// open the same way: an arrow beside the toolbar control summons them as a
-// popover, and the pin on the panel's header moves it into the right-hand
-// rail. Pinning one keeps the other out of the rail, so the two never split
-// the image area between them.
+// Ticking every field is the same as "all" mode, so the panel needs no
+// separate switch: the mode follows the ticks. The last ticked field cannot
+// be unticked — a search over no field would find nothing.
// ---------------------------------------------------------------------------
-function openSettingsPanel(panel: 'search' | 'filter', ev?: MouseEvent): void {
- // A pinned rail already holds both panels as tabs; an arrow click merely
- // turns to the requested one instead of spawning a second surface.
- if (pinnedPanel.value) {
- panelTab.value = panel
- openPanel.value = ''
- return
- }
- // The arrow is a toggle: a second press on the same arrow retracts the
- // panel, which is also why its icon points up while the panel is out.
- if (openPanel.value === panel) {
- openPanel.value = ''
- return
- }
- openPanel.value = panel
- panelTab.value = panel
- if (ev) updatePanelPosition(ev)
+let prefsTimer: ReturnType<typeof setTimeout> | undefined
+function persistSearchPrefs() {
+ if (!configLoaded.value) return
+ if (prefsTimer) clearTimeout(prefsTimer)
+ prefsTimer = setTimeout(() => {
+ void updateMyPreferences({
+ gallery: { mode: searchMode.value, status: { ...searchStatus.value } },
+ })
+ }, 500)
}
-/** Anchor the floating panel just below the arrow that summoned it. */
-function updatePanelPosition(ev: MouseEvent): void {
- const root = rootEl.value?.getBoundingClientRect()
- const btn = (ev.currentTarget as HTMLElement | null)?.getBoundingClientRect()
- if (!root || !btn) return
- const width = 320
- const left = Math.max(8, Math.min(btn.left - root.left, root.width - width - 12))
- panelPos.value = { top: btn.bottom - root.top + 6, left }
+function onSearchFieldToggle(attrId: string, checked: boolean) {
+ const on = new Set(activeSearchIds.value)
+ if (checked) on.add(attrId)
+ else on.delete(attrId)
+ const next: Record<string, string> = { ...searchStatus.value }
+ for (const attr of searchAttrs.value) next[attr.id] = on.has(attr.id) ? 'on' : 'off'
+ searchStatus.value = next
+ searchMode.value = on.size === searchAttrs.value.length ? 'all' : 'custom'
+ persistSearchPrefs()
+ if (keyword.value.trim()) resetPageAndReload()
}
-const floatingStyle = computed(() =>
- panelPos.value
- ? { top: `${panelPos.value.top}px`, left: `${panelPos.value.left}px`, right: 'auto' }
- : {},
-)
-
-// Any click landing outside the floating panel and outside the arrows closes
-// it: moving on to another toolbar control means leaving the panel. Clicks
-// inside the panel itself, and on the toggling arrows, are left alone.
-function onDocClick(e: MouseEvent): void {
- if (!openPanel.value || pinnedPanel.value) return
- const target = e.target as HTMLElement | null
- if (!target) return
- if (target.closest('.ig-panel-slot')) return
- if (target.closest('.ig-scope-arrow')) return
- openPanel.value = ''
+function isLastSearchField(attrId: string): boolean {
+ const ids = activeSearchIds.value
+ return ids.length === 1 && ids[0] === attrId
}
-function togglePin(panel: 'search' | 'filter'): void {
- if (pinnedPanel.value === panel) {
- pinnedPanel.value = ''
- return
- }
- pinnedPanel.value = panel
- panelTab.value = panel
- openPanel.value = ''
+// ---------------------------------------------------------------------------
+// Sort
+// ---------------------------------------------------------------------------
+const sortFieldLabel = computed(() => {
+ const attr = sortAttrs.value.find((a) => a.id === sortBy.value)
+ return attr ? attrLabel(attr) : ''
+})
+
+function selectSortField(id: string): void {
+ if (sortBy.value === id) return
+ sortBy.value = id
+ resetPageAndReload()
}
-function onFilterScopeChange(value: string | number | boolean): void {
- filterScope.value = value === 'custom' ? 'custom' : 'all'
+function selectSortOrder(order: 'asc' | 'desc'): void {
+ if (sortOrder.value === order) return
+ sortOrder.value = order
resetPageAndReload()
}
@@ -420,41 +386,32 @@ function onFilterScopeChange(value: string | number | boolean): void {
// Loading
// ---------------------------------------------------------------------------
function buildParams(): ImageListParams {
- const attrFilters: Record<string, string[]> = {}
- for (const [id, values] of Object.entries(attrSelections.value)) {
- if (values && values.length) attrFilters[id] = values
- }
- // The filter switch decides whether verdicts are imposed at all: reading
- // "全显示" means the panel's verdicts are not applied, whatever is set in it.
- const rules = filterScope.value === 'custom' ? activeRules.value : {}
- const params: ImageListParams = {
+ const rules = activeRules.value
+ const selections = activeSelections.value
+ return {
keyword: keyword.value.trim() || undefined,
searchIn: activeSearchIds.value,
sortBy: sortBy.value || undefined,
sortOrder: sortOrder.value,
- attrFilters: Object.keys(attrFilters).length ? attrFilters : undefined,
+ attrFilters: Object.keys(selections).length ? selections : undefined,
attrRules: Object.keys(rules).length ? rules : undefined,
page: page.value,
pageSize: pageSize.value,
}
- return params
}
// Bumped by every listing, so a slower earlier response (a debounced search
// overtaken by a page change) cannot overwrite the grid of a newer query.
let listToken = 0
-async function reload() {
+/**
+ * Fetch the current page. `focus` is where the viewer lands on the new page
+ * when it walked past a page edge; it is applied together with the new items
+ * so the viewer never renders a stale index against them.
+ */
+async function reload(focus?: 'first' | 'last') {
if (!props.knowledgeBaseId) return
const token = ++listToken
- // Searching with every field switched off would silently fall back to the
- // server default — not what a custom-mode user asked for. Short-circuit.
- if (keyword.value.trim() && activeSearchIds.value.length === 0) {
- items.value = []
- total.value = 0
- loading.value = false
- return
- }
loading.value = true
error.value = ''
try {
@@ -462,7 +419,8 @@ async function reload() {
if (token !== listToken) return
items.value = res.items
total.value = res.total
- if (viewerOpen.value && viewerIndex.value >= res.items.length) closeViewer()
+ if (focus && res.items.length) viewerIndex.value = focus === 'first' ? 0 : res.items.length - 1
+ else if (viewerOpen.value && viewerIndex.value >= res.items.length) closeViewer()
void resolveThumbnails(token)
} catch (e) {
if (token !== listToken) return
@@ -470,6 +428,7 @@ async function reload() {
items.value = []
total.value = 0
thumbUrls.value = {}
+ closeViewer()
} finally {
if (token === listToken) loading.value = false
}
@@ -477,57 +436,12 @@ async function reload() {
function resetPageAndReload() {
page.value = 1
+ scrollGridToTop()
reload()
}
-// ---------------------------------------------------------------------------
-// Personal state persistence (mode + per-field search toggles)
-// ---------------------------------------------------------------------------
-let prefsTimer: ReturnType<typeof setTimeout> | undefined
-function persistSearchPrefs() {
- if (!configLoaded.value) return
- if (prefsTimer) clearTimeout(prefsTimer)
- prefsTimer = setTimeout(() => {
- void updateMyPreferences({
- gallery: { mode: searchMode.value, status: { ...searchStatus.value } },
- })
- }, 500)
-}
-
-// The search panel's master switch: on searches every eligible field, off
-// restricts the search to the fields the user switched on below it.
-const searchAllOn = computed({
- get: () => searchMode.value === 'all',
- set: (on: boolean) => onSearchModeChange(on ? 'all' : 'custom'),
-})
-
-function onSearchModeChange(value: string | number | boolean) {
- searchMode.value = value === 'custom' ? 'custom' : 'all'
- persistSearchPrefs()
- resetPageAndReload()
-}
-
-// Reconcile the whole on/off map from one checkbox-group change, then
-// persist and re-query. In "all" mode every field is searched and the
-// checkboxes are only decorative (dimmed): touching one means the user
-// wants a custom selection, so the master switch drops to custom with
-// every field still on except the one just unticked.
-function onSearchFieldsChange(vals: Array<string | number | boolean>) {
- const next: Record<string, string> = { ...searchStatus.value }
- for (const attr of searchAttrs.value) {
- next[attr.id] = vals.includes(attr.id) ? 'on' : 'off'
- }
- searchStatus.value = next
- if (searchMode.value === 'all') searchMode.value = 'custom'
- persistSearchPrefs()
- resetPageAndReload()
-}
-
-// ---------------------------------------------------------------------------
-// Filter interactions
-// ---------------------------------------------------------------------------
-function onSearch() {
- resetPageAndReload()
+function scrollGridToTop() {
+ scrollEl.value?.scrollTo({ top: 0 })
}
let searchTimer: ReturnType<typeof setTimeout> | undefined
@@ -536,88 +450,63 @@ function onSearchInput() {
searchTimer = setTimeout(() => resetPageAndReload(), 350)
}
-function onAttrGroupChange(attrId: string, values: Array<string | number | boolean>) {
- attrSelections.value = {
- ...attrSelections.value,
- [attrId]: values.map((v) => String(v)),
- }
- resetPageAndReload()
-}
-
-function onKeywordsInput(attrId: string, raw: string) {
- const values = raw
- .split(/[,,;;\n]/)
- .map((s) => s.trim())
- .filter(Boolean)
- attrSelections.value = { ...attrSelections.value, [attrId]: values }
- resetPageAndReload()
-}
-
-function keywordsInputValue(attrId: string): string {
- return (attrSelections.value[attrId] || []).join(', ')
-}
-
-// Apply one verdict to every value of every value-typed filter attribute.
-// The "-" position clears all verdicts, which also drops the scope back to
-// "全显示": custom mode with no rules constrains nothing.
-function setAllVerdicts(verdict: Verdict): void {
- const next: Record<string, Record<string, string>> = {}
- for (const attr of filterAttrs.value) {
- if (attr.type === 'keywords') continue
- const perValue: Record<string, string> = { ...(attrVerdicts.value[attr.id] || {}) }
- for (const v of attr.values || []) {
- if (verdict === 'default') delete perValue[v.value]
- else perValue[v.value] = verdict
- }
- if (Object.keys(perValue).length > 0) next[attr.id] = perValue
- }
- attrVerdicts.value = next
- const hasRules = Object.values(next).some((perValue) =>
- Object.values(perValue).some((v) => v === 'off' || v === 'on'),
- )
- filterScope.value = hasRules ? 'custom' : 'all'
+function onSearchNow() {
+ if (searchTimer) clearTimeout(searchTimer)
resetPageAndReload()
}
-function hasActiveFilters(): boolean {
- return !!keyword.value.trim() || Object.values(attrSelections.value).some((v) => v.length)
-}
-
function onPageChange(next: number) {
page.value = next
+ scrollGridToTop()
reload()
}
// ---------------------------------------------------------------------------
// Viewer
// ---------------------------------------------------------------------------
+const viewerOpen = ref(false)
+const viewerIndex = ref(0)
+
function openViewer(index: number) {
viewerIndex.value = index
- imageFailed.value = false
viewerOpen.value = true
}
function closeViewer() {
+ if (!viewerOpen.value) return
viewerOpen.value = false
+ // The viewer may have walked onto another image, or another page; bring
+ // the card it stopped on into view so the grid picks up where it left off.
+ const index = viewerIndex.value
+ void nextTick(() => {
+ scrollEl.value
+ ?.querySelectorAll<HTMLElement>('.ig-card')
+ [index]?.scrollIntoView({ block: 'nearest' })
+ })
}
-function prevImage() {
- if (!items.value.length) return
- viewerIndex.value = (viewerIndex.value - 1 + items.value.length) % items.value.length
- imageFailed.value = false
+/** The viewer walked past the edge of this page: load the neighbour. */
+async function onViewerStep(delta: 1 | -1) {
+ const target = page.value + delta
+ if (target < 1 || (target - 1) * pageSize.value >= total.value) return
+ page.value = target
+ await reload(delta > 0 ? 'first' : 'last')
}
-function nextImage() {
- if (!items.value.length) return
- viewerIndex.value = (viewerIndex.value + 1) % items.value.length
- imageFailed.value = false
+function onOpenSource(knowledgeId: string) {
+ closeViewer()
+ emit('open-source-doc', knowledgeId)
}
-function onViewerKey(e: KeyboardEvent) {
- if (!viewerOpen.value) return
- if (e.key === 'Escape') closeViewer()
- else if (e.key === 'ArrowLeft') prevImage()
- else if (e.key === 'ArrowRight') nextImage()
+function attrRows(img: ImageAsset): GalleryAttrRow[] {
+ return Object.entries(img.attrs || {}).map(([name, raw]) => {
+ const attr = findAttrByRawName(name)
+ return {
+ key: name,
+ label: attr ? attrLabel(attr) : name,
+ value: displayObservedValue(attr, raw),
+ }
+ })
}
function sourceLabel(img: ImageAsset): string {
@@ -627,12 +516,7 @@ function sourceLabel(img: ImageAsset): string {
// ---------------------------------------------------------------------------
// Lifecycle
// ---------------------------------------------------------------------------
-onMounted(() => {
- document.addEventListener('click', onDocClick)
-})
-
onBeforeUnmount(() => {
- document.removeEventListener('click', onDocClick)
if (searchTimer) clearTimeout(searchTimer)
// Orphan any in-flight listing so it cannot map new blobs after unmount.
listToken++
@@ -650,7 +534,7 @@ let initToken = 0
// everything scoped to the previous knowledge base is dropped first.
async function initGallery() {
const token = ++initToken
- closeViewer()
+ viewerOpen.value = false
items.value = []
total.value = 0
page.value = 1
@@ -658,12 +542,12 @@ async function initGallery() {
sortBy.value = ''
attrSelections.value = {}
attrVerdicts.value = {}
- filterScope.value = 'all'
thumbUrls.value = {}
thumbBroken.value = {}
releaseBlobs()
configLoaded.value = false
config.value = { attribute_sources: [], attributes: [], mode: 'all', status: {} }
+ loading.value = true
try {
const cfg = await fetchGalleryConfig(props.knowledgeBaseId)
if (token !== initToken) return
@@ -693,843 +577,740 @@ watch(
</script>
<template>
- <div ref="rootEl" class="image-gallery" @keydown="onViewerKey">
- <div class="ig-layout" :class="{ 'has-rail': !!pinnedPanel }">
- <!--
- One settings panel, two placements: pinning it moves it out of the
- grid and into the right-hand rail, where the two panels take turns as
- tabs. Only one can hold the rail, so the image area never has to share
- its width with both of them.
- -->
- <aside
- v-if="openPanel || pinnedPanel"
- class="ig-panel-slot"
- :class="{ 'is-floating': openPanel && !pinnedPanel }"
- :style="openPanel && !pinnedPanel ? floatingStyle : undefined"
- >
- <div class="ig-panel-head">
- <t-tabs v-model="panelTab" class="ig-panel-tabs">
- <!-- Same order as the toolbar: search on the left, filter on the right. -->
- <t-tab-panel value="search" :label="t('knowledgeEditor.wikiBrowser.gallery.panelSearch')" />
- <t-tab-panel value="filter" :label="t('knowledgeEditor.wikiBrowser.gallery.panelFilter')" />
- </t-tabs>
+ <div class="image-gallery">
+ <!-- Same shape as the documents tab: what is listed on the left, the
+ controls that narrow and order it on the right. -->
+ <div class="ig-toolbar">
+ <div class="ig-toolbar__summary">
+ <span class="ig-toolbar__title">{{ t(`${NS}.allImages`) }}</span>
+ <span v-if="configLoaded || total" class="ig-toolbar__count">
+ {{ t(isNarrowed ? `${NS}.countFiltered` : `${NS}.count`, { count: total }) }}
+ </span>
+ </div>
+
+ <div class="ig-toolbar__trailing">
+ <t-input
+ v-model="keyword"
+ :placeholder="t(`${NS}.searchPlaceholder`)"
+ :aria-label="t(`${NS}.searchPlaceholder`)"
+ clearable
+ class="ig-search"
+ @enter="onSearchNow"
+ @input="onSearchInput"
+ @clear="onSearchNow"
+ >
+ <template #prefix-icon><t-icon name="search" size="16px" /></template>
+ </t-input>
+
+ <t-popup
+ v-model:visible="filterPanelVisible"
+ trigger="click"
+ placement="bottom-right"
+ overlay-class-name="gallery-toolbar-popup"
+ :overlay-inner-style="{ padding: 0 }"
+ >
<button
- class="ig-pin"
- :class="{ 'is-pinned': !!pinnedPanel }"
- :title="pinnedPanel === panelTab ? t('knowledgeEditor.wikiBrowser.gallery.unpin') : t('knowledgeEditor.wikiBrowser.gallery.pin')"
- @click="togglePin(panelTab)"
+ type="button"
+ class="ig-tool-btn"
+ :class="{ active: filterPanelVisible || activeFilterCount > 0 }"
+ :aria-expanded="filterPanelVisible"
>
- <t-icon :name="pinnedPanel === panelTab ? 'pin-filled' : 'pin'" />
+ <t-icon name="filter" size="16px" />
+ {{ t(`${NS}.filters`) }}
+ <span v-if="activeFilterCount" class="ig-tool-btn__count">{{ activeFilterCount }}</span>
</button>
- </div>
-
- <div class="ig-panel-body">
- <template v-if="panelTab === 'filter'">
- <div class="ig-row">
- <span class="ig-row-label">{{ t('knowledgeEditor.wikiBrowser.gallery.enableFilter') }}</span>
- <t-switch v-model="filterScopeOn" />
- </div>
+ <template #content>
+ <section class="ig-filter-panel" :aria-label="t(`${NS}.filters`)">
+ <header class="ig-filter-panel__header">
+ <strong>{{ t(`${NS}.filters`) }}</strong>
+ <button type="button" :disabled="!activeFilterCount" @click="clearFilters">
+ {{ t(`${NS}.clearFilters`) }}
+ </button>
+ </header>
+
+ <div v-if="searchAttrs.length" class="ig-filter-section">
+ <div class="ig-filter-section__title">{{ t(`${NS}.searchIn`) }}</div>
+ <div class="ig-filter-section__hint">{{ t(`${NS}.searchInHint`) }}</div>
+ <div class="ig-search-fields">
+ <t-checkbox
+ v-for="attr in searchAttrs"
+ :key="attr.id"
+ :checked="activeSearchIds.includes(attr.id)"
+ :disabled="isLastSearchField(attr.id)"
+ :title="attrDescription(attr)"
+ @change="(checked: boolean) => onSearchFieldToggle(attr.id, checked)"
+ >
+ {{ attrLabel(attr) }}
+ </t-checkbox>
+ </div>
+ </div>
- <div v-if="filterAttrs.length" class="ig-attr-blocks">
- <div v-for="attr in filterAttrs" :key="attr.id" class="ig-attr-block">
- <div class="ig-attr-name" :title="attrDescription(attr)">{{ attrLabel(attr) }}</div>
-
- <!--
- An attribute that declares values gets one row per value,
- each with three positions: leave the images carrying it
- alone, hide them, or force them back in.
- -->
- <div v-if="attr.type !== 'keywords'" class="ig-verdict-rows" :class="{ 'is-idle': !filterScopeOn }">
- <div v-for="v in attr.values || []" :key="v.value" class="ig-verdict-row">
- <t-tooltip :content="attrValueDescription(attr, v.value)">
- <span class="ig-verdict-value">{{ attrValueLabel(attr, v.value) }}</span>
+ <div v-if="filterAttrs.length" class="ig-filter-section">
+ <div class="ig-filter-section__title">{{ t(`${NS}.attrSection`) }}</div>
+ <div class="ig-filter-section__hint">{{ t(`${NS}.attrHint`) }}</div>
+ <div v-for="attr in filterAttrs" :key="attr.id" class="ig-attr">
+ <div class="ig-attr__name">
+ {{ attrLabel(attr) }}
+ <t-tooltip v-if="attrDescription(attr)" :content="attrDescription(attr)">
+ <t-icon name="help-circle" size="14px" class="ig-attr__help" />
</t-tooltip>
- <div class="ig-verdict-group">
- <button
- v-for="verdict in VERDICTS"
- :key="verdict"
- type="button"
- class="ig-verdict"
- :class="['is-' + verdict, { 'is-active': verdictOf(attr.id, v.value) === verdict }]"
- @click="setVerdict(attr.id, v.value, verdict)"
- >
- {{ verdictLabel(verdict) }}
- </button>
- </div>
</div>
+ <!-- A value list gets one row per value with the three
+ positions side by side; a free-text attribute has
+ nothing to position, so it keeps a keyword box. -->
+ <template v-if="attr.type !== 'keywords'">
+ <div v-for="v in attr.values || []" :key="v.value" class="ig-attr__row">
+ <span class="ig-attr__value" :title="attrValueDescription(attr, v.value)">
+ {{ attrValueLabel(attr, v.value) }}
+ </span>
+ <div class="ig-seg" role="radiogroup" :aria-label="attrValueLabel(attr, v.value)">
+ <button
+ v-for="verdict in VERDICTS"
+ :key="verdict"
+ type="button"
+ role="radio"
+ class="ig-seg__item"
+ :class="['is-' + verdict, { active: verdictOf(attr.id, v.value) === verdict }]"
+ :aria-checked="verdictOf(attr.id, v.value) === verdict"
+ @click="setVerdict(attr.id, v.value, verdict)"
+ >
+ {{ verdictLabel(verdict) }}
+ </button>
+ </div>
+ </div>
+ </template>
+ <t-input
+ v-else
+ :value="keywordsInputValue(attr.id)"
+ clearable
+ :placeholder="t(`${NS}.keywordsPlaceholder`)"
+ @change="(v: string) => onKeywordsInput(attr.id, v)"
+ @enter="(v: string) => onKeywordsInput(attr.id, v)"
+ />
</div>
- <!--
- A free-text attribute has no value list to position, so it
- keeps the plain keyword box.
- -->
- <t-input
- v-else
- :value="keywordsInputValue(attr.id)"
- clearable
- class="ig-keywords"
- :placeholder="t('knowledgeEditor.wikiBrowser.gallery.keywordsPlaceholder')"
- @change="(v: string) => onKeywordsInput(attr.id, v)"
- @enter="(v: string) => onKeywordsInput(attr.id, v)"
- />
- </div>
- </div>
- <div v-else class="ig-no-attrs">{{ t('knowledgeEditor.wikiBrowser.gallery.noAttrs') }}</div>
-
- <!--
- One row to speak for every attribute at once: the same three
- positions as a per-value row, applied to all of them in one
- click.
- -->
- <div class="ig-row ig-apply-all">
- <span class="ig-row-label">{{ t('knowledgeEditor.wikiBrowser.gallery.applyAll') }}</span>
- <div class="ig-verdict-group">
- <button
- v-for="verdict in VERDICTS"
- :key="verdict"
- type="button"
- class="ig-verdict"
- :class="['is-' + verdict]"
- @click="setAllVerdicts(verdict)"
- >
- {{ verdictLabel(verdict) }}
- </button>
</div>
- </div>
- </template>
-
- <template v-else>
- <div class="ig-row">
- <span class="ig-row-label">{{ t('knowledgeEditor.wikiBrowser.gallery.searchAll') }}</span>
- <t-switch v-model="searchAllOn" />
- </div>
- <div v-if="searchAttrs.length">
- <!--
- The checkboxes stay visible next to the master switch like the
- filter panel's verdicts do. In "all" mode they are dimmed —
- every field is searched, so the ticks carry no weight — yet
- still clickable: touching one drops the mode to custom. No
- caption above them: showing and hiding it would shift them
- when the switch is flipped.
- -->
- <t-checkbox-group
- :value="activeSearchIds"
- class="ig-search-fields"
- :class="{ 'is-idle': searchMode === 'all' }"
- @change="(vals: Array<string | number | boolean>) => onSearchFieldsChange(vals)"
- >
- <t-checkbox v-for="attr in searchAttrs" :key="attr.id" :value="attr.id" :label="attrLabel(attr)" />
- </t-checkbox-group>
- </div>
+ <div v-if="!searchAttrs.length && !filterAttrs.length" class="ig-filter-panel__empty">
+ {{ t(`${NS}.noAttrs`) }}
+ </div>
+ </section>
</template>
- </div>
- </aside>
-
- <!-- Main content -->
- <section class="ig-main">
- <!--
- Everything that controls the list sits on one horizontal bar, so
- the image area below keeps all the vertical space it can get. The
- two scope switches read as 全显示 / 自定义: the inclusive position
- drops the constraint, and only the custom one has an arrow that
- opens the panel editing it.
- -->
- <div class="ig-toolbar">
- <t-input
- v-model="keyword"
- :placeholder="t('knowledgeEditor.wikiBrowser.gallery.searchPlaceholder')"
- clearable
- class="ig-search"
- @enter="onSearch"
- @input="onSearchInput"
- @clear="onSearch"
+ </t-popup>
+
+ <t-popup
+ v-if="sortAttrs.length"
+ v-model:visible="sortPanelVisible"
+ trigger="click"
+ placement="bottom-right"
+ overlay-class-name="gallery-toolbar-popup"
+ :overlay-inner-style="{ padding: 0 }"
+ >
+ <button
+ type="button"
+ class="ig-tool-btn ig-sort-trigger"
+ :class="{ active: sortPanelVisible }"
+ :aria-label="`${t(`${NS}.sort`)}: ${sortFieldLabel}`"
>
- <template #prefix-icon><t-icon name="search" /></template>
- </t-input>
-
- <div class="ig-scope">
- <span class="ig-scope-name">{{ t('knowledgeEditor.wikiBrowser.gallery.searchScope') }}</span>
- <!--
- The scope word is a status, not a control: it names the mode
- the search is in, and only the arrow beside it opens the panel
- that changes it.
- -->
- <span class="ig-scope-value">
- {{ searchScope === 'all' ? t('knowledgeEditor.wikiBrowser.gallery.scopeAll') : t('knowledgeEditor.wikiBrowser.gallery.scopeCustom') }}
- </span>
- <button
- class="ig-scope-arrow"
- :title="t('knowledgeEditor.wikiBrowser.gallery.editSearch')"
- @click="openSettingsPanel('search', $event)"
- >
- <t-icon :name="openPanel === 'search' && !pinnedPanel ? 'chevron-up' : 'chevron-down'" />
- </button>
- </div>
-
- <div class="ig-scope">
- <span class="ig-scope-name">{{ t('knowledgeEditor.wikiBrowser.gallery.filterScope') }}</span>
- <span class="ig-scope-value">
- {{ filterScope === 'all' ? t('knowledgeEditor.wikiBrowser.gallery.filterOff') : t('knowledgeEditor.wikiBrowser.gallery.filterOn') }}
- </span>
- <button
- class="ig-scope-arrow"
- :title="t('knowledgeEditor.wikiBrowser.gallery.editFilter')"
- @click="openSettingsPanel('filter', $event)"
- >
- <t-icon :name="openPanel === 'filter' && !pinnedPanel ? 'chevron-up' : 'chevron-down'" />
- </button>
- </div>
-
- <span class="ig-scope-sep" />
-
- <t-select v-if="sortAttrs.length" v-model="sortBy" class="ig-sort" @change="resetPageAndReload">
- <t-option v-for="attr in sortAttrs" :key="attr.id" :value="attr.id" :label="attrLabel(attr)" />
- </t-select>
-
- <t-button theme="default" variant="outline" class="ig-order" @click="sortOrder = sortOrder === 'asc' ? 'desc' : 'asc'; resetPageAndReload()">
- <t-icon :name="sortOrder === 'asc' ? 'arrow-up' : 'arrow-down'" />
- {{ sortOrder === 'asc' ? t('knowledgeEditor.wikiBrowser.gallery.orderAsc') : t('knowledgeEditor.wikiBrowser.gallery.orderDesc') }}
- </t-button>
-
- <span class="ig-count">{{ t('knowledgeEditor.wikiBrowser.gallery.count', { count: total }) }}</span>
- </div>
-
- <t-loading :loading="loading" class="ig-loading-area">
- <div v-if="error" class="ig-error">{{ error }}</div>
-
- <div v-else-if="!items.length" class="ig-empty">
- {{ hasActiveFilters()
- ? t('knowledgeEditor.wikiBrowser.gallery.emptyFiltered')
- : t('knowledgeEditor.wikiBrowser.gallery.empty') }}
- </div>
-
- <div v-else class="ig-grid">
- <button
- v-for="(img, idx) in items"
- :key="img.id"
- type="button"
- class="ig-card"
- @click="openViewer(idx)"
- >
- <div class="ig-card-thumb">
- <img
- v-if="!thumbBroken[img.id]"
- :src="thumbUrl(img)"
- :alt="img.caption"
- loading="lazy"
- @error="onThumbError(img.id)"
- />
- <div v-else class="ig-thumb-error">
- {{ t('knowledgeEditor.wikiBrowser.gallery.imageLoadError') }}
+ <t-icon name="filter-sort" size="16px" />
+ <span class="ig-sort-trigger__label">{{ t(`${NS}.sort`) }} · {{ sortFieldLabel }}</span>
+ <t-icon :name="sortOrder === 'asc' ? 'arrow-up' : 'arrow-down'" size="14px" />
+ </button>
+ <template #content>
+ <div class="ig-sort-panel" role="menu" :aria-label="t(`${NS}.sort`)">
+ <section class="ig-sort-group">
+ <div class="ig-sort-group__label">{{ t(`${NS}.sortField`) }}</div>
+ <div class="ig-sort-group__options">
+ <button
+ v-for="attr in sortAttrs"
+ :key="attr.id"
+ type="button"
+ role="menuitemradio"
+ class="ig-sort-option"
+ :class="{ active: sortBy === attr.id }"
+ :aria-checked="sortBy === attr.id"
+ @click="selectSortField(attr.id)"
+ >
+ <span>{{ attrLabel(attr) }}</span>
+ <t-icon v-if="sortBy === attr.id" name="check" size="14px" />
+ </button>
</div>
- </div>
- <div class="ig-card-meta">
- <div class="ig-card-caption">{{ img.caption || t('knowledgeEditor.wikiBrowser.gallery.noCaption') }}</div>
- <div class="ig-card-source">{{ sourceLabel(img) }}</div>
- </div>
- </button>
- </div>
- </t-loading>
-
- <t-pagination
- v-if="total > pageSize"
- :total="total"
- :page-size="pageSize"
- :current="page"
- class="ig-pagination"
- @current-change="onPageChange"
- />
- </section>
+ </section>
+ <section class="ig-sort-group">
+ <div class="ig-sort-group__label">{{ t(`${NS}.sortOrder`) }}</div>
+ <div class="ig-sort-group__options">
+ <button
+ v-for="order in (['desc', 'asc'] as const)"
+ :key="order"
+ type="button"
+ role="menuitemradio"
+ class="ig-sort-option"
+ :class="{ active: sortOrder === order }"
+ :aria-checked="sortOrder === order"
+ @click="selectSortOrder(order)"
+ >
+ <span>{{ t(order === 'asc' ? `${NS}.orderAsc` : `${NS}.orderDesc`) }}</span>
+ <t-icon v-if="sortOrder === order" name="check" size="14px" />
+ </button>
+ </div>
+ </section>
+ </div>
+ </template>
+ </t-popup>
+ </div>
</div>
- <!-- Single-image viewer -->
- <div v-if="viewerOpen && current" class="ig-viewer-overlay" @click.self="closeViewer">
- <div class="ig-viewer">
- <button class="ig-viewer-close" :title="t('knowledgeEditor.wikiBrowser.gallery.viewerClose')" @click="closeViewer">
- <t-icon name="close" />
- </button>
- <button class="ig-nav ig-nav-prev" :title="t('knowledgeEditor.wikiBrowser.gallery.prev')" @click="prevImage">
- <t-icon name="chevron-left" />
- </button>
-
- <div class="ig-viewer-image">
- <!--
- Rendered only once a displayable source exists: the raw
- resource:// handle (or an empty string) would fire the error
- handler and mask the image that is still being fetched.
- -->
- <img v-if="viewerUrl && !imageFailed" :src="viewerUrl" :alt="current.caption" @error="imageFailed = true" />
- <div v-else-if="imageFailed" class="ig-viewer-image-error">{{ t('knowledgeEditor.wikiBrowser.gallery.imageLoadError') }}</div>
- </div>
+ <div ref="scrollEl" class="ig-scroll" :class="{ 'is-empty': !items.length }">
+ <t-loading :loading="loading" size="small" class="ig-loading">
+ <div v-if="error" class="ig-error">{{ error }}</div>
- <button class="ig-nav ig-nav-next" :title="t('knowledgeEditor.wikiBrowser.gallery.next')" @click="nextImage">
- <t-icon name="chevron-right" />
- </button>
+ <EmptyState
+ v-else-if="!items.length && !loading"
+ icon="image"
+ :title="isNarrowed ? t(`${NS}.emptyFiltered`) : t(`${NS}.empty`)"
+ :description="isNarrowed ? '' : t(`${NS}.emptyHint`)"
+ >
+ <t-button v-if="isNarrowed" variant="outline" @click="clearAll">{{ t(`${NS}.clearFilters`) }}</t-button>
+ </EmptyState>
- <aside class="ig-viewer-info">
- <h3>{{ t('knowledgeEditor.wikiBrowser.gallery.attributes') }}</h3>
- <div v-if="currentAttrs.length">
- <div v-for="a in currentAttrs" :key="a.key" class="ig-info-row">
- <span class="ig-info-key">{{ a.label }}</span>
- <span class="ig-info-val">{{ a.value }}</span>
+ <div v-else class="ig-grid">
+ <button
+ v-for="(img, idx) in items"
+ :key="img.id"
+ type="button"
+ class="ig-card"
+ :class="{ 'is-disabled': !img.is_enabled }"
+ @click="openViewer(idx)"
+ >
+ <div class="ig-card__thumb">
+ <img
+ v-if="thumbUrls[img.id] && !thumbBroken[img.id]"
+ :src="thumbUrls[img.id]"
+ :alt="img.caption"
+ loading="lazy"
+ draggable="false"
+ @error="onThumbError(img.id)"
+ />
+ <div v-else-if="thumbBroken[img.id]" class="ig-card__broken">
+ <t-icon name="image-error" size="20px" />
+ <span>{{ t(`${NS}.imageLoadError`) }}</span>
+ </div>
+ <span v-if="!img.is_enabled" class="ig-card__badge">
+ {{ t(`${NS}.attr.builtin_is_enabled_value_false`) }}
+ </span>
</div>
- </div>
- <div v-else class="ig-info-muted">{{ t('knowledgeEditor.wikiBrowser.gallery.noAttrs') }}</div>
-
- <h3>{{ t('knowledgeEditor.wikiBrowser.gallery.caption') }}</h3>
- <p class="ig-info-text">{{ current.caption || t('knowledgeEditor.wikiBrowser.gallery.noCaption') }}</p>
-
- <h3>{{ t('knowledgeEditor.wikiBrowser.gallery.ocr') }}</h3>
- <p class="ig-info-text">{{ current.ocr_text || t('knowledgeEditor.wikiBrowser.gallery.noOcr') }}</p>
+ <div class="ig-card__meta">
+ <div class="ig-card__caption" :class="{ 'is-empty': !img.caption }">
+ {{ img.caption || t(`${NS}.noCaption`) }}
+ </div>
+ <div class="ig-card__source" :title="sourceLabel(img)">
+ <t-icon name="file" size="12px" />
+ <span>{{ sourceLabel(img) }}</span>
+ </div>
+ </div>
+ </button>
+ </div>
+ </t-loading>
+ </div>
- <h3>{{ t('knowledgeEditor.wikiBrowser.gallery.source') }}</h3>
- <p class="ig-info-text">
- {{ sourceLabel(current) }}
- <span class="ig-info-sub">{{ current.knowledge_id }}</span>
- </p>
- </aside>
- </div>
+ <div v-if="total > pageSize" class="ig-footer">
+ <t-pagination
+ :total="total"
+ :page-size="pageSize"
+ :current="page"
+ :show-page-size="false"
+ :total-content="false"
+ size="small"
+ @current-change="onPageChange"
+ />
</div>
+
+ <GalleryViewer
+ v-if="viewerOpen && items.length"
+ :items="items"
+ :index="viewerIndex"
+ :offset="(page - 1) * pageSize"
+ :total="total"
+ :loading="loading"
+ :thumb-urls="thumbUrls"
+ :resolve-src="resolveImageSrc"
+ :attr-rows="attrRows"
+ @select="(i: number) => (viewerIndex = i)"
+ @step="onViewerStep"
+ @close="closeViewer"
+ @open-source="onOpenSource"
+ />
</div>
</template>
-<style scoped>
+<style>
+/* Popups render outside the component, so their shell is styled unscoped;
+ same frame as the documents tab's filter popup. */
+.gallery-toolbar-popup .t-popup__content {
+ border: 1px solid var(--td-component-stroke);
+ border-radius: var(--app-radius-xl);
+ box-shadow: 0 8px 32px rgb(0 0 0 / 10%);
+}
+</style>
+
+<style scoped lang="less">
.image-gallery {
- position: relative;
display: flex;
flex-direction: column;
- height: 100%;
- padding: 16px;
- box-sizing: border-box;
-}
-
-.ig-layout {
- display: grid;
- grid-template-columns: 1fr;
- gap: 16px;
flex: 1;
min-height: 0;
+ min-width: 0;
+ container-type: inline-size;
+ container-name: image-gallery;
}
-/* A pinned panel takes the right column; the image area keeps the rest.
- The panel precedes the main section in the DOM, so the columns it lands
- in are pinned down explicitly instead of left to source order. */
-.ig-layout.has-rail {
- grid-template-columns: minmax(0, 1fr) 300px;
-}
-.ig-layout.has-rail .ig-main {
- grid-row: 1;
- grid-column: 1;
-}
-.ig-layout.has-rail .ig-panel-slot {
- grid-row: 1;
- grid-column: 2;
-}
+// Mirrors .doc-filter-bar in KnowledgeBase.vue so switching tabs keeps the
+// toolbar in place.
+.ig-toolbar {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 16px;
+ flex-shrink: 0;
+ padding: 0 0 16px;
+ border-bottom: 1px solid var(--td-component-stroke);
+
+ &__summary {
+ display: flex;
+ align-items: baseline;
+ gap: 12px;
+ min-width: 0;
+ min-height: 32px;
+ line-height: 32px;
+ }
-/* -------------------------------------------------------------------------
- Settings panel
- One element, two placements: pinned it sits in the rail, otherwise it is
- lifted out of the grid and floats over the image area near its toolbar
- control. Keeping a single element means the two never drift apart.
- ------------------------------------------------------------------------- */
-.ig-panel-slot {
- display: none;
- align-self: start;
- max-height: 100%;
-}
-.ig-layout.has-rail .ig-panel-slot {
- display: block;
-}
+ &__title {
+ color: var(--td-text-color-primary);
+ font-size: var(--app-text-md);
+ font-weight: 600;
+ white-space: nowrap;
+ }
-.ig-panel-slot.is-floating {
- display: block;
- position: absolute;
- top: 92px;
- right: 28px;
- width: 320px;
- z-index: 20;
- max-height: calc(100% - 120px);
- overflow: auto;
- background: var(--td-bg-color-container);
- border: 1px solid var(--td-component-border);
- border-radius: var(--td-radius-medium);
- box-shadow: var(--td-shadow-card));
-}
+ &__count {
+ color: var(--td-text-color-placeholder);
+ font-size: var(--app-text-sm);
+ font-variant-numeric: tabular-nums;
+ white-space: nowrap;
+ }
-.ig-panel-head {
- display: flex;
- align-items: center;
- gap: 8px;
- padding: 8px 12px;
- /* No bottom border here: the tab bar already draws one, and a second
- divider under it just reads as visual noise. */
+ &__trailing {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ min-width: 0;
+ }
}
-.ig-panel-tabs {
- flex: 1 1 0;
- min-width: 0;
+
+.ig-search {
+ width: 220px;
+ min-width: 100px;
+
+ :deep(.t-input) {
+ background: transparent;
+ border-color: var(--td-component-stroke);
+ border-radius: var(--app-radius-md);
+ font-size: var(--app-text-md);
+ }
}
-.ig-pin {
- /* The tab bar would otherwise stretch and shove the pin out of the head. */
- flex-shrink: 0;
+
+.ig-tool-btn {
display: inline-flex;
align-items: center;
justify-content: center;
- width: 28px;
- height: 28px;
- padding: 0;
- border: 1px solid transparent;
- border-radius: var(--app-radius-sm);
+ gap: 6px;
+ height: 32px;
+ padding: 0 10px;
+ border: 1px solid var(--td-component-stroke);
+ border-radius: var(--app-radius-md);
background: transparent;
color: var(--td-text-color-secondary);
+ font: inherit;
+ font-size: var(--app-text-md);
+ white-space: nowrap;
cursor: pointer;
-}
-.ig-pin:hover {
- background: var(--td-bg-color-container-hover);
-}
-.ig-pin.is-pinned {
- color: var(--td-brand-color);
+
+ &:hover,
+ &.active {
+ background: var(--td-bg-color-secondarycontainer);
+ color: var(--td-text-color-primary);
+ }
+
+ &:focus-visible {
+ outline: 2px solid var(--app-focus-border);
+ outline-offset: 2px;
+ }
+
+ &__count {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ min-width: 17px;
+ height: 17px;
+ padding: 0 2px;
+ color: var(--td-brand-color);
+ font-weight: 600;
+ font-size: var(--app-text-xs);
+ font-variant-numeric: tabular-nums;
+ }
}
-.ig-panel-body {
- padding: 12px;
+.ig-sort-trigger {
+ max-width: 220px;
+
+ &__label {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
}
-.ig-row {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 12px;
- margin-bottom: 14px;
-}
-.ig-row-label {
- font-size: var(--app-text-md);
+// Filter panel — same frame and type scale as .doc-filter-panel.
+.ig-filter-panel {
+ width: 360px;
+ max-width: calc(100vw - 32px);
+ max-height: min(600px, 80vh);
+ overflow-y: auto;
+ padding: 16px;
+ box-sizing: border-box;
color: var(--td-text-color-primary);
-}
-.ig-hint {
- font-size: var(--app-text-sm);
- color: var(--td-text-color-placeholder);
-}
-.ig-attr-blocks {
- display: flex;
- flex-direction: column;
- gap: 14px;
-}
-.ig-attr-block {
- display: flex;
- flex-direction: column;
- gap: 6px;
-}
-.ig-attr-name {
font-size: var(--app-text-md);
- font-weight: 600;
- color: var(--td-text-color-primary);
-}
-.ig-verdict-rows {
- display: flex;
- flex-direction: column;
- gap: 4px;
+
+ button {
+ font: inherit;
+ cursor: pointer;
+ }
+
+ &__header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ margin-bottom: 12px;
+
+ strong {
+ font-size: var(--app-text-base);
+ font-weight: 600;
+ }
+
+ button {
+ border: 0;
+ padding: 0;
+ background: transparent;
+ color: var(--td-text-color-secondary);
+ font-size: var(--app-text-sm);
+
+ &:hover:not(:disabled) { color: var(--td-brand-color); }
+ &:disabled { color: var(--td-text-color-disabled); cursor: default; }
+ }
+ }
+
+ &__empty {
+ padding: 8px 0;
+ color: var(--td-text-color-placeholder);
+ }
}
-/* A gated block reads as inactive: dimmed text and buttons, but still
- clickable so the first touch can activate the master switch. */
-.ig-verdict-rows.is-idle,
-.ig-search-fields.is-idle {
- opacity: 0.4;
+
+.ig-filter-section {
+ & + & {
+ margin-top: 16px;
+ padding-top: 14px;
+ border-top: 1px solid var(--td-component-stroke);
+ }
+
+ &__title {
+ font-weight: 600;
+ line-height: 20px;
+ }
+
+ &__hint {
+ margin: 2px 0 10px;
+ color: var(--td-text-color-placeholder);
+ font-size: var(--app-text-xs);
+ line-height: 17px;
+ }
}
+
.ig-search-fields {
display: flex;
- flex-direction: column;
- gap: 4px;
-}
-.ig-verdict-row {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 8px;
+ flex-wrap: wrap;
+ gap: 4px 16px;
}
-.ig-verdict-value {
- font-size: var(--app-text-md);
- color: var(--td-text-color-primary);
- cursor: default;
+
+.ig-attr {
+ & + & { margin-top: 12px; }
+
+ &__name {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ margin-bottom: 4px;
+ color: var(--td-text-color-secondary);
+ font-size: var(--app-text-sm);
+ }
+
+ &__help {
+ color: var(--td-text-color-placeholder);
+ cursor: help;
+ }
+
+ &__row {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ min-height: 32px;
+ }
+
+ &__value {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
}
-.ig-verdict-group {
+
+// Three-position switch, drawn like the documents tab's view toggle.
+.ig-seg {
display: inline-flex;
- border: 1px solid var(--td-component-border);
- border-radius: var(--app-radius-sm);
- overflow: hidden;
-}
-.ig-verdict {
- min-width: 30px;
- padding: 2px 6px;
- border: none;
- border-right: 1px solid var(--td-component-border);
- background: var(--td-bg-color-container);
- font-size: var(--app-text-sm);
- line-height: 20px;
- color: var(--td-text-color-secondary);
- cursor: pointer;
-}
-.ig-verdict:last-child {
- border-right: none;
-}
-.ig-verdict:hover {
- background: var(--td-bg-color-container-hover);
+ flex-shrink: 0;
+ padding: 2px;
+ border-radius: var(--app-radius-md);
+ background: var(--td-bg-color-secondarycontainer);
+
+ &__item {
+ height: 24px;
+ padding: 0 10px;
+ border: 0;
+ border-radius: var(--app-radius-xs);
+ background: transparent;
+ color: var(--td-text-color-secondary);
+ font-size: var(--app-text-sm);
+ white-space: nowrap;
+ transition: background-color var(--app-motion-fast) ease, color var(--app-motion-fast) ease;
+
+ &:hover { color: var(--td-text-color-primary); }
+
+ &.active {
+ background: var(--td-bg-color-container);
+ color: var(--td-text-color-primary);
+ box-shadow: 0 1px 3px rgb(0 0 0 / 8%);
+ }
+
+ &.is-off.active { color: var(--td-error-color); }
+ &.is-on.active { color: var(--td-brand-color); }
+
+ &:focus-visible {
+ outline: 2px solid var(--app-focus-border);
+ outline-offset: 1px;
+ }
+ }
}
-.ig-verdict.is-active.is-default {
- background: var(--td-bg-color-secondary);
+
+// Sort panel — same shape as .document-sort-panel.
+.ig-sort-panel {
+ width: 280px;
+ max-width: calc(100vw - 32px);
+ padding: 6px;
+ box-sizing: border-box;
color: var(--td-text-color-primary);
- font-weight: 600;
-}
-.ig-verdict.is-active.is-off {
- background: var(--td-error-color-1);
- color: var(--td-error-color);
- font-weight: 600;
-}
-.ig-verdict.is-active.is-on {
- background: var(--td-success-color-1);
- color: var(--td-success-color);
- font-weight: 600;
}
-/* Toolbar: one row, so nothing steals vertical space from the grid. */
-.ig-toolbar {
- display: flex;
- align-items: center;
- gap: 10px;
- margin-bottom: 12px;
- flex-wrap: wrap;
-}
-.ig-search {
- width: 200px;
- max-width: 260px;
+.ig-sort-group {
+ padding: 7px 6px 8px;
+
+ & + & { border-top: 1px solid var(--td-component-stroke); }
+
+ &__label {
+ padding: 0 4px 6px;
+ font-size: var(--app-text-md);
+ font-weight: 600;
+ line-height: 20px;
+ }
+
+ &__options {
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: 4px;
+ }
}
-.ig-scope {
+
+.ig-sort-option {
display: inline-flex;
align-items: center;
- gap: 4px;
-}
-.ig-scope-name {
- font-size: var(--app-text-md);
- color: var(--td-text-color-secondary);
- white-space: nowrap;
-}
-.ig-scope-value {
- font-size: var(--app-text-md);
+ justify-content: space-between;
+ min-width: 0;
+ height: 32px;
+ padding: 0 10px;
+ border: 0;
+ border-radius: var(--app-radius-sm);
+ background: transparent;
color: var(--td-text-color-primary);
- white-space: nowrap;
-}
-.ig-scope-arrow {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- width: 24px;
- height: 28px;
- padding: 0;
- border: 1px solid var(--td-component-border);
- border-radius: var(--td-radius-medium);
- background: var(--td-bg-color-container);
- color: var(--td-text-color-secondary);
- cursor: pointer;
-}
-.ig-scope-arrow:hover:not(:disabled) {
- border-color: var(--td-brand-color);
- color: var(--td-brand-color);
-}
-.ig-scope-arrow:disabled {
- opacity: 0.45;
- cursor: not-allowed;
-}
-.ig-scope-sep {
- width: 1px;
- height: 20px;
- margin: 0 2px;
- background: var(--td-component-border);
-}
-.ig-sort {
- width: 140px;
-}
-.ig-order {
- white-space: nowrap;
-}
-/* The button wraps its content in .t-button__text, an inline-flex box whose
- default stretch pins the explicitly-sized 16px icon to the top of the 22px
- line box, so the arrow reads as riding high; center it instead. */
-.ig-order :deep(.t-button__text) {
- align-items: center;
-}
-.ig-count {
- margin-left: auto;
+ font-family: var(--app-font-family);
font-size: var(--app-text-md);
- color: var(--td-text-color-secondary);
- white-space: nowrap;
-}
+ cursor: pointer;
-.ig-filter-group {
- margin-bottom: 18px;
-}
-.ig-filter-label {
- display: block;
- font-size: var(--app-text-md);
- color: var(--td-text-color-secondary);
- margin-bottom: 8px;
-}
-.ig-search-hint {
- font-size: var(--app-text-sm);
- color: var(--td-text-color-placeholder);
- margin-top: 6px;
-}
-.ig-search-fields {
- margin-top: 6px;
- display: flex;
- flex-direction: column;
- gap: 2px;
-}
-.ig-attr-filter {
- margin-bottom: 12px;
-}
-.ig-attr-name {
- font-size: var(--app-text-md);
- font-weight: 500;
- margin-bottom: 4px;
-}
-.ig-no-attrs {
- font-size: var(--app-text-md);
-}
-.ig-apply-all {
- margin-top: 4px;
-}
-.ig-apply-all .ig-verdict-group {
- flex-shrink: 0;
+ &:hover { background: var(--td-bg-color-secondarycontainer); }
+
+ &.active {
+ background: var(--td-brand-color-light);
+ color: var(--td-brand-color);
+ font-weight: 500;
+ }
}
-/* Main */
-.ig-main {
- display: flex;
- flex-direction: column;
- min-width: 0;
+// Grid
+.ig-scroll {
+ flex: 1;
min-height: 0;
+ overflow-y: auto;
+ overflow-x: hidden;
+ padding: 16px 0;
+
+ &.is-empty {
+ display: flex;
+ flex-direction: column;
+ }
}
-.ig-toolbar {
+
+.ig-loading {
+ min-height: 100%;
display: flex;
- align-items: center;
- gap: 12px;
- margin-bottom: 14px;
- flex-wrap: wrap;
-}
-.ig-search {
- flex: 1;
- min-width: 220px;
-}
-.ig-sort {
- width: 160px;
-}
-.ig-count {
- font-size: var(--app-text-md);
- color: var(--td-text-color-secondary);
- white-space: nowrap;
-}
-.ig-loading-area {
- flex: 1;
- min-height: 0;
- overflow: auto;
+ flex-direction: column;
}
+
.ig-error {
- color: var(--td-error-color);
padding: 16px 0;
-}
-.ig-empty {
- color: var(--td-text-color-placeholder);
- padding: 48px 0;
- text-align: center;
+ color: var(--td-error-color);
}
-/* Grid */
.ig-grid {
display: grid;
- grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
- gap: 14px;
+ grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr));
+ gap: 12px;
+ align-content: start;
}
+
.ig-card {
+ display: flex;
+ flex-direction: column;
+ min-width: 0;
+ padding: 0;
+ overflow: hidden;
border: 1px solid var(--td-component-border);
border-radius: var(--app-radius-md);
- overflow: hidden;
background: var(--td-bg-color-container);
- cursor: pointer;
- padding: 0;
+ box-shadow: 0 1px 2px rgb(0 0 0 / 6%);
+ color: inherit;
+ font: inherit;
text-align: left;
- transition: box-shadow var(--app-motion-fast), transform var(--app-motion-fast);
- display: flex;
- flex-direction: column;
-}
-.ig-card:hover {
- box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
- transform: translateY(-2px);
-}
-.ig-card-thumb {
- aspect-ratio: 4 / 3;
- background: #f3f3f3;
- display: flex;
- align-items: center;
- justify-content: center;
- overflow: hidden;
-}
-.ig-card-thumb img {
- width: 100%;
- height: 100%;
- object-fit: cover;
-}
-.ig-thumb-error {
- font-size: var(--app-text-sm);
- color: var(--td-text-color-placeholder);
- padding: 0 8px;
- text-align: center;
-}
-.ig-card-meta {
- padding: 8px 10px;
-}
-.ig-card-caption {
- font-size: var(--app-text-md);
- line-height: 1.4;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- overflow: hidden;
-}
-.ig-card-source {
- font-size: var(--app-text-sm);
- color: var(--td-text-color-secondary);
- margin-top: 4px;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
-}
+ cursor: pointer;
+ transition: border-color var(--app-motion-base) ease, box-shadow var(--app-motion-base) ease;
-.ig-pagination {
- margin-top: 16px;
- justify-content: center;
-}
+ &:hover {
+ border-color: color-mix(in srgb, var(--td-component-stroke) 55%, var(--td-brand-color));
+ box-shadow: 0 4px 14px rgb(0 0 0 / 7%);
-/* Viewer */
-.ig-viewer-overlay {
- position: fixed;
- inset: 0;
- background: rgba(0, 0, 0, 0.72);
- z-index: 2000;
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 24px;
- box-sizing: border-box;
-}
-.ig-viewer {
- position: relative;
- display: grid;
- grid-template-columns: 1fr 340px;
- gap: 0;
- width: min(1100px, 96vw);
- height: min(80vh, 760px);
- background: var(--td-bg-color-container);
- border-radius: var(--app-radius-xl);
- overflow: hidden;
-}
-.ig-viewer-image {
- display: flex;
- align-items: center;
- justify-content: center;
- background: #1a1a1a;
- padding: 12px;
- min-width: 0;
-}
-.ig-viewer-image img {
- max-width: 100%;
- max-height: 100%;
- object-fit: contain;
-}
-.ig-viewer-image-error {
- color: #ddd;
-}
-.ig-viewer-info {
- padding: 20px;
- overflow: auto;
- border-left: 1px solid var(--td-component-border);
-}
-.ig-viewer-info h3 {
- font-size: var(--app-text-md);
- text-transform: uppercase;
- letter-spacing: 0.04em;
- color: var(--td-text-color-secondary);
- margin: 16px 0 8px;
-}
-.ig-viewer-info h3:first-child {
- margin-top: 0;
-}
-.ig-info-row {
- display: flex;
- justify-content: space-between;
- gap: 12px;
- padding: 4px 0;
- font-size: var(--app-text-base);
-}
-.ig-info-key {
- color: var(--td-text-color-secondary);
-}
-.ig-info-val {
- font-weight: 500;
- text-align: right;
-}
-.ig-info-text {
- font-size: var(--app-text-base);
- line-height: 1.6;
- white-space: pre-wrap;
- word-break: break-word;
- margin: 0;
-}
-.ig-info-muted {
- color: var(--td-text-color-placeholder);
- font-size: var(--app-text-base);
-}
-.ig-info-sub {
- display: block;
- font-size: var(--app-text-sm);
- color: var(--td-text-color-placeholder);
- margin-top: 2px;
- word-break: break-all;
-}
-.ig-viewer-close {
- position: absolute;
- top: 10px;
- right: 10px;
- z-index: 2;
- border: none;
- background: rgba(0, 0, 0, 0.45);
- color: #fff;
- width: 32px;
- height: 32px;
- border-radius: 50%;
- cursor: pointer;
- display: flex;
- align-items: center;
- justify-content: center;
+ .ig-card__thumb img { transform: scale(1.03); }
+ }
+
+ &:focus-visible {
+ outline: 2px solid var(--app-focus-border);
+ outline-offset: 2px;
+ }
+
+ &.is-disabled .ig-card__thumb img { opacity: 0.55; }
+
+ &__thumb {
+ position: relative;
+ aspect-ratio: 4 / 3;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ overflow: hidden;
+ background: var(--td-bg-color-secondarycontainer);
+
+ img {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ transition: transform var(--app-motion-slow) ease;
+ }
+ }
+
+ &__broken {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 4px;
+ padding: 0 8px;
+ color: var(--td-text-color-placeholder);
+ font-size: var(--app-text-sm);
+ text-align: center;
+ }
+
+ &__badge {
+ position: absolute;
+ top: 8px;
+ left: 8px;
+ padding: 0 6px;
+ border-radius: var(--app-radius-xs);
+ background: rgb(0 0 0 / 55%);
+ color: #fff;
+ font-size: var(--app-text-xs);
+ line-height: 18px;
+ }
+
+ &__meta {
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ padding: 10px 12px 12px;
+ }
+
+ &__caption {
+ display: -webkit-box;
+ min-height: calc(2 * 1.5em);
+ overflow: hidden;
+ color: var(--td-text-color-primary);
+ font-size: var(--app-text-md);
+ line-height: 1.5;
+ -webkit-line-clamp: 2;
+ -webkit-box-orient: vertical;
+
+ &.is-empty { color: var(--td-text-color-placeholder); }
+ }
+
+ &__source {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ min-width: 0;
+ color: var(--td-text-color-placeholder);
+ font-size: var(--app-text-sm);
+
+ span {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+ }
}
-.ig-nav {
- position: absolute;
- top: 50%;
- transform: translateY(-50%);
- z-index: 2;
- border: none;
- background: rgba(0, 0, 0, 0.45);
- color: #fff;
- width: 40px;
- height: 40px;
- border-radius: 50%;
- cursor: pointer;
+
+.ig-footer {
display: flex;
- align-items: center;
- justify-content: center;
-}
-.ig-nav-prev {
- left: 12px;
+ justify-content: flex-end;
+ flex-shrink: 0;
+ padding: 12px 0 16px;
+ border-top: 1px solid var(--td-component-stroke);
}
-.ig-nav-next {
- right: 352px;
+
+@container image-gallery (max-width: 780px) {
+ .ig-toolbar { flex-wrap: wrap; gap: 12px; }
+ .ig-toolbar__trailing { width: 100%; }
+ .ig-search { flex: 1; width: auto; }
}
</style>