Skip to content

Commit f0275aa

Browse files
committed
feat: 更新组件样式和逻辑,优化用户体验
1 parent 3a6e76e commit f0275aa

File tree

7 files changed

+274
-309
lines changed

7 files changed

+274
-309
lines changed

web/src/components/FileTable.vue

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
</div>
4747
</div>
4848

49-
<div class="batch-actions-compact" v-if="selectedRowKeys.length > 0">
49+
<div class="batch-actions" v-if="selectedRowKeys.length > 0">
5050
<div class="batch-info">
5151
<span>{{ selectedRowKeys.length }} 项</span>
5252
<a-button
@@ -74,7 +74,7 @@
7474
:columns="columnsCompact"
7575
:data-source="filteredFiles"
7676
row-key="file_id"
77-
class="my-table-compact"
77+
class="my-table"
7878
size="small"
7979
:pagination="paginationCompact"
8080
:row-selection="{
@@ -373,7 +373,8 @@ import { parseToShanghai } from '@/utils/time';
373373
.file-table-container {
374374
display: flex;
375375
flex-direction: column;
376-
height: 100%;
376+
max-height: 100%;
377+
overflow: hidden;
377378
border-radius: 12px;
378379
border: 1px solid var(--gray-150);
379380
padding-top: 6px;
@@ -416,12 +417,12 @@ import { parseToShanghai } from '@/utils/time';
416417
}
417418
}
418419
419-
.batch-actions-compact {
420+
.batch-actions {
420421
display: flex;
421422
align-items: center;
422423
justify-content: space-between;
423-
padding: 2px 4px;
424-
background-color: var(--main-5);
424+
padding: 2px 12px;
425+
background-color: var(--main-10);
425426
border-radius: 4px;
426427
margin-bottom: 4px;
427428
flex-shrink: 0;
@@ -434,31 +435,31 @@ import { parseToShanghai } from '@/utils/time';
434435
}
435436
436437
.batch-info span {
437-
font-size: 11px;
438+
font-size: 12px;
438439
font-weight: 500;
439440
color: var(--gray-700);
440441
}
441442
442-
.batch-actions-compact .ant-btn {
443-
font-size: 11px;
443+
.batch-actions .ant-btn {
444+
font-size: 12px;
444445
padding: 0 6px;
445446
height: 22px;
446447
border-radius: 3px;
447448
}
448449
449-
.batch-actions-compact .ant-btn:hover {
450+
.batch-actions .ant-btn:hover {
450451
background-color: var(--main-20);
451452
color: var(--main-color);
452453
}
453454
454-
.my-table-compact {
455+
.my-table {
455456
flex: 1;
456457
overflow: auto;
457458
background-color: transparent;
458459
min-height: 0; /* 让 flex 子项可以正确缩小 */
459460
}
460461
461-
.my-table-compact .main-btn {
462+
.my-table .main-btn {
462463
padding: 0;
463464
height: auto;
464465
line-height: 1.4;
@@ -468,32 +469,32 @@ import { parseToShanghai } from '@/utils/time';
468469
text-decoration: none;
469470
}
470471
471-
.my-table-compact .main-btn:hover {
472+
.my-table .main-btn:hover {
472473
cursor: pointer;
473474
color: var(--main-color);
474475
}
475476
476-
.my-table-compact .del-btn {
477+
.my-table .del-btn {
477478
color: var(--gray-500);
478479
}
479480
480-
.my-table-compact .download-btn {
481+
.my-table .download-btn {
481482
color: var(--gray-500);
482483
}
483484
484-
.my-table-compact .download-btn:hover {
485+
.my-table .download-btn:hover {
485486
color: var(--main-color);
486487
}
487488
488-
.my-table-compact .del-btn:hover {
489+
.my-table .del-btn:hover {
489490
color: var(--error-color);
490491
}
491492
492-
.my-table-compact .del-btn:disabled {
493+
.my-table .del-btn:disabled {
493494
cursor: not-allowed;
494495
}
495496
496-
.my-table-compact .span-type {
497+
.my-table .span-type {
497498
display: inline-block;
498499
padding: 1px 5px;
499500
font-size: 10px;

web/src/components/FileUploadModal.vue

Lines changed: 69 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
<div class="add-files-content">
2222
<div class="upload-header">
2323
<div class="source-selector">
24-
<div class="upload-mode-selector" @click="uploadMode = 'file'" :class="{ active: uploadMode === 'file' }">
25-
<FileOutlined /> 上传文件
26-
</div>
27-
<div class="upload-mode-selector" @click="uploadMode = 'url'" :class="{ active: uploadMode === 'url' }">
28-
<LinkOutlined /> 输入网址
29-
</div>
24+
<a-segmented
25+
v-model:value="uploadMode"
26+
:options="uploadModeOptions"
27+
size="large"
28+
class="source-segmented"
29+
/>
3030
</div>
3131
<div class="config-controls">
3232
<a-button type="dashed" @click="showChunkConfigModal" v-if="!isGraphBased">
@@ -35,7 +35,7 @@
3535
</div>
3636
</div>
3737

38-
<div class="ocr-config">
38+
<div class="ocr-config" v-if="uploadMode === 'file'">
3939
<a-form layout="horizontal">
4040
<a-form-item label="使用OCR" name="enable_ocr">
4141
<div class="ocr-controls">
@@ -67,36 +67,6 @@
6767
</a-form>
6868
</div>
6969

70-
<div class="qa-split-config" v-if="isQaSplitSupported">
71-
<a-form layout="horizontal">
72-
<a-form-item label="QA分割模式" name="use_qa_split">
73-
<div class="toggle-controls">
74-
<a-switch
75-
v-model:checked="chunkParams.use_qa_split"
76-
style="margin-right: 12px;"
77-
/>
78-
<span class="param-description">
79-
{{ chunkParams.use_qa_split ? '启用QA分割(忽略chunk大小设置)' : '使用普通分割模式' }}
80-
</span>
81-
</div>
82-
</a-form-item>
83-
<a-form-item
84-
v-if="chunkParams.use_qa_split"
85-
label="QA分隔符"
86-
name="qa_separator"
87-
>
88-
<a-input
89-
v-model:value="chunkParams.qa_separator"
90-
placeholder="输入QA分隔符"
91-
style="width: 200px; margin-right: 12px;"
92-
/>
93-
<span class="param-description">
94-
用于分割不同QA对的分隔符,默认为3个换行符
95-
</span>
96-
</a-form-item>
97-
</a-form>
98-
</div>
99-
10070
<!-- PDF/图片OCR提醒 -->
10171
<div v-if="uploadMode === 'file' && hasPdfOrImageFiles && !isOcrEnabled" class="ocr-warning-alert">
10272
⚠️ 检测到PDF或图片文件,请启用OCR功能以提取文本内容
@@ -181,7 +151,7 @@
181151
</template>
182152

183153
<script setup>
184-
import { ref, computed, onMounted } from 'vue';
154+
import { ref, computed, onMounted, watch } from 'vue';
185155
import { message, Upload } from 'ant-design-vue';
186156
import { useUserStore } from '@/stores/user';
187157
import { useDatabaseStore } from '@/stores/database';
@@ -295,6 +265,24 @@ const chunkLoading = computed(() => store.state.chunkLoading);
295265
296266
// 上传模式
297267
const uploadMode = ref('file');
268+
const previousOcrSelection = ref('disable');
269+
270+
const uploadModeOptions = computed(() => [
271+
{
272+
value: 'file',
273+
label: h('div', { class: 'segmented-option' }, [
274+
h(FileOutlined, { class: 'option-icon' }),
275+
h('span', { class: 'option-text' }, '上传文件'),
276+
]),
277+
},
278+
{
279+
value: 'url',
280+
label: h('div', { class: 'segmented-option' }, [
281+
h(LinkOutlined, { class: 'option-icon' }),
282+
h('span', { class: 'option-text' }, '输入网址'),
283+
]),
284+
},
285+
]);
298286
299287
// 文件列表
300288
const fileList = ref([]);
@@ -349,6 +337,15 @@ const isOcrEnabled = computed(() => {
349337
return chunkParams.value.enable_ocr !== 'disable';
350338
});
351339
340+
watch(uploadMode, (mode, previous) => {
341+
if (mode === 'url') {
342+
previousOcrSelection.value = chunkParams.value.enable_ocr;
343+
chunkParams.value.enable_ocr = 'disable';
344+
} else if (mode === 'file' && previous === 'url') {
345+
chunkParams.value.enable_ocr = previousOcrSelection.value || 'disable';
346+
}
347+
});
348+
352349
// 计算属性:是否有PDF或图片文件
353350
const hasPdfOrImageFiles = computed(() => {
354351
if (fileList.value.length === 0) {
@@ -647,45 +644,60 @@ const chunkData = async () => {
647644
648645
.source-selector {
649646
display: flex;
650-
gap: 12px;
647+
align-items: center;
651648
}
652649
653-
.upload-mode-selector {
654-
padding: 8px 16px;
655-
border: 1px solid var(--gray-300);
656-
border-radius: 6px;
657-
cursor: pointer;
658-
transition: all 0.3s;
650+
.config-controls {
651+
display: flex;
652+
align-items: center;
653+
}
654+
655+
.source-segmented {
656+
background-color: var(--gray-100);
657+
border-radius: 999px;
658+
padding: 4px;
659+
border: 1px solid var(--gray-200);
659660
}
660661
661-
.upload-mode-selector:hover {
662-
border-color: var(--main-color);
662+
.source-segmented :deep(.ant-segmented-item) {
663+
border-radius: 999px;
664+
}
665+
666+
.source-segmented :deep(.ant-segmented-item-label) {
667+
display: flex;
668+
align-items: center;
669+
gap: 8px;
670+
padding: 6px 16px;
671+
font-weight: 500;
672+
color: var(--gray-600);
663673
}
664674
665-
.upload-mode-selector.active {
666-
border-color: var(--main-color);
675+
.source-segmented :deep(.ant-segmented-thumb) {
667676
background-color: var(--main-30);
677+
border-radius: 999px;
678+
}
679+
680+
.source-segmented :deep(.ant-segmented-item-selected .ant-segmented-item-label) {
668681
color: var(--main-color);
669682
}
670683
671-
.config-controls {
684+
.source-segmented :deep(.segmented-option) {
672685
display: flex;
673686
align-items: center;
687+
gap: 8px;
688+
}
689+
690+
.source-segmented :deep(.option-icon) {
691+
font-size: 16px;
674692
}
675693
676-
.ocr-config,
677-
.qa-split-config {
694+
.ocr-config {
678695
margin-bottom: 20px;
679696
padding: 16px;
680697
background-color: var(--gray-50);
681698
border-radius: 6px;
682699
}
683700
684-
.toggle-controls {
685-
display: flex;
686-
align-items: center;
687-
}
688-
689701
.param-description {
690702
font-size: 12px;
691703
color: var(--gray-600);

0 commit comments

Comments
 (0)