Skip to content

Commit 3e6b3b2

Browse files
committed
style: 优化部分按钮并统一部分颜色
1 parent 1700628 commit 3e6b3b2

File tree

5 files changed

+73
-46
lines changed

5 files changed

+73
-46
lines changed

server/routers/knowledge_router.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -407,12 +407,14 @@ async def run_rechunks(context: TaskContext):
407407
error_type = "timeout" if isinstance(doc_error, TimeoutError) else "processing_error"
408408
error_msg = "处理超时" if isinstance(doc_error, TimeoutError) else "处理失败"
409409

410-
processed_items.append({
411-
"file_id": file_id,
412-
"status": "failed",
413-
"error": f"{error_msg}: {str(doc_error)}",
414-
"error_type": error_type
415-
})
410+
processed_items.append(
411+
{
412+
"file_id": file_id,
413+
"status": "failed",
414+
"error": f"{error_msg}: {str(doc_error)}",
415+
"error_type": error_type,
416+
}
417+
)
416418

417419
except asyncio.CancelledError:
418420
await context.set_progress(100.0, "任务已取消")
@@ -422,13 +424,15 @@ async def run_rechunks(context: TaskContext):
422424
logger.exception(f"Task rechunking failed: {task_error}")
423425
await context.set_progress(100.0, f"任务处理失败: {str(task_error)}")
424426
# 将所有未处理的文档标记为失败
425-
for file_id in file_ids[len(processed_items):]:
426-
processed_items.append({
427-
"file_id": file_id,
428-
"status": "failed",
429-
"error": f"任务失败: {str(task_error)}",
430-
"error_type": "task_failed"
431-
})
427+
for file_id in file_ids[len(processed_items) :]:
428+
processed_items.append(
429+
{
430+
"file_id": file_id,
431+
"status": "failed",
432+
"error": f"任务失败: {str(task_error)}",
433+
"error_type": "task_failed",
434+
}
435+
)
432436
raise
433437

434438
failed_count = len([_p for _p in processed_items if _p.get("status") == "failed"])

src/knowledge/utils/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@
2121
"prepare_item_metadata",
2222
"split_text_into_chunks",
2323
"split_text_into_qa_chunks",
24+
"merge_processing_params",
2425
"validate_file_path",
2526
]

