Skip to content

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

fix(ui): 优化知识库文档交互与对话布局 (#3420)

lyingbug2a6a9c251734
diff --git a/docs/assets/knowledge-tag-popover.png b/docs/assets/knowledge-tag-popover.png
new file mode 100644
index 000000000..12b3bcb9b
Binary files /dev/null and b/docs/assets/knowledge-tag-popover.png differ
diff --git a/frontend/src/assets/dropdown-menu.less b/frontend/src/assets/dropdown-menu.less
index 970f65a6a..846a96eb1 100644
--- a/frontend/src/assets/dropdown-menu.less
+++ b/frontend/src/assets/dropdown-menu.less
@@ -48,10 +48,7 @@
border-radius: var(--app-radius-lg) !important;
background: var(--td-bg-color-container) !important;
border: 0.5px solid var(--td-component-stroke) !important;
- box-shadow:
- 0 0 0 0.5px rgba(0, 0, 0, 0.03),
- 0 2px 4px rgba(0, 0, 0, 0.04),
- 0 8px 24px rgba(0, 0, 0, 0.1) !important;
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.08) !important;
backdrop-filter: blur(20px) saturate(180%) !important;
-webkit-backdrop-filter: blur(20px) saturate(180%) !important;
animation: dropdownSlideIn 0.18s cubic-bezier(0.2, 0, 0, 1) both;
@@ -71,22 +68,23 @@
.popup-menu-item {
display: flex;
align-items: center;
- gap: 10px;
- padding: 8px 12px;
+ gap: 8px;
+ padding: 6px 10px;
cursor: pointer;
- transition: all var(--app-motion-fast) cubic-bezier(0.2, 0, 0, 1);
+ transition: background-color var(--app-motion-fast) ease, color var(--app-motion-fast) ease;
color: var(--td-text-color-primary);
+ font-family: var(--app-font-family);
font-size: var(--app-text-base);
font-weight: 400;
line-height: 20px;
- border-radius: var(--app-radius-sm);
+ border-radius: var(--app-radius-xs);
position: relative;
.menu-icon {
- font-size: var(--app-text-xl);
+ font-size: var(--app-text-2xl);
flex-shrink: 0;
color: var(--td-text-color-secondary);
- transition: all var(--app-motion-fast) cubic-bezier(0.2, 0, 0, 1);
+ transition: background-color var(--app-motion-fast) ease, color var(--app-motion-fast) ease;
}
&:hover {
@@ -100,7 +98,6 @@
&:active {
background: var(--td-bg-color-container-active);
- transform: scale(0.98);
}
&.delete,
@@ -152,10 +149,7 @@
border-radius: var(--app-radius-lg) !important;
background: var(--td-bg-color-container) !important;
border: 0.5px solid var(--td-component-stroke) !important;
- box-shadow:
- 0 0 0 0.5px rgba(0, 0, 0, 0.03),
- 0 2px 4px rgba(0, 0, 0, 0.04),
- 0 8px 24px rgba(0, 0, 0, 0.1) !important;
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.08) !important;
backdrop-filter: blur(20px) saturate(180%) !important;
-webkit-backdrop-filter: blur(20px) saturate(180%) !important;
color: var(--td-text-color-primary);
@@ -182,13 +176,15 @@
.card-menu-item {
display: flex;
align-items: center;
- gap: 10px;
- padding: 8px 12px;
+ gap: 8px;
+ padding: 6px 10px;
cursor: pointer;
color: var(--td-text-color-primary);
- transition: all var(--app-motion-fast) cubic-bezier(0.2, 0, 0, 1);
- border-radius: var(--app-radius-sm);
+ transition: background-color var(--app-motion-fast) ease, color var(--app-motion-fast) ease;
+ border-radius: var(--app-radius-xs);
+ font-family: var(--app-font-family);
font-size: var(--app-text-base);
+ font-weight: 400;
line-height: 20px;
&:hover {
@@ -197,13 +193,12 @@
&:active {
background: var(--td-bg-color-container-active);
- transform: scale(0.98);
}
.icon {
- font-size: var(--app-text-xl);
+ font-size: var(--app-text-2xl);
color: var(--td-text-color-secondary);
- transition: all var(--app-motion-fast) cubic-bezier(0.2, 0, 0, 1);
+ transition: background-color var(--app-motion-fast) ease, color var(--app-motion-fast) ease;
}
&:hover .icon {
@@ -351,16 +346,18 @@
四、TDesign Dropdown 统一样式
适用于 <t-dropdown> 组件(挂载到 body 上)
============================================ */
+.t-popup__content.t-dropdown {
+ border: 1px solid var(--td-component-stroke);
+ border-radius: var(--app-radius-md);
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.08);
+}
+
.t-popup__content {
.t-dropdown__menu {
background: var(--td-bg-color-container);
- border: 0.5px solid var(--td-component-stroke);
- box-shadow:
- 0 0 0 0.5px rgba(0, 0, 0, 0.03),
- 0 2px 4px rgba(0, 0, 0, 0.04),
- 0 8px 24px rgba(0, 0, 0, 0.1);
- backdrop-filter: blur(20px) saturate(180%);
- -webkit-backdrop-filter: blur(20px) saturate(180%);
+ border: 0;
+ box-shadow: none;
+ gap: 2px;
padding: 4px;
min-width: 148px;
animation: dropdownSlideIn 0.18s cubic-bezier(0.2, 0, 0, 1) both;
@@ -399,11 +396,14 @@
}
.t-dropdown__item {
- padding: 8px 12px;
- border-radius: var(--app-radius-sm);
- margin: 1px 0;
- transition: all var(--app-motion-fast) cubic-bezier(0.2, 0, 0, 1);
+ padding: 6px 10px;
+ border-radius: var(--app-radius-xs);
+ margin: 0;
+ transition: background-color var(--app-motion-fast) ease, color var(--app-motion-fast) ease;
+ font-family: var(--app-font-family);
font-size: var(--app-text-base);
+ font-weight: 400;
+ line-height: 20px;
color: var(--td-text-color-primary);
cursor: pointer;
min-width: auto !important;
@@ -420,7 +420,6 @@
&:active {
background: var(--td-bg-color-container-active);
- transform: scale(0.98);
}
.t-dropdown__item-icon {
@@ -429,10 +428,12 @@
color: var(--td-text-color-secondary);
display: flex;
align-items: center;
- transition: all var(--app-motion-fast) cubic-bezier(0.2, 0, 0, 1);
+ transition: background-color var(--app-motion-fast) ease, color var(--app-motion-fast) ease;
.t-icon {
- font-size: var(--app-text-xl);
+ font-size: var(--app-text-2xl);
+ width: var(--app-text-2xl);
+ height: var(--app-text-2xl);
}
}
@@ -452,6 +453,12 @@
display: block;
}
+ // Match sidebar text: normal/hover stays primary, current selection is branded.
+ &.t-dropdown__item--theme-default:not(.t-dropdown__item--disabled) {
+ &:hover { color: var(--td-text-color-primary); }
+ &.t-dropdown__item--active { color: var(--td-brand-color); }
+ }
+
/* TDesign error 主题项(删除操作) */
&.t-dropdown__item--theme-error {
color: var(--td-error-color-6) !important;
@@ -488,126 +495,9 @@
}
}
-/* tag 更多弹窗 */
-.tag-more-popup {
- z-index: 99 !important;
- .t-popup__content {
- padding: 4px !important;
- margin-top: 4px !important;
- min-width: 120px;
- border-radius: var(--app-radius-lg) !important;
- background: var(--td-bg-color-container) !important;
- border: 0.5px solid var(--td-component-stroke) !important;
- box-shadow:
- 0 0 0 0.5px rgba(0, 0, 0, 0.03),
- 0 2px 4px rgba(0, 0, 0, 0.04),
- 0 8px 24px rgba(0, 0, 0, 0.1) !important;
- backdrop-filter: blur(20px) saturate(180%) !important;
- -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
- animation: dropdownSlideIn 0.18s cubic-bezier(0.2, 0, 0, 1) both;
- overflow: hidden;
- }
-}
-/* 文档卡片标签选择弹窗 */
-.card-tag-popup {
- z-index: 99 !important;
- .t-popup__content {
- padding: 4px !important;
- margin-top: 4px !important;
- border-radius: var(--app-radius-lg) !important;
- background: var(--td-bg-color-container) !important;
- border: 0.5px solid var(--td-component-stroke) !important;
- box-shadow:
- 0 0 0 0.5px rgba(0, 0, 0, 0.03),
- 0 2px 4px rgba(0, 0, 0, 0.04),
- 0 8px 24px rgba(0, 0, 0, 0.1) !important;
- backdrop-filter: blur(20px) saturate(180%) !important;
- -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
- animation: dropdownSlideIn 0.18s cubic-bezier(0.2, 0, 0, 1) both;
- overflow: hidden;
- }
-
- .tag-popup-list {
- min-width: 160px;
- max-width: 240px;
- max-height: 280px;
- overflow-y: auto;
- display: flex;
- flex-direction: column;
- gap: 2px;
- }
-
- .tag-popup-item {
- display: flex;
- align-items: center;
- gap: 6px;
- padding: 6px 8px;
- border-radius: var(--app-radius-sm);
- font-size: var(--app-text-md);
- color: var(--td-text-color-primary);
- cursor: pointer;
- line-height: 1.2;
- transition: background-color var(--app-motion-fast) ease;
-
- &:hover {
- background: var(--td-bg-color-container-hover);
- }
-
- &.is-selected {
- color: var(--td-brand-color);
- background: var(--td-bg-color-secondarycontainer);
- }
- }
-
- .tag-popup-check {
- font-size: var(--app-text-base);
- color: var(--td-brand-color);
- visibility: hidden;
- flex-shrink: 0;
-
- &.visible {
- visibility: visible;
- }
- }
-
- .tag-popup-name {
- flex: 1;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-
- &.muted {
- color: var(--td-text-color-secondary);
- }
- }
-
- .tag-popup-item.is-action {
- color: var(--td-text-color-secondary);
-
- .tag-popup-check {
- visibility: visible;
- color: var(--td-text-color-secondary);
- }
-
- &:hover {
- color: var(--td-error-color);
- background: var(--td-error-color-1);
-
- .tag-popup-check {
- color: var(--td-error-color);
- }
- }
- }
-
- .tag-popup-divider {
- height: 1px;
- margin: 4px 4px;
- background: var(--td-component-stroke);
- }
-}
/* ============================================
五、锚定表单/确认弹层(成员邀请、Wiki 移动/删除等)
@@ -680,8 +570,6 @@
:root[theme-mode="dark"] {
.card-more-popup .t-popup__content,
.card-more .t-popup__content,
- .tag-more-popup .t-popup__content,
- .card-tag-popup .t-popup__content,
.anchored-form-popup-overlay .t-popup__content {
background: rgba(36, 36, 36, 0.92) !important;
border-color: rgba(255, 255, 255, 0.08) !important;
@@ -700,13 +588,14 @@
0 8px 32px rgba(0, 0, 0, 0.28);
}
+ .t-popup__content.t-dropdown {
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 6px 20px rgba(0, 0, 0, 0.24);
+ }
+
.t-popup__content .t-dropdown__menu {
- background: rgba(36, 36, 36, 0.85);
- border-color: rgba(255, 255, 255, 0.08);
- box-shadow:
- 0 0 0 0.5px rgba(255, 255, 255, 0.05),
- 0 2px 4px rgba(0, 0, 0, 0.12),
- 0 8px 32px rgba(0, 0, 0, 0.28);
+ background: var(--td-bg-color-container);
+ border: 0;
+ box-shadow: none;
&:hover {
scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
diff --git a/frontend/src/assets/theme/tdesign-overrides.less b/frontend/src/assets/theme/tdesign-overrides.less
index 59367bc35..e48294a26 100644
--- a/frontend/src/assets/theme/tdesign-overrides.less
+++ b/frontend/src/assets/theme/tdesign-overrides.less
@@ -20,3 +20,28 @@
background: rgba(36, 36, 36, 0.92);
border-color: rgba(255, 255, 255, 0.08);
}
+
+// A quiet option surface, with the brand accent reserved for the small check.
+.t-select-option.t-is-selected:not(.t-is-disabled),
+.t-select-option.t-is-selected:not(.t-is-disabled):hover {
+ background-color: var(--app-selection-bg);
+ color: var(--td-text-color-primary);
+ font-weight: 500;
+}
+
+// A check keeps single-selection menus distinct from hover without using color alone.
+.t-select-option.t-is-selected:not(.t-is-disabled):not(:has(.t-checkbox))::after {
+ content: '';
+ flex: 0 0 auto;
+ width: 5px;
+ height: 9px;
+ margin-left: auto;
+ margin-right: 2px;
+ color: var(--td-brand-color);
+ border: solid currentColor;
+ border-width: 0 1.5px 1.5px 0;
+ transform: translateY(-1px) rotate(45deg);
+}
+.t-select-option.t-is-selected:not(.t-is-disabled):not(:has(.t-checkbox)) {
+ gap: 8px;
+}
diff --git a/frontend/src/assets/theme/theme.css b/frontend/src/assets/theme/theme.css
index e61233866..51aa65412 100644
--- a/frontend/src/assets/theme/theme.css
+++ b/frontend/src/assets/theme/theme.css
@@ -201,6 +201,14 @@ select:-webkit-autofill {
box-shadow: none;
}
+/* Keep selection surfaces quiet; small indicators retain the brand accent. */
+:root {
+ --app-selection-bg: color-mix(in srgb, var(--td-text-color-primary) 4%, var(--td-bg-color-container));
+ --app-selection-text: var(--td-text-color-primary);
+ --app-selection-border: color-mix(in srgb, var(--td-brand-color) 30%, var(--td-component-stroke));
+ --app-focus-border: var(--td-brand-color);
+}
+
/* 应用级强调色:智能体 / 图谱等「非品牌但反复出现」的语义色,透明叠加请用 color-mix */
:root {
--app-accent-purple: #7c4dff;
@@ -223,6 +231,9 @@ select:-webkit-autofill {
* 新代码请引用令牌,样式守卫会统计残留字面量。
* ============================================================ */
:root {
+ /* 对话标题与右侧面板共用同一条头部分割线。 */
+ --app-chat-header-height: 40px;
+
/* 圆角 */
--app-radius-xs: 4px;
--app-radius-sm: 6px;
diff --git a/frontend/src/components/ChatAttachmentPreviewDrawer.vue b/frontend/src/components/ChatAttachmentPreviewDrawer.vue
index dec2b0f87..67f03aa60 100644
--- a/frontend/src/components/ChatAttachmentPreviewDrawer.vue
+++ b/frontend/src/components/ChatAttachmentPreviewDrawer.vue
@@ -163,15 +163,15 @@ onUnmounted(() => {
.chat-attachment-drawer-header-icon {
flex-shrink: 0;
- width: 32px;
- height: 32px;
- border-radius: 9px;
+ width: 24px;
+ height: 24px;
+ border-radius: var(--app-radius-sm);
display: flex;
align-items: center;
justify-content: center;
background: color-mix(in srgb, var(--td-brand-color) 10%, transparent);
color: var(--td-brand-color);
- font-size: var(--app-text-xl);
+ font-size: var(--app-text-lg);
}
.chat-attachment-drawer-header-text {
@@ -180,9 +180,9 @@ onUnmounted(() => {
}
.chat-attachment-drawer-header-title {
- font-size: var(--app-text-lg);
- font-weight: 600;
- line-height: 1.4;
+ font-size: var(--app-text-base);
+ font-weight: 500;
+ line-height: 20px;
color: var(--td-text-color-primary);
overflow: hidden;
text-overflow: ellipsis;
@@ -240,11 +240,19 @@ onUnmounted(() => {
}
.t-drawer__header {
- padding: 14px 18px;
+ height: var(--app-chat-header-height);
+ min-height: var(--app-chat-header-height);
+ padding: 0 12px;
border-bottom: 1px solid var(--td-component-stroke);
flex-shrink: 0;
}
+ .t-drawer__close-btn {
+ top: calc((var(--app-chat-header-height) - 28px) / 2);
+ width: 28px;
+ height: 28px;
+ }
+
.t-drawer__body {
flex: 1;
min-height: 0;
diff --git a/frontend/src/components/ChatHeader.vue b/frontend/src/components/ChatHeader.vue
index 9b574f179..d987c9d2c 100644
--- a/frontend/src/components/ChatHeader.vue
+++ b/frontend/src/components/ChatHeader.vue
@@ -1,5 +1,5 @@
<template>
- <header class="chat-header" :class="{ 'is-editing': titleEditing, 'is-docked': hasReferencesPanel }">
+ <header class="chat-header">
<form
v-if="titleEditing"
class="chat-header__edit"
@@ -140,7 +140,6 @@ type MenuMode = 'menu' | 'clear' | 'delete'
const props = defineProps<{
session: ChatHeaderSession | null
- hasReferencesPanel?: boolean
}>()
const { t } = useI18n()
@@ -350,54 +349,12 @@ function handleMenuClick(data: { value: string }): void {
<style scoped lang="less">
.chat-header {
- position: absolute;
- top: 10px;
- left: 12px;
- z-index: 6;
display: inline-flex;
align-items: center;
gap: 2px;
- max-width: min(280px, calc(100% - 24px));
+ max-width: min(360px, calc(100% - 36px));
min-width: 0;
- padding: 2px 2px 2px 8px;
- border-radius: var(--app-radius-md);
box-sizing: border-box;
- background: color-mix(in srgb, var(--td-bg-color-container) 88%, transparent);
- backdrop-filter: blur(8px);
- -webkit-backdrop-filter: blur(8px);
- pointer-events: auto;
-
- &.is-editing {
- max-width: min(360px, calc(100% - 24px));
- padding: 2px;
- }
-
- @media (min-width: 960px) {
- &.is-docked {
- position: relative;
- top: auto;
- left: auto;
- align-self: stretch;
- z-index: 5;
- flex-shrink: 0;
- width: 100%;
- max-width: none;
- margin: 0;
- padding: 10px 12px;
- border-radius: 0;
- border-bottom: 1px solid var(--td-component-stroke);
- background: var(--td-bg-color-container);
- backdrop-filter: none;
- -webkit-backdrop-filter: none;
- box-sizing: border-box;
- transition: border-color var(--app-motion-slow) cubic-bezier(0.22, 0.61, 0.36, 1);
-
- &.is-editing {
- max-width: none;
- padding: 8px 12px;
- }
- }
- }
}
.chat-header__edit {
diff --git a/frontend/src/components/ChatReferencesDrawer.vue b/frontend/src/components/ChatReferencesDrawer.vue
index 11720df8c..6c8ea81d3 100644
--- a/frontend/src/components/ChatReferencesDrawer.vue
+++ b/frontend/src/components/ChatReferencesDrawer.vue
@@ -20,7 +20,7 @@
:aria-label="t('common.close')"
@click="close"
>
- <t-icon name="close" size="20px" />
+ <t-icon name="close" size="16px" />
</button>
</header>
@@ -357,7 +357,10 @@ watch(visible, (open) => {
align-items: center;
justify-content: space-between;
gap: 12px;
- padding: 16px 16px 12px;
+ height: var(--app-chat-header-height);
+ flex-shrink: 0;
+ box-sizing: border-box;
+ padding: 0 12px;
border-bottom: 1px solid var(--td-component-stroke);
}
@@ -373,7 +376,10 @@ watch(visible, (open) => {
font-size: var(--app-text-base);
font-weight: 500;
color: var(--td-text-color-secondary);
- line-height: 1.4;
+ line-height: 20px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
}
.chat-references-panel__count {
@@ -385,9 +391,9 @@ watch(visible, (open) => {
border: 0;
background: var(--td-bg-color-secondarycontainer);
color: var(--td-text-color-secondary);
- width: 36px;
- height: 36px;
- border-radius: var(--app-radius-lg);
+ width: 28px;
+ height: 28px;
+ border-radius: var(--app-radius-md);
cursor: pointer;
display: inline-flex;
align-items: center;
@@ -395,10 +401,6 @@ watch(visible, (open) => {
flex-shrink: 0;
transition: background var(--app-motion-fast) ease, color var(--app-motion-fast) ease;
- :deep(.t-icon) {
- font-size: var(--app-text-3xl);
- }
-
&:hover {
background: color-mix(in srgb, var(--td-text-color-primary) 8%, var(--td-bg-color-secondarycontainer));
color: var(--td-text-color-primary);
diff --git a/frontend/src/components/Input-field.vue b/frontend/src/components/Input-field.vue
index b24366a79..9488a93cf 100644
--- a/frontend/src/components/Input-field.vue
+++ b/frontend/src/components/Input-field.vue
@@ -507,6 +507,10 @@ const sharedAgentOrgName = computed(() => {
});
const props = defineProps({
+ compact: {
+ type: Boolean,
+ default: false
+ },
autoFocus: {
type: Boolean,
default: false
@@ -2634,7 +2638,7 @@ defineExpose({
</script>
<template>
- <div class="answers-input" :class="{ 'is-embedded': embeddedMode }" @drop="onDrop" @dragover="onDragOver">
+ <div class="answers-input" :class="{ 'is-embedded': embeddedMode, 'is-compact': compact }" @drop="onDrop" @dragover="onDragOver">
<!-- Hidden file input for image upload -->
<input ref="imageInputRef" type="file" accept="image/jpeg,image/png,image/gif,image/webp" multiple
style="display:none" @change="handleImageSelect" />
@@ -3216,7 +3220,7 @@ const getImgSrc = (url: string) => {
:deep(.t-textarea__inner) {
width: 100%;
max-height: 152px !important;
- min-height: 72px !important;
+ min-height: var(--composer-input-min-height, 72px) !important;
resize: none;
color: var(--td-text-color-primary);
font-size: var(--app-text-xl);
@@ -3268,6 +3272,24 @@ const getImgSrc = (url: string) => {
}
}
+.answers-input.is-compact {
+ --composer-input-min-height: 56px;
+
+ .rich-input-container :deep(.t-textarea__inner) {
+ padding: 12px 14px;
+ }
+
+ .control-bar {
+ margin: 0 12px 8px;
+ padding-top: 4px;
+ }
+
+ .control-icon {
+ width: 16px;
+ height: 16px;
+ }
+}
+
.control-left {
display: flex;
align-items: center;
diff --git a/frontend/src/components/KBSwitcherDropdown.vue b/frontend/src/components/KBSwitcherDropdown.vue
index b98d5a517..228dbc999 100644
--- a/frontend/src/components/KBSwitcherDropdown.vue
+++ b/frontend/src/components/KBSwitcherDropdown.vue
@@ -110,23 +110,24 @@ const handleSelect = (id: string): void => {
gap: 8px;
padding: 6px 10px;
border: none;
- border-radius: var(--app-radius-sm);
+ border-radius: var(--app-radius-xs);
background: transparent;
color: var(--td-text-color-primary);
- font-size: var(--app-text-md);
- line-height: 1.4;
+ font-family: var(--app-font-family);
+ font-size: var(--app-text-base);
+ font-weight: 400;
+ line-height: 20px;
cursor: pointer;
transition: background var(--app-motion-fast) ease, color var(--app-motion-fast) ease;
text-align: left;
&:hover {
- background: var(--td-bg-color-secondarycontainer);
+ background: var(--td-bg-color-container-hover);
}
&.active {
- background: var(--td-brand-color-light);
+ background: var(--app-selection-bg);
color: var(--td-brand-color);
- font-weight: 500;
}
}
diff --git a/frontend/src/components/SessionSourceFilter.vue b/frontend/src/components/SessionSourceFilter.vue
index 6aeb5df9d..b4b9b42da 100644
--- a/frontend/src/components/SessionSourceFilter.vue
+++ b/frontend/src/components/SessionSourceFilter.vue
@@ -275,10 +275,10 @@ onBeforeUnmount(() => {
width: max-content;
min-width: 108px;
max-width: min(200px, calc(100vw - 16px));
- padding: 3px;
+ padding: 4px;
border: 1px solid var(--td-component-stroke);
- border-radius: 7px;
- background: var(--td-bg-color-sidebar);
+ border-radius: var(--app-radius-md);
+ background: var(--td-bg-color-container);
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05), 0 0 1px rgba(0, 0, 0, 0.04);
}
@@ -286,12 +286,12 @@ onBeforeUnmount(() => {
display: flex;
align-items: center;
justify-content: space-between;
- gap: 6px;
+ gap: 8px;
width: 100%;
- min-height: 28px;
- padding: 4px 6px;
+ min-height: 32px;
+ padding: 6px 10px;
border: 0;
- border-radius: 5px;
+ border-radius: var(--app-radius-xs);
background: transparent;
color: var(--td-text-color-primary);
cursor: pointer;
@@ -306,10 +306,10 @@ onBeforeUnmount(() => {
&--active {
background: var(--td-bg-color-secondarycontainer);
- color: var(--td-text-color-primary);
+ color: var(--td-brand-color);
.session-source-filter__icon {
- color: var(--td-text-color-secondary);
+ color: var(--td-brand-color);
}
.session-source-filter__logo {
@@ -320,16 +320,17 @@ onBeforeUnmount(() => {
}
.session-source-filter__option-label {
- font-size: var(--app-text-sm);
- font-weight: 500;
- line-height: 16px;
+ font-size: var(--app-text-base);
+ font-weight: 400;
+ line-height: 20px;
+ letter-spacing: normal;
}
.session-source-filter__check {
flex: 0 0 13px;
width: 13px;
margin-left: 2px;
- color: var(--td-text-color-placeholder);
+ color: var(--td-brand-color);
font-size: var(--app-text-sm) !important;
visibility: hidden;
diff --git a/frontend/src/components/chat/ChatQuestionMinimap.test.ts b/frontend/src/components/chat/ChatQuestionMinimap.test.ts
index adf843e03..71ab0daa4 100644
--- a/frontend/src/components/chat/ChatQuestionMinimap.test.ts
+++ b/frontend/src/components/chat/ChatQuestionMinimap.test.ts
@@ -16,7 +16,7 @@ test('opens a following preview card to the right of the left-side rail', () =>
assert.match(component, /question-minimap__answer/)
assert.doesNotMatch(component, /question-minimap__kicker/)
assert.match(component, /CLOSE_DELAY_MS = 150/)
- assert.match(component, /left: `\$\{RAIL_INSET_PX\}px`/)
+ assert.match(component, /left: var\(--chat-content-inset, 20px\)/)
assert.match(component, /top: `\$\{peakYPx\}px`/)
assert.doesNotMatch(component, /flex-direction: row-reverse/)
assert.doesNotMatch(component, /right: `\$\{scrollbarGutterPx \+ RAIL_INSET_PX\}px`/)
@@ -32,7 +32,6 @@ test('grows nearby ticks into a mountain under the pointer', () => {
test('centers the rail in the thread instead of stretching top to bottom', () => {
assert.match(component, /top: 50%/)
assert.match(component, /transform: translateY\(-50%\)/)
- assert.match(component, /RAIL_INSET_PX = 0/)
assert.match(component, /height: `\$\{trackHeight\}px`/)
assert.doesNotMatch(component, /inset-block: 0/)
assert.doesNotMatch(component, /align-self: flex-start/)
@@ -66,7 +65,6 @@ test('keeps scroll-driven active question changes from clobbering keyboard navig
test('does not draw a second scrollbar thumb next to the native scrollbar', () => {
assert.doesNotMatch(component, /question-minimap__viewport/)
- assert.match(component, /RAIL_INSET_PX = 0/)
assert.match(component, /scrollbar-width: none/)
})
diff --git a/frontend/src/components/chat/ChatQuestionMinimap.vue b/frontend/src/components/chat/ChatQuestionMinimap.vue
index 97adbac42..f13fcbbf6 100644
--- a/frontend/src/components/chat/ChatQuestionMinimap.vue
+++ b/frontend/src/components/chat/ChatQuestionMinimap.vue
@@ -3,7 +3,7 @@
v-if="visible"
ref="rootRef"
class="question-minimap"
- :style="{ left: `${RAIL_INSET_PX}px`, height: `${trackHeight}px` }"
+ :style="{ height: `${trackHeight}px` }"
:aria-label="t('chat.questionMinimapAriaLabel')"
@mouseenter="handleMouseEnter"
@mouseleave="handleMouseLeave"
@@ -69,7 +69,6 @@ import {
} from '@/utils/chatQuestionMinimap'
const CLOSE_DELAY_MS = 150
-const RAIL_INSET_PX = 0
const props = defineProps<{
scrollContainer: HTMLElement | null
@@ -298,7 +297,7 @@ onBeforeUnmount(() => {
.question-minimap {
position: absolute;
top: 50%;
- left: 0;
+ left: var(--chat-content-inset, 20px);
z-index: 11;
display: flex;
align-items: stretch;
diff --git a/frontend/src/components/chat/SandboxSidePanel.vue b/frontend/src/components/chat/SandboxSidePanel.vue
index a214870e5..0a24f2794 100644
--- a/frontend/src/components/chat/SandboxSidePanel.vue
+++ b/frontend/src/components/chat/SandboxSidePanel.vue
@@ -41,7 +41,7 @@
:aria-label="t('common.close')"
@click="panel?.close()"
>
- <t-icon name="close" size="20px" />
+ <t-icon name="close" size="16px" />
</button>
</div>
@@ -312,8 +312,8 @@ function startResize(event: MouseEvent) {
border: 0;
background: var(--td-bg-color-secondarycontainer);
color: var(--td-text-color-secondary);
- width: 32px;
- height: 32px;
+ width: 28px;
+ height: 28px;
border-radius: var(--app-radius-md);
cursor: pointer;
display: inline-flex;
@@ -332,7 +332,9 @@ function startResize(event: MouseEvent) {
display: flex;
align-items: center;
gap: 8px;
- padding: 8px 12px;
+ height: var(--app-chat-header-height);
+ box-sizing: border-box;
+ padding: 0 12px;
border-bottom: 1px solid var(--td-component-stroke);
flex-shrink: 0;
}
@@ -349,7 +351,9 @@ function startResize(event: MouseEvent) {
display: inline-flex;
align-items: center;
gap: 6px;
- padding: 6px 10px;
+ height: 28px;
+ padding: 0 8px;
+ line-height: 20px;
border: 0;
border-radius: var(--app-radius-sm);
background: transparent;
diff --git a/frontend/src/components/doc-content.vue b/frontend/src/components/doc-content.vue
index fffe978c6..148fad7d3 100644
--- a/frontend/src/components/doc-content.vue
+++ b/frontend/src/components/doc-content.vue
@@ -22,6 +22,7 @@ import { diffWikiLines, type WikiDiffLine } from '@/utils/wikiLineDiff';
import { useI18n } from 'vue-i18n';
import { useAuthStore } from '@/stores/auth';
import DocumentPreview from '@/components/document-preview.vue';
+import DocumentFileIcon from '@/views/knowledge/components/DocumentFileIcon.vue';
import KnowledgeProcessingTimeline from '@/components/knowledge-processing-timeline.vue';
import { resolveKnowledgeDownloadFileName } from '@/views/knowledge/knowledgeDownloadFileName';
import { isKnownPreviewableExt, resolveFilePreviewExt } from '@/utils/filePreview';
@@ -192,15 +193,11 @@ const detailTags = computed(() => {
return Array.isArray(tags) ? tags : [];
});
-const headerIconName = computed(() => {
- switch (props.details?.type) {
- case 'url':
- return 'link';
- case 'manual':
- return 'edit';
- default:
- return 'file';
- }
+const headerIconFileName = computed(() => {
+ const detail = props.details;
+ return detail?.file_type
+ ? `document.${detail.file_type.toLowerCase()}`
+ : detail?.original_file_name || detail?.file_name || detail?.title || '';
});
const showSummarySection = computed(() =>
@@ -1584,7 +1581,7 @@ const handleChunkPageChange = (pageInfo: { current: number }) => {
<template #header>
<div class="doc-drawer-header">
<div class="doc-drawer-header-icon">
- <t-icon :name="headerIconName" />
+ <DocumentFileIcon :source-type="details.type" :file-name="headerIconFileName" />
</div>
<div class="doc-drawer-header-text">
<div class="doc-drawer-header-title">{{ getDisplayTitle() }}</div>
@@ -2252,14 +2249,10 @@ const handleChunkPageChange = (pageInfo: { current: number }) => {
.doc-drawer-header-icon {
flex-shrink: 0;
width: 32px;
- height: 32px;
- border-radius: 9px;
+ height: 38px;
display: flex;
align-items: center;
justify-content: center;
- background: color-mix(in srgb, var(--td-brand-color) 10%, transparent);
- color: var(--td-brand-color);
- font-size: var(--app-text-xl);
}
.doc-drawer-header-text {
diff --git a/frontend/src/composables/useKnowledgeTagSelection.test.ts b/frontend/src/composables/useKnowledgeTagSelection.test.ts
deleted file mode 100644
index ef9f152ec..000000000
--- a/frontend/src/composables/useKnowledgeTagSelection.test.ts
+++ /dev/null
@@ -1,149 +0,0 @@
-import assert from 'node:assert/strict'
-import test from 'node:test'
-import { effectScope, nextTick, ref } from 'vue'
-import { useKnowledgeTagSelection, type KnowledgeTag } from './useKnowledgeTagSelection.ts'
-
-function harness(createTag: Parameters<typeof useKnowledgeTagSelection>[0]['createTag'] = async () => {
- throw new Error('unexpected creation')
-}) {
- const visible = ref(false)
- const kbId = ref('kb-a')
- const tags = ref<KnowledgeTag[]>([{ id: 'a', name: 'Alpha' }, { id: 'b', name: 'Beta' }])
- const selectedIds = ref(['a'])
- const errors: unknown[] = []
- let created = 0
- const scope = effectScope()
- const selection = scope.run(() => useKnowledgeTagSelection({
- visible: () => visible.value,
- kbId: () => kbId.value,
- tags: () => tags.value,
- selectedIds: () => selectedIds.value,
- createTag,
- onCreated: () => { created++ },
- onError: error => errors.push(error),
- }))!
- return { selection, visible, kbId, tags, selectedIds, errors, created: () => created, stop: () => scope.stop() }
-}
-
-test('opening hydrates selection and reopening discards edits using the latest parent values', async (t) => {
- const h = harness()
- t.after(h.stop)
- h.visible.value = true
- await nextTick()
- assert.deepEqual([...h.selection.selectedSet.value], ['a'])
- h.selection.toggleTag('b')
- h.selection.searchQuery.value = 'draft search'
- h.selection.newTagName.value = 'draft tag'
- h.selectedIds.value = ['b']
- await nextTick()
- assert.deepEqual([...h.selection.selectedSet.value], ['a', 'b'], 'parent refresh must not overwrite an open draft')
- h.visible.value = false
- await nextTick()
- h.visible.value = true
- await nextTick()
- assert.deepEqual([...h.selection.selectedSet.value], ['b'])
- assert.equal(h.selection.searchQuery.value, '')
- assert.equal(h.selection.newTagName.value, '')
-})
-
-test('search excludes selected tags, tracks refreshed names, and preserves IDs absent from the current list', async (t) => {
- const h = harness()
- t.after(h.stop)
- h.selectedIds.value = ['a', 'not-loaded']
- h.visible.value = true
- await nextTick()
- assert.deepEqual(h.selection.selectedTagsList.value.map(tag => tag.id), ['a'])
- assert.deepEqual([...h.selection.selectedSet.value], ['a', 'not-loaded'])
- h.selection.searchQuery.value = ' BETA '
- assert.deepEqual(h.selection.availableTagsList.value.map(tag => tag.id), ['b'])
- h.selection.toggleTag('b')
- assert.deepEqual(h.selection.availableTagsList.value, [])
- h.selection.toggleTag('b')
- h.tags.value = [{ id: 'a', name: 'Renamed' }, { id: 'b', name: 'Gamma' }]
- assert.equal(h.selection.selectedTagsList.value[0]?.name, 'Renamed')
- assert.deepEqual(h.selection.availableTagsList.value, [])
- h.selection.searchQuery.value = ''
- h.selection.clearAll()
- assert.equal(h.selection.selectedSet.value.size, 0)
- assert.equal(h.selection.availableTagsList.value.length, 2)
-})
-
-test('search creation uses the current KB, selects the returned tag and clears only the search input', async (t) => {
- const requests: [string, { name: string }][] = []
- const h = harness(async (kbId, data) => {
- requests.push([kbId, data])
- return { data: { id: 'new', name: data.name } }
- })
- t.after(h.stop)
- h.kbId.value = 'kb-b'
- h.selection.searchQuery.value = ' New tag '
- h.selection.newTagName.value = 'separate draft'
- await h.selection.handleCreateTag()
- assert.deepEqual(requests, [['kb-b', { name: 'New tag' }]])
- assert.deepEqual([...h.selection.selectedSet.value], ['new'])
- assert.equal(h.selection.searchQuery.value, '')
- assert.equal(h.selection.newTagName.value, 'separate draft')
- assert.equal(h.created(), 1)
- assert.equal(h.selection.creatingTag.value, false)
- h.tags.value.push({ id: 'new', name: 'New tag' })
- assert.equal(h.selection.selectedTagsList.value[0]?.name, 'New tag')
-})
-
-test('manual entry reuses an exact existing name without creating or announcing a new tag', async (t) => {
- const h = harness()
- t.after(h.stop)
- h.selection.newTagName.value = ' Alpha '
- await h.selection.handleAddNewTag()
- assert.deepEqual([...h.selection.selectedSet.value], ['a'])
- assert.equal(h.selection.newTagName.value, '')
- assert.equal(h.created(), 0)
- assert.deepEqual(h.errors, [])
-})
-
-test('manual creation accepts an unwrapped response without clearing a separate search', async (t) => {
- const h = harness(async (_, data) => ({ id: 'new', name: data.name }))
- t.after(h.stop)
- h.selection.newTagName.value = 'New'
- h.selection.searchQuery.value = 'retained search'
- await h.selection.handleAddNewTag()
- assert.deepEqual([...h.selection.selectedSet.value], ['new'])
- assert.equal(h.selection.newTagName.value, '')
- assert.equal(h.selection.searchQuery.value, 'retained search')
- assert.equal(h.created(), 1)
-})
-
-test('failed creation preserves the draft and selection, releases loading and permits retry', async (t) => {
- let reject!: (error: Error) => void
- const h = harness(() => new Promise((_, rejectRequest) => { reject = rejectRequest }))
- t.after(h.stop)
- h.selection.toggleTag('a')
- h.selection.newTagName.value = 'retry me'
- const pending = h.selection.handleAddNewTag()
- assert.equal(h.selection.creatingTag.value, true)
- const failure = new Error('denied')
- reject(failure)
- await pending
- assert.equal(h.selection.creatingTag.value, false)
- assert.equal(h.selection.newTagName.value, 'retry me')
- assert.deepEqual([...h.selection.selectedSet.value], ['a'])
- assert.deepEqual(h.errors, [failure])
- assert.equal(h.created(), 0)
- const retry = h.selection.handleAddNewTag()
- assert.equal(h.selection.creatingTag.value, true)
- reject(failure)
- await retry
- assert.equal(h.errors.length, 2)
-})
-
-test('empty inputs do not create tags and dialogs keep independent selection state', async (t) => {
- const first = harness(), second = harness()
- t.after(first.stop)
- t.after(second.stop)
- first.selection.searchQuery.value = ' '
- first.selection.newTagName.value = ' '
- await first.selection.handleCreateTag()
- await first.selection.handleAddNewTag()
- assert.deepEqual(first.errors, [])
- first.selection.toggleTag('a')
- assert.equal(second.selection.selectedSet.value.size, 0)
-})
diff --git a/frontend/src/composables/useKnowledgeTagSelection.ts b/frontend/src/composables/useKnowledgeTagSelection.ts
deleted file mode 100644
index 05f532536..000000000
--- a/frontend/src/composables/useKnowledgeTagSelection.ts
+++ /dev/null
@@ -1,89 +0,0 @@
-import { computed, ref, watch, type Ref } from 'vue'
-
-export interface KnowledgeTag {
- id: string
- name: string
- color?: string
- knowledge_count?: number
-}
-
-interface TagSelectionOptions {
- visible: () => boolean
- kbId: () => string
- tags: () => KnowledgeTag[]
- selectedIds: () => string[]
- createTag: (kbId: string, data: { name: string }) => Promise<KnowledgeTag | { data: KnowledgeTag }>
- onCreated: () => void
- onError: (error: unknown) => void
-}
-
-/** Shared selection and creation state; each dialog owns its submit/close behavior. */
-export function useKnowledgeTagSelection(options: TagSelectionOptions) {
- const searchQuery = ref('')
- const newTagName = ref('')
- const selectedSet = ref(new Set<string>())
- const creatingTag = ref(false)
-
- watch(options.visible, (visible) => {
- if (visible) {
- selectedSet.value = new Set(options.selectedIds())
- searchQuery.value = ''
- newTagName.value = ''
- }
- })
-
- const tagMap = computed(() => new Map(options.tags().map(tag => [tag.id, tag])))
- const selectedTagsList = computed(() => Array.from(selectedSet.value)
- .map(id => tagMap.value.get(id))
- .filter((tag): tag is KnowledgeTag => Boolean(tag)))
- const availableTagsList = computed(() => {
- const query = searchQuery.value.trim().toLowerCase()
- return options.tags().filter(tag => !selectedSet.value.has(tag.id)
- && (!query || (tag.name || '').toLowerCase().includes(query)))
- })
-
- function selectTag(id: string) {
- selectedSet.value = new Set([...selectedSet.value, id])
- }
-
- function toggleTag(id: string) {
- const next = new Set(selectedSet.value)
- if (next.has(id)) next.delete(id)
- else next.add(id)
- selectedSet.value = next
- }
-
- function clearAll() {
- selectedSet.value = new Set()
- }
-
- async function createFrom(input: Ref<string>, reuseExisting: boolean) {
- const name = input.value.trim()
- if (!name) return
- const existing = reuseExisting && options.tags().find(tag => tag.name === name)
- if (existing) {
- selectTag(existing.id)
- input.value = ''
- return
- }
- creatingTag.value = true
- try {
- const response = await options.createTag(options.kbId(), { name })
- const tag = 'data' in response ? response.data : response
- selectTag(tag.id)
- input.value = ''
- options.onCreated()
- } catch (error) {
- options.onError(error)
- } finally {
- creatingTag.value = false
- }
- }
-
- return {
- searchQuery, newTagName, selectedSet, creatingTag, selectedTagsList, availableTagsList,
- toggleTag, clearAll,
- handleCreateTag: () => createFrom(searchQuery, false),
- handleAddNewTag: () => createFrom(newTagName, true),
- }
-}
diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts
index 6a6e47cee..fe93bafae 100755
--- a/frontend/src/i18n/locales/en-US.ts
+++ b/frontend/src/i18n/locales/en-US.ts
@@ -486,6 +486,11 @@ export default {
sharedTooltip: 'Accessed from an external workspace via a shared space'
},
knowledgeBase: {
+ tagAddAction: 'Add tags',
+ documentCount: '{count} documents',
+ filters: 'Filters',
+ clearFilters: 'Clear filters',
+
title: 'Knowledge Base',
fileContent: 'File Content',
accessInfo: {
@@ -526,11 +531,10 @@ export default {
settings: 'Settings',
tagUpdateSuccess: 'Tag updated successfully',
tagEditDialogHeading: 'Edit tags',
- tagEditSearch: 'Search tags...',
- tagEditSelectedSection: 'Selected',
- tagEditAvailableSection: 'Available',
- tagEditNoSelected: 'None selected',
folderTree: {
+ totalDocuments: '{count} documents total',
+ countHint: '{direct} documents in this folder; {total} including subfolders',
+ filteredCount: '{count} matching documents',
title: 'Folders',
rootRow: 'Root',
rootRowTip: 'Knowledge base root; documents not in a subfolder live here',
@@ -572,9 +576,10 @@ export default {
tagManageDocCount: '{count} documents',
tagManageFaqCount: '{count} FAQ entries',
tagSelectedCount: '{count} selected',
- tagNewPlaceholder: 'New tag name, press Enter to add',
+ tagPickerSearch: "Search or create a tag",
+ tagPickerInUse: "This tag is in use. Remove its document associations before deleting it.",
+ tagPickerDeleteConfirm: "Delete tag “{name}”?",
untagged: 'Untagged',
- tagClearAction: 'Clear selection',
tagCreateAction: 'Create tag',
tagSearchPlaceholder: 'Type to filter tags',
tagNamePlaceholder: 'Enter tag name',
@@ -765,9 +770,6 @@ export default {
batchTag: 'Batch Tag',
batchTagDialogHeading: 'Batch Tag',
batchTagSubtitle: 'Set tags for {count} selected documents (will replace existing tags)',
- batchTagSelectedSection: 'Selected',
- batchTagAvailableSection: 'Available',
- batchTagNoSelected: 'None selected',
batchTagSuccess: 'Tags applied to {count} documents',
batchTagFailed: 'Batch tag failed',
confirmBatchReparseDocument: 'Rebuild {count} selected documents? Existing content will be cleared and each document will be re-parsed.',
diff --git a/frontend/src/i18n/locales/ja-JP.ts b/frontend/src/i18n/locales/ja-JP.ts
index 93b2532d8..d41dee86f 100644
--- a/frontend/src/i18n/locales/ja-JP.ts
+++ b/frontend/src/i18n/locales/ja-JP.ts
@@ -486,6 +486,11 @@ export default {
sharedTooltip: '共有スペース経由で外部ワークスペースからアクセス'
},
knowledgeBase: {
+ tagAddAction: 'タグを追加',
+ documentCount: '{count} 件のドキュメント',
+ filters: '絞り込み',
+ clearFilters: '絞り込みをクリア',
+
title: 'ナレッジベース',
fileContent: 'ファイル内容',
accessInfo: {
@@ -526,11 +531,10 @@ export default {
settings: '設定',
tagUpdateSuccess: 'タグを更新しました',
tagEditDialogHeading: 'タグを編集',
- tagEditSearch: 'タグを検索...',
- tagEditSelectedSection: '選択中',
- tagEditAvailableSection: '選択可能',
- tagEditNoSelected: '未選択',
folderTree: {
+ totalDocuments: '全 {count} 件',
+ countHint: 'このフォルダ内 {direct} 件、サブフォルダを含めて {total} 件',
+ filteredCount: '{count} 件一致',
title: 'フォルダ',
rootRow: 'ルート',
rootRowTip: 'ナレッジベースのルート。サブフォルダに属さないドキュメントはここに置かれます',
@@ -572,9 +576,10 @@ export default {
tagManageDocCount: '{count}件のドキュメント',
tagManageFaqCount: '{count}件のFAQ',
tagSelectedCount: '{count}件選択中',
- tagNewPlaceholder: '新しいタグ名を入力し、Enterキーで追加',
+ tagPickerSearch: "タグを検索または作成",
+ tagPickerInUse: "使用中のタグです。先にドキュメントとの関連付けを解除してください。",
+ tagPickerDeleteConfirm: "タグ「{name}」を削除しますか?",
untagged: 'タグなし',
- tagClearAction: '選択を解除',
tagCreateAction: 'タグを作成',
tagSearchPlaceholder: 'タグ名で絞り込み',
tagNamePlaceholder: 'タグ名を入力してください',
@@ -765,9 +770,6 @@ export default {
batchTag: '一括タグ付け',
batchTagDialogHeading: '一括タグ付け',
batchTagSubtitle: '選択した{count}件のドキュメントにタグを設定します(既存のタグは置き換えられます)',
- batchTagSelectedSection: '選択中',
- batchTagAvailableSection: '選択可能',
- batchTagNoSelected: '未選択',
batchTagSuccess: '{count}件のドキュメントにタグを設定しました',
batchTagFailed: '一括タグ付けに失敗しました',
confirmBatchReparseDocument: '選択した{count}件のドキュメントを再構築しますか?既存の内容は削除され、各ドキュメントが再解析されます。',
diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.ts
index 8b839f09f..d0449bb74 100755
--- a/frontend/src/i18n/locales/ko-KR.ts
+++ b/frontend/src/i18n/locales/ko-KR.ts
@@ -6725,6 +6725,11 @@ export default {
}
},
knowledgeBase: {
+ tagAddAction: '태그 추가',
+ documentCount: '문서 {count}개',
+ filters: '필터',
+ clearFilters: '필터 지우기',
+
title: '지식베이스',
fileContent: '파일 내용',
name: '이름',
@@ -6732,11 +6737,10 @@ export default {
settings: '설정',
tagUpdateSuccess: '태그 업데이트 성공',
tagEditDialogHeading: '태그 편집',
- tagEditSearch: '태그 검색...',
- tagEditSelectedSection: '선택된 태그',
- tagEditAvailableSection: '선택 가능',
- tagEditNoSelected: '선택 없음',
folderTree: {
+ totalDocuments: '전체 문서 {count}개',
+ countHint: '현재 폴더 문서 {direct}개, 하위 폴더 포함 {total}개',
+ filteredCount: '일치하는 문서 {count}개',
title: '폴더',
rootRow: '루트',
rootRowTip: '지식 베이스 루트 디렉터리, 하위 폴더에 없는 문서가 여기에 있습니다',
@@ -6778,9 +6782,10 @@ export default {
tagManageDocCount: '문서 {count}개',
tagManageFaqCount: 'FAQ {count}개',
tagSelectedCount: '{count}개 선택됨',
- tagNewPlaceholder: '새 태그 이름 입력, Enter로 추가',
+ tagPickerSearch: "태그 검색 또는 만들기",
+ tagPickerInUse: "사용 중인 태그입니다. 먼저 문서 연결을 해제하세요.",
+ tagPickerDeleteConfirm: "“{name}” 태그를 삭제할까요?",
untagged: '태그 없음',
- tagClearAction: '선택 해제',
tagCreateAction: '태그 생성',
tagSearchPlaceholder: '태그 이름 키워드 입력',
tagNamePlaceholder: '태그 이름을 입력하세요',
@@ -6971,9 +6976,6 @@ export default {
batchTag: '일괄 태그',
batchTagDialogHeading: '일괄 태그 지정',
batchTagSubtitle: '선택한 {count}개 문서에 태그를 일괄 설정합니다 (기존 태그는 대체됩니다)',
- batchTagSelectedSection: '선택된 태그',
- batchTagAvailableSection: '선택 가능',
- batchTagNoSelected: '선택 없음',
batchTagSuccess: '{count}개 문서에 태그가 적용되었습니다',
batchTagFailed: '일괄 태그 실패',
confirmBatchReparseDocument: '선택한 {count}개 문서를 재구축하시겠습니까? 기존 내용이 삭제되고 각 문서가 다시 파싱됩니다.',
diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts
index 31be03720..d2a680b3c 100755
--- a/frontend/src/i18n/locales/ru-RU.ts
+++ b/frontend/src/i18n/locales/ru-RU.ts
@@ -6725,6 +6725,11 @@ export default {
}
},
knowledgeBase: {
+ tagAddAction: 'Добавить теги',
+ documentCount: 'Документов: {count}',
+ filters: 'Фильтры',
+ clearFilters: 'Сбросить фильтры',
+
title: 'База знаний',
fileContent: 'Содержимое файла',
name: 'Название',
@@ -6732,11 +6737,10 @@ export default {
settings: 'Настройки',
tagUpdateSuccess: 'Тег успешно обновлен',
tagEditDialogHeading: 'Редактировать теги',
- tagEditSearch: 'Поиск тегов...',
- tagEditSelectedSection: 'Выбранные',
- tagEditAvailableSection: 'Доступные',
- tagEditNoSelected: 'Ничего не выбрано',
folderTree: {
+ totalDocuments: 'Всего документов: {count}',
+ countHint: 'В этой папке: {direct}, с подпапками: {total}',
+ filteredCount: 'Найдено документов: {count}',
title: 'Папки',
rootRow: 'Корень',
rootRowTip: 'Корневая папка базы знаний; документы без подпапки находятся здесь',
@@ -6778,9 +6782,10 @@ export default {
tagManageDocCount: '{count} документов',
tagManageFaqCount: '{count} записей FAQ',
tagSelectedCount: 'Выбрано: {count}',
- tagNewPlaceholder: 'Название нового тега, Enter для добавления',
+ tagPickerSearch: "Найти или создать тег",
+ tagPickerInUse: "Тег используется. Сначала удалите его связи с документами.",
+ tagPickerDeleteConfirm: "Удалить тег «{name}»?",
untagged: 'Без тега',
- tagClearAction: 'Очистить выбор',
tagCreateAction: 'Создать тег',
tagSearchPlaceholder: 'Введите название тега',
tagNamePlaceholder: 'Введите название тега',
@@ -6971,9 +6976,6 @@ export default {
batchTag: 'Пакетная метка',
batchTagDialogHeading: 'Пакетное назначение меток',
batchTagSubtitle: 'Установить метки для {count} выбранных документов (заменит существующие метки)',
- batchTagSelectedSection: 'Выбранные',
- batchTagAvailableSection: 'Доступные',
- batchTagNoSelected: 'Ничего не выбрано',
batchTagSuccess: 'Метки применены к {count} документам',
batchTagFailed: 'Ошибка пакетного назначения меток',
confirmBatchReparseDocument: 'Пересобрать {count} выбранных документов? Существующее содержимое будет удалено, и каждый документ будет обработан заново.',
diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts
index 51f2f1821..67b26ec1c 100755
--- a/frontend/src/i18n/locales/zh-CN.ts
+++ b/frontend/src/i18n/locales/zh-CN.ts
@@ -6727,6 +6727,11 @@ export default {
}
},
knowledgeBase: {
+ tagAddAction: '添加标签',
+ documentCount: '{count} 个文档',
+ filters: '筛选',
+ clearFilters: '清除筛选',
+
title: '知识库',
fileContent: '文件内容',
name: '名称',
@@ -6734,11 +6739,10 @@ export default {
settings: '设置',
tagUpdateSuccess: '标签已更新',
tagEditDialogHeading: '编辑标签',
- tagEditSearch: '搜索标签...',
- tagEditSelectedSection: '已选标签',
- tagEditAvailableSection: '可选标签',
- tagEditNoSelected: '暂未选择',
folderTree: {
+ totalDocuments: '共 {count} 个文档',
+ countHint: '当前目录 {direct} 个文档,含子目录共 {total} 个',
+ filteredCount: '匹配 {count} 个文档',
title: '目录',
rootRow: '根目录',
rootRowTip: '知识库根目录,未归入子文件夹的文档在此',
@@ -6780,9 +6784,10 @@ export default {
tagManageDocCount: '{count} 个文档',
tagManageFaqCount: '{count} 个 FAQ',
tagSelectedCount: '已选 {count} 个标签',
- tagNewPlaceholder: '输入新标签名称,回车添加',
+ tagPickerSearch: "搜索或新建标签",
+ tagPickerInUse: "此标签仍被使用,请先移除文档上的关联再删除",
+ tagPickerDeleteConfirm: "确定删除标签“{name}”?",
untagged: '无标签',
- tagClearAction: '清空已选',
tagCreateAction: '新建标签',
tagSearchPlaceholder: '输入标签名称关键字',
tagNamePlaceholder: '请输入标签名称',
@@ -6973,9 +6978,6 @@ export default {
batchTag: '批量打标签',
batchTagDialogHeading: '批量打标签',
batchTagSubtitle: '为选中的 {count} 个文档统一设置标签(将替换文档原有标签)',
- batchTagSelectedSection: '已选标签',
- batchTagAvailableSection: '可选标签',
- batchTagNoSelected: '暂未选择',
batchTagSuccess: '已为 {count} 个文档成功设置标签',
batchTagFailed: '批量打标签失败',
confirmBatchReparseDocument: '确认重建选中的 {count} 个文档?现有内容将被清除并重新解析。',
diff --git a/frontend/src/views/artifacts/ArtifactLibrary.vue b/frontend/src/views/artifacts/ArtifactLibrary.vue
index e97fbdfd3..ac4036b71 100644
--- a/frontend/src/views/artifacts/ArtifactLibrary.vue
+++ b/frontend/src/views/artifacts/ArtifactLibrary.vue
@@ -460,7 +460,7 @@ onBeforeUnmount(() => {
&[aria-selected='true'] {
background: var(--td-bg-color-container);
- color: var(--td-text-color-primary);
+ color: var(--td-brand-color);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
diff --git a/frontend/src/views/chat/components/ChatArtifactsDrawer.vue b/frontend/src/views/chat/components/ChatArtifactsDrawer.vue
index 16184bf23..3f7963eef 100644
--- a/frontend/src/views/chat/components/ChatArtifactsDrawer.vue
+++ b/frontend/src/views/chat/components/ChatArtifactsDrawer.vue
@@ -462,23 +462,23 @@ onUnmounted(() => {
.artifact-drawer-header-icon {
flex-shrink: 0;
- width: 32px;
- height: 32px;
- border-radius: 9px;
+ width: 24px;
+ height: 24px;
+ border-radius: var(--app-radius-sm);
display: flex;
align-items: center;
justify-content: center;
background: color-mix(in srgb, var(--td-brand-color) 10%, transparent);
color: var(--td-brand-color);
- font-size: var(--app-text-xl);
+ font-size: var(--app-text-lg);
}
.artifact-drawer-header-title {
min-width: 0;
flex: 1;
- font-size: var(--app-text-lg);
- font-weight: 600;
- line-height: 1.4;
+ font-size: var(--app-text-base);
+ font-weight: 500;
+ line-height: 20px;
color: var(--td-text-color-primary);
overflow: hidden;
text-overflow: ellipsis;
@@ -628,10 +628,20 @@ onUnmounted(() => {
<style lang="less">
.chat-artifacts-drawer.t-drawer {
.t-drawer__header {
- padding: 16px 20px;
+ height: var(--app-chat-header-height);
+ min-height: var(--app-chat-header-height);
+ padding: 0 12px;
+ border-bottom: 1px solid var(--td-component-stroke);
+ flex-shrink: 0;
font-weight: normal;
}
+ .t-drawer__close-btn {
+ top: calc((var(--app-chat-header-height) - 28px) / 2);
+ width: 28px;
+ height: 28px;
+ }
+
.t-drawer__body {
padding: 4px 20px 16px;
}
@@ -643,12 +653,6 @@ onUnmounted(() => {
height: 100%;
}
- .t-drawer__header {
- padding: 14px 18px;
- border-bottom: 1px solid var(--td-component-stroke);
- flex-shrink: 0;
- }
-
.t-drawer__body {
flex: 1;
min-height: 0;
diff --git a/frontend/src/views/chat/index.vue b/frontend/src/views/chat/index.vue
index 29fde475b..60162c957 100644
--- a/frontend/src/views/chat/index.vue
+++ b/frontend/src/views/chat/index.vue
@@ -5,22 +5,23 @@
'has-references-panel': referencesDrawerVisible,
'has-sandbox-panel': sandboxPanel.visible.value,
}" :style="{ '--sandbox-panel-width': `${sandboxPanel.width.value}px` }">
- <ChatHeader v-if="!embeddedMode" :session="currentSession" :has-references-panel="referencesDrawerVisible" />
- <!-- 沙箱面板收起时:图标与左侧栏展开按钮同一套,位置镜像会话左上角三个点。 -->
- <div v-if="!embeddedMode && !sandboxPanel.visible.value" class="sandbox-header-toggle">
- <t-tooltip placement="bottom">
- <template #content>{{ t('chatHeader.toggleSandboxPanel') }}</template>
- <button type="button" class="sandbox-header-toggle__btn"
- :aria-label="t('chatHeader.toggleSandboxPanel')" @click="sandboxPanel.open()">
- <svg viewBox="0 0 20 20" width="18" height="18" fill="none" xmlns="http://www.w3.org/2000/svg"
- aria-hidden="true">
- <rect x="1.5" y="1.5" width="17" height="17" rx="3" stroke="currentColor" stroke-width="1.2" />
- <line x1="12.5" y1="1.5" x2="12.5" y2="18.5" stroke="currentColor" stroke-width="1.2" />
- <line x1="16" y1="7.5" x2="16" y2="12.5" stroke="currentColor" stroke-width="1.2"
- stroke-linecap="round" />
- </svg>
- </button>
- </t-tooltip>
+ <div v-if="!embeddedMode" class="chat-topbar">
+ <ChatHeader :session="currentSession" />
+ <div v-if="!sandboxPanel.visible.value" class="sandbox-header-toggle">
+ <t-tooltip placement="bottom">
+ <template #content>{{ t('chatHeader.toggleSandboxPanel') }}</template>
+ <button type="button" class="sandbox-header-toggle__btn"
+ :aria-label="t('chatHeader.toggleSandboxPanel')" @click="sandboxPanel.open()">
+ <svg viewBox="0 0 20 20" width="16" height="16" fill="none" xmlns="http://www.w3.org/2000/svg"
+ aria-hidden="true">
+ <rect x="1.5" y="1.5" width="17" height="17" rx="3" stroke="currentColor" stroke-width="1.2" />
+ <line x1="12.5" y1="1.5" x2="12.5" y2="18.5" stroke="currentColor" stroke-width="1.2" />
+ <line x1="16" y1="7.5" x2="16" y2="12.5" stroke="currentColor" stroke-width="1.2"
+ stroke-linecap="round" />
+ </svg>
+ </button>
+ </t-tooltip>
+ </div>
</div>
<div class="chat_thread">
<div ref="scrollContainer" class="chat_scroll_box" @scroll="handleScroll">
@@ -148,13 +149,13 @@
<ChatQuestionMinimap v-if="!embeddedMode" :scroll-container="scrollContainer" :messages="messagesList"
@jump="jumpToQuestion" />
</div>
- <transition name="scroll-btn-fade">
- <div v-show="userHasScrolledUp" class="scroll-to-bottom-btn" @click="onClickScrollToBottom">
- <t-icon name="chevron-down" size="20px" />
- </div>
- </transition>
<div class="input-container" :class="{ 'is-embedded': embeddedMode }">
- <InputField ref="inputFieldRef" :auto-focus="focusComposerOnMount"
+ <transition name="scroll-btn-fade">
+ <div v-show="userHasScrolledUp" class="scroll-to-bottom-btn" @click="onClickScrollToBottom">
+ <t-icon name="chevron-down" size="18px" />
+ </div>
+ </transition>
+ <InputField ref="inputFieldRef" :auto-focus="focusComposerOnMount" :compact="!embeddedMode"
@send-msg="(query, modelId, mentionedItems, imageFiles, attachmentFiles, options) => sendMsg(query, modelId, mentionedItems, imageFiles, attachmentFiles, options)"
@steer-msg="(query, mentionedItems, delivery) => handleSteerMsg(query, mentionedItems, delivery)"
@promote-steer="handlePromoteSteer"
@@ -1602,10 +1603,8 @@ onBeforeRouteUpdate((to, from, next) => {
.chat {
// 水平方向不留 padding,让滚动条贴到内容区最右缘;
// 消息列与输入列各自用 --chat-content-inset 做左右对称的留白(窄屏时才可见)。
- padding: 0 0 20px 0;
+ padding: 0 0 max(8px, env(safe-area-inset-bottom)) 0;
--chat-content-inset: 20px;
- // 右侧抽屉让出的宽度。回到底部按钮按「剩余聊天列」居中,而不是整页 50%。
- --chat-right-inset: 0px;
box-sizing: border-box;
flex: 1;
// The parent .platform-route-outlet is a flex column with min-height:0
@@ -1639,17 +1638,12 @@ onBeforeRouteUpdate((to, from, next) => {
&.has-references-panel:not(.is-embedded) {
@media (min-width: 960px) {
- --chat-right-inset: 420px;
padding-right: 420px;
box-sizing: border-box;
.chat_scroll_box {
padding-top: 0;
}
-
- .sandbox-header-toggle {
- right: 432px;
- }
}
}
@@ -1657,7 +1651,6 @@ onBeforeRouteUpdate((to, from, next) => {
// composable 持久化),聊天区 padding 跟随面板宽度让位。
&.has-sandbox-panel:not(.is-embedded) {
@media (min-width: 960px) {
- --chat-right-inset: var(--sandbox-panel-width, 420px);
padding-right: var(--sandbox-panel-width, 420px);
box-sizing: border-box;
}
@@ -1665,12 +1658,10 @@ onBeforeRouteUpdate((to, from, next) => {
&.has-sandbox-panel.has-references-panel:not(.is-embedded) {
@media (min-width: 1400px) {
- --chat-right-inset: calc(420px + var(--sandbox-panel-width, 420px));
padding-right: calc(420px + var(--sandbox-panel-width, 420px));
}
@media (max-width: 1399.98px) and (min-width: 960px) {
- --chat-right-inset: var(--sandbox-panel-width, 420px);
padding-right: var(--sandbox-panel-width, 420px);
}
}
@@ -1715,22 +1706,24 @@ onBeforeRouteUpdate((to, from, next) => {
overflow: hidden;
}
-// 沙箱面板入口:chrome 对齐会话左上角三个点(毛玻璃底 + 24px 图标按钮),
-// 图标是左侧栏 sidebar-toggle 的水平镜像(栏在右侧)。
+.chat-topbar {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ flex: 0 0 var(--app-chat-header-height);
+ width: 100%;
+ min-width: 0;
+ padding: 0 12px 0 var(--chat-content-inset, 20px);
+ box-sizing: border-box;
+ border-bottom: 1px solid var(--td-component-stroke);
+ background: var(--td-bg-color-container);
+}
+
.sandbox-header-toggle {
- position: absolute;
- top: 10px;
- right: 12px;
- z-index: 6;
display: inline-flex;
align-items: center;
- padding: 2px;
- border-radius: var(--app-radius-md);
- box-sizing: border-box;
- background: color-mix(in srgb, var(--td-bg-color-container) 88%, transparent);
- backdrop-filter: blur(8px);
- -webkit-backdrop-filter: blur(8px);
- pointer-events: auto;
+ flex-shrink: 0;
+ margin-left: auto;
}
.sandbox-header-toggle__btn {
@@ -1786,12 +1779,12 @@ onBeforeRouteUpdate((to, from, next) => {
.scroll-to-bottom-btn {
position: absolute;
- left: calc((100% - var(--chat-right-inset, 0px)) / 2);
+ left: 50%;
transform: translateX(-50%);
- bottom: 140px;
+ bottom: calc(100% + 8px);
z-index: 10;
- width: 36px;
- height: 36px;
+ width: 32px;
+ height: 32px;
border-radius: 50%;
background: var(--td-bg-color-container);
border: 1px solid var(--td-component-stroke);
@@ -1801,7 +1794,7 @@ onBeforeRouteUpdate((to, from, next) => {
justify-content: center;
cursor: pointer;
color: var(--td-text-color-secondary);
- transition: left var(--app-motion-slow) cubic-bezier(0.22, 0.61, 0.36, 1), background-color var(--app-motion-base) ease, color var(--app-motion-base) ease, box-shadow var(--app-motion-base) ease;
+ transition: background-color var(--app-motion-base) ease, color var(--app-motion-base) ease, box-shadow var(--app-motion-base) ease;
&:hover {
background: var(--td-bg-color-container-hover);
@@ -1859,7 +1852,7 @@ onBeforeRouteUpdate((to, from, next) => {
}
.input-container {
- min-height: 115px;
+ min-height: 0;
flex-shrink: 0;
margin: 0 auto;
width: 100%;
@@ -1879,7 +1872,7 @@ onBeforeRouteUpdate((to, from, next) => {
padding: 12px 16px 16px;
min-height: auto;
box-sizing: border-box;
- overflow-x: hidden;
+ overflow-x: clip;
}
}
diff --git a/frontend/src/views/knowledge/KnowledgeBase.vue b/frontend/src/views/knowledge/KnowledgeBase.vue
index 21034d1e7..0889a5bba 100644
--- a/frontend/src/views/knowledge/KnowledgeBase.vue
+++ b/frontend/src/views/knowledge/KnowledgeBase.vue
@@ -2,22 +2,18 @@
import { ref, onMounted, onUnmounted, watch, reactive, computed, nextTick } from "vue";
import { MessagePlugin } from "tdesign-vue-next";
import DocContent from "@/components/doc-content.vue";
-import KnowledgeTagFilter from './components/KnowledgeTagFilter.vue';
import useKnowledgeBase from '@/hooks/useKnowledgeBase';
import { useRoute, useRouter } from 'vue-router';
import EmptyKnowledge from '@/components/empty-knowledge.vue';
import ContextualGuide from '@/components/ContextualGuide.vue';
import KBInfoPopover from '@/components/KBInfoPopover.vue';
import KBSwitcherDropdown from '@/components/KBSwitcherDropdown.vue';
-import { getSessionsList, createSessions, generateSessionsTitle } from "@/api/chat/index";
-import { useMenuStore } from '@/stores/menu';
import { useUIStore } from '@/stores/ui';
import { useOrganizationStore } from '@/stores/organization';
import { useAuthStore } from '@/stores/auth';
import { useChatResourcesStore } from '@/stores/chatResources';
import { useEditorResourcesStore } from '@/stores/editorResources';
import KnowledgeBaseEditorModal from './KnowledgeBaseEditorModal.vue';
-const usemenuStore = useMenuStore();
const uiStore = useUIStore();
const orgStore = useOrganizationStore();
const authStore = useAuthStore();
@@ -52,9 +48,7 @@ import DocumentCardView from './components/DocumentCardView.vue';
import DocumentBatchBar from './components/DocumentBatchBar.vue';
import KbUploadSourceDropdown from './components/KbUploadSourceDropdown.vue';
import KbFolderTree from './components/KbFolderTree.vue';
-import TagEditDialog from './components/TagEditDialog.vue';
import BatchTagDialog from './components/BatchTagDialog.vue';
-import KbTagManageDrawer from './components/KbTagManageDrawer.vue';
import type { KnowledgeProcessOverrides } from '@/types/knowledgeProcess';
import { useUploadConfirmStore, type UploadConfirmResult } from '@/stores/uploadConfirm';
import { useUploadTasksStore } from '@/stores/uploadTasks';
@@ -70,7 +64,6 @@ import { resolveKnowledgeDownloadFileName } from './knowledgeDownloadFileName';
import {
buildUploadFileName,
canMoveFolderTo,
- childFolders,
folderBreadcrumbs as buildFolderBreadcrumbs,
folderPathExists as folderExistsInTree,
isFilteringDocuments,
@@ -335,7 +328,7 @@ const canDownloadKnowledge = computed(() => {
});
const knowledgeList = ref<Array<{ id: string; name: string; type?: string }>>([]);
-let { cardList, total, moreIndex, details, getKnowled, openMore, onVisibleChange: _onVisibleChange, getCardDetails, getfDetails } = useKnowledgeBase(kbId.value)
+let { cardList, total, moreIndex, details, getKnowled, onVisibleChange: _onVisibleChange, getCardDetails, getfDetails } = useKnowledgeBase(kbId.value)
const showKbDetailContextualGuide = computed(() => {
return Boolean(kbId.value)
@@ -370,14 +363,6 @@ function isParseInFlight(status?: string): boolean {
return isKnowledgeParseInFlight(status);
}
-function isTraceMenuVisible(item: KnowledgeCard): boolean {
- if (!item?.id) return false;
- if (isParseInFlight(item.parse_status)) {
- return true;
- }
- return traceAvailableById[item.id] === true;
-}
-
async function probeTraceAvailable(item: KnowledgeCard) {
const id = item.id;
if (!id || traceProbeInflight.has(id)) return;
@@ -427,8 +412,8 @@ type DocViewMode = 'grid' | 'list';
const VIEW_MODE_KEY = 'weknora.kb.docs.viewMode';
const initViewMode = (): DocViewMode => {
try {
- return localStorage.getItem(VIEW_MODE_KEY) === 'list' ? 'list' : 'grid';
- } catch { return 'grid'; }
+ return localStorage.getItem(VIEW_MODE_KEY) === 'grid' ? 'grid' : 'list';
+ } catch { return 'list'; }
};
const viewMode = ref<DocViewMode>(initViewMode());
watch(viewMode, (v) => {
@@ -593,11 +578,16 @@ const confirmBatchReparse = async () => {
}
};
-const tagFilterCleared = ref(false);
-const tagManageDrawerVisible = ref(false);
const selectedTagIds = ref<string[]>([]);
+const selectedTagNames = ref<Record<string, string>>({});
const tagList = ref<any[]>([]);
+// Keep selected tags reachable even when the search or loaded page changes.
+const filterTagOptions = computed(() => [
+ ...tagList.value,
+ ...selectedTagIds.value.filter(id => !tagList.value.some(tag => tag.id === id))
+ .map(id => ({ id, name: selectedTagNames.value[id] || t('knowledgeBase.columnTag') })),
+]);
const tagLoading = ref(false);
const tagSearchQuery = ref('');
const TAG_PAGE_SIZE = 50;
@@ -664,11 +654,24 @@ const sourceOptions = computed(() => [
]);
// Date range as [start, end] in "YYYY-MM-DD" form (t-date-range-picker default).
const updatedTimeRange = ref<string[]>([]);
+const filtersExpanded = ref(false);
+const activeFilterCount = computed(() =>
+ [selectedFileType.value, selectedParseStatus.value, selectedSource.value,
+ updatedTimeRange.value?.some(Boolean)].filter(Boolean).length + selectedTagIds.value.length,
+);
+const clearDocumentFilters = () => {
+ selectedFileType.value = '';
+ selectedParseStatus.value = '';
+ selectedSource.value = '';
+ updatedTimeRange.value = [];
+ handleTagFilterChange([]);
+};
// Disable any date after today so users cannot filter into the future.
const disableFutureDate = { after: new Date(new Date().setHours(23, 59, 59, 999)) };
// ── Folder tree (documents uploaded as a folder keep their relative path) ──
-const FOLDER_TREE_COLLAPSED_KEY = 'weknora.kbFolderTreeCollapsed';
+// The directory sidebar is now the sole folder navigation and starts expanded.
+const FOLDER_TREE_COLLAPSED_KEY = 'weknora.kbDirectorySidebarCollapsed';
const readStoredFlag = (key: string, fallback = false) => {
try {
const raw = localStorage.getItem(key);
@@ -706,14 +709,6 @@ const isFiltering = computed(() =>
timeRange: updatedTimeRange.value,
}),
);
-// Sub-folder entries shown at the top of the list while browsing. Search results
-// are flat, so they are dropped as soon as a filter is active. When the sidebar
-// tree is open it already lists the same folders, so skip the duplicate rows.
-const currentChildFolders = computed(() => {
- if (isFiltering.value) return [];
- if (showFolderTree.value && !folderTreeCollapsed.value) return [];
- return childFolders(folderTree.value, selectedFolderPath.value);
-});
// A row's folder is worth showing only when the list can span folders.
const showDocumentFolderPath = computed(() => hasFolders.value && isFiltering.value);
const folderBreadcrumbs = computed(() => buildFolderBreadcrumbs(selectedFolderPath.value));
@@ -729,8 +724,7 @@ const filterParams = computed(() => {
start_time: start ? `${start} 00:00:00` : undefined,
end_time: end ? `${end} 23:59:59` : undefined,
folder_path: selectedFolderPath.value,
- // Searching descends into sub-folders; browsing shows one level, with the
- // sub-folders themselves rendered as entries in the list.
+ // Filtering searches descendants; browsing shows this folder's documents.
folder_recursive: isFiltering.value,
};
});
@@ -742,20 +736,6 @@ const tagMap = computed<Record<string, any>>(() => {
return map;
});
-// 标签编辑弹窗
-const tagEditDialogVisible = ref(false);
-const tagEditTarget = ref<KnowledgeCard | null>(null);
-
-function openTagEditDialog(item: KnowledgeCard) {
- tagEditTarget.value = item;
- tagEditDialogVisible.value = true;
-}
-
-function onTagEditConfirm(tagIds: string[]) {
- if (tagEditTarget.value) {
- handleKnowledgeTagChange(tagEditTarget.value.id, tagIds);
- }
-}
const getPageSize = () => {
const viewportHeight = window.innerHeight || document.documentElement.clientHeight;
const itemHeight = 148;
@@ -763,12 +743,6 @@ const getPageSize = () => {
pageSize = Math.max(35, itemsInView);
}
getPageSize()
-// 直接调用 API 获取知识库文件列表
-const getTagName = (tagId?: string | number) => {
- if (!tagId && tagId !== 0) return '';
- const key = String(tagId);
- return tagMap.value[key]?.name || '';
-};
const loadKnowledgeFiles = (kbIdValue: string): Promise<void> => {
if (!kbIdValue) return Promise.resolve();
@@ -950,6 +924,9 @@ const loadTags = async (kbIdValue: string, reset = false) => {
};
const handleTagFilterChange = (tagIds: string[]) => {
+ selectedTagNames.value = Object.fromEntries(tagIds.map(id => [
+ id, tagMap.value[id]?.name || selectedTagNames.value[id] || t('knowledgeBase.columnTag'),
+ ]));
selectedTagIds.value = tagIds;
// 同步更新 store 中的 selectedTagIds,供 menu.vue 上传时使用
uiStore.clearSelectedTagIds();
@@ -957,54 +934,13 @@ const handleTagFilterChange = (tagIds: string[]) => {
resetPage();
};
-const openTagManageDrawer = () => {
- tagManageDrawerVisible.value = true;
-};
-
-const openTagManageFromEditDialog = () => {
- tagEditDialogVisible.value = false;
- tagManageDrawerVisible.value = true;
-};
-
-const openTagManageFromBatchDialog = () => {
- batchTagDialogVisible.value = false;
- tagManageDrawerVisible.value = true;
-};
-
-const onTagManageChanged = (payload?: { deletedTagId?: string }) => {
- if (!kbId.value) return;
+const onTagCatalogChanged = (payload?: { deletedTagId?: string }) => {
void loadTags(kbId.value, true);
- if (payload?.deletedTagId && selectedTagIds.value.includes(payload.deletedTagId)) {
- selectedTagIds.value = [];
- handleTagFilterChange([]);
- resetPage();
- loadKnowledgeFiles(kbId.value);
- return;
- }
if (payload?.deletedTagId) {
- void (async () => {
- await new Promise((resolve) => setTimeout(resolve, 800));
- if (!kbId.value) return;
- resetPage();
- await loadKnowledgeFiles(kbId.value);
- await loadTags(kbId.value, true);
- })();
- return;
+ handleTagFilterChange(selectedTagIds.value.filter(id => id !== payload.deletedTagId));
}
resetPage();
- loadKnowledgeFiles(kbId.value);
-};
-
-const handleKnowledgeTagChange = async (knowledgeId: string, tagIds: string[]) => {
- try {
- await updateKnowledgeTagBatch({ updates: { [knowledgeId]: tagIds } });
- MessagePlugin.success(t('knowledgeBase.tagUpdateSuccess'));
- resetPage(); // Reset page counter to 1 when reloading files after tag change
- loadKnowledgeFiles(kbId.value);
- loadTags(kbId.value, true);
- } catch (error: any) {
- MessagePlugin.error(error?.message || t('common.operationFailed'));
- }
+ void loadKnowledgeFiles(kbId.value);
};
const loadKnowledgeBaseInfo = async (targetKbId: string, force = false) => {
@@ -1021,7 +957,7 @@ const loadKnowledgeBaseInfo = async (targetKbId: string, force = false) => {
kbInfo.value = data;
selectedTagIds.value = [];
- tagFilterCleared.value = false;
+ selectedTagNames.value = {};
uiStore.clearSelectedTagIds();
// 重置store中的标签选择状态,避免上传文档时自动带上之前选择的标签
uiStore.clearSelectedTagIds();
@@ -1362,7 +1298,6 @@ const updateStatus = (analyzeList: KnowledgeCard[]) => {
}
timeout = setTimeout(() => {
batchQueryKnowledge(query).then((result: any) => {
- let hasChanges = false;
let shouldRefreshWikiStatus = false;
if (result.success && result.data) {
(result.data as KnowledgeCard[]).forEach((item: KnowledgeCard) => {
@@ -1391,8 +1326,7 @@ const updateStatus = (analyzeList: KnowledgeCard[]) => {
cardList.value[index].summary_status = item.summary_status;
cardList.value[index].description = item.description;
delete traceAvailableById[item.id];
- hasChanges = true;
- }
+ }
});
}
if (shouldRefreshWikiStatus) {
@@ -1555,13 +1489,6 @@ const manualEditorSuccess = ({ kbId: savedKbId }: { kbId: string; knowledgeId: s
}
};
-const documentTitle = computed(() => {
- if (kbInfo.value?.name) {
- return `${kbInfo.value.name} · ${t('knowledgeEditor.document.title')}`;
- }
- return t('knowledgeEditor.document.title');
-});
-
const ensureDocumentKbReady = () => {
if (isFAQ.value) {
MessagePlugin.warning(t('knowledgeBase.operationNotSupportedForType'));
@@ -1589,10 +1516,6 @@ const ensureDocumentKbReady = () => {
return true;
};
-
-const IMAGE_EXTENSIONS = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'];
-const AUDIO_EXTENSIONS = ['mp3', 'wav', 'm4a', 'flac', 'ogg'];
-
const uploadConfirmStore = useUploadConfirmStore();
const uploadTasksStore = useUploadTasksStore();
@@ -2198,37 +2121,6 @@ const handleKBEditorSuccess = (kbIdValue: string) => {
loadKnowledgeBaseInfo(kbIdValue, true);
}
};
-
-const getTitle = (session_id: string, value: string) => {
- const now = new Date().toISOString();
- let obj = {
- title: t('knowledgeBase.newSession'),
- path: `chat/${session_id}`,
- id: session_id,
- isMore: false,
- isNoTitle: true,
- created_at: now,
- updated_at: now
- };
- usemenuStore.updataMenuChildren(obj);
- usemenuStore.changeIsFirstSession(true);
- usemenuStore.changeFirstQuery(value);
- router.push(`/platform/chat/${session_id}`);
-};
-
-async function createNewSession(value: string): Promise<void> {
- // Session 不再和知识库绑定,直接创建 Session
- createSessions({}).then(res => {
- if (res.data && res.data.id) {
- getTitle(res.data.id, value);
- } else {
- // 错误处理
- console.error(t('knowledgeBase.createSessionFailed'));
- }
- }).catch(error => {
- console.error(t('knowledgeBase.createSessionError'), error);
- });
-}
</script>
<template>
@@ -2292,13 +2184,13 @@ async function createNewSession(value: string): Promise<void> {
<KBInfoPopover v-if="kbInfo && !authStore.isLiteMode" :kb-info="kbInfo"
:supported-file-types="[...supportedFileTypes]" />
<t-tooltip v-if="canManage" :content="$t('knowledgeBase.settings')" placement="top">
- <button type="button" class="kb-settings-button" :disabled="!kbId" @click="handleOpenKBSettings">
+ <button type="button" class="kb-settings-button" :aria-label="$t('knowledgeBase.settings')" :disabled="!kbId" @click="handleOpenKBSettings">
<t-icon name="setting" size="16px" />
</button>
</t-tooltip>
</div>
</div>
- <p class="document-subtitle">{{ $t('knowledgeEditor.document.subtitle') }}</p>
+ <p v-if="kbInfo?.description" class="document-subtitle">{{ kbInfo.description }}</p>
<p v-if="unsupportedFileTypes.length" class="parser-hint" @click="goToParserSettings">
<t-icon name="info-circle" class="parser-hint-icon" />
<span>{{$t('knowledgeBase.unsupportedTypesHint', {
@@ -2325,117 +2217,120 @@ async function createNewSession(value: string): Promise<void> {
<template v-if="activeKbTab === 'documents' || !isWiki">
<div class="knowledge-main">
<KbFolderTree v-if="showFolderTree && !folderTreeCollapsed" :tree="folderTree" :selected-path="selectedFolderPath"
- :loading="folderTreeLoading" :can-edit="canEdit"
+ :loading="folderTreeLoading" :can-edit="canEdit" :root-label="kbInfo?.name"
@select="handleFolderSelect" @update:collapsed="handleFolderTreeCollapsedChange"
@rename="handleFolderRename" />
<div class="tag-content">
<div class="doc-card-area">
- <nav v-if="showFolderTree" class="doc-folder-path"
- :aria-label="$t('knowledgeBase.folderTree.title')">
- <t-tooltip v-if="folderTreeCollapsed" :content="$t('knowledgeBase.folderTree.expand')" placement="top">
- <button type="button" class="doc-folder-path__tree-toggle"
+ <div class="doc-filter-bar">
+ <nav class="doc-folder-path" :aria-label="$t('knowledgeBase.folderTree.title')">
+ <button v-if="showFolderTree && folderTreeCollapsed" type="button" class="doc-folder-path__tree-toggle"
+ :aria-expanded="false" :title="$t('knowledgeBase.folderTree.expand')"
:aria-label="$t('knowledgeBase.folderTree.expand')"
@click="handleFolderTreeCollapsedChange(false)">
- <t-icon name="folder" size="14px" />
+ <t-icon name="view-list" size="16px" />
</button>
- </t-tooltip>
- <span v-if="!folderBreadcrumbs.length" class="doc-folder-path__crumb is-current">
- {{ $t('knowledgeBase.folderTree.rootRow') }}
- </span>
- <button v-else type="button" class="doc-folder-path__crumb"
- @click="handleFolderSelect('')">
- {{ $t('knowledgeBase.folderTree.rootRow') }}
- </button>
- <template v-for="(crumb, index) in folderBreadcrumbs" :key="crumb.path">
- <t-icon name="chevron-right" class="doc-folder-path__sep" />
- <span v-if="index === folderBreadcrumbs.length - 1" class="doc-folder-path__crumb is-current">
- {{ crumb.name }}
- </span>
- <button v-else type="button" class="doc-folder-path__crumb" @click="handleFolderSelect(crumb.path)">
- {{ crumb.name }}
+ <button v-if="folderBreadcrumbs.length" type="button" class="doc-folder-path__crumb" :title="kbInfo?.name" @click="handleFolderSelect('')">
+ {{ kbInfo?.name }}
</button>
- </template>
- <!-- Filtering silently widens the scope to sub-folders, so say so. -->
- <span v-if="isFiltering" class="doc-folder-path__scope">
- {{ $t('knowledgeBase.folderTree.searchingSubtree') }}
- </span>
- </nav>
- <div class="doc-filter-bar">
- <t-input v-model.trim="docSearchKeyword" :placeholder="$t('knowledgeBase.docSearchPlaceholder')"
- clearable class="doc-search-input" @clear="loadKnowledgeFiles(kbId)"
- @enter="loadKnowledgeFiles(kbId)">
- <template #prefix-icon>
- <t-icon name="search" size="16px" />
+ <span v-else class="doc-folder-path__crumb is-current" :title="kbInfo?.name" aria-current="page">{{ kbInfo?.name }}</span>
+ <template v-for="(crumb, index) in folderBreadcrumbs" :key="crumb.path">
+ <t-icon name="chevron-right" class="doc-folder-path__sep" />
+ <span v-if="index === folderBreadcrumbs.length - 1" class="doc-folder-path__crumb is-current" :title="crumb.name" aria-current="page">{{ crumb.name }}</span>
+ <button v-else type="button" class="doc-folder-path__crumb" :title="crumb.name" @click="handleFolderSelect(crumb.path)">{{ crumb.name }}</button>
</template>
- </t-input>
- <div class="doc-filter-bar__filters">
- <KnowledgeTagFilter v-model:search="tagSearchQuery" v-model:cleared="tagFilterCleared"
- :tags="tagList" :selected-ids="selectedTagIds" :total="tagTotal"
- :loading="tagLoading" :loading-more="tagLoadingMore" :has-more="tagHasMore"
- :can-manage="canEdit" variant="documents" @change="handleTagFilterChange"
- @load-more="kbId && loadTags(kbId)" @manage="openTagManageDrawer" />
- <div class="doc-filter-field">
- <t-select v-model="selectedFileType" :options="fileTypeOptions"
- :placeholder="$t('knowledgeBase.fileTypeFilter')" class="doc-type-select doc-filter-field__control"
- clearable>
- <template #prefixIcon>
- <t-icon name="file" size="16px" />
- </template>
- </t-select>
- </div>
- <div class="doc-filter-field">
- <t-select v-model="selectedParseStatus" :options="parseStatusOptions"
- :placeholder="$t('knowledgeBase.parseStatusFilter')" class="doc-type-select doc-filter-field__control"
- clearable>
- <template #prefixIcon>
- <t-icon name="check-circle" size="16px" />
- </template>
- </t-select>
- </div>
- <div class="doc-filter-field">
- <t-select v-model="selectedSource" :options="sourceOptions"
- :placeholder="$t('knowledgeBase.sourceFilter')" class="doc-type-select doc-filter-field__control"
- clearable>
- <template #prefixIcon>
- <t-icon name="link" size="16px" />
+ <span v-if="!docListLoading" class="doc-folder-path__count">{{ $t(isFiltering ? 'knowledgeBase.folderTree.filteredCount' : 'knowledgeBase.documentCount', { count: total }) }}</span>
+ <t-tooltip v-if="showFolderTree && isFiltering" :content="$t('knowledgeBase.folderTree.searchingSubtree')">
+ <t-icon name="info-circle" class="doc-folder-path__sep" />
+ </t-tooltip>
+ </nav>
+ <div class="doc-filter-bar__trailing">
+ <t-input v-model.trim="docSearchKeyword" :placeholder="$t('knowledgeBase.docSearchPlaceholder')"
+ :aria-label="$t('knowledgeBase.docSearchPlaceholder')" clearable class="doc-search-input" @clear="loadKnowledgeFiles(kbId)"
+ @enter="loadKnowledgeFiles(kbId)">
+ <template #prefix-icon>
+ <t-icon name="search" size="16px" />
</template>
- </t-select>
- </div>
- <div class="doc-filter-field doc-filter-field--wide">
- <t-date-range-picker v-model="updatedTimeRange"
- :placeholder="[$t('knowledgeBase.updatedTimeFrom'), $t('knowledgeBase.updatedTimeTo')]"
- :disable-date="disableFutureDate" class="doc-date-range doc-filter-field__control" clearable
- allow-input>
- <template #prefixIcon>
- <t-icon name="time" size="16px" />
+ </t-input>
+ <t-popup v-model:visible="filtersExpanded" trigger="click" placement="bottom-right"
+ overlay-class-name="document-filter-popup" :overlay-inner-style="{ padding: 0 }">
+ <button type="button" class="doc-filter-toggle" :class="{ active: filtersExpanded || activeFilterCount > 0 }"
+ :aria-expanded="filtersExpanded" aria-controls="document-filters">
+ <t-icon name="filter" size="16px" />
+ {{ $t('knowledgeBase.filters') }}
+ <span v-if="activeFilterCount" class="doc-filter-count">{{ activeFilterCount }}</span>
+ </button>
+ <template #content>
+ <section id="document-filters" class="doc-filter-panel" :aria-label="$t('knowledgeBase.filters')">
+ <header class="doc-filter-panel__header">
+ <strong>{{ $t('knowledgeBase.filters') }}</strong>
+ <button type="button" :disabled="!activeFilterCount" @click="clearDocumentFilters">{{ $t('knowledgeBase.clearFilters') }}</button>
+ </header>
+ <div class="doc-filter-panel__fields">
+ <div class="doc-filter-field">
+ <span>{{ $t('knowledgeBase.fileTypeFilter') }}</span>
+ <t-select v-model="selectedFileType" :options="fileTypeOptions" :placeholder="$t('knowledgeBase.fileTypeFilter')" clearable />
+ </div>
+ <div class="doc-filter-field">
+ <span>{{ $t('knowledgeBase.parseStatusFilter') }}</span>
+ <t-select v-model="selectedParseStatus" :options="parseStatusOptions" :placeholder="$t('knowledgeBase.parseStatusFilter')" clearable />
+ </div>
+ <div class="doc-filter-field">
+ <span>{{ $t('knowledgeBase.sourceFilter') }}</span>
+ <t-select v-model="selectedSource" :options="sourceOptions" :placeholder="$t('knowledgeBase.sourceFilter')" clearable />
+ </div>
+ <div class="doc-filter-field">
+ <span>{{ $t('knowledgeBase.columnUpdatedAt') }}</span>
+ <t-date-range-picker v-model="updatedTimeRange"
+ :placeholder="[$t('knowledgeBase.updatedTimeFrom'), $t('knowledgeBase.updatedTimeTo')]"
+ :disable-date="disableFutureDate" clearable allow-input />
+ </div>
+ </div>
+ <div class="doc-filter-tags">
+ <div class="doc-filter-tags__heading">
+ <span>{{ $t('knowledgeBase.columnTag') }}<span v-if="selectedTagIds.length" class="doc-filter-tags__count">{{ selectedTagIds.length }}</span></span>
+ </div>
+ <t-input v-model.trim="tagSearchQuery" :placeholder="$t('knowledgeBase.tagSearchPlaceholder')" clearable>
+ <template #prefix-icon><t-icon name="search" size="14px" /></template>
+ </t-input>
+ <div class="doc-filter-tags__list">
+ <t-loading v-if="tagLoading && !tagList.length" size="small" />
+ <t-checkbox v-for="tag in filterTagOptions" :key="tag.id" class="doc-filter-tag" :title="tag.name"
+ :checked="selectedTagIds.includes(tag.id)"
+ @change="(checked: boolean) => handleTagFilterChange(checked ? [...selectedTagIds, tag.id] : selectedTagIds.filter(id => id !== tag.id))">
+ <span>{{ tag.name }}</span>
+ </t-checkbox>
+ <span v-if="!tagLoading && !filterTagOptions.length" class="doc-filter-tags__empty">{{ $t(tagSearchQuery ? 'knowledgeBase.tagEmptyResult' : 'knowledgeBase.noTags') }}</span>
+ </div>
+ <t-button v-if="tagHasMore" variant="text" size="small" :loading="tagLoadingMore" @click="kbId && loadTags(kbId)">{{ $t('tenant.loadMore') }}</t-button>
+ </div>
+ </section>
</template>
- </t-date-range-picker>
- </div>
- </div>
- <div class="doc-filter-bar__trailing">
- <t-button v-if="(canDownloadKnowledge || canMutateKnowledge) && cardList.length"
- variant="outline" size="small"
+ </t-popup>
+ <button v-if="viewMode === 'grid' && (canDownloadKnowledge || canMutateKnowledge) && cardList.length"
+ type="button" class="doc-filter-toggle doc-batch-toggle" :class="{ active: batchMode }" :aria-pressed="batchMode"
:disabled="batchDeleting || batchReparsing || batchTagging || batchDownloading"
@click="toggleBatchMode">
- {{ $t(batchMode ? 'knowledgeBase.clearSelection' : 'menu.batchManage') }}
- </t-button>
+ <t-icon :name="batchMode ? 'close' : 'check-rectangle'" size="16px" />
+ {{ $t(batchMode ? 'common.cancel' : 'menu.batchManage') }}
+ </button>
<div class="doc-view-toggle" role="group" :aria-label="$t('knowledgeBase.viewModeToggle')">
<t-tooltip :content="$t('knowledgeBase.viewModeGrid')" placement="top">
<button type="button" class="doc-view-toggle-btn" :class="{ active: viewMode === 'grid' }"
- @click="viewMode = 'grid'" :aria-pressed="viewMode === 'grid'">
+ :aria-label="$t('knowledgeBase.viewModeGrid')" @click="viewMode = 'grid'" :aria-pressed="viewMode === 'grid'">
<t-icon name="view-module" size="16px" />
</button>
</t-tooltip>
<t-tooltip :content="$t('knowledgeBase.viewModeList')" placement="top">
<button type="button" class="doc-view-toggle-btn" :class="{ active: viewMode === 'list' }"
- @click="viewMode = 'list'" :aria-pressed="viewMode === 'list'">
+ :aria-label="$t('knowledgeBase.viewModeList')" @click="viewMode = 'list'" :aria-pressed="viewMode === 'list'">
<t-icon name="view-list" size="16px" />
</button>
</t-tooltip>
</div>
<div v-if="canEdit" class="doc-filter-actions">
<KbUploadSourceDropdown ref="uploadSourceRef" :accept-file-types="acceptFileTypes"
- :supported-file-types="[...supportedFileTypes]" include-manual trigger-icon="file-add"
+ :supported-file-types="[...supportedFileTypes]" include-manual trigger-icon="add" :trigger-label="t('knowledgeBase.addDocument')"
trigger-class="content-bar-icon-btn" data-guide="kb-detail-add-doc"
:tooltip="t('knowledgeBase.addDocument')" placement="bottom-right" @files="handleUploadSourceFiles"
@url="handleUploadSourceUrl" @manual="handleManualCreate" />
@@ -2444,7 +2339,7 @@ async function createNewSession(value: string): Promise<void> {
</div>
<div class="doc-scroll-container"
:class="{
- 'is-empty': !cardList.length && !currentChildFolders.length && !docListLoading,
+ 'is-empty': !cardList.length && !docListLoading,
'is-marquee-active': docMarqueeVisible,
}"
ref="knowledgeScroll" @scroll="handleScroll" @mousedown="onDocMarqueeMouseDown">
@@ -2452,7 +2347,12 @@ async function createNewSession(value: string): Promise<void> {
:class="{ 'is-add': docMarqueeMode === 'add', 'is-subtract': docMarqueeMode === 'subtract' }"
:style="docMarqueeBoxStyle" aria-hidden="true" />
<!-- 文档骨架屏 -->
- <div v-if="docListLoading && cardList.length === 0 && !currentChildFolders.length" class="doc-card-list doc-card-list-animated">
+ <div v-if="docListLoading && !cardList.length && viewMode === 'list'" class="doc-list-skeleton">
+ <div v-for="n in 8" :key="n" class="doc-list-skeleton-row">
+ <t-skeleton animation="gradient" :row-col="[[{ width: '32px', height: '38px', type: 'rect' }, { width: '55%', height: '16px' }]]" />
+ </div>
+ </div>
+ <div v-else-if="docListLoading && cardList.length === 0" class="doc-card-list doc-card-list-animated">
<div v-for="n in 8" :key="'doc-skel-' + n" class="knowledge-card knowledge-card-skeleton">
<div class="card-content">
<div class="card-content-nav">
@@ -2467,17 +2367,16 @@ async function createNewSession(value: string): Promise<void> {
</div>
</div>
</div>
- <template v-else-if="(cardList.length || currentChildFolders.length) && viewMode === 'grid'">
- <DocumentCardView
+ <template v-else-if="cardList.length && viewMode === 'grid'">
+ <DocumentCardView :kb-id="kbId"
:items="cardList"
- :folders="currentChildFolders" :folder-options="folderOptions"
+ :folder-options="folderOptions"
:selected-ids="selectedIds"
:batch-mode="batchMode"
:can-edit="canEdit"
:can-download="canDownloadKnowledge"
:can-mutate-knowledge="canMutateKnowledge"
:trace-available-by-id="traceAvailableById"
- :tag-list="tagList"
:move-menu-mode="moveMenuMode"
:move-target-kbs="moveTargetKbs"
:move-targets-loading="moveTargetsLoading"
@@ -2491,16 +2390,16 @@ async function createNewSession(value: string): Promise<void> {
@toggle-checkbox="onCardGridCheckboxChange"
@menu-visible-change="(visible: boolean, item: any) => onCardMoreVisibleChange(visible, item)"
@action="(action: any, item: any) => handleCardAction(action, item)"
- @tag-edit="(item: any) => openTagEditDialog(item)"
+ @tags-changed="onTagCatalogChanged"
@move-select-target="(kb: any) => handleMoveSelectTarget(kb)"
@move-back="handleMoveBack"
@move-confirm="handleMoveConfirm"
@update:move-mode="(mode: any) => moveMode = mode"
/>
</template>
- <template v-else-if="(cardList.length || currentChildFolders.length) && viewMode === 'list'">
- <DocumentListView :items="cardList" :folders="currentChildFolders" :folder-options="folderOptions"
- :selected-ids="selectedIds" :tag-list="tagList"
+ <template v-else-if="cardList.length && viewMode === 'list'">
+ <DocumentListView :kb-id="kbId" :items="cardList" :folder-options="folderOptions"
+ :selected-ids="selectedIds"
:can-edit="canEdit" :can-download="canDownloadKnowledge" :can-mutate-knowledge="canMutateKnowledge"
:trace-visible-ids="traceAvailableById"
:move-menu-mode="moveMenuMode"
@@ -2515,7 +2414,7 @@ async function createNewSession(value: string): Promise<void> {
@open="(item: any) => openKnowledgeItem(item)" @toggle-row="toggleSelectRow"
@toggle-all="toggleSelectAll" @action="(action: any, item: any) => handleListAction(action, item)"
@probe-trace="(item: any) => probeTraceAvailable(item)"
- @tag-edit="(item: any) => openTagEditDialog(item)"
+ @tags-changed="onTagCatalogChanged"
@move-select-target="(kb: any) => handleMoveSelectTarget(kb)"
@move-back="handleMoveBack"
@move-confirm="handleMoveConfirm"
@@ -2524,7 +2423,7 @@ async function createNewSession(value: string): Promise<void> {
</template>
<template v-else-if="!docListLoading">
<div class="doc-empty-state">
- <p v-if="selectedFolderPath || isFiltering" class="doc-empty-folder">
+ <p v-if="hasFolders || selectedFolderPath || isFiltering" class="doc-empty-folder">
{{ isFiltering
? $t('knowledgeBase.folderTree.emptySearch')
: $t('knowledgeBase.folderTree.emptyFolder') }}
@@ -2568,70 +2467,34 @@ async function createNewSession(value: string): Promise<void> {
<ContextualGuide tour="kbDetail" :when="showKbDetailContextualGuide" />
- <!-- 标签编辑弹窗 -->
- <TagEditDialog :visible="tagEditDialogVisible"
- :knowledge-name="tagEditTarget?.display_name || tagEditTarget?.file_name || tagEditTarget?.title || ''"
- :kb-id="kbId" :tag-list="tagList" :selected-tags="tagEditTarget?.tags || []" :can-manage="canEdit"
- @update:visible="tagEditDialogVisible = $event" @confirm="onTagEditConfirm" @tag-created="loadTags(kbId, true)"
- @open-manage="openTagManageFromEditDialog" />
-
<!-- 批量打标签弹窗 -->
- <BatchTagDialog :visible="batchTagDialogVisible"
- :count="selectedIds.size" :kb-id="kbId" :tag-list="tagList"
- :pre-selected-tag-ids="batchTagPreSelectedIds" :can-manage="canEdit"
+ <BatchTagDialog @tags-changed="onTagCatalogChanged" :visible="batchTagDialogVisible"
+ :count="selectedIds.size" :kb-id="kbId"
+ :pre-selected-tag-ids="batchTagPreSelectedIds"
:confirm-loading="batchTagging"
- @update:visible="batchTagDialogVisible = $event" @confirm="onBatchTagConfirm"
- @tag-created="loadTags(kbId, true)" @open-manage="openTagManageFromBatchDialog" />
-
- <KbTagManageDrawer
- v-if="!isFAQ"
- v-model:visible="tagManageDrawerVisible"
- :kb-id="kbId"
- :is-faq="isFAQ"
- @changed="onTagManageChanged"
- />
+ @update:visible="batchTagDialogVisible = $event" @confirm="onBatchTagConfirm" />
+
</template>
<style>
/* 下拉菜单容器样式已统一至 @/assets/dropdown-menu.less */
-
-.tag-more-popup .tag-menu {
- display: flex;
- flex-direction: column;
-}
-
-.tag-more-popup .tag-menu-item {
- display: flex;
- align-items: center;
- padding: 8px 16px;
- cursor: pointer;
- transition: all var(--app-motion-base) ease;
- color: var(--td-text-color-primary);
- font-family: var(--app-font-family);
- font-size: var(--app-text-base);
- font-weight: 400;
+.document-filter-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%);
}
-.tag-more-popup .tag-menu-item .menu-icon {
- margin-right: 8px;
- font-size: var(--app-text-xl);
-}
-
-.tag-more-popup .tag-menu-item:hover {
- background: var(--td-bg-color-secondarycontainer);
- color: var(--td-text-color-primary);
-}
</style>
<style scoped lang="less">
.knowledge-layout {
display: flex;
flex-direction: column;
- margin: 0 16px 0 4px;
- gap: 20px;
+ margin: 0 16px 0 0;
+ gap: 16px;
height: 100%;
flex: 1;
width: 100%;
min-width: 0;
- padding: 24px 32px 0px;
+ padding: 20px 28px 0;
box-sizing: border-box;
}
@@ -2679,7 +2542,7 @@ async function createNewSession(value: string): Promise<void> {
overflow: hidden;
}
-// 与列表页一致:浅灰底圆角区,左侧筛选为白底卡片
+// Directory navigation and the document content share the available width.
.knowledge-main {
display: flex;
flex: 1;
@@ -2688,6 +2551,21 @@ async function createNewSession(value: string): Promise<void> {
border: none;
}
+@media (max-width: 1000px) {
+ .knowledge-main {
+ flex-direction: column;
+ :deep(.kb-folder-tree) {
+ width: 100%;
+ max-height: 200px;
+ padding: 0 0 12px;
+ margin: 0 0 16px;
+ border-right: 0;
+ border-bottom: 1px solid var(--td-component-stroke);
+ }
+ :deep(.kb-folder-tree__header) { height: 28px; padding-bottom: 4px; }
+ }
+}
+
// 标签筛选浮层:点击工具栏入口展开,不占文档列表横向空间
.tag-content {
@@ -2711,261 +2589,183 @@ async function createNewSession(value: string): Promise<void> {
position: relative;
container-type: inline-size;
container-name: doc-card-area;
- /* 作为批量工具栏悬浮的定位上下文 */
}
-// 目录树选中路径的面包屑:与顶部知识库面包屑同一套视觉语言,只是更轻量。
-.doc-folder-path {
+// One navigation row; filters open in a single anchored panel.
+.doc-filter-bar {
display: flex;
align-items: center;
- flex-wrap: wrap;
- gap: 2px;
- padding: 0 0 8px;
+ justify-content: space-between;
+ gap: 16px;
flex-shrink: 0;
-
+ padding: 0 0 16px;
+ border-bottom: 1px solid var(--td-component-stroke);
+ &__trailing { display: flex; align-items: center; gap: 8px; min-width: 0; }
+ .doc-search-input { width: 220px; min-width: 100px; }
+ :deep(.doc-search-input .t-input) {
+ background: transparent;
+ border-color: var(--td-component-stroke);
+ border-radius: var(--app-radius-md);
+ font-size: var(--app-text-md);
+ }
+ .doc-filter-actions :deep(.content-bar-icon-btn) {
+ height: 32px;
+ padding: 0 12px;
+ border-radius: var(--app-radius-md);
+ background: var(--td-brand-color);
+ color: var(--td-text-color-anti);
+ &:hover { background: var(--td-brand-color-hover); }
+ }
+}
+.doc-folder-path {
+ display: flex;
+ align-items: baseline;
+ gap: 6px;
+ min-width: 0;
+ min-height: 32px;
+ line-height: 20px;
+ flex-wrap: wrap;
&__tree-toggle {
- flex-shrink: 0;
display: inline-flex;
align-items: center;
justify-content: center;
- width: 24px;
- height: 24px;
- margin-right: 4px;
- padding: 0;
- border: 1px solid var(--td-component-border);
- border-radius: var(--app-radius-sm);
+ flex-shrink: 0;
+ align-self: center;
+ gap: 6px;
+ height: 32px;
+ padding: 0 10px;
+ font: inherit;
+ font-size: var(--app-text-md);
+ border: 1px solid var(--td-component-stroke);
+ border-radius: var(--app-radius-md);
background: var(--td-bg-color-container);
color: var(--td-text-color-secondary);
cursor: pointer;
- transition: border-color var(--app-motion-fast) ease, color var(--app-motion-fast) ease, background var(--app-motion-fast) ease;
-
- &:hover {
- border-color: var(--td-brand-color);
- color: var(--td-brand-color);
- background: var(--td-bg-color-container-hover);
- }
+ &:hover { background: var(--td-bg-color-container-hover); color: var(--td-text-color-primary); }
}
-
&__crumb {
- max-width: 220px;
- padding: 2px 4px;
+ max-width: 160px;
+ padding: 6px 2px;
border: 0;
- border-radius: var(--app-radius-xs);
background: transparent;
color: var(--td-text-color-secondary);
- font-family: var(--app-font-family);
- font-size: var(--app-text-sm);
- line-height: 18px;
+ font: inherit;
+ font-size: var(--app-text-md);
+ line-height: 20px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;
- transition: color var(--app-motion-fast) ease, background var(--app-motion-fast) ease;
-
- &:hover {
- color: var(--td-brand-color);
- background: var(--td-bg-color-container-hover);
- }
-
- &.is-current {
- color: var(--td-text-color-primary);
- font-weight: 500;
- cursor: default;
-
- &:hover {
- background: transparent;
- color: var(--td-text-color-primary);
- }
- }
- }
-
- &__sep {
- flex-shrink: 0;
- font-size: var(--app-text-sm);
- color: var(--td-text-color-placeholder);
+ &:is(button):hover { color: var(--td-brand-color); }
+ &.is-current { color: var(--td-text-color-primary); font-weight: 600; cursor: default; }
}
+ &__count { padding: 6px 0; line-height: 20px; margin-left: 6px; color: var(--td-text-color-placeholder); font-size: var(--app-text-sm); font-variant-numeric: tabular-nums; white-space: nowrap; }
+ &__sep, &__scope { align-self: center; flex-shrink: 0; color: var(--td-text-color-placeholder); font-size: var(--app-text-sm); }
}
-
-.doc-filter-bar {
- padding: 0 0 12px 0;
- flex-shrink: 0;
- display: grid;
- grid-template-columns: 1fr auto;
- grid-template-areas:
- 'search trailing'
- 'filters filters';
- gap: 8px 12px;
+.doc-filter-toggle {
+ display: inline-flex;
align-items: center;
-
- .doc-search-input {
- grid-area: search;
- min-width: 0;
- width: 100%;
- }
-
- &__filters {
- grid-area: filters;
- display: flex;
- align-items: center;
- gap: 12px;
- min-width: 0;
- overflow-x: auto;
- flex-wrap: nowrap;
- -webkit-overflow-scrolling: touch;
- scrollbar-width: thin;
- scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
-
- &::-webkit-scrollbar {
- height: 4px;
- }
-
- &::-webkit-scrollbar-thumb {
- background-color: rgba(0, 0, 0, 0.15);
- border-radius: 2px;
- }
- }
-
- &__trailing {
- grid-area: trailing;
- display: flex;
- align-items: center;
- gap: 8px;
- flex-shrink: 0;
- position: relative;
- z-index: 1;
- }
-
- // The folder tree changes the available document width without changing the
- // viewport width. Switch to a single row only when this content area itself
- // is wide enough for TDesign's fixed-width filter controls.
- @container doc-card-area (min-width: 1240px) {
- display: flex;
- flex-direction: row;
- flex-wrap: nowrap;
- gap: 12px;
-
- &__filters {
- flex: 1 1 auto;
- overflow-x: auto;
- }
- }
-
- .doc-filter-field {
- width: 140px;
- flex-shrink: 0;
-
- &--wide {
- width: 280px;
- }
-
- &__control {
- width: 100%;
- }
- }
-
- @media (min-width: 1280px) {
- .doc-search-input {
- flex: 1 1 220px;
- min-width: 220px;
- }
- }
-
- .doc-type-select {
- width: 100%;
- }
-
- .doc-date-range {
- width: 100%;
-
- // TDesign focuses both the outer popup reference and inner inputs, which
- // visually stacks into a "double border" — drop the inner shadow.
- :deep(.t-input--focused),
- :deep(.t-is-focused) {
- box-shadow: none;
- }
- }
-
- .doc-view-toggle {
- flex-shrink: 0;
+ justify-content: center;
+ 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;
+ &:hover, &.active { background: var(--td-bg-color-secondarycontainer); color: var(--td-text-color-primary); }
+}
+.doc-filter-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;
+}
+.doc-view-toggle {
+ display: inline-flex;
+ align-items: center;
+ background: var(--td-bg-color-secondarycontainer);
+ border: 1px solid transparent;
+ border-radius: var(--app-radius-md);
+ padding: 2px;
+ .doc-view-toggle-btn {
display: inline-flex;
align-items: center;
- padding: 2px;
- background: var(--td-bg-color-secondarycontainer);
- border-radius: var(--app-radius-sm);
- gap: 0;
-
- .doc-view-toggle-btn {
- width: 28px;
- height: 24px;
- display: inline-flex;
- align-items: center;
- justify-content: center;
- border: 0;
- background: transparent;
- border-radius: var(--app-radius-xs);
- color: var(--td-text-color-secondary);
- cursor: pointer;
- transition: background-color var(--app-motion-instant) ease, color var(--app-motion-instant) ease;
-
- &:hover {
- color: var(--td-text-color-primary);
- }
-
- &.active {
- background: var(--td-bg-color-container);
- color: var(--td-brand-color);
- box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
- }
- }
- }
-
- .doc-filter-actions {
- flex-shrink: 0;
-
- :deep(.content-bar-icon-btn) {
- color: var(--td-text-color-secondary);
- background: transparent;
- border: none;
-
- &:hover {
- color: var(--td-brand-color);
- background: var(--td-bg-color-secondarycontainer);
- }
- }
+ justify-content: center;
+ width: 28px;
+ height: 26px;
+ padding: 0;
+ border: 0;
+ border-radius: var(--app-radius-xs);
+ background: transparent;
+ color: var(--td-text-color-placeholder);
+ cursor: pointer;
+ &:hover { color: var(--td-text-color-primary); }
+ &.active { background: var(--td-bg-color-container); color: var(--td-brand-color); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
}
-
- :deep(.t-input) {
- font-size: var(--app-text-md);
- background-color: var(--td-bg-color-secondarycontainer);
- border-color: transparent;
- border-radius: var(--app-radius-sm);
- box-shadow: none !important;
-
- &:hover,
- &:focus,
- &.t-is-focused {
- border-color: var(--td-brand-color);
- background-color: var(--td-bg-color-container);
- box-shadow: none !important;
- }
+}
+.doc-filter-panel {
+ width: 340px;
+ 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);
+ font-size: var(--app-text-md);
+ button { font: inherit; cursor: pointer; }
+ &__header {
+ display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;
+ 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); }
+ button:disabled { color: var(--td-text-color-disabled); cursor: default; }
+ }
+ &__fields { display: flex; flex-direction: column; gap: 10px; }
+ .doc-filter-field {
+ display: grid; grid-template-columns: 72px minmax(0, 1fr); align-items: center; gap: 8px;
+ > span { color: var(--td-text-color-secondary); font-size: var(--app-text-sm); }
+ :deep(.t-date-range-picker) { width: 100%; }
}
+}
+.doc-filter-tags {
+ margin-top: 16px;
+ padding-top: 14px;
+ border-top: 1px solid var(--td-component-stroke);
+ &__heading {
+ display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;
+ button { padding: 0; border: 0; background: transparent; color: var(--td-text-color-secondary); font-size: var(--app-text-sm); }
+ }
+ &__count { margin-left: 6px; color: var(--td-text-color-placeholder); font-variant-numeric: tabular-nums; }
+ &__list { display: flex; flex-direction: column; gap: 2px; max-height: 168px; overflow-y: auto; margin-top: 8px; }
+ &__empty { color: var(--td-text-color-placeholder); padding: 8px 0; }
+}
+.doc-filter-tag {
+ display: flex; align-items: center; flex-shrink: 0; width: 100%; min-height: 28px; margin: 0;
+ padding: 4px 6px; box-sizing: border-box; border-radius: var(--app-radius-xs);
+ &:hover { background: var(--td-bg-color-container-hover); }
+ :deep(.t-checkbox__label) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+ :deep(.t-checkbox__input) { flex-shrink: 0; }
+}
+.doc-batch-toggle {
+ &:disabled { cursor: not-allowed; opacity: 0.5; }
+ &.active { color: var(--app-selection-text); border-color: var(--td-component-border); background: var(--app-selection-bg); }
+}
+.doc-filter-bar button:focus-visible, .doc-filter-panel button:focus-visible {
+ outline: 2px solid var(--app-focus-border); outline-offset: 2px;
+}
+.doc-list-skeleton-row { padding: 16px 40px; }
+@container doc-card-area (max-width: 780px) {
+ .doc-filter-bar { flex-wrap: wrap; gap: 12px; }
+ .doc-filter-bar__trailing { width: 100%; }
+ .doc-filter-bar .doc-search-input { flex: 1; width: auto; }
+}
- :deep(.t-select) {
- .t-input {
- font-size: var(--app-text-md);
- background-color: var(--td-bg-color-secondarycontainer);
- border-color: transparent;
- border-radius: var(--app-radius-sm);
- box-shadow: none !important;
-
- &:hover,
- &.t-is-focused {
- border-color: var(--td-brand-color);
- background-color: var(--td-bg-color-container);
- box-shadow: none !important;
- }
- }
- }
+@container doc-card-area (max-width: 540px) {
+ .doc-filter-bar__trailing { flex-wrap: wrap; }
+ .doc-filter-bar .doc-search-input { flex: 1 0 100%; }
}
.doc-scroll-container {
@@ -3007,16 +2807,14 @@ async function createNewSession(value: string): Promise<void> {
}
}
-/* 批量条悬浮在滚动区底部,不挤占列表高度 */
+/* Reserve space for the batch actions so the last document stays reachable. */
.doc-batch-bar-anchor {
- position: absolute;
- left: 0;
- right: 0;
- bottom: 12px;
+ position: relative;
+ flex-shrink: 0;
z-index: 6;
display: flex;
justify-content: center;
- padding: 0 16px;
+ padding: 12px 0 0;
pointer-events: none;
&>* {
@@ -3196,9 +2994,6 @@ async function createNewSession(value: string): Promise<void> {
}
-.document-upload-input {
- display: none;
-}
.kb-settings-button {
width: 30px;
@@ -3238,46 +3033,6 @@ async function createNewSession(value: string): Promise<void> {
margin: 0 16px 0 4px;
}
-@media (max-width: 1250px) and (min-width: 1045px) {
- .answers-input {
- transform: translateX(-329px);
- }
-
- :deep(.t-textarea__inner) {
- width: 654px !important;
- }
-}
-
-@media (max-width: 1045px) {
- .answers-input {
- transform: translateX(-250px);
- }
-
- :deep(.t-textarea__inner) {
- width: 500px !important;
- }
-}
-
-@media (max-width: 750px) {
- .answers-input {
- transform: translateX(-182px);
- }
-
- :deep(.t-textarea__inner) {
- width: 340px !important;
- }
-}
-
-@media (max-width: 600px) {
- .answers-input {
- transform: translateX(-164px);
- }
-
- :deep(.t-textarea__inner) {
- width: 300px !important;
- }
-}
-
@keyframes contentFadeIn {
from {
opacity: 0;
@@ -3294,8 +3049,8 @@ async function createNewSession(value: string): Promise<void> {
box-sizing: border-box;
display: grid;
// 文档卡片信息量较大(标题 + 摘要 + 标签/类型),保持稍宽的最小列宽,避免一行塞太多导致内容拥挤。
- grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
- gap: 12px;
+ grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
+ gap: 10px;
align-content: flex-start;
width: 100%;
@@ -3312,7 +3067,7 @@ async function createNewSession(value: string): Promise<void> {
min-height: 0;
display: flex;
flex-direction: column;
- padding: 10px 14px 8px;
+ padding: 10px;
}
.card-content-nav {
@@ -3344,11 +3099,11 @@ async function createNewSession(value: string): Promise<void> {
}
.knowledge-card {
- min-width: 240px;
+ min-width: 0;
display: flex;
flex-direction: column;
border: 1px solid var(--td-component-border);
- height: 136px;
+ height: 164px;
border-radius: var(--app-radius-md);
overflow: hidden;
box-sizing: border-box;
@@ -3363,7 +3118,7 @@ async function createNewSession(value: string): Promise<void> {
min-height: 0;
display: flex;
flex-direction: column;
- padding: 10px 14px 8px;
+ padding: 12px;
}
.card-content-nav {
diff --git a/frontend/src/views/knowledge/components/BatchTagDialog.test.ts b/frontend/src/views/knowledge/components/BatchTagDialog.test.ts
index 4ff519a3f..7ea932d21 100644
--- a/frontend/src/views/knowledge/components/BatchTagDialog.test.ts
+++ b/frontend/src/views/knowledge/components/BatchTagDialog.test.ts
@@ -1,43 +1,100 @@
import assert from 'node:assert/strict'
-import test from 'node:test'
import { readFileSync } from 'node:fs'
+import { runInNewContext } from 'node:vm'
+import test from 'node:test'
+import ts from 'typescript'
+import { compileScript, parse } from '@vue/compiler-sfc'
+import * as vue from 'vue'
-const component = readFileSync(new URL('./BatchTagDialog.vue', import.meta.url), 'utf8')
-const zhCN = readFileSync(new URL('../../../i18n/locales/zh-CN.ts', import.meta.url), 'utf8')
-const enUS = readFileSync(new URL('../../../i18n/locales/en-US.ts', import.meta.url), 'utf8')
-const koKR = readFileSync(new URL('../../../i18n/locales/ko-KR.ts', import.meta.url), 'utf8')
-const jaJP = readFileSync(new URL('../../../i18n/locales/ja-JP.ts', import.meta.url), 'utf8')
-const ruRU = readFileSync(new URL('../../../i18n/locales/ru-RU.ts', import.meta.url), 'utf8')
-
-test('uses a compact flat dialog with selected and available sections', () => {
- assert.match(component, /dialog-class-name="batch-tag-dialog"/)
- assert.match(component, /width="420px"/)
- assert.match(component, /<template #header>/)
- assert.match(component, /class="batch-tag-heading-icon"/)
- assert.match(component, /name="discount"/)
- assert.match(component, /class="setting-drawer__section"/)
- assert.match(component, /class="setting-drawer__section-title"/)
- assert.match(component, /batchTagSelectedSection/)
- assert.match(component, /batchTagAvailableSection/)
- assert.match(component, /preSelectedTagIds/)
- assert.match(component, /confirmLoading/)
- assert.match(component, /canManage/)
- assert.match(component, /tagManageLink/)
- assert.match(component, /open-manage/)
- assert.match(component, /selectedTagsList/)
- assert.match(component, /availableTagsList/)
- assert.match(component, /class="batch-tag-chip"/)
- assert.match(component, /class="batch-tag-create-row"/)
- assert.match(component, /class="batch-tag-footer"/)
- assert.match(component, /function handleConfirm\(\) {\s*if \(props\.confirmLoading\) return;\s*emit\('confirm', Array.from\(selectedSet\.value\)\);\s*}/)
+const source = readFileSync(new URL('./BatchTagDialog.vue', import.meta.url), 'utf8')
+const { descriptor } = parse(source)
+const compiled = ts.transpileModule(compileScript(descriptor, { id: 'tag-popover-test', inlineTemplate: true }).content, {
+ compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022 },
+}).outputText
+const translate = (key: string) => key
+type Host = { type: string; props: Record<string, any>; children: Host[]; text: string; parent?: Host }
+const node = (type: string): Host => ({ type, props: {}, children: [], text: '' })
+const renderer = vue.createRenderer<Host, Host>({
+ createElement: node,
+ createText: text => ({ ...node('#text'), text }),
+ createComment: text => ({ ...node('#comment'), text }),
+ patchProp: (el, key, _old, value) => { el.props[key] = value },
+ setText: (el, text) => { el.text = text },
+ setElementText: (el, text) => { el.children = []; el.text = text },
+ parentNode: el => el.parent || null,
+ nextSibling: el => el.parent?.children[el.parent.children.indexOf(el) + 1] || null,
+ insert(el, parent, anchor) {
+ if (el.parent) el.parent.children.splice(el.parent.children.indexOf(el), 1)
+ el.parent = parent
+ const index = anchor ? parent.children.indexOf(anchor) : -1
+ parent.children.splice(index < 0 ? parent.children.length : index, 0, el)
+ },
+ remove(el) {
+ el.parent?.children.splice(el.parent.children.indexOf(el), 1)
+ el.parent = undefined
+ },
})
+const textOf = (el: Host): string => el.type === '#comment' ? '' : el.text + el.children.map(textOf).join('')
+const all = (el: Host, predicate: (node: Host) => boolean): Host[] => [
+ ...(predicate(el) ? [el] : []), ...el.children.flatMap(child => all(child, predicate)),
+]
+
-test('defines batch tag dialog strings in every supported locale', () => {
- for (const locale of [zhCN, enUS, koKR, jaJP, ruRU]) {
- assert.match(locale, /batchTagDialogHeading:/)
- assert.match(locale, /batchTagSelectedSection:/)
- assert.match(locale, /batchTagAvailableSection:/)
- assert.match(locale, /batchTagSuccess:/)
- assert.match(locale, /batchTagFailed:/)
+async function fixture() {
+ const state = vue.reactive({ visible: false, kbId: 'kb', count: 2, preSelectedTagIds: ['a'], confirmLoading: false })
+ const confirmations: string[][] = []
+ const exports: { default?: vue.Component } = {}
+ runInNewContext(compiled, { exports, require(name: string) {
+ if (name === 'vue') return vue
+ if (name === './KnowledgeTagPicker.vue') return { __esModule: true, default: vue.defineComponent({
+ props: ['selectedIds'], emits: ['update:selectedIds', 'busy-change'],
+ setup: (props, { emit }) => () => vue.h('picker', { selectedIds: props.selectedIds,
+ onSelect: (ids: string[]) => emit('update:selectedIds', ids), onBusy: (busy: boolean) => emit('busy-change', busy),
+ }),
+ }) }
+ throw new Error(name)
+ } })
+ const root = node('root')
+ const app = renderer.createApp({ setup: () => () => vue.h(exports.default!, {
+ ...state, 'onUpdate:visible': (value: boolean) => { state.visible = value },
+ onConfirm: (ids: string[]) => confirmations.push([...ids]),
+ }) })
+ app.config.globalProperties.$t = translate as typeof app.config.globalProperties.$t
+ for (const [name, type] of [['t-dialog','dialog'],['t-button','button'],['t-icon','icon']]) {
+ app.component(name!, vue.defineComponent({ setup: (_props,{slots}) => () => vue.h(type!,{},slots.default?.()) }))
}
+ app.mount(root)
+ const settle = async () => { for (let i=0;i<5;i++) await vue.nextTick() }
+ const find = (predicate: (el: Host) => boolean) => { const el=all(root,predicate)[0]; assert.ok(el); return el }
+ const fire = async (el: Host,event='onClick',value?: unknown) => { await el.props[event](value); await settle() }
+ state.visible=true; await settle()
+ return { state, confirmations, find, fire, settle, close: () => app.unmount() }
+}
+
+test('batch tagging starts with common tags and keeps the draft until the parent completes saving', async t => {
+ const f=await fixture(); t.after(f.close)
+ assert.deepEqual([...f.find(el=>el.type==='picker').props.selectedIds], ['a'])
+ await f.fire(f.find(el=>el.type==='picker'),'onSelect',['a','b'])
+ f.state.preSelectedTagIds=['c']; await f.settle()
+ await f.fire(f.find(el=>el.type==='button'&&textOf(el)==='common.confirm'))
+ assert.deepEqual(f.confirmations, [['a','b']])
+ assert.equal(f.state.visible,true)
+ f.state.visible=false; await f.settle()
+ f.state.visible=true; await f.settle()
+ assert.deepEqual([...f.find(el=>el.type==='picker').props.selectedIds], ['c'])
+})
+
+test('tag mutations and batch saving prevent duplicate confirms and closing', async t => {
+ const f=await fixture(); t.after(f.close)
+ await f.fire(f.find(el=>el.type==='picker'),'onBusy',true)
+ await f.fire(f.find(el=>el.type==='button'&&textOf(el)==='common.confirm'))
+ await f.fire(f.find(el=>el.type==='button'&&textOf(el)==='common.cancel'))
+ assert.equal(f.confirmations.length,0)
+ assert.equal(f.state.visible,true)
+ await f.fire(f.find(el=>el.type==='picker'),'onBusy',false)
+ f.state.confirmLoading=true; await f.settle()
+ await f.fire(f.find(el=>el.type==='button'&&textOf(el)==='common.confirm'))
+ await f.fire(f.find(el=>el.type==='button'&&textOf(el)==='common.cancel'))
+ assert.equal(f.confirmations.length,0)
+ assert.equal(f.state.visible,true)
})
diff --git a/frontend/src/views/knowledge/components/BatchTagDialog.vue b/frontend/src/views/knowledge/components/BatchTagDialog.vue
index f267022de..b4e444505 100644
--- a/frontend/src/views/knowledge/components/BatchTagDialog.vue
+++ b/frontend/src/views/knowledge/components/BatchTagDialog.vue
@@ -11,74 +11,18 @@
</div>
</template>
- <div class="batch-tag-body">
- <section class="setting-drawer__section">
- <div class="batch-tag-section-head">
- <h4 class="setting-drawer__section-title">{{ $t('knowledgeBase.batchTagSelectedSection') }}</h4>
- <t-button v-if="selectedSet.size > 0" variant="text" size="small" theme="default" @click="clearAll">
- {{ $t('knowledgeBase.tagClearAction') }}
- </t-button>
- </div>
- <div v-if="selectedTagsList.length > 0" class="batch-tag-chips">
- <button v-for="tag in selectedTagsList" :key="tag.id" type="button" class="batch-tag-chip is-selected"
- :title="tag.name" @click="toggleTag(tag.id)">
- {{ tag.name }}
- </button>
- </div>
- <p v-else class="batch-tag-section-empty">{{ $t('knowledgeBase.batchTagNoSelected') }}</p>
- </section>
-
- <section class="setting-drawer__section">
- <div class="batch-tag-section-head">
- <h4 class="setting-drawer__section-title">{{ $t('knowledgeBase.batchTagAvailableSection') }}</h4>
- <t-button
- v-if="canManage"
- variant="text"
- size="small"
- theme="default"
- class="batch-tag-manage-link"
- @click="handleOpenManage"
- >
- {{ $t('knowledgeBase.tagManageLink') }}
- </t-button>
- </div>
- <div class="batch-tag-search-bar">
- <t-input v-model="searchQuery" :placeholder="$t('knowledgeBase.tagEditSearch')" clearable size="small">
- <template #prefix-icon>
- <t-icon name="search" size="14px" />
- </template>
- </t-input>
- </div>
- <div v-if="availableTagsList.length > 0" class="batch-tag-chips">
- <button v-for="tag in availableTagsList" :key="tag.id" type="button" class="batch-tag-chip"
- :title="tag.knowledge_count !== undefined ? `${tag.name} (${tag.knowledge_count})` : tag.name"
- @click="toggleTag(tag.id)">
- {{ tag.name }}
- </button>
- </div>
- <div v-else class="batch-tag-section-empty batch-tag-section-empty--row">
- <span>{{ searchQuery.trim() ? $t('knowledgeBase.tagEmptyResult') : $t('knowledgeBase.noTags') }}</span>
- <t-button v-if="searchQuery.trim()" variant="text" theme="default" size="small" :loading="creatingTag"
- @click="handleCreateTag">
- {{ $t('knowledgeBase.tagCreateAction') }} "{{ searchQuery.trim() }}"
- </t-button>
- </div>
- <div class="batch-tag-create-row">
- <t-input v-model="newTagName" :placeholder="$t('knowledgeBase.tagNewPlaceholder')" size="small"
- :maxlength="40" :disabled="creatingTag" @enter="handleAddNewTag" />
- </div>
- </section>
- </div>
+ <KnowledgeTagPicker v-if="visible" :kb-id="kbId" :selected-ids="selectedIds"
+ @update:selected-ids="selectedIds = $event" @changed="emit('tags-changed', $event)" @busy-change="tagBusy = $event" />
<div class="batch-tag-footer">
<span class="batch-tag-selected-count">
- {{ $t('knowledgeBase.tagSelectedCount', { count: selectedSet.size }) }}
+ {{ $t('knowledgeBase.tagSelectedCount', { count: selectedIds.length }) }}
</span>
<div class="batch-tag-footer-right">
<t-button variant="outline" size="small" :disabled="confirmLoading" @click="handleClose">
{{ $t('common.cancel') }}
</t-button>
- <t-button theme="primary" size="small" :loading="confirmLoading" @click="handleConfirm">
+ <t-button theme="primary" size="small" :loading="confirmLoading" :disabled="tagBusy" @click="handleConfirm">
{{ $t('common.confirm') }}
</t-button>
</div>
@@ -87,60 +31,35 @@
</template>
<script setup lang="ts">
-import { useI18n } from 'vue-i18n';
-import { MessagePlugin } from 'tdesign-vue-next';
-import { createKnowledgeBaseTag } from '@/api/knowledge-base';
-
-import { useKnowledgeTagSelection, type KnowledgeTag as Tag } from '@/composables/useKnowledgeTagSelection';
+import { ref, watch } from 'vue';
+import KnowledgeTagPicker from './KnowledgeTagPicker.vue';
const props = defineProps<{
visible: boolean;
count: number;
kbId: string;
- tagList: Tag[];
preSelectedTagIds?: string[];
- canManage?: boolean;
confirmLoading?: boolean;
}>();
-
const emit = defineEmits<{
(e: 'update:visible', value: boolean): void;
(e: 'confirm', tagIds: string[]): void;
- (e: 'tag-created'): void;
- (e: 'open-manage'): void;
+ (e: 'tags-changed', payload?: { deletedTagId?: string }): void;
}>();
-
-const { t } = useI18n();
-
-const {
- searchQuery, newTagName, selectedSet, creatingTag, selectedTagsList, availableTagsList,
- toggleTag, clearAll, handleCreateTag, handleAddNewTag,
-} = useKnowledgeTagSelection({
- visible: () => props.visible,
- kbId: () => props.kbId,
- tags: () => props.tagList,
- selectedIds: () => props.preSelectedTagIds ?? [],
- createTag: createKnowledgeBaseTag,
- onCreated: () => {
- emit('tag-created');
- MessagePlugin.success(t('knowledgeBase.tagCreateSuccess'));
- },
- onError: (error: any) => MessagePlugin.error(error?.message || t('common.operationFailed')),
-});
+const selectedIds = ref<string[]>([]);
+const tagBusy = ref(false);
+watch(() => props.visible, visible => {
+ if (visible) selectedIds.value = [...(props.preSelectedTagIds ?? [])];
+}, { immediate: true });
function handleConfirm() {
- if (props.confirmLoading) return;
- emit('confirm', Array.from(selectedSet.value));
+ if (props.confirmLoading || tagBusy.value) return;
+ emit('confirm', [...selectedIds.value]);
}
-
function handleClose() {
+ if (props.confirmLoading || tagBusy.value) return;
emit('update:visible', false);
}
-
-function handleOpenManage() {
- emit('update:visible', false);
- emit('open-manage');
-}
</script>
<style>
@@ -222,200 +141,6 @@ function handleOpenManage() {
white-space: nowrap;
}
-.batch-tag-body {
- display: flex;
- flex-direction: column;
- margin-top: 16px;
-}
-
-.batch-tag-body .setting-drawer__section {
- padding: 12px 0 16px;
- border-bottom: 1px solid var(--td-component-stroke);
- display: flex;
- flex-direction: column;
- gap: 10px;
-}
-
-.batch-tag-body .setting-drawer__section:first-child {
- padding-top: 0;
-}
-
-.batch-tag-body .setting-drawer__section:last-child {
- border-bottom: none;
- padding-bottom: 0;
-}
-
-.batch-tag-body .setting-drawer__section-title {
- font-size: var(--app-text-md);
- font-weight: 600;
- color: var(--td-text-color-primary);
- margin: 0 0 4px;
- user-select: none;
- display: flex;
- align-items: center;
- gap: 8px;
-}
-
-.batch-tag-body .setting-drawer__section-title::before {
- content: '';
- width: 3px;
- height: 14px;
- background: var(--td-brand-color);
- border-radius: 2px;
- flex-shrink: 0;
-}
-
-.batch-tag-section-head {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 8px;
-}
-
-.batch-tag-section-head .setting-drawer__section-title {
- margin-bottom: 0;
- flex: 1;
- min-width: 0;
-}
-
-.batch-tag-section-head :deep(.t-button) {
- height: auto;
- padding: 0;
- font-size: var(--app-text-sm);
- color: var(--td-text-color-placeholder);
- flex-shrink: 0;
- border: none !important;
- background: transparent !important;
- box-shadow: none !important;
- transition: color var(--app-motion-fast) ease;
-}
-
-.batch-tag-section-head :deep(.batch-tag-manage-link.t-button:hover),
-.batch-tag-section-head :deep(.batch-tag-manage-link.t-button:focus-visible) {
- color: var(--td-brand-color) !important;
- background: transparent !important;
- border-color: transparent !important;
- text-decoration: none;
-}
-
-.batch-tag-search-bar {
- margin: 0;
-}
-
-.batch-tag-search-bar :deep(.t-input) {
- font-size: var(--app-text-sm);
- background-color: var(--td-bg-color-secondarycontainer);
- border-color: transparent;
- border-radius: var(--app-radius-xs);
- box-shadow: none !important;
-}
-
-.batch-tag-search-bar :deep(.t-input:hover),
-.batch-tag-search-bar :deep(.t-input.t-is-focused) {
- border-color: var(--td-component-border);
- background-color: var(--td-bg-color-container);
- box-shadow: none !important;
-}
-
-.batch-tag-chips {
- display: flex;
- flex-wrap: wrap;
- gap: 6px;
- max-height: min(120px, 24vh);
- overflow-y: auto;
- scrollbar-width: thin;
-}
-
-.batch-tag-chips::-webkit-scrollbar {
- width: 4px;
-}
-
-.batch-tag-chips::-webkit-scrollbar-thumb {
- border-radius: 2px;
- background: var(--td-scrollbar-color);
-}
-
-.batch-tag-chip {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- max-width: 100%;
- height: 22px;
- padding: 0 8px;
- border: 1px solid var(--td-component-stroke);
- border-radius: var(--app-radius-xs);
- background: transparent;
- color: var(--td-text-color-secondary);
- font-family: var(--app-font-family);
- font-size: var(--app-text-xs);
- line-height: 22px;
- text-align: center;
- cursor: pointer;
- outline: none;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- transition: border-color var(--app-motion-fast) ease, background var(--app-motion-fast) ease, color var(--app-motion-fast) ease;
- -webkit-font-smoothing: antialiased;
-}
-
-.batch-tag-chip:hover {
- border-color: var(--td-component-stroke);
- background: var(--td-bg-color-secondarycontainer);
- color: var(--td-text-color-primary);
-}
-
-.batch-tag-chip:focus-visible {
- box-shadow: 0 0 0 2px color-mix(in srgb, var(--td-component-stroke) 60%, transparent);
-}
-
-.batch-tag-chip.is-selected {
- border-color: transparent;
- background: var(--td-bg-color-secondarycontainer);
- color: var(--td-text-color-primary);
- font-weight: 500;
-}
-
-.batch-tag-chip.is-selected:hover {
- background: color-mix(in srgb, var(--td-bg-color-secondarycontainer) 70%, var(--td-bg-color-container));
-}
-
-.batch-tag-section-empty {
- margin: 0;
- min-height: 22px;
- font-size: var(--app-text-sm);
- line-height: 22px;
- color: var(--td-text-color-placeholder);
-}
-
-.batch-tag-section-empty--row {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 8px;
-}
-
-.batch-tag-create-row {
- margin-top: 0;
-}
-
-.batch-tag-create-row :deep(.t-input) {
- font-size: var(--app-text-sm);
- background-color: transparent;
- border-style: dashed;
- border-color: var(--td-component-stroke);
- border-radius: var(--app-radius-xs);
- box-shadow: none !important;
-}
-
-.batch-tag-create-row :deep(.t-input:hover),
-.batch-tag-create-row :deep(.t-input.t-is-focused) {
- border-color: var(--td-component-border);
- border-style: dashed;
- background-color: var(--td-bg-color-secondarycontainer);
- box-shadow: none !important;
-}
-
.batch-tag-footer {
display: flex;
align-items: center;
diff --git a/frontend/src/views/knowledge/components/DocumentActionMenu.vue b/frontend/src/views/knowledge/components/DocumentActionMenu.vue
index 1aaffcda8..30d492e53 100644
--- a/frontend/src/views/knowledge/components/DocumentActionMenu.vue
+++ b/frontend/src/views/knowledge/components/DocumentActionMenu.vue
@@ -1,6 +1,5 @@
<script setup lang="ts">
import { computed } from 'vue';
-import { useI18n } from 'vue-i18n';
interface KnowledgeItem {
id: string;
@@ -31,7 +30,6 @@ const emit = defineEmits<{
(e: 'delete'): void;
}>();
-const { t } = useI18n();
const CANCELABLE_PARSE_STATUSES = new Set(['pending', 'processing', 'finalizing']);
@@ -130,14 +128,16 @@ const fileName = computed(() => props.item.file_name || props.item.title || prop
.doc-action-menu-item {
display: flex;
align-items: center;
- gap: 10px;
- padding: 8px 12px;
+ gap: 8px;
+ padding: 6px 10px;
+ font-family: var(--app-font-family);
font-size: var(--app-text-base);
+ font-weight: 400;
line-height: 20px;
color: var(--td-text-color-primary);
cursor: pointer;
- border-radius: var(--app-radius-sm);
- transition: background-color var(--app-motion-fast) cubic-bezier(0.2, 0, 0, 1), transform var(--app-motion-instant) ease;
+ border-radius: var(--app-radius-xs);
+ transition: background-color var(--app-motion-fast) cubic-bezier(0.2, 0, 0, 1);
&:hover {
background: var(--td-bg-color-container-hover);
@@ -145,11 +145,10 @@ const fileName = computed(() => props.item.file_name || props.item.title || prop
&:active {
background: var(--td-bg-color-container-active);
- transform: scale(0.98);
}
.icon {
- font-size: var(--app-text-xl);
+ font-size: var(--app-text-2xl);
color: var(--td-text-color-secondary);
transition: color var(--app-motion-fast) ease;
}
diff --git a/frontend/src/views/knowledge/components/DocumentBatchBar.vue b/frontend/src/views/knowledge/components/DocumentBatchBar.vue
index 824f82f0f..86cd9803d 100644
--- a/frontend/src/views/knowledge/components/DocumentBatchBar.vue
+++ b/frontend/src/views/knowledge/components/DocumentBatchBar.vue
@@ -75,7 +75,7 @@ const folderPickerVisible = ref(false);
<t-button v-if="canMutate" theme="default" variant="outline" size="small"
:disabled="count === 0 || deleteLoading || reparseLoading || tagLoading || downloadLoading" :loading="tagLoading"
@click="emit('batchTag')">
- <template #icon><t-icon name="discount" size="14px" /></template>
+ <template #icon><t-icon name="tag" size="14px" /></template>
{{ t('knowledgeBase.batchTag') }}
</t-button>
@@ -135,11 +135,11 @@ const folderPickerVisible = ref(false);
.batch-bar-left {
display: flex;
- flex-wrap: wrap;
+ flex-wrap: nowrap;
align-items: center;
gap: 4px;
min-width: 0;
- flex: 1;
+ flex: 0 0 auto;
}
.batch-bar-count {
@@ -157,12 +157,13 @@ const folderPickerVisible = ref(false);
color: var(--td-text-color-secondary) !important;
&:hover {
- color: var(--td-brand-color) !important;
+ color: var(--td-text-color-primary) !important;
}
}
.batch-bar-actions {
- flex-shrink: 0;
+ flex: 1 1 auto;
+ min-width: 0;
display: flex;
flex-wrap: wrap;
align-items: center;
@@ -170,6 +171,8 @@ const folderPickerVisible = ref(false);
gap: 8px;
}
+.batch-bar-actions > * { flex-shrink: 0; }
+
.batch-download-trigger {
display: inline-flex;
}
diff --git a/frontend/src/views/knowledge/components/DocumentCardView.vue b/frontend/src/views/knowledge/components/DocumentCardView.vue
index a99f529d6..d839d6400 100644
--- a/frontend/src/views/knowledge/components/DocumentCardView.vue
+++ b/frontend/src/views/knowledge/components/DocumentCardView.vue
@@ -2,17 +2,13 @@
import { ref, computed, nextTick, onBeforeUnmount, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { formatFileSize } from '@/utils/files';
-import { useTagChipsOverflow } from '@/composables/useTagChipsOverflow';
+import { formatReferenceSnippet } from '@/utils/referenceSources';
+import KnowledgeTagPopover from './KnowledgeTagPopover.vue';
+import DocumentFileIcon from './DocumentFileIcon.vue';
import DocumentActionMenu from './DocumentActionMenu.vue';
import FolderPickerMenu, { type FolderOption } from './FolderPickerMenu.vue';
import KnowledgeProcessingTimeline from '@/components/knowledge-processing-timeline.vue';
-interface Tag {
- id: string;
- name: string;
- color?: string;
-}
-
interface KnowledgeCard {
id: string;
knowledge_base_id?: string;
@@ -39,15 +35,13 @@ interface KnowledgeCard {
const props = defineProps<{
items: KnowledgeCard[];
+ kbId: string;
selectedIds: Set<string>;
batchMode: boolean;
canEdit: boolean;
canDownload: boolean;
canMutateKnowledge: boolean;
traceAvailableById: Record<string, boolean>;
- tagList: Tag[];
- /** Sub-folders of the folder currently being browsed. */
- folders?: Array<{ path: string; name: string; total_count: number }>;
/** Every folder of the knowledge base, for the "move to folder" picker. */
folderOptions?: FolderOption[];
/**
@@ -69,7 +63,7 @@ const emit = defineEmits<{
(e: 'toggle-checkbox', id: string, checked: boolean, ctx?: { e?: Event }): void;
(e: 'menu-visible-change', visible: boolean, item: KnowledgeCard): void;
(e: 'action', action: 'download' | 'edit' | 'view-trace' | 'reparse' | 'cancel-parse' | 'move' | 'move-folder' | 'batch-manage' | 'delete', item: KnowledgeCard): void;
- (e: 'tag-edit', item: KnowledgeCard): void;
+ (e: 'tags-changed', payload?: { deletedTagId?: string }): void;
(e: 'open-folder', path: string): void;
(e: 'move-to-folder', item: KnowledgeCard, folderPath: string): void;
// Move sub-flow emits
@@ -80,13 +74,8 @@ const emit = defineEmits<{
}>();
const { t } = useI18n();
-
-const {
- setupTagChipsObserver,
- getTagLimit,
- hasTagOverflow,
- getOverflowCount,
-} = useTagChipsOverflow('tagItemId');
+const tagEditorId = ref<string | null>(null);
+const cardSummaries = computed(() => new Map(props.items.map(item => [item.id, formatReferenceSnippet(item.description)])));
// Which row's action popup is currently showing the folder picker. Kept local so
// picking a folder stays inside the menu the user already opened, exactly like
@@ -95,11 +84,16 @@ const folderPickerItemId = ref<string | null>(null);
// --- Menu index tracking ---
const activeMenuIndex = ref(-1);
-const openMenu = (index: number) => {
- activeMenuIndex.value = index;
-};
-const onMenuVisibleChange = (visible: boolean, item: KnowledgeCard) => {
- if (!visible) {
+const onMenuVisibleChange = (visible: boolean, item: KnowledgeCard, index: number) => {
+ // Let the popup own the trigger click. Opening it in the button's click
+ // handler makes the popup interpret that same click as a request to close.
+ if (visible) {
+ dismissCardPopover();
+ if (activeMenuIndex.value !== index) folderPickerItemId.value = null;
+ activeMenuIndex.value = index;
+ } else {
+ // Closing the previous card must not dismiss a newly opened card's menu.
+ if (activeMenuIndex.value !== index) return;
activeMenuIndex.value = -1;
folderPickerItemId.value = null;
}
@@ -173,6 +167,7 @@ const onCardClick = (item: KnowledgeCard) => {
emit('toggle-checkbox', item.id, !props.selectedIds.has(item.id));
return;
}
+ dismissCardPopover();
emit('open', item);
};
@@ -182,7 +177,7 @@ const cardPopoverPos = ref({ x: 0, y: 0 });
const CARD_POPOVER_OFFSET = 12;
const CARD_POPOVER_ESTIMATED_WIDTH = 360;
const CARD_POPOVER_ESTIMATED_HEIGHT = 300;
-const cardHoverShowDelay = 300;
+const cardHoverShowDelay = 650;
let cardHoverTimer: ReturnType<typeof setTimeout> | null = null;
let cardPopoverElement: HTMLElement | null = null;
@@ -252,6 +247,7 @@ const calculatePopoverPositionFromCard = (cardElement: HTMLElement): { x: number
};
const onCardMouseEnter = (ev: MouseEvent, item: KnowledgeCard) => {
+ if (props.batchMode || activeMenuIndex.value !== -1) return;
if (cardHoverTimer) {
clearTimeout(cardHoverTimer);
cardHoverTimer = null;
@@ -298,6 +294,14 @@ const onFolderPicked = (item: KnowledgeCard, path: string) => {
emit('move-to-folder', item, path);
};
+const editTags = (item: KnowledgeCard) => {
+ dismissCardPopover();
+ activeMenuIndex.value = -1;
+ item.isMore = false;
+ emit('menu-visible-change', false, item);
+ tagEditorId.value = item.id;
+};
+
// --- Action handlers ---
const handleAction = (action: 'download' | 'edit' | 'view-trace' | 'reparse' | 'cancel-parse' | 'move' | 'move-folder' | 'batch-manage' | 'delete', item: KnowledgeCard) => {
// The folder picker opens inside this same popup, so keep the menu open.
@@ -316,26 +320,8 @@ const handleAction = (action: 'download' | 'edit' | 'view-trace' | 'reparse' | '
<template>
<div class="doc-card-view">
- <div class="doc-card-list doc-card-list-animated">
- <div
- v-for="folder in folders"
- :key="'folder-' + folder.path"
- class="folder-card"
- :title="folder.path"
- role="button"
- tabindex="0"
- @click="onOpenFolder(folder.path)"
- @keydown.enter="onOpenFolder(folder.path)"
- >
- <div class="folder-card__body">
- <t-icon name="folder" class="folder-card__icon" />
- <span class="folder-card__title">{{ folder.name }}</span>
- </div>
- <div class="folder-card__footer">
- {{ t('knowledgeBase.folderTree.folderCardCount', { count: folder.total_count }) }}
- </div>
- </div>
+ <div class="doc-card-list doc-card-list-animated">
<div
class="knowledge-card"
:class="{ 'is-selected': selectedIds.has(item.id), 'batch-mode': batchMode }"
@@ -343,38 +329,44 @@ const handleAction = (action: 'download' | 'edit' | 'view-trace' | 'reparse' | '
v-for="(item, index) in items"
:key="item.id"
@click="onCardClick(item)"
- @mouseenter="onCardMouseEnter($event, item)"
- @mouseleave="onCardMouseLeave"
>
<div class="card-content">
<div class="card-content-nav">
+ <div class="card-file-icon">
+ <DocumentFileIcon :source-type="item.type"
+ :file-name="item.file_type ? `document.${item.file_type.toLowerCase()}` : (item.original_file_name || item.file_name || '')" />
+ </div>
+ <button type="button" class="card-content-title" :title="item.file_name"
+ @click.stop="onCardClick(item)">{{ item.file_name }}</button>
<div v-if="(canEdit || canDownload) && batchMode" class="card-nav-check" @click.stop>
<t-checkbox
class="card-select-checkbox"
size="small"
:checked="selectedIds.has(item.id)"
+ :aria-label="item.file_name"
:title="item.file_name"
@change="(checked: boolean, ctx?: { e?: Event }) => emit('toggle-checkbox', item.id, checked, ctx)"
/>
</div>
- <span class="card-content-title" :title="item.file_name">{{ item.file_name }}</span>
<t-popup
- v-if="canEdit"
- v-model="item.isMore"
+ v-else-if="canEdit"
+ :visible="activeMenuIndex === index"
overlayClassName="card-more"
- :on-visible-change="(v: boolean) => onMenuVisibleChange(v, item)"
+ :on-visible-change="(v: boolean) => onMenuVisibleChange(v, item, index)"
trigger="click"
destroy-on-close
placement="bottom-right"
>
- <div
- variant="outline"
+ <button
+ type="button"
+ :aria-label="`${item.file_name} · ${t('knowledgeBase.columnActions')}`"
+ :aria-expanded="activeMenuIndex === index"
class="more-wrap"
- @click.stop="openMenu(index)"
+ @click.stop
:class="[activeMenuIndex === index ? 'active-more' : '']"
>
- <img class="more-icon" src="@/assets/img/more.png" alt="" />
- </div>
+ <t-icon name="more" size="18px" />
+ </button>
<template #content>
<!-- Move: folder picker (must win over the normal menu while open) -->
<div v-if="folderPickerItemId === item.id" class="card-menu move-menu">
@@ -389,11 +381,16 @@ const handleAction = (action: 'download' | 'edit' | 'view-trace' | 'reparse' | '
<!-- Normal menu -->
<div v-else-if="moveMenuMode === 'normal'" class="card-menu">
+ <button type="button" class="card-menu-item card-tag-menu-action" @click.stop="editTags(item)">
+ <t-icon class="icon" name="tag" />
+ <span>{{ t('knowledgeBase.tagEditDialogHeading') }}</span>
+ </button>
<DocumentActionMenu
:item="item"
:can-download="canDownload"
:can-mutate-knowledge="canMutateKnowledge"
:trace-visible="isTraceMenuVisible(item)"
+ :folders-available="Boolean(folderOptions?.length)"
@download="handleAction('download', item)"
@edit="handleAction('edit', item)"
@view-trace="handleAction('view-trace', item)"
@@ -479,6 +476,7 @@ const handleAction = (action: 'download' | 'edit' | 'view-trace' | 'reparse' | '
</t-popup>
</div>
+ <div class="card-preview" @mouseenter="onCardMouseEnter($event, item)" @mouseleave="onCardMouseLeave">
<!-- Parse status display -->
<div v-if="isParseInFlight(item.parse_status)" class="card-analyze card-analyze-trace">
<t-icon name="loading" class="card-analyze-loading"></t-icon>
@@ -533,87 +531,46 @@ const handleAction = (action: 'download' | 'edit' | 'view-trace' | 'reparse' | '
<t-icon name="loading" class="card-analyze-loading"></t-icon>
<span class="card-analyze-txt">{{ $t('knowledgeBase.generatingSummary') }}</span>
</div>
- <div v-else-if="item.parse_status === 'completed'" class="card-content-txt">
- {{ item.description }}
+ <div v-else-if="item.parse_status === 'cancelled'" class="card-analyze card-cancelled">
+ <t-icon name="stop-circle" />
+ <span>{{ t('knowledgeBase.statusCancelled') }}</span>
+ </div>
+ <div v-else class="card-content-txt" :class="{ 'is-empty': !cardSummaries.get(item.id) }">
+ {{ cardSummaries.get(item.id) || t('knowledgeBase.noDocumentSummary') }}
+ </div>
</div>
</div>
+ <KnowledgeTagPopover :kb-id="kbId" :knowledge-id="item.id" :tags="item.tags || []" :disabled="!canEdit"
+ :visible="tagEditorId === item.id"
+ @update:visible="(visible: boolean) => { if (visible) tagEditorId = item.id; else if (tagEditorId === item.id) tagEditorId = null }"
+ @changed="emit('tags-changed', $event)">
+ <div class="card-tags">
+ <template v-if="item.tags?.length">
+ <button v-for="tag in item.tags.slice(0, 3)" :key="tag.id" type="button" class="card-tag-chip"
+ :disabled="!canEdit" :title="tag.name">{{ tag.name }}</button>
+ <button v-if="item.tags.length > 3" type="button" class="card-tag-overflow" :disabled="!canEdit"
+ :title="item.tags.slice(3).map(tag => tag.name).join('、')">+{{ item.tags.length - 3 }}</button>
+ </template>
+ <button v-else-if="canEdit" type="button" class="card-tag-add">
+ <t-icon name="add" size="12px" />{{ t('knowledgeBase.tagAddAction') }}
+ </button>
+ </div>
+ </KnowledgeTagPopover>
+
<div class="card-bottom">
<button v-if="showFolderPath && item.folder_path" type="button" class="card-folder"
- :title="item.folder_path" @click.stop="emit('open-folder', item.folder_path)">
+ :title="item.folder_path" @click.stop="onOpenFolder(item.folder_path)">
<t-icon name="folder" />
<span>{{ item.folder_path }}</span>
</button>
- <span v-else class="card-time">{{ formatDocTime(item.updated_at) }}</span>
- <div class="card-bottom-right">
- <div v-if="tagList.length" class="card-tag-selector" @click.stop>
- <!-- Editable mode -->
- <template v-if="canEdit">
- <template v-if="(item.tags || []).length > 0">
- <t-tooltip
- v-if="hasTagOverflow(item.id, (item.tags || []).length)"
- :content="(item.tags || []).map((t: any) => t.name).join(', ')"
- placement="top"
- >
- <div
- class="card-tag-chips"
- :ref="(el: any) => setupTagChipsObserver(el, item.id, (item.tags || []).length)"
- @click="emit('tag-edit', item)"
- >
- <t-tag v-for="tag in (item.tags || []).slice(0, getTagLimit(item.id))" :key="tag.id" size="small" variant="light-outline" class="card-tag-chip">
- <span class="tag-text">{{ tag.name }}</span>
- </t-tag>
- <span class="card-tag-overflow">+{{ getOverflowCount(item.id, (item.tags || []).length) }}</span>
- </div>
- </t-tooltip>
- <div
- v-else
- class="card-tag-chips"
- :ref="(el: any) => setupTagChipsObserver(el, item.id, (item.tags || []).length)"
- @click="emit('tag-edit', item)"
- >
- <t-tag v-for="tag in (item.tags || []).slice(0, getTagLimit(item.id))" :key="tag.id" size="small" variant="light-outline" class="card-tag-chip">
- <span class="tag-text">{{ tag.name }}</span>
- </t-tag>
- </div>
- </template>
- <span v-else class="card-tag-add" @click="emit('tag-edit', item)">
- <t-icon name="add" size="12px" />
- <span>{{ $t('knowledgeBase.tagLabel') }}</span>
- </span>
- </template>
- <!-- Read-only mode -->
- <template v-else-if="(item.tags || []).length > 0">
- <t-tooltip
- v-if="hasTagOverflow(item.id, (item.tags || []).length)"
- :content="(item.tags || []).map((t: any) => t.name).join(', ')"
- placement="top"
- >
- <div
- class="card-tag-chips"
- :ref="(el: any) => setupTagChipsObserver(el, item.id, (item.tags || []).length)"
- >
- <t-tag v-for="tag in (item.tags || []).slice(0, getTagLimit(item.id))" :key="tag.id" size="small" variant="light-outline" class="card-tag-chip">
- <span class="tag-text">{{ tag.name }}</span>
- </t-tag>
- <span class="card-tag-overflow">+{{ getOverflowCount(item.id, (item.tags || []).length) }}</span>
- </div>
- </t-tooltip>
- <div
- v-else
- class="card-tag-chips"
- :ref="(el: any) => setupTagChipsObserver(el, item.id, (item.tags || []).length)"
- >
- <t-tag v-for="tag in (item.tags || []).slice(0, getTagLimit(item.id))" :key="tag.id" size="small" variant="light-outline" class="card-tag-chip">
- <span class="tag-text">{{ tag.name }}</span>
- </t-tag>
- </div>
- </template>
- </div>
- <div class="card-type">
- <span>{{ getKnowledgeType(item) }}</span>
- </div>
- </div>
+ <span v-else class="card-time" :title="t('knowledgeBase.columnUpdatedAt')">{{ formatDocTime(item.updated_at) }}</span>
+ <span class="card-type">
+ {{ getKnowledgeType(item) }}
+ <template v-if="item.type !== 'manual' && item.type !== 'url' && Number(item.file_size) > 0">
+ <span class="card-meta-separator">·</span>{{ formatFileSize(Number(item.file_size)) }}
+ </template>
+ </span>
</div>
</div>
</div>
@@ -648,7 +605,7 @@ const handleAction = (action: 'download' | 'edit' | 'view-trace' | 'reparse' | '
{{ $t('knowledgeBase.draft') }}
</div>
<template v-else>
- <div v-if="hoveredCardItem.description" class="card-popover-desc">{{ hoveredCardItem.description }}</div>
+ <div v-if="cardSummaries.get(hoveredCardItem.id)" class="card-popover-desc">{{ cardSummaries.get(hoveredCardItem.id) }}</div>
<div v-if="(hoveredCardItem as any).source" class="card-popover-source" :title="(hoveredCardItem as any).source">
<t-icon name="link" size="12px" /> {{ (hoveredCardItem as any).source }}
</div>
@@ -694,272 +651,115 @@ const handleAction = (action: 'download' | 'edit' | 'view-trace' | 'reparse' | '
.doc-card-view {
width: 100%;
+ padding-top: 12px;
}
.doc-card-list {
- box-sizing: border-box;
display: grid;
- grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
- gap: 12px;
- align-content: flex-start;
+ grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
+ gap: 10px;
width: 100%;
-
- &.doc-card-list-animated {
- animation: contentFadeIn 0.32s ease-out;
- }
-}
-
-.folder-card {
- min-width: 240px;
- height: 136px;
- box-sizing: border-box;
- display: flex;
- flex-direction: column;
- border: 1px solid var(--td-component-border);
- border-radius: var(--app-radius-md);
- overflow: hidden;
- background: var(--td-bg-color-container);
- box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
- cursor: pointer;
- transition: border-color var(--app-motion-base) ease, box-shadow var(--app-motion-base) ease, background-color var(--app-motion-base) ease;
-
- &:hover {
- border-color: color-mix(in srgb, var(--td-component-stroke) 55%, var(--td-brand-color));
- box-shadow: 0 4px 14px rgba(0, 0, 0, 0.07);
- }
-
- &:focus-visible {
- outline: none;
- box-shadow: 0 0 0 2px color-mix(in srgb, var(--td-brand-color) 30%, transparent);
- }
-}
-
-.folder-card__body {
- flex: 1;
- min-height: 0;
- display: flex;
- flex-direction: column;
- justify-content: flex-start;
- gap: 8px;
- padding: 12px 14px 10px;
- overflow: hidden;
-}
-
-.folder-card__icon {
- flex-shrink: 0;
- font-size: 28px;
- line-height: 1;
- color: var(--td-brand-color);
- opacity: 0.88;
-}
-
-.folder-card__title {
- flex: 1;
- min-height: 0;
- font-size: var(--app-text-base);
- font-weight: 500;
- line-height: 20px;
- max-height: 40px;
- color: var(--td-text-color-primary);
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow: hidden;
- word-break: break-all;
-}
-
-.folder-card__footer {
- flex-shrink: 0;
- padding: 8px 14px;
- border-top: 1px solid var(--td-component-stroke);
- font-size: var(--app-text-sm);
- line-height: 1.4;
- color: var(--td-text-color-placeholder);
+ &.doc-card-list-animated { animation: contentFadeIn 0.32s ease-out; }
}
.knowledge-card {
- min-width: 240px;
+ min-width: 0;
+ height: 164px;
display: flex;
flex-direction: column;
- border: 1px solid var(--td-component-border);
- height: 136px;
- border-radius: var(--app-radius-md);
- overflow: hidden;
+ padding: 10px;
box-sizing: border-box;
- box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
+ border: 1px solid var(--td-component-stroke);
+ border-radius: var(--app-radius-md);
background: var(--td-bg-color-container);
- position: relative;
cursor: pointer;
- transition: border-color var(--app-motion-base) ease, box-shadow var(--app-motion-base) ease, background-color var(--app-motion-base) ease;
-
+ transition: border-color var(--app-motion-base) ease, box-shadow var(--app-motion-base) ease;
&:hover {
- border-color: color-mix(in srgb, var(--td-component-stroke) 55%, var(--td-brand-color));
- box-shadow: 0 4px 14px rgba(0, 0, 0, 0.07);
+ border-color: var(--app-selection-border);
+ box-shadow: 0 3px 12px rgba(0, 0, 0, 0.035);
}
- .card-nav-check {
- flex-shrink: 0;
- display: inline-flex;
- align-items: center;
- justify-content: center;
- width: 22px;
- height: 29px;
- margin-right: 8px;
- cursor: pointer;
-
- .card-select-checkbox {
- margin: 0;
- line-height: 0;
-
- :deep(.t-checkbox) { align-items: center; }
- :deep(.t-checkbox__label) { display: none !important; width: 0 !important; min-width: 0 !important; margin: 0 !important; padding: 0 !important; }
- :deep(.t-checkbox__input) { margin: 0; }
- :deep(.t-checkbox__input-wrapper) { margin: 0; }
- }
- }
+ &.is-selected { border-color: var(--app-selection-border); background: var(--td-bg-color-container); box-shadow: none; }
- .card-content {
+ .card-content { min-width: 0; }
+ .card-content-nav { display: flex; align-items: flex-start; gap: 8px; height: 40px; margin-bottom: 6px; }
+ .card-content-title {
flex: 1;
- min-height: 0;
- display: flex;
- flex-direction: column;
- padding: 10px 14px 8px;
- }
-
- .card-analyze {
- flex-shrink: 0;
- height: 52px;
- display: flex;
- align-items: flex-start;
- }
-
- .card-analyze-loading {
- display: block;
- color: var(--td-brand-color);
+ min-width: 0;
+ display: -webkit-box;
+ -webkit-box-orient: vertical;
+ -webkit-line-clamp: 2;
+ overflow: hidden;
+ overflow-wrap: anywhere;
+ padding: 0;
+ border: 0;
+ background: transparent;
+ color: var(--td-text-color-primary);
+ font: inherit;
font-size: var(--app-text-base);
- margin-top: 2px;
- }
-
- .card-analyze-txt {
- color: var(--td-brand-color);
- font-family: var(--app-font-family);
- font-size: var(--app-text-xs);
- margin-left: 8px;
- }
-
- .card-analyze-trace {
- height: auto;
- min-height: 0;
- align-items: center;
- gap: 2px;
- }
-
- .card-analyze-trace-link {
+ font-weight: 600;
+ line-height: 20px;
+ text-align: left;
cursor: pointer;
- &:hover { text-decoration: underline; }
}
-
- .card-analyze-trace-btn {
+ .more-wrap {
flex-shrink: 0;
- display: inline-flex;
+ display: flex;
align-items: center;
justify-content: center;
- margin: 0;
- padding: 2px;
- border: none;
+ width: 24px;
+ height: 24px;
+ margin: -3px -5px 0 0;
+ padding: 0;
+ border: 0;
+ border-radius: var(--app-radius-xs);
background: transparent;
- color: var(--td-brand-color);
+ color: var(--td-text-color-placeholder);
cursor: pointer;
- line-height: 1;
- border-radius: var(--app-radius-xs);
-
- :deep(.t-icon) { font-size: var(--app-text-base); }
- &:hover { background: var(--td-bg-color-component-hover); }
- }
-
- .card-analyze.failure .card-analyze-trace-btn { color: var(--td-error-color); }
-
- .failure { color: var(--td-error-color); }
-
- .card-content-nav {
- flex-shrink: 0;
- display: flex;
- align-items: flex-start;
- gap: 0;
- margin-bottom: 6px;
+ &:hover, &.active-more { background: var(--td-bg-color-component-hover); color: var(--td-text-color-primary); }
}
-
- .card-content-title {
- flex: 1;
- min-width: 0;
- height: 24px;
- line-height: 24px;
- display: inline-block;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- color: var(--td-text-color-primary);
- font-family: var(--app-font-family);
- font-size: var(--app-text-base);
- font-weight: 600;
- letter-spacing: 0.01em;
- margin-right: 8px;
+ .card-file-icon {
+ position: relative;
+ flex: 0 0 32px;
+ width: 32px;
+ height: 38px;
}
-
- .more-wrap {
+ .card-nav-check {
flex-shrink: 0;
display: flex;
- width: 25px;
- height: 25px;
- justify-content: center;
align-items: center;
- border-radius: 5px;
- cursor: pointer;
-
- &:hover { background: var(--td-component-stroke); }
+ justify-content: center;
+ width: 24px;
+ height: 24px;
+ margin: -3px -5px 0 0;
+ .card-select-checkbox { display: flex; margin: 0; padding: 0; line-height: 1; }
+ :deep(.t-checkbox__label) { display: none; }
}
-
- .more-icon { width: 14px; height: 14px; }
- .active-more { background: var(--td-component-stroke); }
-
+ .card-preview { height: 40px; }
.card-content-txt {
- flex: 1;
- min-height: 0;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
- line-clamp: 2;
overflow: hidden;
+ overflow-wrap: anywhere;
color: var(--td-text-color-secondary);
- font-family: var(--app-font-family);
font-size: var(--app-text-sm);
- font-weight: 400;
- line-height: 19px;
+ line-height: 20px;
+ &.is-empty { color: var(--td-text-color-placeholder); }
}
-
.card-bottom {
- flex-shrink: 0;
- margin-top: auto;
- padding: 0 14px;
- box-sizing: border-box;
- height: 32px;
- width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
- background: var(--td-bg-color-container);
- border-top: 1px solid var(--td-component-stroke);
- }
-
- .card-time {
- flex-shrink: 0;
- color: var(--td-text-color-secondary);
- font-family: var(--app-font-family);
- font-size: var(--app-text-sm);
- font-weight: 400;
- white-space: nowrap;
+ gap: 8px;
+ margin-top: auto;
+ color: var(--td-text-color-placeholder);
+ font-size: var(--app-text-xs);
+ line-height: 18px;
}
-
+ .card-time { flex-shrink: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
+ .card-type { display: flex; align-items: center; gap: 5px; min-width: 0; white-space: nowrap; }
+ .card-meta-separator { opacity: 0.6; }
.card-folder {
display: inline-flex;
align-items: center;
@@ -970,150 +770,81 @@ const handleAction = (action: 'download' | 'edit' | 'view-trace' | 'reparse' | '
border: 0;
background: transparent;
color: var(--td-text-color-secondary);
- font-family: var(--app-font-family);
- font-size: var(--app-text-sm);
+ font: inherit;
cursor: pointer;
- transition: color var(--app-motion-fast) ease;
-
- &:hover {
- color: var(--td-brand-color);
- }
-
- span {
- min-width: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
-
- .t-icon {
- flex: 0 0 auto;
- font-size: var(--app-text-md);
- }
- }
-
- .card-type {
- flex-shrink: 0;
- color: var(--td-text-color-placeholder);
- font-family: var(--app-font-family);
- font-size: var(--app-text-xs);
- font-weight: 500;
- padding: 0;
- background: transparent;
- letter-spacing: 0.02em;
+ &:hover { color: var(--td-brand-color); }
+ span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+ .t-icon { flex-shrink: 0; }
}
}
-.card-bottom-right {
- flex: 1 1 auto;
- min-width: 0;
+.card-tags {
display: flex;
- align-items: center;
- justify-content: flex-end;
- gap: 6px;
+ align-items: flex-start;
+ align-content: flex-start;
+ flex-wrap: nowrap;
+ gap: 5px;
+ height: 20px;
+ margin-top: 6px;
overflow: hidden;
-}
-
-// --- Card draft ---
-.card-draft {
- display: flex;
- align-items: center;
- gap: 8px;
- padding: 6px 0;
- flex-shrink: 0;
-}
-
-.card-draft-tip {
- color: var(--td-warning-color);
- font-size: var(--app-text-xs);
-}
-
-// --- Tag selector ---
-.card-tag-selector {
- display: flex;
- align-items: center;
-
- .card-tag-chips {
+ button {
display: inline-flex;
align-items: center;
gap: 4px;
- flex-wrap: nowrap;
- cursor: pointer;
- }
-
- .card-tag-overflow {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- height: 18px;
- min-width: 18px;
- padding: 0 5px;
- border-radius: var(--app-radius-pill);
+ max-width: min(90px, calc((100% - 40px) / 3));
+ height: 20px;
+ padding: 0 6px;
border: 1px solid var(--td-component-stroke);
- color: var(--td-text-color-placeholder);
- font-size: var(--app-text-2xs);
- line-height: 1;
- cursor: pointer;
- transition: all var(--app-motion-base) ease;
-
- &:hover {
- border-color: var(--td-brand-color);
- color: var(--td-brand-color);
- background: var(--td-bg-color-secondarycontainer);
- }
- }
-
- :deep(.t-tag) {
- cursor: pointer;
- max-width: 120px;
- height: 18px;
- line-height: 18px;
- border-radius: var(--app-radius-pill);
- border-color: var(--td-component-stroke);
+ border-radius: var(--app-radius-xs);
+ background: var(--td-bg-color-container);
color: var(--td-text-color-secondary);
- padding: 0 6px;
- background: transparent;
- transition: all var(--app-motion-base) ease;
-
- &:hover {
- border-color: var(--td-brand-color);
- color: var(--td-brand-color-active);
- background: var(--td-bg-color-secondarycontainer);
- }
- }
-
- .tag-text {
- display: inline-block;
- max-width: 80px;
+ font: inherit;
+ font-size: var(--app-text-xs);
+ line-height: 18px;
+ white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
- white-space: nowrap;
- vertical-align: middle;
- font-size: var(--app-text-xs);
- }
-
- .card-tag-add {
- display: inline-flex;
- align-items: center;
- gap: 2px;
- height: 18px;
- padding: 0 6px;
- border-radius: var(--app-radius-pill);
- border: 1px dashed var(--td-component-stroke);
- color: var(--td-text-color-placeholder);
- font-size: var(--app-text-xs);
cursor: pointer;
- transition: all var(--app-motion-base) ease;
-
- .t-icon { font-size: var(--app-text-sm); }
-
- &:hover {
- border-color: var(--td-brand-color);
- color: var(--td-brand-color-active);
- background: var(--td-bg-color-secondarycontainer);
- border-style: solid;
- }
+ &:disabled { cursor: default; }
+ &:not(:disabled):hover { color: var(--td-brand-color); border-color: var(--app-selection-border); background: var(--app-selection-bg); }
}
+ .card-tag-chip { display: block; }
+ .card-tag-add { max-width: none; border-style: dashed; color: var(--td-text-color-placeholder); background: transparent; }
+ .card-tag-overflow { flex-shrink: 0; }
+}
+.card-tag-menu-action { width: 100%; border: 0; background: transparent; font-family: inherit; text-align: left; }
+
+.card-analyze, .card-draft {
+ display: flex;
+ align-items: center;
+ gap: 7px;
+ min-height: 28px;
+ color: var(--td-brand-color);
+ font-size: var(--app-text-sm);
+}
+.card-analyze-loading { flex-shrink: 0; }
+.card-analyze-trace-link { cursor: pointer; &:hover { text-decoration: underline; } }
+.card-analyze-trace-btn {
+ display: inline-flex;
+ align-items: center;
+ padding: 3px;
+ border: 0;
+ border-radius: var(--app-radius-xs);
+ background: transparent;
+ color: inherit;
+ cursor: pointer;
+ &:hover { background: var(--td-bg-color-component-hover); }
+}
+.card-analyze.failure { color: var(--td-error-color); }
+.card-draft { color: var(--td-warning-color); }
+.card-cancelled { color: var(--td-text-color-placeholder); }
+.card-draft-tip { font-size: var(--app-text-xs); }
+.knowledge-card button:focus-visible {
+ outline: 2px solid var(--app-focus-border);
+ outline-offset: 3px;
+}
+@media (prefers-reduced-motion: reduce) {
+ .doc-card-list.doc-card-list-animated { animation: none; }
}
// --- Hover popover ---
diff --git a/frontend/src/views/knowledge/components/DocumentFileIcon.vue b/frontend/src/views/knowledge/components/DocumentFileIcon.vue
new file mode 100644
index 000000000..92a5a98d4
--- /dev/null
+++ b/frontend/src/views/knowledge/components/DocumentFileIcon.vue
@@ -0,0 +1,44 @@
+<template>
+ <span v-if="sourceType === 'manual' || sourceType === 'url'" class="document-source-icon"
+ :class="`document-source-icon--${sourceType}`" aria-hidden="true">
+ <svg viewBox="0 0 32 38" fill="none">
+ <path class="file-sheet" d="M6 1.5h13L28.5 11v22A3.5 3.5 0 0 1 25 36.5H6A3.5 3.5 0 0 1 2.5 33V5A3.5 3.5 0 0 1 6 1.5Z" />
+ <path class="file-fold" d="M19 1.5V8a3 3 0 0 0 3 3h6.5" />
+ <path class="file-lines" d="M8 14h9M8 18h14" />
+ </svg>
+ <span class="document-source-icon__badge"><t-icon :name="sourceType === 'manual' ? 'edit' : 'link'" size="13px" /></span>
+ </span>
+ <ArtifactFileIcon v-else :file-name="fileName" />
+</template>
+
+<script setup lang="ts">
+import ArtifactFileIcon from '@/views/chat/components/ArtifactFileIcon.vue';
+defineProps<{ sourceType?: string; fileName: string }>();
+</script>
+
+<style scoped lang="less">
+@import '@/components/css/artifact-file-icon.less';
+.document-source-icon {
+ position: relative;
+ display: inline-flex;
+ flex: 0 0 32px;
+ width: 32px;
+ height: 38px;
+ color: #7885ad;
+ &--url { color: #53978e; }
+ > svg { .artifact-file-icon-style(); color: inherit; }
+ &__badge {
+ position: absolute;
+ right: 1px;
+ bottom: 1px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 24px;
+ height: 16px;
+ border-radius: var(--app-radius-xs);
+ background: currentColor;
+ .t-icon { color: #fff; }
+ }
+}
+</style>
diff --git a/frontend/src/views/knowledge/components/DocumentListView.vue b/frontend/src/views/knowledge/components/DocumentListView.vue
index fdfdb4be6..7f0faefcc 100644
--- a/frontend/src/views/knowledge/components/DocumentListView.vue
+++ b/frontend/src/views/knowledge/components/DocumentListView.vue
@@ -1,8 +1,9 @@
<script setup lang="ts">
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n';
-import { formatFileSize, getFileIcon } from '@/utils/files';
-import { useTagChipsOverflow } from '@/composables/useTagChipsOverflow';
+import { formatFileSize } from '@/utils/files';
+import KnowledgeTagPopover from './KnowledgeTagPopover.vue';
+import DocumentFileIcon from './DocumentFileIcon.vue';
import DocumentActionMenu from './DocumentActionMenu.vue';
import FolderPickerMenu, { type FolderOption } from './FolderPickerMenu.vue';
@@ -15,6 +16,7 @@ interface Tag {
interface KnowledgeItem {
id: string;
file_name: string;
+ original_file_name?: string;
folder_path?: string;
file_type?: string;
file_size?: number | string;
@@ -31,15 +33,13 @@ interface KnowledgeItem {
const props = defineProps<{
items: KnowledgeItem[];
+ kbId: string;
selectedIds: Set<string>;
canEdit: boolean;
canDownload: boolean;
canMutateKnowledge: boolean;
traceVisibleIds: Record<string, boolean>;
- tagList: Tag[];
loading?: boolean;
- /** Sub-folders of the folder currently being browsed. */
- folders?: Array<{ path: string; name: string; total_count: number }>;
/** Every folder of the knowledge base, for the "move to folder" picker. */
folderOptions?: FolderOption[];
/**
@@ -63,7 +63,7 @@ const emit = defineEmits<{
(e: 'toggle-all', checked: boolean): void;
(e: 'action', action: 'download' | 'edit' | 'reparse' | 'cancel-parse' | 'move' | 'move-folder' | 'delete' | 'view-trace' | 'batch-manage', item: KnowledgeItem): void;
(e: 'probe-trace', item: KnowledgeItem): void;
- (e: 'tag-edit', item: KnowledgeItem): void;
+ (e: 'tags-changed', payload?: { deletedTagId?: string }): void;
(e: 'open-folder', path: string): void;
(e: 'move-to-folder', item: KnowledgeItem, folderPath: string): void;
// Move sub-flow emits
@@ -75,23 +75,7 @@ const emit = defineEmits<{
}>();
const { t } = useI18n();
-
-const {
- setupTagChipsObserver,
- getTagLimit,
- hasTagOverflow,
- getOverflowCount,
-} = useTagChipsOverflow('listTagItemId');
-
-const tagMap = computed(() => {
- const map: Record<string, Tag> = {};
- for (const tag of props.tagList) map[String(tag.id)] = tag;
- return map;
-});
-const getTagName = (tagId?: string | number) => {
- if (!tagId && tagId !== 0) return '';
- return tagMap.value[String(tagId)]?.name || '';
-};
+const tagEditorId = ref<string | null>(null);
const formatTime = (time?: string) => {
if (!time) return '--';
@@ -153,7 +137,7 @@ const computeStatus = (item: KnowledgeItem): StatusInfo => {
return { label: t('knowledgeBase.statusFailed'), theme: 'danger', icon: 'close-circle' };
}
if (item.parse_status === 'cancelled') {
- return { label: t('knowledgeBase.statusCancelled'), theme: 'warning', icon: 'close-circle' };
+ return { label: t('knowledgeBase.statusCancelled'), theme: 'default', icon: 'stop-circle' };
}
if (item.parse_status === 'draft') {
return { label: t('knowledgeBase.statusDraft'), theme: 'warning' };
@@ -197,6 +181,8 @@ const onRowCheckboxChange = (item: KnowledgeItem, checked: boolean, ctx?: { e?:
const moreOpen = ref<string | null>(null);
const onMoreVisible = (id: string, visible: boolean) => {
+ if (!visible && moreOpen.value !== id) return;
+ if (visible && moreOpen.value !== id) folderPickerItemId.value = null;
moreOpen.value = visible ? id : null;
if (visible) {
const it = props.items.find(i => i.id === id);
@@ -256,7 +242,7 @@ const handleAction = (action: 'download' | 'edit' | 'reparse' | 'cancel-parse' |
</script>
<template>
- <div class="doc-list-view" :class="{ 'is-loading': loading }">
+ <div class="doc-list-view" :class="{ 'is-loading': loading }" role="table" :aria-label="t('knowledgeEditor.document.title')">
<div ref="stickySentinel" class="doc-list-sticky-sentinel" aria-hidden="true"></div>
<div class="doc-list-header" :class="{ 'is-stuck': headerStuck }" role="row">
<div class="cell cell-check" role="columnheader" @click.stop>
@@ -264,106 +250,69 @@ const handleAction = (action: 'download' | 'edit' | 'reparse' | 'cancel-parse' |
:disabled="!items.length" :title="t('knowledgeBase.selectAll')" @change="onHeaderCheckboxChange" />
</div>
<div class="cell cell-name" role="columnheader">{{ t('knowledgeBase.columnName') }}</div>
- <div class="cell cell-tag" role="columnheader">{{ t('knowledgeBase.columnTag') }}</div>
- <div class="cell cell-source" role="columnheader">{{ t('knowledgeBase.columnSource') }}</div>
- <div class="cell cell-size" role="columnheader">{{ t('knowledgeBase.columnSize') }}</div>
+ <div class="cell cell-tags" role="columnheader">{{ t('knowledgeBase.columnTag') }}</div>
<div class="cell cell-status" role="columnheader">{{ t('knowledgeBase.columnStatus') }}</div>
- <div class="cell cell-time" role="columnheader">{{ t('knowledgeBase.columnUpdatedAt') }}</div>
<div class="cell cell-actions" role="columnheader" v-if="canEdit"></div>
</div>
- <div class="doc-list-body">
- <div
- v-for="folder in folders"
- :key="'folder-' + folder.path"
- class="doc-list-row doc-list-row--folder"
- :title="folder.path"
- role="row"
- @click="emit('open-folder', folder.path)"
- >
- <div class="cell cell-check" aria-hidden="true"></div>
- <div class="cell cell-name">
- <span class="row-file-icon-wrap">
- <t-icon name="folder" class="row-folder-icon" />
- </span>
- <div class="row-file-text">
- <span class="row-file-name">{{ folder.name }}</span>
- </div>
- </div>
- <div class="cell cell-tag"></div>
- <div class="cell cell-source">
- <span class="row-folder-meta">
- {{ t('knowledgeBase.folderTree.folderCardCount', { count: folder.total_count }) }}
- </span>
- </div>
- <div class="cell cell-size"></div>
- <div class="cell cell-status"></div>
- <div class="cell cell-time"></div>
- <div v-if="canEdit" class="cell cell-actions" aria-hidden="true"></div>
- </div>
-
+ <div class="doc-list-body" role="rowgroup">
<div v-for="item in items" :key="item.id" class="doc-list-row"
:class="{ selected: selectedIds.has(item.id), 'menu-open': moreOpen === item.id }" :data-select-id="item.id"
role="row" @click="emit('open', item)">
- <div class="cell cell-check" @click.stop>
+ <div class="cell cell-check" role="cell" @click.stop>
<t-checkbox v-if="canEdit || canDownload" class="doc-list-check" size="small" :checked="selectedIds.has(item.id)" :title="item.file_name"
@change="(c: boolean, ctx?: { e?: Event }) => onRowCheckboxChange(item, c, ctx)" />
</div>
- <div class="cell cell-name">
- <span class="row-file-icon-wrap">
- <t-icon :name="getFileIcon(item)" />
- </span>
+ <div class="cell cell-name" role="cell">
+ <DocumentFileIcon :source-type="item.type"
+ :file-name="item.file_type ? `document.${item.file_type.toLowerCase()}` : (item.original_file_name || item.file_name)" />
<div class="row-file-text">
- <span class="row-file-name" :title="item.file_name">{{ item.file_name }}</span>
+ <div class="row-title-line">
+ <button type="button" class="row-file-name" :title="item.description ? `${item.file_name}\n${item.description}` : item.file_name"
+ @click.stop="emit('open', item)">{{ item.file_name }}</button>
+ </div>
+ <span class="row-file-meta">
+ <span class="row-source"><t-icon :name="getSourceInfo(item).icon" />{{ getSourceInfo(item).label }}</span>
+ <template v-if="formatFileSize(item.file_size)">
+ <span class="meta-sep" aria-hidden="true">·</span>
+ <span>{{ formatFileSize(item.file_size) }}</span>
+ </template>
+ <span class="meta-sep" aria-hidden="true">·</span>
+ <span :title="t('knowledgeBase.columnUpdatedAt')">{{ formatTime(item.updated_at) }}</span>
+ </span>
<button v-if="showFolderPath && item.folder_path" type="button" class="row-file-folder"
:title="item.folder_path" @click.stop="emit('open-folder', item.folder_path)">
<t-icon name="folder" />
<span>{{ item.folder_path }}</span>
</button>
- <span v-if="item.description" class="row-file-desc" :title="item.description">{{ item.description }}</span>
</div>
</div>
- <div class="cell cell-tag">
- <template v-if="item.tags && item.tags.length > 0">
- <t-tooltip v-if="hasTagOverflow(item.id, (item.tags || []).length)"
- :content="(item.tags || []).map((t: any) => t.name).join(', ')" placement="top">
- <div class="row-tag-chips" :ref="(el: any) => setupTagChipsObserver(el, item.id, (item.tags || []).length)"
- :class="{ 'is-clickable': canEdit }" @click.stop="canEdit && emit('tag-edit', item)">
- <t-tag v-for="tag in (item.tags || []).slice(0, getTagLimit(item.id))" :key="tag.id" size="small"
- variant="light-outline" class="row-tag">
- {{ tag.name }}
- </t-tag>
- <span class="row-tag-overflow">+{{ getOverflowCount(item.id, (item.tags || []).length) }}</span>
+ <div class="cell cell-tags" role="cell">
+ <KnowledgeTagPopover :kb-id="kbId" :knowledge-id="item.id" :tags="item.tags || []" :disabled="!canEdit"
+ :visible="tagEditorId === item.id"
+ @update:visible="(visible: boolean) => { if (visible) tagEditorId = item.id; else if (tagEditorId === item.id) tagEditorId = null }"
+ @changed="emit('tags-changed', $event)">
+ <div class="row-tag-trigger">
+ <div v-if="item.tags?.length" class="row-tags">
+ <button v-for="tag in item.tags.slice(0, 5)" :key="tag.id" type="button" class="row-tag"
+ :disabled="!canEdit" :title="tag.name">{{ tag.name }}</button>
+ <button v-if="item.tags.length > 5" type="button" class="row-tag row-tag--overflow"
+ :disabled="!canEdit" :title="item.tags.slice(5).map(tag => tag.name).join(', ')">+{{ item.tags.length - 5 }}</button>
</div>
- </t-tooltip>
- <div v-else class="row-tag-chips" :ref="(el: any) => setupTagChipsObserver(el, item.id, (item.tags || []).length)"
- :class="{ 'is-clickable': canEdit }" @click.stop="canEdit && emit('tag-edit', item)">
- <t-tag v-for="tag in (item.tags || []).slice(0, getTagLimit(item.id))" :key="tag.id" size="small"
- variant="light-outline" class="row-tag">
- {{ tag.name }}
- </t-tag>
+ <button v-else-if="canEdit" type="button" class="row-tag-add">
+ <t-icon name="add" size="12px" />
+ {{ t('knowledgeBase.tagAddAction') }}
+ </button>
</div>
- </template>
- <span v-else class="row-tag-chips is-clickable" @click.stop="canEdit && emit('tag-edit', item)">
- <span class="row-tag-add">+ {{ t('knowledgeBase.tagLabel') }}</span>
- </span>
- </div>
-
- <div class="cell cell-source">
- <t-icon class="row-source-icon" :name="getSourceInfo(item).icon" />
- <span class="row-source-label">{{ getSourceInfo(item).label }}</span>
- </div>
-
- <div class="cell cell-size">
- <span class="row-mono">{{ formatFileSize(item.file_size) || '--' }}</span>
+ </KnowledgeTagPopover>
</div>
- <div class="cell cell-status">
+ <div class="cell cell-status" role="cell">
<template v-if="statusByRow.get(item.id) as StatusInfo | undefined">
<t-tag v-if="statusByRow.get(item.id)!.label !== '--'" size="small" :theme="statusByRow.get(item.id)!.theme"
- variant="light-outline" class="row-status-tag">
+ variant="light" class="row-status-tag" :class="`status-${statusByRow.get(item.id)!.theme}`">
<template v-if="statusByRow.get(item.id)!.icon" #icon>
<t-icon :name="statusByRow.get(item.id)!.icon!"
:class="{ 'icon-spin': statusByRow.get(item.id)!.spin }" />
@@ -374,15 +323,11 @@ const handleAction = (action: 'download' | 'edit' | 'reparse' | 'cancel-parse' |
</template>
</div>
- <div class="cell cell-time">
- <span class="row-mono">{{ formatTime(item.updated_at) }}</span>
- </div>
-
- <div class="cell cell-actions" v-if="canEdit" @click.stop>
- <t-popup placement="bottom-right" trigger="click" destroy-on-close overlay-class-name="card-more"
+ <div class="cell cell-actions" role="cell" v-if="canEdit" @click.stop>
+ <t-popup :visible="moreOpen === item.id" placement="bottom-right" trigger="click" destroy-on-close overlay-class-name="card-more"
:on-visible-change="(v: boolean) => onMoreVisible(item.id, v)">
<button class="row-more-btn" :class="{ active: moreOpen === item.id }" type="button"
- :aria-label="t('knowledgeBase.columnActions')">
+ :aria-label="`${item.file_name} · ${t('knowledgeBase.columnActions')}`" :aria-expanded="moreOpen === item.id">
<t-icon name="more" size="16px" />
</button>
<template #content>
@@ -399,6 +344,10 @@ const handleAction = (action: 'download' | 'edit' | 'reparse' | 'cancel-parse' |
<!-- Normal menu -->
<div v-else-if="moveMenuMode === 'normal'" class="card-menu">
+ <button type="button" class="card-menu-item row-tag-menu-action" @click.stop="moreOpen = null; tagEditorId = item.id">
+ <t-icon name="discount" class="icon" />
+ <span>{{ t('knowledgeBase.tagEditDialogHeading') }}</span>
+ </button>
<DocumentActionMenu
:item="item"
:can-download="canDownload"
@@ -499,30 +448,19 @@ const handleAction = (action: 'download' | 'edit' | 'reparse' | 'cancel-parse' |
display: flex;
flex-direction: column;
width: 100%;
- background: var(--td-bg-color-container);
- border: 1px solid var(--td-component-stroke);
- border-radius: 9px;
+ background: transparent;
/* 不能用 overflow:hidden,否则表头 position:sticky 相对外层滚动区失效 */
overflow: visible;
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
animation: doc-list-fade-in 0.32s ease-out;
}
.doc-list-header,
.doc-list-row {
display: grid;
- grid-template-columns:
- 44px // checkbox
- minmax(260px, 2.6fr) // name
- minmax(100px, 0.9fr) // tag
- minmax(96px, 0.8fr) // source
- 96px // size
- minmax(96px, 0.7fr) // status
- 140px // updated_at
- 48px; // actions
+ grid-template-columns: 24px minmax(0, 1fr) minmax(180px, 24%) 100px 28px;
align-items: center;
- column-gap: 0;
- padding: 0 16px;
+ column-gap: 12px;
+ padding: 0 8px;
}
.doc-list-sticky-sentinel {
@@ -542,10 +480,8 @@ const handleAction = (action: 'download' | 'edit' | 'reparse' | 'cancel-parse' |
font-weight: 500;
font-family: var(--app-font-family);
color: var(--td-text-color-secondary);
- background: var(--td-bg-color-secondarycontainer);
- border-bottom: 1px solid var(--td-component-stroke);
- border-radius: 8px 8px 0 0;
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
+ background: var(--td-bg-color-container);
+ border-bottom: 0;
transition: border-radius var(--app-motion-fast) ease, box-shadow var(--app-motion-base) ease;
&.is-stuck {
@@ -557,28 +493,28 @@ const handleAction = (action: 'download' | 'edit' | 'reparse' | 'cancel-parse' |
.doc-list-body {
display: flex;
flex-direction: column;
- border-radius: 0 0 8px 8px;
- overflow: hidden;
+ gap: 2px;
+ padding: 6px 0 72px;
}
.doc-list-row {
position: relative;
- min-height: 60px;
+ min-height: 68px;
+ padding-top: 10px;
+ padding-bottom: 10px;
+ box-sizing: border-box;
+ border-radius: var(--app-radius-md);
font-size: var(--app-text-md);
color: var(--td-text-color-primary);
- border-bottom: 1px solid var(--td-component-stroke);
cursor: pointer;
transition: background-color var(--app-motion-base) ease, box-shadow var(--app-motion-base) ease, border-color var(--app-motion-base) ease;
- &:last-child {
- border-bottom: 0;
- }
-
&:hover:not(.selected),
&.menu-open:not(.selected) {
background: var(--td-bg-color-secondarycontainer);
}
+ &:focus-within .row-more-btn,
&:hover .row-more-btn,
&.menu-open .row-more-btn,
&.selected .row-more-btn {
@@ -590,7 +526,7 @@ const handleAction = (action: 'download' | 'edit' | 'reparse' | 'cancel-parse' |
display: flex;
align-items: center;
min-width: 0;
- padding: 0 8px;
+ padding: 0;
&:first-child {
padding-left: 0;
@@ -607,15 +543,10 @@ const handleAction = (action: 'download' | 'edit' | 'reparse' | 'cancel-parse' |
}
.cell-name {
- gap: 10px;
+ gap: 12px;
font-family: var(--app-font-family);
}
-.cell-size,
-.cell-time {
- justify-content: flex-end;
-}
-
.cell-actions {
justify-content: flex-end;
}
@@ -647,14 +578,14 @@ const handleAction = (action: 'download' | 'edit' | 'reparse' | 'cancel-parse' |
.row-file-icon-wrap {
flex-shrink: 0;
- width: 28px;
- height: 28px;
+ width: 32px;
+ height: 38px;
border-radius: var(--app-radius-sm);
display: inline-flex;
align-items: center;
justify-content: center;
- font-size: var(--app-text-xl);
- background: var(--td-bg-color-secondarycontainer);
+ font-size: 26px;
+ background: transparent;
color: var(--td-text-color-secondary);
}
@@ -663,7 +594,7 @@ const handleAction = (action: 'download' | 'edit' | 'reparse' | 'cancel-parse' |
min-width: 0;
display: flex;
flex-direction: column;
- gap: 2px;
+ gap: 4px;
}
.row-file-name {
@@ -672,12 +603,22 @@ const handleAction = (action: 'download' | 'edit' | 'reparse' | 'cancel-parse' |
overflow: hidden;
text-overflow: ellipsis;
font-size: var(--app-text-base);
- font-weight: 600;
- letter-spacing: 0.01em;
+ font-weight: 500;
+ line-height: 1.4;
+ text-align: left;
+ border: 0;
+ padding: 0;
+ background: transparent;
+ font-family: inherit;
+ cursor: pointer;
color: var(--td-text-color-primary);
}
-.row-file-desc {
+.row-file-meta {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ font-variant-numeric: tabular-nums;
min-width: 0;
white-space: nowrap;
overflow: hidden;
@@ -686,25 +627,6 @@ const handleAction = (action: 'download' | 'edit' | 'reparse' | 'cancel-parse' |
color: var(--td-text-color-placeholder);
}
-.doc-list-row--folder {
- cursor: pointer;
-
- .row-file-name {
- font-weight: 500;
- }
-}
-
-.row-folder-icon {
- color: var(--td-brand-color);
-}
-
-.row-folder-meta,
-.row-folder-chevron {
- font-size: var(--app-text-sm);
- color: var(--td-text-color-placeholder);
- transition: color var(--app-motion-fast) ease;
-}
-
.row-file-folder {
display: inline-flex;
align-items: center;
@@ -737,100 +659,69 @@ const handleAction = (action: 'download' | 'edit' | 'reparse' | 'cancel-parse' |
}
}
-.cell-source {
- gap: 6px;
- min-width: 0;
+.row-muted {
+ color: var(--td-text-color-disabled);
}
-.row-source-icon {
- flex-shrink: 0;
- font-size: var(--app-text-base);
+.row-status-tag {
+ background: transparent;
+ border: 0;
+ padding: 0;
color: var(--td-text-color-secondary);
-}
-
-.row-source-label {
- min-width: 0;
- white-space: nowrap;
+ &.status-success::before { content: ''; width: 5px; height: 5px; margin-right: 6px; border-radius: 50%; background: var(--td-success-color); }
+ &.status-danger { color: var(--td-error-color); }
+ &.status-warning { color: var(--td-warning-color); }
+ &.status-primary { color: var(--td-brand-color); }
+ &.status-default { color: var(--td-text-color-placeholder); }
+}
+.row-title-line { display: flex; align-items: center; min-width: 0; }
+.row-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; min-width: 0; width: 100%; }
+.row-tag {
+ flex: 0 0 auto;
+ max-width: min(180px, 100%);
+ box-sizing: border-box;
+ padding: 2px 7px;
+ border: 0;
+ border-radius: 5px;
+ background: var(--td-bg-color-secondarycontainer);
+ color: var(--td-text-color-secondary);
+ font: inherit;
+ font-size: var(--app-text-sm);
+ line-height: 18px;
overflow: hidden;
text-overflow: ellipsis;
- font-size: var(--app-text-sm);
- color: var(--td-text-color-secondary);
-}
-
-.row-tag {
- max-width: 100%;
-
- :deep(.t-tag__text) {
- overflow: hidden;
- text-overflow: ellipsis;
- max-width: 120px;
- display: inline-block;
- }
+ white-space: nowrap;
+ cursor: pointer;
+ &:disabled { cursor: default; }
+ &:not(:disabled):hover { color: var(--td-brand-color); background: var(--td-brand-color-light); }
+ &--overflow { background: transparent; color: var(--td-text-color-placeholder); }
}
-
-.row-tag-chips {
+.row-tag-add {
display: inline-flex;
align-items: center;
gap: 4px;
- flex-wrap: nowrap;
-
- &.is-clickable {
- cursor: pointer;
- }
-}
-
-.row-tag-overflow {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- height: 20px;
- min-width: 20px;
- padding: 0 4px;
- border-radius: var(--app-radius-pill);
- border: 1px solid var(--td-component-stroke);
+ padding: 2px 7px;
+ border: 1px dashed var(--td-component-stroke);
+ border-radius: 5px;
+ background: transparent;
color: var(--td-text-color-placeholder);
- font-size: var(--app-text-2xs);
- line-height: 1;
+ font: inherit;
+ font-size: var(--app-text-sm);
+ line-height: 18px;
+ white-space: nowrap;
cursor: pointer;
- transition: all var(--app-motion-base) ease;
+ transition: color var(--app-motion-fast) ease, border-color var(--app-motion-fast) ease, background var(--app-motion-fast) ease;
&:hover {
- border-color: var(--td-brand-color);
color: var(--td-brand-color);
- background: var(--td-bg-color-secondarycontainer);
- }
-}
-
-.row-tag-add {
- font-size: var(--app-text-xs);
- color: var(--td-text-color-placeholder);
- border: 1px dashed var(--td-component-stroke);
- border-radius: var(--app-radius-pill);
- padding: 0 6px;
- height: 20px;
- display: inline-flex;
- align-items: center;
- white-space: nowrap;
-
- &:hover {
border-color: var(--td-brand-color);
- color: var(--td-brand-color);
- background: var(--td-bg-color-secondarycontainer);
- border-style: solid;
+ background: var(--td-brand-color-light);
}
}
-
-.row-muted {
- color: var(--td-text-color-disabled);
+.row-tag-menu-action {
+ width: 100%; border: 0; background: transparent; text-align: left; font-family: inherit; cursor: pointer;
+ &:hover { background: var(--td-bg-color-container-hover); }
}
-
-.row-mono {
- font-variant-numeric: tabular-nums;
- font-size: var(--app-text-sm);
- font-family: var(--app-font-family);
- color: var(--td-text-color-secondary);
-}
-
.row-status-tag :deep(.t-icon) {
margin-right: 2px;
}
@@ -865,4 +756,39 @@ const handleAction = (action: 'download' | 'edit' | 'reparse' | 'cancel-parse' |
}
}
+.row-source {
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+}
+.meta-sep { opacity: 0.6; }
+.doc-list-row.selected { background: var(--app-selection-bg); }
+.row-file-name:focus-visible,
+.row-file-folder:focus-visible,
+.row-more-btn:focus-visible,
+.row-tag:focus-visible,
+.row-tag-add:focus-visible {
+ outline: 2px solid var(--app-focus-border);
+ outline-offset: 3px;
+ border-radius: var(--app-radius-xs);
+}
+@container doc-card-area (max-width: 720px) {
+ .doc-list-header, .doc-list-row {
+ grid-template-columns: 24px minmax(0, 1fr) 100px 28px;
+ column-gap: 8px;
+ }
+ .doc-list-header .cell-tags { display: none; }
+ .doc-list-row .cell-tags { grid-column: 2; grid-row: 2; padding-left: 44px; }
+ .row-tags { padding-top: 6px; }
+ .row-tag-add { margin-top: 6px; }
+ .cell-status { grid-column: 3; grid-row: 1; }
+ .cell-actions { grid-column: 4; grid-row: 1; }
+ .row-file-meta { flex-wrap: wrap; gap: 2px 6px; }
+}
+@media (hover: none) {
+ .row-more-btn { opacity: 1; }
+}
+@media (prefers-reduced-motion: reduce) {
+ .doc-list-view, .icon-spin { animation: none; }
+}
</style>
diff --git a/frontend/src/views/knowledge/components/FAQEntryManager.vue b/frontend/src/views/knowledge/components/FAQEntryManager.vue
index 637436bd2..b322a8e03 100644
--- a/frontend/src/views/knowledge/components/FAQEntryManager.vue
+++ b/frontend/src/views/knowledge/components/FAQEntryManager.vue
@@ -289,25 +289,6 @@
</template>
</div>
<div class="faq-card-status" @click.stop>
- <!-- 暂时隐藏推荐开关
- <t-tooltip
- :content="entry.is_recommended ? $t('knowledgeEditor.faq.recommendedEnabled') : $t('knowledgeEditor.faq.recommendedDisabled')"
- placement="top"
- >
- <div class="status-item-compact">
- <t-switch
- :key="`${entry.id}-recommended-${entry.is_recommended}`"
- size="small"
- :value="entry.is_recommended"
- :loading="!!entryRecommendedLoading[entry.id]"
- :disabled="!!entryRecommendedLoading[entry.id]"
- @click.stop
- @change="(value: boolean) => handleEntryRecommendedChange(entry, value)"
- />
- <span class="status-label">{{ $t('knowledgeEditor.faq.recommended') }}</span>
- </div>
- </t-tooltip>
- -->
<t-tooltip
:content="entry.is_enabled ? $t('knowledgeEditor.faq.statusEnabled') : $t('knowledgeEditor.faq.statusDisabled')"
placement="top">
@@ -778,7 +759,7 @@
<script setup lang="ts">
import { ref, reactive, watch, onMounted, computed, nextTick, onUnmounted, h } from 'vue'
import KnowledgeTagFilter from './KnowledgeTagFilter.vue'
-import { MessagePlugin, DialogPlugin, Icon as TIcon } from 'tdesign-vue-next'
+import { MessagePlugin, Icon as TIcon } from 'tdesign-vue-next'
import { useConfirmDelete } from '@/components/settings/useConfirmDelete'
import type { FormRules, FormInstanceFunctions } from 'tdesign-vue-next'
import { useI18n } from 'vue-i18n'
@@ -951,7 +932,6 @@ const loading = ref(true)
const loadingMore = ref(false)
const entries = ref<FAQEntry[]>([])
const entryStatusLoading = reactive<Record<number, boolean>>({})
-const entryRecommendedLoading = reactive<Record<number, boolean>>({})
const selectedRowKeys = ref<number[]>([])
const batchDeleteLoading = ref(false)
const batchTagLoading = ref(false)
@@ -1350,32 +1330,6 @@ const handleEntryStatusChange = async (entry: FAQEntry, value: boolean) => {
}
}
-const handleEntryRecommendedChange = async (entry: FAQEntry, value: boolean) => {
- if (entryRecommendedLoading[entry.id]) {
- return
- }
- const entryIndex = entries.value.findIndex(e => e.id === entry.id)
- if (entryIndex === -1) {
- return
- }
- const actualEntry = entries.value[entryIndex]
- const previous = actualEntry.is_recommended
- if (previous === value) {
- return
- }
- actualEntry.is_recommended = value
- entryRecommendedLoading[entry.id] = true
- try {
- await updateFAQEntryFieldsBatch(props.kbId, { by_id: { [entry.id]: { is_recommended: value } } })
- MessagePlugin.success(t(value ? 'knowledgeEditor.faq.recommendedEnableSuccess' : 'knowledgeEditor.faq.recommendedDisableSuccess'))
- } catch (error: any) {
- actualEntry.is_recommended = previous
- MessagePlugin.error(error?.message || t('knowledgeEditor.faq.recommendedUpdateFailed'))
- } finally {
- entryRecommendedLoading[entry.id] = false
- }
-}
-
const editorRules: FormRules<FAQEntryPayload> = {
standard_question: [
{ required: true, message: t('knowledgeEditor.messages.nameRequired') },
@@ -1687,22 +1641,6 @@ const handleBatchStatusChange = async (isEnabled: boolean) => {
}
}
-const handleBatchRecommendedChange = async (isRecommended: boolean) => {
- if (!selectedRowKeys.value.length || !props.kbId) return
- try {
- const by_id: Record<number, { is_recommended: boolean }> = {}
- selectedRowKeys.value.forEach(id => {
- by_id[id] = { is_recommended: isRecommended }
- })
- await updateFAQEntryFieldsBatch(props.kbId, { by_id })
- MessagePlugin.success(t(isRecommended ? 'knowledgeEditor.faq.recommendedEnableSuccess' : 'knowledgeEditor.faq.recommendedDisableSuccess'))
- selectedRowKeys.value = []
- await loadEntries()
- } catch (error: any) {
- MessagePlugin.error(error?.message || t('common.operationFailed'))
- }
-}
-
const handleMenuEdit = (entry: FAQEntry) => {
entry.showMore = false
openEditor(entry)
@@ -2521,17 +2459,6 @@ const handleSearch = async () => {
}
}
-const getMatchTypeLabel = (matchType?: string) => {
- if (!matchType) return ''
- if (matchType === 'embedding') {
- return t('knowledgeEditor.faq.matchTypeEmbedding')
- }
- if (matchType === 'keywords') {
- return t('knowledgeEditor.faq.matchTypeKeywords')
- }
- return matchType
-}
-
const toggleResult = (result: FAQEntry) => {
result.expanded = !result.expanded
}
@@ -2839,45 +2766,9 @@ watch(() => entries.value.map(e => ({
}
}
-:deep(.tag-menu) {
- display: flex;
- flex-direction: column;
-}
-
-:deep(.tag-menu-item) {
- display: flex;
- align-items: center;
- padding: 8px 16px;
- cursor: pointer;
- transition: all var(--app-motion-base) ease;
- color: var(--td-text-color-primary);
- font-family: var(--app-font-family);
- font-size: var(--app-text-base);
- font-weight: 400;
-
- .menu-icon {
- margin-right: 8px;
- font-size: var(--app-text-xl);
- }
-
- &:hover {
- background: var(--td-bg-color-secondarycontainer);
- color: var(--td-text-color-primary);
- }
- &.danger {
- color: var(--td-text-color-primary);
- &:hover {
- background: var(--td-error-color-light);
- color: var(--td-error-color);
- .menu-icon {
- color: var(--td-error-color);
- }
- }
- }
-}
.faq-header {
display: flex;
@@ -3325,15 +3216,14 @@ watch(() => entries.value.map(e => ({
cursor: pointer;
&:hover {
- border-color: var(--td-brand-color);
- box-shadow: 0 2px 8px color-mix(in srgb, var(--td-brand-color) 10%, transparent);
+ border-color: var(--app-selection-border);
}
}
&.selected {
- border-color: var(--td-brand-color);
- background: var(--td-success-color-light);
- box-shadow: 0 2px 8px color-mix(in srgb, var(--td-brand-color) 15%, transparent);
+ border-color: var(--app-selection-border);
+ background: var(--td-bg-color-container);
+ box-shadow: none;
}
}
diff --git a/frontend/src/views/knowledge/components/FolderPickerMenu.vue b/frontend/src/views/knowledge/components/FolderPickerMenu.vue
index b592a7c78..b195cf73c 100644
--- a/frontend/src/views/knowledge/components/FolderPickerMenu.vue
+++ b/frontend/src/views/knowledge/components/FolderPickerMenu.vue
@@ -249,12 +249,16 @@ const commitNewFolder = async () => {
padding: 6px 10px;
margin-bottom: 2px;
border-bottom: 1px solid var(--td-component-stroke);
- color: var(--td-text-color-secondary);
- font-size: var(--app-text-md);
+ color: var(--td-text-color-primary);
+ font-family: var(--app-font-family);
+ font-size: var(--app-text-base);
+ font-weight: 400;
+ line-height: 20px;
cursor: pointer;
&:hover {
- color: var(--td-brand-color);
+ color: var(--td-text-color-primary);
+ background: var(--td-bg-color-container-hover);
}
}
@@ -277,12 +281,15 @@ const commitNewFolder = async () => {
display: flex;
align-items: center;
gap: 6px;
- height: 30px;
+ height: 32px;
box-sizing: border-box;
padding: 0 8px 0 calc(var(--folder-picker-depth, 0) * var(--folder-picker-indent) + 10px);
- border-radius: var(--app-radius-sm);
+ border-radius: var(--app-radius-xs);
color: var(--td-text-color-primary);
- font-size: var(--app-text-md);
+ font-family: var(--app-font-family);
+ font-size: var(--app-text-base);
+ font-weight: 400;
+ line-height: 20px;
cursor: pointer;
transition: background var(--app-motion-fast) ease;
diff --git a/frontend/src/views/knowledge/components/KbFolderTree.test.ts b/frontend/src/views/knowledge/components/KbFolderTree.test.ts
index c51d25157..5f35aabac 100644
--- a/frontend/src/views/knowledge/components/KbFolderTree.test.ts
+++ b/frontend/src/views/knowledge/components/KbFolderTree.test.ts
@@ -50,5 +50,5 @@ test('folder navigation cancels stale card hover popovers', () => {
assert.match(cardView, /if \(!cardElement\.isConnected/)
assert.match(cardView, /watch\(\(\) => props\.items, dismissCardPopover\)/)
assert.match(cardView, /const onOpenFolder = \(path: string\)[\s\S]*?dismissCardPopover\(\)[\s\S]*?emit\('open-folder', path\)/)
- assert.match(cardView, /@click="onOpenFolder\(folder\.path\)"/)
+ assert.match(cardView, /@click\.stop="onOpenFolder\(item\.folder_path\)"/)
})
diff --git a/frontend/src/views/knowledge/components/KbFolderTree.vue b/frontend/src/views/knowledge/components/KbFolderTree.vue
index d52f40032..bda0a0d08 100644
--- a/frontend/src/views/knowledge/components/KbFolderTree.vue
+++ b/frontend/src/views/knowledge/components/KbFolderTree.vue
@@ -3,6 +3,10 @@
<div class="kb-folder-tree__header">
<template v-if="!collapsed">
<span class="kb-folder-tree__title">{{ t('knowledgeBase.folderTree.title') }}</span>
+ <span v-if="tree && !loading" class="kb-folder-tree__total"
+ :title="t('knowledgeBase.folderTree.totalDocuments', { count: tree.total_document_count })">
+ {{ t('knowledgeBase.folderTree.totalDocuments', { count: tree.total_document_count }) }}
+ </span>
<t-tooltip :content="t('knowledgeBase.folderTree.collapse')" placement="top">
<button
type="button"
@@ -48,12 +52,17 @@
role="button"
tabindex="0"
@click="emit('select', row.path)"
- @keydown.enter="emit('select', row.path)"
+ @keydown.enter.self="emit('select', row.path)"
+ @keydown.space.prevent.self="emit('select', row.path)"
>
<span
v-if="row.hasChildren"
class="kb-folder-row__toggle"
role="button"
+ tabindex="0"
+ :aria-expanded="isExpanded(row.path)"
+ @keydown.enter.stop.prevent="toggle(row.path)"
+ @keydown.space.stop.prevent="toggle(row.path)"
:aria-label="t(isExpanded(row.path)
? 'knowledgeBase.folderTree.collapseFolder'
: 'knowledgeBase.folderTree.expandFolder')"
@@ -81,10 +90,13 @@
/>
<template v-else>
<span class="kb-folder-row__label">
- {{ row.kind === 'root' ? t('knowledgeBase.folderTree.rootRow') : row.name }}
+ {{ row.kind === 'root' ? (rootLabel || t('knowledgeBase.folderTree.rootRow')) : row.name }}
</span>
<span class="kb-folder-row__trailing">
- <span class="kb-folder-row__count">{{ row.totalCount }}</span>
+ <span class="kb-folder-row__count"
+ :title="t('knowledgeBase.folderTree.countHint', { direct: row.documentCount, total: row.totalCount })">
+ {{ row.documentCount }}
+ </span>
<t-popup
v-if="canEdit && row.kind === 'folder'"
:visible="menuOpenPath === row.path"
@@ -98,7 +110,7 @@
type="button"
class="kb-folder-row__more"
:class="{ 'is-open': menuOpenPath === row.path }"
- :aria-label="t('knowledgeBase.moreOptions')"
+ :aria-label="t('knowledgeBase.columnActions')"
@click.stop
>
<t-icon name="more" />
@@ -112,6 +124,7 @@
</div>
</template>
</t-popup>
+ <span v-else class="kb-folder-row__more-placeholder" aria-hidden="true"></span>
</span>
</template>
</div>
@@ -135,6 +148,7 @@ import {
const props = withDefaults(defineProps<{
tree: KnowledgeFolderTree | null
/** Selected folder path; the empty string is the knowledge base top level. */
+ rootLabel?: string
selectedPath: string
loading?: boolean
collapsed?: boolean
@@ -239,14 +253,14 @@ watch(
<style scoped lang="less">
.kb-folder-tree {
- --kb-folder-indent: 10px;
+ --kb-folder-indent: 14px;
display: flex;
flex-direction: column;
flex-shrink: 0;
- width: 268px;
+ width: 220px;
min-height: 0;
padding-right: 12px;
- margin-right: 12px;
+ margin-right: 16px;
border-right: 1px solid var(--td-component-stroke);
box-sizing: border-box;
@@ -263,19 +277,32 @@ watch(
justify-content: space-between;
gap: 6px;
height: 32px;
+ padding-bottom: 16px;
flex-shrink: 0;
}
.kb-folder-tree__title {
font-size: var(--app-text-md);
- font-weight: 600;
+ font-weight: 500;
color: var(--td-text-color-primary);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
+.kb-folder-tree__total {
+ flex: 1;
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ font-size: var(--app-text-xs);
+ font-weight: 400;
+ color: var(--td-text-color-placeholder);
+}
+
.kb-folder-tree__icon-btn {
+ flex-shrink: 0;
width: 24px;
height: 24px;
padding: 0;
@@ -300,7 +327,7 @@ watch(
min-height: 0;
overflow-y: auto;
overflow-x: hidden;
- padding: 4px 0 12px;
+ padding: 8px 0 12px;
scrollbar-width: thin;
&::-webkit-scrollbar {
@@ -323,8 +350,9 @@ watch(
gap: 4px;
box-sizing: border-box;
width: 100%;
- height: 30px;
- padding: 0 8px 0 calc(var(--kb-folder-depth, 0) * var(--kb-folder-indent));
+ height: 32px;
+ margin-bottom: 2px;
+ padding: 0 4px 0 calc(4px + var(--kb-folder-depth, 0) * var(--kb-folder-indent));
border-radius: var(--app-radius-sm);
background: transparent;
color: var(--td-text-color-primary);
@@ -341,16 +369,18 @@ watch(
&:focus-visible {
outline: none;
- box-shadow: 0 0 0 2px color-mix(in srgb, var(--td-brand-color) 30%, transparent);
+ outline: 2px solid var(--app-focus-border);
+ outline-offset: 2px;
}
&.active {
- background: var(--td-bg-color-container-hover);
+ background: var(--app-selection-bg);
.kb-folder-row__label,
.kb-folder-row__icon {
color: var(--td-brand-color);
}
+ .kb-folder-row__label { font-weight: 500; }
}
&.is-root .kb-folder-row__label {
@@ -385,8 +415,8 @@ watch(
.kb-folder-row__icon {
flex: 0 0 auto;
- font-size: var(--app-text-lg);
- color: var(--td-text-color-placeholder);
+ font-size: var(--app-text-xl);
+ color: var(--td-text-color-secondary);
}
.kb-folder-row__label {
@@ -399,7 +429,7 @@ watch(
.kb-folder-row__trailing {
flex: 0 0 auto;
- width: 22px;
+ gap: 2px;
height: 20px;
display: flex;
align-items: center;
@@ -408,14 +438,20 @@ watch(
}
.kb-folder-row__count {
+ min-width: 16px;
+ text-align: right;
font-size: var(--app-text-xs);
color: var(--td-text-color-placeholder);
font-variant-numeric: tabular-nums;
line-height: 1;
}
+.kb-folder-row__more-placeholder { width: 20px; }
+
.kb-folder-row__more {
- display: none;
+ display: inline-flex;
+ opacity: 0;
+ pointer-events: none;
width: 20px;
height: 20px;
padding: 0;
@@ -439,13 +475,11 @@ watch(
}
.kb-folder-row.is-editable:hover,
+.kb-folder-row.is-editable:focus-within,
.kb-folder-row.is-menu-open {
- .kb-folder-row__count {
- display: none;
- }
-
.kb-folder-row__more {
- display: inline-flex;
+ opacity: 1;
+ pointer-events: auto;
}
}
diff --git a/frontend/src/views/knowledge/components/KbUploadSourceDropdown.vue b/frontend/src/views/knowledge/components/KbUploadSourceDropdown.vue
index e87338d2c..7dd72e439 100644
--- a/frontend/src/views/knowledge/components/KbUploadSourceDropdown.vue
+++ b/frontend/src/views/knowledge/components/KbUploadSourceDropdown.vue
@@ -29,9 +29,14 @@
theme="default"
:class="['kb-upload-source-trigger', triggerClass]"
:data-guide="dataGuide || undefined"
+ :aria-label="tooltipText"
size="small"
>
- <template #icon><t-icon :name="triggerIcon" size="16px" /></template>
+ <template #icon>
+ <component v-if="triggerIconComponent" :is="triggerIconComponent" size="18px" :stroke-width="1.7" class="kb-source-icon" />
+ <t-icon v-else :name="triggerIcon" size="18px" />
+ </template>
+ <span v-if="triggerLabel">{{ triggerLabel }}</span>
</t-button>
</t-dropdown>
</t-tooltip>
@@ -63,7 +68,8 @@
<script setup lang="ts">
import { ref, computed, h } from 'vue'
import { useI18n } from 'vue-i18n'
-import { MessagePlugin, Icon as TIcon } from 'tdesign-vue-next'
+import { MessagePlugin } from 'tdesign-vue-next'
+import { AddIcon, FileAddIcon, UploadIcon, FolderAddIcon, LinkIcon, EditIcon } from 'tdesign-icons-vue-next'
import { filterUploadFiles } from '../utils/uploadSources'
const props = withDefaults(defineProps<{
@@ -71,6 +77,7 @@ const props = withDefaults(defineProps<{
supportedFileTypes?: string[]
includeManual?: boolean
triggerIcon?: string
+ triggerLabel?: string
triggerClass?: string
dataGuide?: string
tooltip?: string
@@ -101,29 +108,37 @@ const urlInputValue = ref('')
const tooltipText = computed(() => props.tooltip || t('knowledgeBase.addDocument'))
+const triggerIconComponent = computed(() => ({
+ add: AddIcon,
+ 'file-add': FileAddIcon,
+ upload: UploadIcon,
+}[props.triggerIcon]));
+
+const sourceIconProps = { size: '18px', strokeWidth: 1.7, class: 'kb-source-icon' };
+
const dropdownOptions = computed(() => {
const options = [
{
content: t('upload.uploadDocument'),
value: 'upload',
- prefixIcon: () => h(TIcon, { name: 'upload', size: '16px' }),
+ prefixIcon: () => h(FileAddIcon, sourceIconProps),
},
{
content: t('upload.uploadFolder'),
value: 'uploadFolder',
- prefixIcon: () => h(TIcon, { name: 'folder-add', size: '16px' }),
+ prefixIcon: () => h(FolderAddIcon, sourceIconProps),
},
{
content: t('knowledgeBase.importURL'),
value: 'importURL',
- prefixIcon: () => h(TIcon, { name: 'link', size: '16px' }),
+ prefixIcon: () => h(LinkIcon, sourceIconProps),
},
]
if (props.includeManual) {
options.push({
content: t('upload.onlineEdit'),
value: 'manualCreate',
- prefixIcon: () => h(TIcon, { name: 'edit', size: '16px' }),
+ prefixIcon: () => h(EditIcon, sourceIconProps),
})
}
return options
@@ -249,3 +264,11 @@ defineExpose({ openUrlDialog })
}
}
</style>
+
+<style lang="less">
+// Use consistent rounded strokes for this small family of document-source actions.
+.kb-source-icon path {
+ stroke-linecap: round;
+ stroke-linejoin: round;
+}
+</style>
diff --git a/frontend/src/views/knowledge/components/KnowledgeTagPicker.test.ts b/frontend/src/views/knowledge/components/KnowledgeTagPicker.test.ts
new file mode 100644
index 000000000..61d7a5491
--- /dev/null
+++ b/frontend/src/views/knowledge/components/KnowledgeTagPicker.test.ts
@@ -0,0 +1,134 @@
+import assert from 'node:assert/strict'
+import { readFileSync } from 'node:fs'
+import { runInNewContext } from 'node:vm'
+import test from 'node:test'
+import ts from 'typescript'
+import { compileScript, parse } from '@vue/compiler-sfc'
+import * as vue from 'vue'
+
+const source = readFileSync(new URL('./KnowledgeTagPicker.vue', import.meta.url), 'utf8')
+const { descriptor } = parse(source)
+const compiled = ts.transpileModule(compileScript(descriptor, { id: 'picker-test', inlineTemplate: true }).content, {
+ compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022 },
+}).outputText
+const translate = (key: string) => key
+type Host = { type: string; props: Record<string, any>; children: Host[]; text: string; parent?: Host }
+const node = (type: string): Host => ({ type, props: {}, children: [], text: '' })
+const renderer = vue.createRenderer<Host, Host>({
+ createElement: node,
+ createText: text => ({ ...node('#text'), text }),
+ createComment: text => ({ ...node('#comment'), text }),
+ patchProp: (el, key, _old, value) => { el.props[key] = value },
+ setText: (el, text) => { el.text = text },
+ setElementText: (el, text) => { el.children = []; el.text = text },
+ parentNode: el => el.parent || null,
+ nextSibling: el => el.parent?.children[el.parent.children.indexOf(el) + 1] || null,
+ insert(el, parent, anchor) {
+ if (el.parent) el.parent.children.splice(el.parent.children.indexOf(el), 1)
+ el.parent = parent
+ const index = anchor ? parent.children.indexOf(anchor) : -1
+ parent.children.splice(index < 0 ? parent.children.length : index, 0, el)
+ },
+ remove(el) {
+ el.parent?.children.splice(el.parent.children.indexOf(el), 1)
+ el.parent = undefined
+ },
+})
+const textOf = (el: Host): string => el.type === '#comment' ? '' : el.text + el.children.map(textOf).join('')
+const all = (el: Host, predicate: (node: Host) => boolean): Host[] => [
+ ...(predicate(el) ? [el] : []), ...el.children.flatMap(child => all(child, predicate)),
+]
+const hasClass = (el: Host, name: string) => String(el.props.class || '').split(' ').includes(name)
+
+
+async function fixture() {
+ const calls: { create: unknown[][]; rename: unknown[][]; remove: unknown[][] } = { create: [], rename: [], remove: [] }
+ let rows = [{ id: 'used', seq_id: 1, name: 'Used', knowledge_count: 2 }, { id: 'free', seq_id: 2, name: 'Free', knowledge_count: 0 }]
+ const exports: { default?: vue.Component } = {}
+ runInNewContext(compiled, { exports, setTimeout, clearTimeout, require(name: string) {
+ if (name === 'vue') return vue
+ if (name === 'vue-i18n') return { useI18n: () => ({ t: translate }) }
+ if (name === 'tdesign-vue-next') return { MessagePlugin: { success() {}, error() {}, warning() {} } }
+ if (name === '@/api/knowledge-base') return {
+ listKnowledgeTags: async (_kb: string, params: { keyword?: string }) => {
+ const filtered = rows.filter(r => !params.keyword || r.name.includes(params.keyword))
+ return { data: { data: filtered.map(r => ({ ...r })), total: filtered.length } }
+ },
+ createKnowledgeBaseTag: async (...args: any[]) => {
+ calls.create.push(args)
+ const tag = { id: 'new', seq_id: 3, name: args[1].name, knowledge_count: 0 }
+ rows.push(tag)
+ return { data: tag }
+ },
+ updateKnowledgeBaseTag: async (...args: any[]) => { calls.rename.push(args); rows.find(r => r.id === args[1])!.name = args[2].name },
+ deleteKnowledgeBaseTag: async (...args: any[]) => { calls.remove.push(args); rows = rows.filter(r => r.seq_id !== args[1]) },
+ }
+ throw new Error('Unexpected import: ' + name)
+ } })
+ const selectedIds = vue.ref<string[]>([])
+ const changes: unknown[] = []
+ const root = node('root')
+ const app = renderer.createApp({ setup: () => () => vue.h(exports.default!, {
+ kbId: 'kb', selectedIds: selectedIds.value,
+ 'onUpdate:selectedIds': (ids: string[]) => { selectedIds.value = ids },
+ onChanged: (payload: unknown) => changes.push(payload),
+ }) })
+ app.config.globalProperties.$t = translate as typeof app.config.globalProperties.$t
+ for (const [name, type] of [['t-input', 'input'], ['t-button', 'button'], ['t-checkbox', 'checkbox'], ['t-popconfirm', 'popconfirm'], ['t-tooltip', 'tooltip'], ['t-icon', 'icon'], ['t-loading', 'loading']]) {
+ app.component(name!, vue.defineComponent({ setup: (_props, { slots }) => () => vue.h(type!, {}, slots.default?.()) }))
+ }
+ app.component('t-popup', vue.defineComponent({
+ props: ['visible'], emits: ['visible-change'],
+ setup: (props, { slots, emit }) => () => vue.h('popup', { onOpen: () => emit('visible-change', true) }, [slots.default?.(), props.visible ? slots.content?.() : null]),
+ }))
+ app.mount(root)
+ const settle = async () => { for (let i = 0; i < 6; i++) await vue.nextTick() }
+ await settle()
+ const find = (predicate: (el: Host) => boolean) => { const el = all(root, predicate)[0]; assert.ok(el); return el }
+ const fire = async (el: Host, event = 'onClick', value?: unknown) => { await el.props[event](value); await settle() }
+ const search = async (value: string) => {
+ await fire(find(el => el.type === 'input'), 'onUpdate:modelValue', value)
+ await new Promise(resolve => setTimeout(resolve, 270))
+ await settle()
+ }
+ return { root, calls, selectedIds, changes, find, fire, search, close: () => app.unmount() }
+}
+
+test('search, create and select happen in one panel without losing previous selection', async t => {
+ const f = await fixture(); t.after(f.close)
+ await f.fire(f.find(el => el.type === 'checkbox'), 'onChange', true)
+ assert.deepEqual([...f.selectedIds.value], ['used'])
+ await f.search('New')
+ await f.fire(f.find(el => hasClass(el, 'tag-picker-create')))
+ assert.deepEqual(JSON.parse(JSON.stringify(f.calls.create)), [['kb', { name: 'New' }]])
+ assert.deepEqual([...f.selectedIds.value], ['used', 'new'])
+ assert.equal(f.changes.length, 1)
+})
+
+test('rename saves in place without changing selection', async t => {
+ const f = await fixture(); t.after(f.close)
+ f.selectedIds.value = ['used']; await vue.nextTick()
+ await f.fire(f.find(el => el.type === 'popup'), 'onOpen')
+ await f.fire(f.find(el => el.type === 'button' && textOf(el) === 'knowledgeBase.tagEditAction'))
+ const input = f.find(el => el.type === 'input' && el.props['aria-label'] === 'knowledgeBase.tagEditAction')
+ await f.fire(input, 'onUpdate:modelValue', 'Renamed')
+ await f.fire(f.find(el => el.type === 'button' && el.props['aria-label'] === 'common.save'))
+ assert.deepEqual(JSON.parse(JSON.stringify(f.calls.rename)), [['kb', 'used', { name: 'Renamed' }]])
+ assert.deepEqual([...f.selectedIds.value], ['used'])
+ assert.ok(textOf(f.root).includes('Renamed'))
+})
+
+test('used tags cannot be deleted; unused deletion never requests cascading content removal', async t => {
+ const f = await fixture(); t.after(f.close)
+ await f.fire(f.find(el => el.type === 'popup'), 'onOpen')
+ const deleteButtons = all(f.root, el => el.type === 'button' && textOf(el) === 'knowledgeBase.tagDeleteAction')
+ assert.ok('disabled' in deleteButtons[0]!.props && deleteButtons[0]!.props.disabled !== false)
+ assert.equal(all(f.root, el => el.type === 'popconfirm').length, 0)
+ await f.fire(all(f.root, el => el.type === 'popup')[1]!, 'onOpen')
+ assert.equal(all(f.root, el => el.type === 'popconfirm').length, 1)
+ f.selectedIds.value = ['used', 'free']; await vue.nextTick()
+ await f.fire(f.find(el => el.type === 'popconfirm'), 'onConfirm')
+ assert.deepEqual(JSON.parse(JSON.stringify(f.calls.remove)), [['kb', 2]])
+ assert.deepEqual([...f.selectedIds.value], ['used'])
+ assert.equal(all(f.root, el => hasClass(el, 'tag-picker-row')).length, 1)
+})
diff --git a/frontend/src/views/knowledge/components/KnowledgeTagPicker.vue b/frontend/src/views/knowledge/components/KnowledgeTagPicker.vue
new file mode 100644
index 000000000..bb0ca914e
--- /dev/null
+++ b/frontend/src/views/knowledge/components/KnowledgeTagPicker.vue
@@ -0,0 +1,194 @@
+<template>
+ <div class="knowledge-tag-picker">
+ <t-input v-model="query" :disabled="busy" :placeholder="$t('knowledgeBase.tagPickerSearch')" :maxlength="40" clearable>
+ <template #prefix-icon><t-icon name="search" size="16px" /></template>
+ </t-input>
+ <div class="tag-picker-list" :aria-label="$t('knowledgeBase.columnTag')">
+ <t-loading v-if="loading && !tags.length" size="small" />
+ <div v-for="tag in tags" :key="tag.id" class="tag-picker-row">
+ <template v-if="editingId === tag.id">
+ <t-input v-model="editingName" autofocus :maxlength="40" size="small" :disabled="busy"
+ :aria-label="$t('knowledgeBase.tagEditAction')" @enter="saveName(tag)"
+ @keydown="(_v: string, ctx: { e: KeyboardEvent }) => { if (ctx.e.key === 'Escape') cancelEdit() }" />
+ <t-button variant="text" shape="square" size="small" :loading="busy" :aria-label="$t('common.save')" @click="saveName(tag)"><t-icon name="check" size="14px" /></t-button>
+ <t-button theme="default" variant="text" shape="square" size="small" :disabled="busy" :aria-label="$t('common.cancel')" @click="cancelEdit"><t-icon name="close" size="14px" /></t-button>
+ </template>
+ <template v-else>
+ <t-checkbox :checked="selectedIds.includes(tag.id)" :disabled="busy" @change="toggle(tag.id)"><span :title="tag.name">{{ tag.name }}</span></t-checkbox>
+ <t-popup attach="body" trigger="click" placement="bottom-right" :visible="menuTagId === tag.id"
+ @visible-change="(visible: boolean) => { if (visible) menuTagId = tag.id; else if (menuTagId === tag.id) menuTagId = '' }">
+ <button type="button" class="tag-picker-more" :class="{ 'is-open': menuTagId === tag.id }" :disabled="busy"
+ :aria-label="`${tag.name} · ${$t('knowledgeBase.columnActions')}`" :aria-expanded="menuTagId === tag.id"><t-icon name="ellipsis" size="16px" /></button>
+ <template #content>
+ <div class="tag-picker-menu">
+ <button type="button" @click="startEdit(tag)">{{ $t('knowledgeBase.tagEditAction') }}</button>
+ <t-tooltip v-if="isUsed(tag)" :content="$t('knowledgeBase.tagPickerInUse')">
+ <span><button type="button" disabled>{{ $t('knowledgeBase.tagDeleteAction') }}</button></span>
+ </t-tooltip>
+ <t-popconfirm v-else attach="body" :content="$t('knowledgeBase.tagPickerDeleteConfirm', { name: tag.name })"
+ :confirm-btn="{ content: $t('common.delete'), theme: 'danger', loading: busy }"
+ :cancel-btn="{ content: $t('common.cancel') }" @confirm="removeTag(tag)">
+ <button type="button" class="tag-picker-delete" :disabled="busy">{{ $t('knowledgeBase.tagDeleteAction') }}</button>
+ </t-popconfirm>
+ </div>
+ </template>
+ </t-popup>
+ </template>
+ </div>
+ <button v-if="canCreate && !loading" type="button" class="tag-picker-create" :disabled="busy" @click="createTag">
+ <t-icon :name="busy ? 'loading' : 'add'" size="16px" />
+ <span :title="query.trim()">{{ $t('knowledgeBase.tagCreateAction') }} “{{ query.trim() }}”</span>
+ </button>
+ <p v-if="!loading && !tags.length && !canCreate" class="tag-picker-empty">{{ $t(query.trim() ? 'knowledgeBase.tagEmptyResult' : 'knowledgeBase.noTags') }}</p>
+ <t-button v-if="hasMore" variant="text" theme="default" size="small" :loading="loading" @click="load(false)">{{ $t('tenant.loadMore') }}</t-button>
+ </div>
+ </div>
+</template>
+
+<script setup lang="ts">
+import { computed, onBeforeUnmount, ref, watch } from 'vue';
+import { useI18n } from 'vue-i18n';
+import { MessagePlugin } from 'tdesign-vue-next';
+import { listKnowledgeTags, createKnowledgeBaseTag, updateKnowledgeBaseTag, deleteKnowledgeBaseTag } from '@/api/knowledge-base';
+
+type Tag = { id: string; seq_id: number; name: string; knowledge_count?: number; chunk_count?: number };
+const props = defineProps<{ kbId: string; selectedIds: string[] }>();
+const emit = defineEmits<{
+ 'update:selectedIds': [ids: string[]];
+ 'busy-change': [busy: boolean];
+ changed: [payload?: { deletedTagId?: string }];
+}>();
+const { t } = useI18n();
+const query = ref('');
+const tags = ref<Tag[]>([]);
+const loading = ref(false);
+const busy = ref(false);
+const page = ref(1);
+const hasMore = ref(false);
+const editingId = ref('');
+const menuTagId = ref('');
+const editingName = ref('');
+let requestVersion = 0;
+let debounce: ReturnType<typeof setTimeout> | undefined;
+const canCreate = computed(() => query.value.trim() && !tags.value.some(tag => tag.name === query.value.trim()));
+const isUsed = (tag: Tag) => !!(tag.knowledge_count || tag.chunk_count);
+const reportError = (error: any) => MessagePlugin.error(error?.message || t('common.operationFailed'));
+watch(busy, value => emit('busy-change', value), { flush: 'sync' });
+
+async function load(reset = true) {
+ if (!props.kbId || (!reset && loading.value)) return;
+ const version = ++requestVersion;
+ if (reset) { page.value = 1; tags.value = []; hasMore.value = false; }
+ loading.value = true;
+ try {
+ const res: any = await listKnowledgeTags(props.kbId, { page: page.value, page_size: 50, keyword: query.value.trim() || undefined });
+ if (version !== requestVersion) return;
+ const rows = (res.data?.data || []).map((tag: Tag) => ({ ...tag, id: String(tag.id) }));
+ tags.value = reset ? rows : [...tags.value, ...rows];
+ hasMore.value = tags.value.length < (res.data?.total || 0);
+ page.value++;
+ } catch (error) { if (version === requestVersion) reportError(error); }
+ finally { if (version === requestVersion) loading.value = false; }
+}
+watch(query, () => {
+ clearTimeout(debounce);
+ requestVersion++;
+ loading.value = true;
+ cancelEdit();
+ menuTagId.value = '';
+ debounce = setTimeout(() => { void load(); }, 250);
+});
+watch(() => props.kbId, () => { void load(); }, { immediate: true });
+onBeforeUnmount(() => { clearTimeout(debounce); requestVersion++; emit('busy-change', false); });
+
+function toggle(id: string) {
+ emit('update:selectedIds', props.selectedIds.includes(id) ? props.selectedIds.filter(value => value !== id) : [...props.selectedIds, id]);
+}
+function startEdit(tag: Tag) { menuTagId.value = ''; editingId.value = tag.id; editingName.value = tag.name; }
+function cancelEdit() { if (!busy.value) { editingId.value = ''; editingName.value = ''; } }
+async function createTag() {
+ const name = query.value.trim();
+ if (!name || busy.value || loading.value) return;
+ busy.value = true;
+ try {
+ const res: any = await createKnowledgeBaseTag(props.kbId, { name });
+ const tag = res.data || res;
+ emit('update:selectedIds', [...new Set([...props.selectedIds, String(tag.id)])]);
+ emit('changed');
+ query.value = '';
+ MessagePlugin.success(t('knowledgeBase.tagCreateSuccess'));
+ } catch (error) { reportError(error); }
+ finally { busy.value = false; }
+}
+async function saveName(tag: Tag) {
+ const name = editingName.value.trim();
+ if (busy.value) return;
+ if (!name) { MessagePlugin.warning(t('knowledgeBase.tagNameRequired')); return; }
+ if (name === tag.name) { cancelEdit(); return; }
+ busy.value = true;
+ try {
+ await updateKnowledgeBaseTag(props.kbId, tag.id, { name });
+ tag.name = name;
+ editingId.value = '';
+ emit('changed');
+ MessagePlugin.success(t('knowledgeBase.tagEditSuccess'));
+ } catch (error) { reportError(error); }
+ finally { busy.value = false; }
+}
+async function removeTag(tag: Tag) {
+ if (busy.value || isUsed(tag)) return;
+ busy.value = true;
+ try {
+ // Do not force deletion: force also deletes the associated knowledge content.
+ await deleteKnowledgeBaseTag(props.kbId, tag.seq_id);
+ emit('update:selectedIds', props.selectedIds.filter(id => id !== tag.id));
+ menuTagId.value = '';
+ emit('changed', { deletedTagId: tag.id });
+ await load();
+ MessagePlugin.success(t('knowledgeBase.tagDeleteSuccess'));
+ } catch (error) { reportError(error); }
+ finally { busy.value = false; }
+}
+</script>
+
+<style scoped lang="less">
+.knowledge-tag-picker { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
+.tag-picker-list { max-height: min(280px, 40vh); overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-gutter: stable; padding: 2px 4px 2px 0; }
+.tag-picker-row {
+ display: flex; align-items: center; gap: 4px; min-width: 0; box-sizing: border-box; min-height: 34px; padding: 2px 4px; border-radius: var(--app-radius-xs);
+ &:hover { background: var(--td-bg-color-container-hover); }
+ > .t-checkbox { flex: 1; min-width: 0; margin: 0; }
+ :deep(.t-checkbox__label) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 400; }
+ > .t-button, > .t-popup { flex-shrink: 0; }
+ > .t-input__wrap { flex: 1; min-width: 0; }
+ :deep(.t-button--theme-default) { color: var(--td-text-color-secondary); }
+ :deep(.t-button--theme-default.t-is-disabled) { color: var(--td-text-color-disabled); }
+}
+.tag-picker-empty { padding: 12px 4px; margin: 0; font-size: var(--app-text-sm); color: var(--td-text-color-placeholder); }
+.tag-picker-more {
+ display: flex; align-items: center; justify-content: center; width: 26px; height: 26px;
+ padding: 0; border: 0; border-radius: var(--app-radius-xs); background: transparent;
+ color: var(--td-text-color-placeholder); cursor: pointer; opacity: 0;
+ &:hover, &.is-open { background: var(--td-bg-color-secondarycontainer); color: var(--td-text-color-primary); }
+}
+.tag-picker-row:hover .tag-picker-more, .tag-picker-row:focus-within .tag-picker-more, .tag-picker-more.is-open { opacity: 1; }
+.tag-picker-more:focus-visible, .tag-picker-create:focus-visible { outline: 2px solid var(--app-focus-border); outline-offset: 2px; }
+@media (hover: none) { .tag-picker-more { opacity: 1; } }
+.tag-picker-menu {
+ min-width: 112px; display: flex; flex-direction: column; gap: 2px;
+ button { width: 100%; display: block; border: 0; border-radius: var(--app-radius-xs); background: transparent; padding: 6px 10px;
+ font: inherit; font-size: var(--app-text-base); font-weight: 400; line-height: 20px; text-align: left; color: var(--td-text-color-primary); cursor: pointer; }
+ button:hover:enabled { background: var(--td-bg-color-container-hover); color: var(--td-brand-color); }
+ button:disabled { color: var(--td-text-color-disabled); cursor: not-allowed; }
+ .tag-picker-delete:hover:enabled { color: var(--td-error-color); }
+}
+.tag-picker-create {
+ display: flex; align-items: center; gap: 8px; width: 100%; min-height: 36px;
+ padding: 4px; border: 0; border-radius: var(--app-radius-xs); background: transparent;
+ font: inherit; font-size: var(--app-text-md); text-align: left; color: var(--td-text-color-secondary); cursor: pointer;
+ .t-icon { color: var(--td-brand-color); flex-shrink: 0; }
+ span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+ &:hover:enabled { background: var(--td-bg-color-container-hover); color: var(--td-text-color-primary); }
+ &:disabled { cursor: wait; }
+}
+</style>
diff --git a/frontend/src/views/knowledge/components/KnowledgeTagPopover.test.ts b/frontend/src/views/knowledge/components/KnowledgeTagPopover.test.ts
new file mode 100644
index 000000000..c6590a3f8
--- /dev/null
+++ b/frontend/src/views/knowledge/components/KnowledgeTagPopover.test.ts
@@ -0,0 +1,106 @@
+import assert from 'node:assert/strict'
+import { readFileSync } from 'node:fs'
+import { runInNewContext } from 'node:vm'
+import test from 'node:test'
+import ts from 'typescript'
+import { compileScript, parse } from '@vue/compiler-sfc'
+import * as vue from 'vue'
+
+const source = readFileSync(new URL('./KnowledgeTagPopover.vue', import.meta.url), 'utf8')
+const { descriptor } = parse(source)
+const compiled = ts.transpileModule(compileScript(descriptor, { id: 'tag-popover-test', inlineTemplate: true }).content, {
+ compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022 },
+}).outputText
+const translate = (key: string) => key
+type Host = { type: string; props: Record<string, any>; children: Host[]; text: string; parent?: Host }
+const node = (type: string): Host => ({ type, props: {}, children: [], text: '' })
+const renderer = vue.createRenderer<Host, Host>({
+ createElement: node,
+ createText: text => ({ ...node('#text'), text }),
+ createComment: text => ({ ...node('#comment'), text }),
+ patchProp: (el, key, _old, value) => { el.props[key] = value },
+ setText: (el, text) => { el.text = text },
+ setElementText: (el, text) => { el.children = []; el.text = text },
+ parentNode: el => el.parent || null,
+ nextSibling: el => el.parent?.children[el.parent.children.indexOf(el) + 1] || null,
+ insert(el, parent, anchor) {
+ if (el.parent) el.parent.children.splice(el.parent.children.indexOf(el), 1)
+ el.parent = parent
+ const index = anchor ? parent.children.indexOf(anchor) : -1
+ parent.children.splice(index < 0 ? parent.children.length : index, 0, el)
+ },
+ remove(el) {
+ el.parent?.children.splice(el.parent.children.indexOf(el), 1)
+ el.parent = undefined
+ },
+})
+const textOf = (el: Host): string => el.type === '#comment' ? '' : el.text + el.children.map(textOf).join('')
+const all = (el: Host, predicate: (node: Host) => boolean): Host[] => [
+ ...(predicate(el) ? [el] : []), ...el.children.flatMap(child => all(child, predicate)),
+]
+
+
+async function fixture(fail = false) {
+ const state = vue.reactive({ visible: false, kbId: 'kb', knowledgeId: 'doc', tags: [{ id: 'a' }] })
+ const requests: unknown[] = []
+ let changes = 0
+ const exports: { default?: vue.Component } = {}
+ runInNewContext(compiled, { exports, require(name: string) {
+ if (name === 'vue') return vue
+ if (name === 'vue-i18n') return { useI18n: () => ({ t: translate }) }
+ if (name === 'tdesign-vue-next') return { MessagePlugin: { success() {}, error() {} } }
+ if (name === '@/api/knowledge-base') return { updateKnowledgeTagBatch: async (data: unknown) => {
+ requests.push(JSON.parse(JSON.stringify(data)))
+ if (fail) throw new Error('save failed')
+ } }
+ if (name === './KnowledgeTagPicker.vue') return { __esModule: true, default: vue.defineComponent({ props: ['selectedIds'], emits: ['update:selectedIds'], setup: (props, { emit }) => () => vue.h('picker', { selectedIds: props.selectedIds, 'onUpdate:selectedIds': (ids: string[]) => emit('update:selectedIds', ids) }) }) }
+ throw new Error(name)
+ } })
+ const root = node('root')
+ const app = renderer.createApp({ setup: () => () => vue.h(exports.default!, {
+ ...state, 'onUpdate:visible': (value: boolean) => { state.visible = value }, onChanged: () => { changes++ },
+ }) })
+ app.config.globalProperties.$t = translate as typeof app.config.globalProperties.$t
+ app.component('t-popup', vue.defineComponent({
+ props: ['visible'], setup: (props, { slots }) => () => vue.h('popup', {}, props.visible ? slots.content?.() : []),
+ }))
+ app.component('t-button', vue.defineComponent({ setup: (_props, { slots }) => () => vue.h('button', {}, slots.default?.()) }))
+ app.mount(root)
+ const settle = async () => { for (let i=0;i<5;i++) await vue.nextTick() }
+ const find = (predicate: (el: Host) => boolean) => { const el = all(root,predicate)[0]; assert.ok(el); return el }
+ const fire = async (el: Host, event = 'onClick', value?: unknown) => { await el.props[event](value); await settle() }
+ state.visible = true; await settle()
+ return { state, requests, changes: () => changes, root, find, fire, settle, close: () => app.unmount() }
+}
+
+test('opening hydrates tags; refreshing the document preserves an open draft; cancel does not save', async t => {
+ const f = await fixture(); t.after(f.close)
+ const picker = f.find(el => el.type === 'picker')
+ assert.deepEqual([...picker.props.selectedIds], ['a'])
+ await f.fire(picker, 'onUpdate:selectedIds', ['a','b'])
+ f.state.tags = [{ id:'other' }]; await f.settle()
+ assert.deepEqual([...picker.props.selectedIds], ['a','b'])
+ await f.fire(f.find(el => el.type === 'button' && textOf(el) === 'common.cancel'))
+ assert.equal(f.state.visible, false)
+ assert.equal(f.requests.length, 0)
+ f.state.visible = true; await f.settle()
+ assert.deepEqual([...f.find(el => el.type === 'picker').props.selectedIds], ['other'])
+})
+
+test('confirm saves the target document and closes only after successful save', async t => {
+ const f = await fixture(); t.after(f.close)
+ await f.fire(f.find(el => el.type === 'picker'), 'onUpdate:selectedIds', ['b'])
+ await f.fire(f.find(el => el.type === 'button' && textOf(el) === 'common.confirm'))
+ assert.deepEqual(f.requests, [{ updates: { doc: ['b'] } }])
+ assert.equal(f.state.visible, false)
+ assert.equal(f.changes(), 1)
+})
+
+test('a failed save preserves the popup and draft for retry', async t => {
+ const f = await fixture(true); t.after(f.close)
+ await f.fire(f.find(el => el.type === 'picker'), 'onUpdate:selectedIds', ['b'])
+ await f.fire(f.find(el => el.type === 'button' && textOf(el) === 'common.confirm'))
+ assert.equal(f.state.visible, true)
+ assert.equal(f.changes(), 0)
+ assert.deepEqual([...f.find(el => el.type === 'picker').props.selectedIds], ['b'])
+})
diff --git a/frontend/src/views/knowledge/components/KnowledgeTagPopover.vue b/frontend/src/views/knowledge/components/KnowledgeTagPopover.vue
new file mode 100644
index 000000000..da58da69f
--- /dev/null
+++ b/frontend/src/views/knowledge/components/KnowledgeTagPopover.vue
@@ -0,0 +1,74 @@
+<template>
+ <div class="knowledge-tag-anchor" @click.stop @mousedown.stop>
+ <t-popup :visible="visible" :disabled="disabled" trigger="click" placement="bottom-left" attach="body"
+ destroy-on-close overlay-class-name="knowledge-tag-popover" :overlay-inner-style="{ padding: '12px' }"
+ @visible-change="changeVisible">
+ <slot />
+ <template #content>
+ <section v-if="visible" class="tag-popover-panel" :aria-label="$t('knowledgeBase.tagEditDialogHeading')">
+ <KnowledgeTagPicker :kb-id="kbId" :selected-ids="selectedIds" @update:selected-ids="selectedIds = $event"
+ @busy-change="busy = $event" @changed="emit('changed', $event)" />
+ <footer class="tag-popover-footer">
+ <span>{{ $t('knowledgeBase.tagSelectedCount', { count: selectedIds.length }) }}</span>
+ <t-button size="small" variant="text" theme="default" :disabled="busy || saving" @click="changeVisible(false)">{{ $t('common.cancel') }}</t-button>
+ <t-button size="small" theme="primary" :disabled="busy" :loading="saving" @click="save">{{ $t('common.confirm') }}</t-button>
+ </footer>
+ </section>
+ </template>
+ </t-popup>
+ </div>
+</template>
+
+<script setup lang="ts">
+import { ref, watch } from 'vue';
+import { useI18n } from 'vue-i18n';
+import { MessagePlugin } from 'tdesign-vue-next';
+import { updateKnowledgeTagBatch } from '@/api/knowledge-base';
+import KnowledgeTagPicker from './KnowledgeTagPicker.vue';
+const props = defineProps<{
+ kbId: string;
+ knowledgeId: string;
+ tags: { id: string }[];
+ visible: boolean;
+ disabled?: boolean;
+}>();
+const emit = defineEmits<{
+ 'update:visible': [visible: boolean];
+ changed: [payload?: { deletedTagId?: string }];
+}>();
+const { t } = useI18n();
+const selectedIds = ref<string[]>([]);
+const busy = ref(false);
+const saving = ref(false);
+watch(() => props.visible, open => {
+ if (open) selectedIds.value = props.tags.map(tag => tag.id);
+}, { immediate: true });
+function changeVisible(visible: boolean) {
+ if (busy.value || saving.value || (visible && props.disabled)) return;
+ emit('update:visible', visible);
+}
+async function save() {
+ if (busy.value || saving.value) return;
+ saving.value = true;
+ try {
+ await updateKnowledgeTagBatch({ updates: { [props.knowledgeId]: [...selectedIds.value] } });
+ MessagePlugin.success(t('knowledgeBase.tagUpdateSuccess'));
+ emit('update:visible', false);
+ emit('changed');
+ } catch (error: any) {
+ MessagePlugin.error(error?.message || t('common.operationFailed'));
+ } finally { saving.value = false; }
+}
+</script>
+
+<style scoped lang="less">
+.knowledge-tag-anchor { min-width: 0; width: 100%; }
+.tag-popover-panel { width: min(300px, calc(100vw - 56px)); }
+.tag-popover-panel :deep(.knowledge-tag-picker) { margin-top: 0; }
+.tag-popover-panel :deep(.tag-picker-list) { max-height: min(240px, 40vh); }
+.tag-popover-footer {
+ display: flex; align-items: center; gap: 6px; margin-top: 10px; padding-top: 10px;
+ border-top: 1px solid var(--td-component-stroke);
+ > span { flex: 1; font-size: var(--app-text-sm); color: var(--td-text-color-placeholder); }
+}
+</style>
diff --git a/frontend/src/views/knowledge/components/TagEditDialog.test.ts b/frontend/src/views/knowledge/components/TagEditDialog.test.ts
deleted file mode 100644
index 63dd7af1f..000000000
--- a/frontend/src/views/knowledge/components/TagEditDialog.test.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import assert from 'node:assert/strict'
-import test from 'node:test'
-import { readFileSync } from 'node:fs'
-
-const component = readFileSync(new URL('./TagEditDialog.vue', import.meta.url), 'utf8')
-const zhCN = readFileSync(new URL('../../../i18n/locales/zh-CN.ts', import.meta.url), 'utf8')
-const enUS = readFileSync(new URL('../../../i18n/locales/en-US.ts', import.meta.url), 'utf8')
-const koKR = readFileSync(new URL('../../../i18n/locales/ko-KR.ts', import.meta.url), 'utf8')
-const jaJP = readFileSync(new URL('../../../i18n/locales/ja-JP.ts', import.meta.url), 'utf8')
-const ruRU = readFileSync(new URL('../../../i18n/locales/ru-RU.ts', import.meta.url), 'utf8')
-
-test('uses a compact flat dialog with selected and available sections', () => {
- assert.match(component, /dialog-class-name="tag-edit-dialog"/)
- assert.match(component, /width="400px"/)
- assert.match(component, /<template #header>/)
- assert.match(component, /class="tag-edit-heading-icon"/)
- assert.match(component, /name="discount"/)
- assert.match(component, /class="setting-drawer__section"/)
- assert.match(component, /class="setting-drawer__section-title"/)
- assert.match(component, /tagEditSelectedSection/)
- assert.match(component, /tagEditAvailableSection/)
- assert.match(component, /canManage/)
- assert.match(component, /tagManageLink/)
- assert.match(component, /open-manage/)
- assert.match(component, /selectedTagsList/)
- assert.match(component, /availableTagsList/)
- assert.match(component, /class="tag-edit-chip"/)
- assert.match(component, /class="tag-edit-create-row"/)
- assert.match(component, /class="tag-edit-footer"/)
- assert.doesNotMatch(component, /class="tag-edit-create"/)
- assert.doesNotMatch(component, /class="tag-edit-count"/)
- assert.doesNotMatch(component, /:header="title"/)
- assert.doesNotMatch(component, /<t-checkbox/)
-})
-
-test('defines the short dialog heading in every supported locale', () => {
- for (const locale of [zhCN, enUS, koKR, jaJP, ruRU]) {
- assert.match(locale, /tagEditDialogHeading:/)
- assert.match(locale, /tagEditSelectedSection:/)
- assert.match(locale, /tagEditAvailableSection:/)
- }
-})
diff --git a/frontend/src/views/knowledge/components/TagEditDialog.vue b/frontend/src/views/knowledge/components/TagEditDialog.vue
deleted file mode 100644
index 123f0a945..000000000
--- a/frontend/src/views/knowledge/components/TagEditDialog.vue
+++ /dev/null
@@ -1,448 +0,0 @@
-<template>
- <t-dialog :visible="visible" :footer="false" width="400px" dialog-class-name="tag-edit-dialog"
- :close-on-overlay-click="false" destroy-on-close @close="handleClose">
- <template #header>
- <div class="tag-edit-heading">
- <div class="tag-edit-heading-row">
- <t-icon name="discount" size="16px" class="tag-edit-heading-icon" aria-hidden="true" />
- <span class="tag-edit-title">{{ $t('knowledgeBase.tagEditDialogHeading') }}</span>
- </div>
- <p class="tag-edit-document-name" :title="knowledgeName">{{ knowledgeName }}</p>
- </div>
- </template>
-
- <div class="tag-edit-body">
- <section class="setting-drawer__section">
- <div class="tag-edit-section-head">
- <h4 class="setting-drawer__section-title">{{ $t('knowledgeBase.tagEditSelectedSection') }}</h4>
- <t-button v-if="selectedSet.size > 0" variant="text" size="small" theme="default" @click="clearAll">
- {{ $t('knowledgeBase.tagClearAction') }}
- </t-button>
- </div>
- <div v-if="selectedTagsList.length > 0" class="tag-edit-chips">
- <button v-for="tag in selectedTagsList" :key="tag.id" type="button" class="tag-edit-chip is-selected"
- :title="tag.name" @click="toggleTag(tag.id)">
- {{ tag.name }}
- </button>
- </div>
- <p v-else class="tag-edit-section-empty">{{ $t('knowledgeBase.tagEditNoSelected') }}</p>
- </section>
-
- <section class="setting-drawer__section">
- <div class="tag-edit-section-head">
- <h4 class="setting-drawer__section-title">{{ $t('knowledgeBase.tagEditAvailableSection') }}</h4>
- <t-button
- v-if="canManage"
- variant="text"
- size="small"
- theme="default"
- class="tag-edit-manage-link"
- @click="handleOpenManage"
- >
- {{ $t('knowledgeBase.tagManageLink') }}
- </t-button>
- </div>
- <div class="tag-edit-search-bar">
- <t-input v-model="searchQuery" :placeholder="$t('knowledgeBase.tagEditSearch')" clearable size="small">
- <template #prefix-icon>
- <t-icon name="search" size="14px" />
- </template>
- </t-input>
- </div>
- <div v-if="availableTagsList.length > 0" class="tag-edit-chips">
- <button v-for="tag in availableTagsList" :key="tag.id" type="button" class="tag-edit-chip"
- :title="tag.knowledge_count !== undefined ? `${tag.name} (${tag.knowledge_count})` : tag.name"
- @click="toggleTag(tag.id)">
- {{ tag.name }}
- </button>
- </div>
- <div v-else class="tag-edit-section-empty tag-edit-section-empty--row">
- <span>{{ searchQuery.trim() ? $t('knowledgeBase.tagEmptyResult') : $t('knowledgeBase.noTags') }}</span>
- <t-button v-if="searchQuery.trim()" variant="text" theme="default" size="small" :loading="creatingTag"
- @click="handleCreateTag">
- {{ $t('knowledgeBase.tagCreateAction') }} “{{ searchQuery.trim() }}”
- </t-button>
- </div>
- <div class="tag-edit-create-row">
- <t-input v-model="newTagName" :placeholder="$t('knowledgeBase.tagNewPlaceholder')" size="small"
- :maxlength="40" :disabled="creatingTag" @enter="handleAddNewTag" />
- </div>
- </section>
- </div>
-
- <div class="tag-edit-footer">
- <span class="tag-edit-selected-count">
- {{ $t('knowledgeBase.tagSelectedCount', { count: selectedSet.size }) }}
- </span>
- <div class="tag-edit-footer-right">
- <t-button variant="outline" size="small" @click="handleClose">
- {{ $t('common.cancel') }}
- </t-button>
- <t-button theme="primary" size="small" :loading="saving" @click="handleConfirm">
- {{ $t('common.confirm') }}
- </t-button>
- </div>
- </div>
- </t-dialog>
-</template>
-
-<script setup lang="ts">
-import { ref } from 'vue';
-import { useI18n } from 'vue-i18n';
-import { MessagePlugin } from 'tdesign-vue-next';
-import { createKnowledgeBaseTag } from '@/api/knowledge-base';
-
-import { useKnowledgeTagSelection, type KnowledgeTag as Tag } from '@/composables/useKnowledgeTagSelection';
-
-const props = defineProps<{
- visible: boolean;
- knowledgeName: string;
- kbId: string;
- tagList: Tag[];
- selectedTags: Tag[];
- canManage?: boolean;
-}>();
-
-const emit = defineEmits<{
- (e: 'update:visible', value: boolean): void;
- (e: 'confirm', tagIds: string[]): void;
- (e: 'tag-created'): void;
- (e: 'open-manage'): void;
-}>();
-
-const { t } = useI18n();
-
-const {
- searchQuery, newTagName, selectedSet, creatingTag, selectedTagsList, availableTagsList,
- toggleTag, clearAll, handleCreateTag, handleAddNewTag,
-} = useKnowledgeTagSelection({
- visible: () => props.visible,
- kbId: () => props.kbId,
- tags: () => props.tagList,
- selectedIds: () => props.selectedTags.map(tag => tag.id),
- createTag: createKnowledgeBaseTag,
- onCreated: () => {
- emit('tag-created');
- MessagePlugin.success(t('knowledgeBase.tagCreateSuccess'));
- },
- onError: (error: any) => MessagePlugin.error(error?.message || t('common.operationFailed')),
-});
-
-const saving = ref(false);
-
-async function handleConfirm() {
- saving.value = true;
- try {
- emit('confirm', Array.from(selectedSet.value));
- emit('update:visible', false);
- } finally {
- saving.value = false;
- }
-}
-
-function handleClose() {
- emit('update:visible', false);
-}
-
-function handleOpenManage() {
- emit('update:visible', false);
- emit('open-manage');
-}
-</script>
-
-<style>
-.tag-edit-dialog {
- overflow: hidden;
- padding: 0;
- border-radius: var(--app-radius-xs);
-}
-
-.tag-edit-dialog .t-dialog__header {
- min-height: auto;
- padding: 20px 20px 0;
-}
-
-.tag-edit-dialog .t-dialog__body {
- padding: 0 20px 20px;
-}
-
-.tag-edit-dialog .t-dialog__close {
- top: 16px;
- right: 16px;
- width: 28px;
- height: 28px;
- border-radius: var(--app-radius-xs);
- color: var(--td-text-color-secondary);
- transition: background 0.18s ease;
-}
-
-.tag-edit-dialog .t-dialog__close:hover {
- color: var(--td-text-color-primary);
- background: var(--td-bg-color-container-hover);
-}
-
-@media (max-width: 480px) {
- .tag-edit-dialog {
- width: calc(100vw - 24px) !important;
- }
-}
-</style>
-
-<style scoped>
-.tag-edit-heading {
- display: flex;
- flex-direction: column;
- gap: 4px;
- min-width: 0;
- padding-right: 28px;
-}
-
-.tag-edit-heading-row {
- display: flex;
- align-items: center;
- gap: 8px;
- min-width: 0;
-}
-
-.tag-edit-heading-icon {
- flex-shrink: 0;
- color: var(--td-text-color-secondary);
-}
-
-.tag-edit-title {
- color: var(--td-text-color-primary);
- font-size: var(--app-text-lg);
- font-weight: 600;
- line-height: 22px;
- letter-spacing: 0.2px;
-}
-
-.tag-edit-document-name {
- margin: 0;
- min-width: 0;
- overflow: hidden;
- color: var(--td-text-color-placeholder);
- font-size: var(--app-text-sm);
- font-weight: 400;
- line-height: 18px;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.tag-edit-body {
- display: flex;
- flex-direction: column;
- margin-top: 16px;
-}
-
-.tag-edit-body .setting-drawer__section {
- padding: 12px 0 16px;
- border-bottom: 1px solid var(--td-component-stroke);
- display: flex;
- flex-direction: column;
- gap: 10px;
-}
-
-.tag-edit-body .setting-drawer__section:first-child {
- padding-top: 0;
-}
-
-.tag-edit-body .setting-drawer__section:last-child {
- border-bottom: none;
- padding-bottom: 0;
-}
-
-.tag-edit-body .setting-drawer__section-title {
- font-size: var(--app-text-md);
- font-weight: 600;
- color: var(--td-text-color-primary);
- margin: 0 0 4px;
- user-select: none;
- display: flex;
- align-items: center;
- gap: 8px;
-}
-
-.tag-edit-body .setting-drawer__section-title::before {
- content: '';
- width: 3px;
- height: 14px;
- background: var(--td-brand-color);
- border-radius: 2px;
- flex-shrink: 0;
-}
-
-.tag-edit-section-head {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 8px;
-}
-
-.tag-edit-section-head .setting-drawer__section-title {
- margin-bottom: 0;
- flex: 1;
- min-width: 0;
-}
-
-.tag-edit-section-head :deep(.t-button) {
- height: auto;
- padding: 0;
- font-size: var(--app-text-sm);
- color: var(--td-text-color-placeholder);
- flex-shrink: 0;
- border: none !important;
- background: transparent !important;
- box-shadow: none !important;
- transition: color var(--app-motion-fast) ease;
-}
-
-.tag-edit-section-head :deep(.tag-edit-manage-link.t-button:hover),
-.tag-edit-section-head :deep(.tag-edit-manage-link.t-button:focus-visible) {
- color: var(--td-brand-color) !important;
- background: transparent !important;
- border-color: transparent !important;
- text-decoration: none;
-}
-
-.tag-edit-search-bar {
- margin: 0;
-}
-
-.tag-edit-search-bar :deep(.t-input) {
- font-size: var(--app-text-sm);
- background-color: var(--td-bg-color-secondarycontainer);
- border-color: transparent;
- border-radius: var(--app-radius-xs);
- box-shadow: none !important;
-}
-
-.tag-edit-search-bar :deep(.t-input:hover),
-.tag-edit-search-bar :deep(.t-input.t-is-focused) {
- border-color: var(--td-component-border);
- background-color: var(--td-bg-color-container);
- box-shadow: none !important;
-}
-
-.tag-edit-chips {
- display: flex;
- flex-wrap: wrap;
- gap: 6px;
- max-height: min(120px, 24vh);
- overflow-y: auto;
- scrollbar-width: thin;
-}
-
-.tag-edit-chips::-webkit-scrollbar {
- width: 4px;
-}
-
-.tag-edit-chips::-webkit-scrollbar-thumb {
- border-radius: 2px;
- background: var(--td-scrollbar-color);
-}
-
-.tag-edit-chip {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- max-width: 100%;
- height: 22px;
- padding: 0 8px;
- border: 1px solid var(--td-component-stroke);
- border-radius: var(--app-radius-xs);
- background: transparent;
- color: var(--td-text-color-secondary);
- font-family: var(--app-font-family);
- font-size: var(--app-text-xs);
- line-height: 22px;
- text-align: center;
- cursor: pointer;
- outline: none;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- transition: border-color var(--app-motion-fast) ease, background var(--app-motion-fast) ease, color var(--app-motion-fast) ease;
- -webkit-font-smoothing: antialiased;
-}
-
-.tag-edit-chip:hover {
- border-color: var(--td-component-stroke);
- background: var(--td-bg-color-secondarycontainer);
- color: var(--td-text-color-primary);
-}
-
-.tag-edit-chip:focus-visible {
- box-shadow: 0 0 0 2px color-mix(in srgb, var(--td-component-stroke) 60%, transparent);
-}
-
-.tag-edit-chip.is-selected {
- border-color: transparent;
- background: var(--td-bg-color-secondarycontainer);
- color: var(--td-text-color-primary);
- font-weight: 500;
-}
-
-.tag-edit-chip.is-selected:hover {
- background: color-mix(in srgb, var(--td-bg-color-secondarycontainer) 70%, var(--td-bg-color-container));
-}
-
-.tag-edit-section-empty {
- margin: 0;
- min-height: 22px;
- font-size: var(--app-text-sm);
- line-height: 22px;
- color: var(--td-text-color-placeholder);
-}
-
-.tag-edit-section-empty--row {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 8px;
-}
-
-.tag-edit-create-row {
- margin-top: 0;
-}
-
-.tag-edit-create-row :deep(.t-input) {
- font-size: var(--app-text-sm);
- background-color: transparent;
- border-style: dashed;
- border-color: var(--td-component-stroke);
- border-radius: var(--app-radius-xs);
- box-shadow: none !important;
-}
-
-.tag-edit-create-row :deep(.t-input:hover),
-.tag-edit-create-row :deep(.t-input.t-is-focused) {
- border-color: var(--td-component-border);
- border-style: dashed;
- background-color: var(--td-bg-color-secondarycontainer);
- box-shadow: none !important;
-}
-
-.tag-edit-footer {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 12px;
- margin-top: 14px;
- padding-top: 14px;
- border-top: 1px solid var(--td-component-stroke);
-}
-
-.tag-edit-selected-count {
- font-size: var(--app-text-sm);
- color: var(--td-text-color-placeholder);
- white-space: nowrap;
-}
-
-.tag-edit-footer-right {
- display: flex;
- align-items: center;
- gap: 8px;
- flex-shrink: 0;
-}
-</style>
diff --git a/frontend/src/views/knowledge/settings/KnowledgeBaseActivitySettings.vue b/frontend/src/views/knowledge/settings/KnowledgeBaseActivitySettings.vue
index 94a1d1983..d8b87a951 100644
--- a/frontend/src/views/knowledge/settings/KnowledgeBaseActivitySettings.vue
+++ b/frontend/src/views/knowledge/settings/KnowledgeBaseActivitySettings.vue
@@ -865,7 +865,7 @@ onUnmounted(() => detachInfiniteScroll())
&.active {
color: var(--td-brand-color);
- background: var(--td-brand-color-light);
+ background: var(--app-selection-bg);
}
}
@@ -895,23 +895,24 @@ onUnmounted(() => detachInfiniteScroll())
gap: 8px;
padding: 6px 10px;
border: none;
- border-radius: var(--app-radius-sm);
+ border-radius: var(--app-radius-xs);
background: transparent;
color: var(--td-text-color-primary);
- font-size: var(--app-text-md);
- line-height: 1.4;
+ font-family: var(--app-font-family);
+ font-size: var(--app-text-base);
+ font-weight: 400;
+ line-height: 20px;
cursor: pointer;
text-align: left;
transition: background var(--app-motion-fast) ease, color var(--app-motion-fast) ease;
&:hover {
- background: var(--td-bg-color-secondarycontainer);
+ background: var(--td-bg-color-container-hover);
}
&.active {
- background: var(--td-brand-color-light);
+ background: var(--app-selection-bg);
color: var(--td-brand-color);
- font-weight: 500;
}
}