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): distinguish file types and enlarge chat resource chips

wizardchen42aceb17fba0
diff --git a/frontend/src/components/Input-field.vue b/frontend/src/components/Input-field.vue
index 32e8ff2e0..628df7bde 100644
--- a/frontend/src/components/Input-field.vue
+++ b/frontend/src/components/Input-field.vue
@@ -2680,8 +2680,8 @@ defineExpose({
</span>
</span>
<span class="mention-chip__name" :title="item.name">{{ item.name }}</span>
- <span class="mention-chip__remove" @click.stop="removeSelectedItem(item)"
- :aria-label="$t('common.remove')">×</span>
+ <button type="button" class="mention-chip__remove" @click.stop="removeSelectedItem(item)"
+ :aria-label="`${$t('common.remove')} ${item.name}`" :title="$t('common.remove')">×</button>
</span>
</div>
@@ -3059,15 +3059,16 @@ const getImgSrc = (url: string) => {
display: inline-flex;
align-items: center;
gap: 5px;
- min-height: 26px;
- padding: 3px 7px 3px 6px;
+ min-height: 32px;
+ max-width: 100%;
+ padding: 3px 4px 3px 8px;
border-radius: var(--td-radius-medium, 6px);
box-sizing: border-box;
- font-size: 12px;
+ font-size: 14px;
font-weight: 500;
cursor: default;
transition: background 0.15s, border-color 0.15s;
- line-height: 18px;
+ line-height: 20px;
&:hover {
.chat-resource-chip-hover();
@@ -3079,14 +3080,14 @@ const getImgSrc = (url: string) => {
display: inline-flex;
width: 16px;
height: 16px;
- flex: 0 1 auto;
+ flex: 0 0 auto;
min-width: 0;
align-items: center;
justify-content: center;
}
.mention-chip__icon {
- font-size: 12px;
+ font-size: 14px;
display: flex;
align-items: center;
justify-content: center;
@@ -3115,7 +3116,8 @@ const getImgSrc = (url: string) => {
}
.mention-chip__name {
- max-width: 100px;
+ min-width: 0;
+ max-width: 160px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
@@ -3126,15 +3128,19 @@ const getImgSrc = (url: string) => {
display: inline-flex;
align-items: center;
justify-content: center;
- width: 14px;
- height: 14px;
+ width: 24px;
+ height: 24px;
+ padding: 0;
+ border: 0;
+ background: transparent;
margin-left: 1px;
border-radius: 50%;
- font-size: 14px;
+ font-family: inherit;
+ font-size: 18px;
line-height: 1;
font-weight: 400;
cursor: pointer;
- opacity: 0.5;
+ opacity: 0.75;
transition: opacity 0.15s, background 0.15s, color 0.15s;
color: currentColor;
flex-shrink: 0;
@@ -3144,12 +3150,18 @@ const getImgSrc = (url: string) => {
opacity: 0.85;
}
-.mention-chip__remove:hover {
+.mention-chip__remove:hover,
+.mention-chip__remove:focus-visible {
opacity: 1;
background: var(--td-bg-color-component);
color: var(--td-text-color-primary, #1f2937);
}
+.mention-chip__remove:focus-visible {
+ outline: 2px solid var(--td-brand-color);
+ outline-offset: 1px;
+}
+
/* 标签表面保持中性,仅用图标颜色表达资源类型。 */
.mention-chip--kb {
color: var(--td-text-color-primary);
diff --git a/frontend/src/components/css/file-type-colors.less b/frontend/src/components/css/file-type-colors.less
new file mode 100644
index 000000000..5da9610b6
--- /dev/null
+++ b/frontend/src/components/css/file-type-colors.less
@@ -0,0 +1,28 @@
+// Share file-type colors between knowledge cards and list icons.
+.file-type-tone(@icon, @light, @dark) {
+ &[data-file-icon="@{icon}"] {
+ --file-type-color: @light;
+
+ :root[theme-mode="dark"] & {
+ --file-type-color: @dark;
+ }
+ }
+}
+
+.file-type-colors() {
+ --file-type-color: var(--td-text-color-secondary);
+
+ .file-type-tone(file-pdf, #b52a35, #f28b94);
+ .file-type-tone(file-word, #245bb2, #82b2ff);
+ .file-type-tone(file-excel, #187449, #6dcea0);
+ .file-type-tone(file-powerpoint, #ad4d17, #f5ad77);
+ .file-type-tone(code, #7250ad, #baa0ee);
+ .file-type-tone(image, #8f4090, #df9bde);
+ .file-type-tone(sound, #0e747b, #74cdd3);
+ .file-type-tone(video, #654bbb, #b7a1ff);
+ .file-type-tone(link, #245bb2, #82b2ff);
+ .file-type-tone(edit, #0e747b, #74cdd3);
+
+ color: var(--file-type-color);
+ background: color-mix(in srgb, var(--file-type-color) 10%, var(--td-bg-color-container));
+}
diff --git a/frontend/src/views/knowledge/components/DocumentCardView.vue b/frontend/src/views/knowledge/components/DocumentCardView.vue
index 92e98de85..5dc5b6a91 100644
--- a/frontend/src/views/knowledge/components/DocumentCardView.vue
+++ b/frontend/src/views/knowledge/components/DocumentCardView.vue
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { ref, computed, nextTick, onBeforeUnmount, watch } from 'vue';
import { useI18n } from 'vue-i18n';
-import { formatFileSize } from '@/utils/files';
+import { formatFileSize, getFileIcon } from '@/utils/files';
import { useTagChipsOverflow } from '@/composables/useTagChipsOverflow';
import DocumentActionMenu from './DocumentActionMenu.vue';
import FolderPickerMenu, { type FolderOption } from './FolderPickerMenu.vue';
@@ -609,7 +609,8 @@ const handleAction = (action: 'download' | 'edit' | 'view-trace' | 'reparse' | '
</div>
</template>
</div>
- <div class="card-type">
+ <div class="card-type" :data-file-icon="getFileIcon(item)">
+ <t-icon :name="getFileIcon(item)" aria-hidden="true" />
<span>{{ getKnowledgeType(item) }}</span>
</div>
</div>
@@ -686,6 +687,7 @@ const handleAction = (action: 'download' | 'edit' | 'view-trace' | 'reparse' | '
</template>
<style scoped lang="less">
+@import '@/components/css/file-type-colors.less';
@keyframes contentFadeIn {
from { opacity: 0; transform: translateY(6px); }
to { opacity: 1; transform: translateY(0); }
@@ -992,14 +994,21 @@ const handleAction = (action: 'download' | 'edit' | 'view-trace' | 'reparse' | '
}
.card-type {
+ .file-type-colors();
+
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
flex-shrink: 0;
- color: var(--td-text-color-placeholder);
font-family: var(--app-font-family);
font-size: 11px;
font-weight: 500;
- padding: 0;
- background: transparent;
+ line-height: 18px;
+ padding: 1px 5px;
+ border-radius: 4px;
letter-spacing: 0.02em;
+
+ .t-icon { font-size: 13px; }
}
}
diff --git a/frontend/src/views/knowledge/components/DocumentListView.vue b/frontend/src/views/knowledge/components/DocumentListView.vue
index 2fb5fff81..f498f4224 100644
--- a/frontend/src/views/knowledge/components/DocumentListView.vue
+++ b/frontend/src/views/knowledge/components/DocumentListView.vue
@@ -310,7 +310,7 @@ const handleAction = (action: 'download' | 'edit' | 'reparse' | 'cancel-parse' |
</div>
<div class="cell cell-name">
- <span class="row-file-icon-wrap">
+ <span class="row-file-icon-wrap" :data-file-icon="getFileIcon(item)">
<t-icon :name="getFileIcon(item)" />
</span>
<div class="row-file-text">
@@ -483,6 +483,7 @@ const handleAction = (action: 'download' | 'edit' | 'reparse' | 'cancel-parse' |
</template>
<style scoped lang="less">
+@import '@/components/css/file-type-colors.less';
@keyframes doc-list-fade-in {
from {
opacity: 0;
@@ -658,6 +659,10 @@ const handleAction = (action: 'download' | 'edit' | 'reparse' | 'cancel-parse' |
color: var(--td-text-color-secondary);
}
+.row-file-icon-wrap[data-file-icon] {
+ .file-type-colors();
+}
+
.row-file-text {
flex: 1;
min-width: 0;