src/knowledge/utils/kb_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def merge_processing_params(metadata_params: dict | None, request_params: dict |
229229
if request_params:
230230
merged_params.update(request_params)
231231

232-
logger.debug(f"Merged processing params: metadata={metadata_params}, request={request_params}, result={merged_params}")
232+
logger.debug(f"Merged processing params: {metadata_params=}, {request_params=}, {merged_params=}")
233233
return merged_params
234234

235235

web/src/assets/css/base.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
--color-success: #45b30e;
5151
--color-error: #c73234;
5252
--color-info: #0058d4;
53+
--color-warning: #faad14;
5354

5455
/* Chart Colors - 图表颜色系统 */
5556
--chart-primary: var(--main-500); /* 主色调 - 用于主要数据 */

web/src/components/FileTable.vue

Lines changed: 53 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<div class="batch-info">
5151
<span>{{ selectedRowKeys.length }} 项</span>
5252
<a-button
53-
type="text"
53+
type="link"
5454
size="small"
5555
@click="selectAllFailedFiles"
5656
:disabled="lock"
@@ -61,20 +61,20 @@
6161
</div>
6262
<div style="display: flex; gap: 4px;">
6363
<a-button
64-
type="text"
64+
type="link"
6565
@click="handleBatchRechunk"
6666
:loading="batchRechunking"
6767
:disabled="!canBatchRechunk"
68-
:icon="h(ReloadOutlined)"
68+
:icon="h(RefreshCw)"
6969
title="批量重新分块"
7070
/>
7171
<a-button
72-
type="text"
72+
type="link"
7373
danger
7474
@click="handleBatchDelete"
7575
:loading="batchDeleting"
7676
:disabled="!canBatchDelete"
77-
:icon="h(DeleteOutlined)"
77+
:icon="h(Trash2)"
7878
title="批量删除"
7979
/>
8080
</div>
@@ -121,33 +121,33 @@
121121
</a-button>
122122
<span v-else-if="column.key === 'type'" :class="['span-type', text]">{{ text?.toUpperCase() }}</span>
123123
<div v-else-if="column.key === 'status'" style="display: flex; align-items: center; justify-content: flex-end;">
124-
<CheckCircleFilled v-if="text === 'done'" style="color: #41A317;"/>
125-
<CloseCircleFilled v-else-if="text === 'failed'" style="color: #FF4D4F;"/>
126-
<HourglassFilled v-else-if="text === 'processing'" style="color: #1677FF;"/>
127-
<ClockCircleFilled v-else-if="text === 'waiting'" style="color: #FFCD43;"/>
124+
<CheckCircleFilled v-if="text === 'done'" style="color: var(--color-success);"/>
125+
<CloseCircleFilled v-else-if="text === 'failed'" style="color: var(--color-error);"/>
126+
<HourglassFilled v-else-if="text === 'processing'" style="color: var(--color-info);"/>
127+
<ClockCircleFilled v-else-if="text === 'waiting'" style="color: var(--color-warning);"/>
128128
</div>
129129

130130
<a-tooltip v-else-if="column.key === 'created_at'" :title="formatRelativeTime(text)" placement="left">
131131
<span>{{ formatRelativeTime(text) }}</span>
132132
</a-tooltip>
133133

134-
<div v-else-if="column.key === 'action'" style="display: flex; gap: 4px;">
135-
<a-button class="download-btn" type="text"
134+
<div v-else-if="column.key === 'action'" class="table-row-actions">
135+
<a-button class="download-btn" type="link"
136136
@click="handleDownloadFile(record)"
137137
:disabled="lock || record.status !== 'done'"
138-
:icon="h(DownloadOutlined)"
138+
:icon="h(Download)"
139139
title="下载"
140140
/>
141-
<a-button class="rechunk-btn" type="text"
141+
<a-button class="rechunk-btn" type="link"
142142
@click="handleRechunkFile(record)"
143143
:disabled="lock || record.status === 'processing' || record.status === 'waiting'"
144-
:icon="h(ReloadOutlined)"
144+
:icon="h(RefreshCw)"
145145
title="重新分块"
146146
/>
147-
<a-button class="del-btn" type="text"
147+
<a-button class="del-btn" type="link"
148148
@click="handleDeleteFile(record.file_id)"
149149
:disabled="lock || record.status === 'processing' || record.status === 'waiting'"
150-
:icon="h(DeleteOutlined)"
150+
:icon="h(Trash2)"
151151
title="删除"
152152
/>
153153
</div>
@@ -168,12 +168,15 @@ import {
168168
HourglassFilled,
169169
CloseCircleFilled,
170170
ClockCircleFilled,
171-
DeleteOutlined,
172171
PlusOutlined,
173-
DownloadOutlined,
174-
ReloadOutlined,
175172
} from '@ant-design/icons-vue';
176-
import { ChevronLast, RefreshCcw } from 'lucide-vue-next';
173+
import {
174+
Trash2,
175+
Download,
176+
RefreshCw,
177+
ChevronLast,
178+
RefreshCcw,
179+
} from 'lucide-vue-next';
177180
178181
const store = useDatabaseStore();
179182
const userStore = useUserStore();
@@ -547,6 +550,11 @@ import ChunkParamsConfig from '@/components/ChunkParamsConfig.vue';
547550
548551
button {
549552
padding: 0 8px;
553+
554+
svg {
555+
width: 16px;
556+
height: 16px;
557+
}
550558
}
551559
552560
button:hover {
@@ -597,13 +605,14 @@ import ChunkParamsConfig from '@/components/ChunkParamsConfig.vue';
597605
padding: 0 6px;
598606
height: 22px;
599607
border-radius: 3px;
600-
}
601608
602-
.batch-actions .ant-btn:hover {
603-
background-color: var(--main-20);
604-
color: var(--main-color);
609+
svg {
610+
width: 14px;
611+
height: 14px;
612+
}
605613
}
606614
615+
607616
.my-table {
608617
flex: 1;
609618
overflow: auto;
@@ -626,6 +635,8 @@ import ChunkParamsConfig from '@/components/ChunkParamsConfig.vue';
626635
color: var(--main-color);
627636
}
628637
638+
639+
629640
.my-table .del-btn {
630641
color: var(--gray-500);
631642
}
@@ -642,8 +653,23 @@ import ChunkParamsConfig from '@/components/ChunkParamsConfig.vue';
642653
color: var(--gray-500);
643654
}
644655
656+
/* 统一设置表格操作按钮的图标尺寸 */
657+
.my-table .table-row-actions {
658+
display: flex;
659+
}
660+
661+
.my-table .table-row-actions button {
662+
display: flex;
663+
align-items: center;
664+
}
665+
666+
.my-table .table-row-actions button svg {
667+
width: 16px;
668+
height: 16px;
669+
}
670+
645671
.my-table .rechunk-btn:hover {
646-
color: #faad14;
672+
color: var(--color-warning);
647673
}
648674
649675
.my-table .del-btn:hover {
@@ -701,15 +727,10 @@ import ChunkParamsConfig from '@/components/ChunkParamsConfig.vue';
701727
color: #fff;
702728
}
703729
704-
.panel-action-btn.auto-refresh-btn.ant-btn-primary:hover {
705-
background-color: var(--main-color) !important;
706-
color: #fff !important;
707-
}
708-
709730
.panel-action-btn:hover {
710-
background-color: var(--main-5);
731+
background-color: var(--gray-50);
711732
color: var(--main-color);
712-
border: 1px solid var(--main-color);
733+
/* border: 1px solid var(--main-100); */
713734
}
714735
715736

0 commit comments

Comments
 (0)