Skip to content

Commit b8e8346

Browse files
committed
refactor(component): 优化UI样式和工具参数显示逻辑
1. 调整多个组件的间距、字体大小和样式细节 2. 重构工具参数显示逻辑,支持更多参数格式 3. 移除状态按钮中的计数显示,更新图标
1 parent a3edaa8 commit b8e8346

File tree

3 files changed

+21
-29
lines changed

3 files changed

+21
-29
lines changed

web/src/components/AgentChatComponent.vue

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464
:class="{ 'has-content': hasAgentStateContent }"
6565
:title="hasAgentStateContent ? '查看工作状态' : '暂无工作状态'"
6666
>
67-
<Layers class="nav-btn-icon" size="18"/>
68-
<span v-if="hasAgentStateContent" class="text">状态({{ totalAgentStateItems }})</span>
67+
<FolderDotIcon class="nav-btn-icon" size="18"/>
68+
<span v-if="hasAgentStateContent" class="text">状态</span>
6969
</div>
7070
</AgentPopover>
7171
<!-- <div class="nav-btn" @click="shareChat" v-if="currentChatId && currentAgent">
@@ -243,7 +243,7 @@ import AgentMessageComponent from '@/components/AgentMessageComponent.vue'
243243
import ImagePreviewComponent from '@/components/ImagePreviewComponent.vue'
244244
import ChatSidebarComponent from '@/components/ChatSidebarComponent.vue'
245245
import RefsComponent from '@/components/RefsComponent.vue'
246-
import { PanelLeftOpen, MessageCirclePlus, LoaderCircle, Layers, ChevronDown } from 'lucide-vue-next';
246+
import { PanelLeftOpen, MessageCirclePlus, LoaderCircle, FolderDotIcon, ChevronDown } from 'lucide-vue-next';
247247
import { handleChatError, handleValidationError } from '@/utils/errorHandler';
248248
import { ScrollController } from '@/utils/scrollController';
249249
import { AgentValidator } from '@/utils/agentValidator';
@@ -397,14 +397,6 @@ const hasAgentStateContent = computed(() => {
397397
return todoCount > 0 || fileCount > 0;
398398
});
399399
400-
const totalAgentStateItems = computed(() => {
401-
const s = currentAgentState.value;
402-
if (!s) return 0;
403-
const todoCount = Array.isArray(s.todos) ? s.todos.length : 0;
404-
const fileCount = countFiles(s.files);
405-
return todoCount + fileCount;
406-
});
407-
408400
const currentThreadMessages = computed(() => threadMessages.value[currentChatId.value] || []);
409401
410402
// 计算是否显示Refs组件的条件
@@ -1841,13 +1833,9 @@ watch(conversations, () => {
18411833
}
18421834
18431835
/* AgentState 按钮有内容时的样式 */
1844-
.agent-nav-btn.agent-state-btn.has-content {
1845-
color: var(--main-600);
1846-
1847-
&:hover:not(.is-disabled) {
1848-
color: var(--main-700);
1849-
background-color: var(--main-40);
1850-
}
1836+
.agent-nav-btn.agent-state-btn.has-content:hover:not(.is-disabled) {
1837+
color: var(--main-700);
1838+
background-color: var(--main-20);
18511839
}
18521840
18531841
@keyframes spin {

web/src/components/AgentMessageComponent.vue

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,10 @@
6060
</span>
6161
</div>
6262
<div class="tool-content" v-show="expandedToolCalls.has(toolCall.id)">
63-
<div class="tool-params" v-if="toolCall.args || toolCall.function?.arguments">
63+
<div class="tool-params" v-if="String(toolCall.args).length > 2 || String(toolCall.function?.arguments).length > 2">
6464
<div class="tool-params-content">
65-
<strong>参数:</strong>
66-
<span v-if="getFormattedToolArgs(toolCall)">{{ getFormattedToolArgs(toolCall) }}</span>
67-
<span v-else>{{ toolCall.args || toolCall.function?.arguments }}</span>
65+
<strong>参数: </strong>
66+
<span>{{ getFormattedToolArgs(toolCall) }}</span>
6867
</div>
6968
</div>
7069
<div class="tool-result" v-if="toolCall.tool_call_result && toolCall.tool_call_result.content">
@@ -205,17 +204,22 @@ const getToolNameByToolCall = (toolCall) => {
205204
};
206205
207206
const getFormattedToolArgs = (toolCall) => {
208-
const args = toolCall.args || toolCall.function?.arguments;
207+
const args = toolCall.args ? toolCall.args : toolCall.function?.arguments;
209208
if (!args) return '';
210209
211210
try {
212211
// 尝试解析JSON格式的参数
213212
if (typeof args === 'string' && args.trim().startsWith('{')) {
214213
const parsed = JSON.parse(args);
215214
return JSON.stringify(parsed, null, 2);
215+
} else if (typeof args === 'object' && args !== null) {
216+
// 如果是对象类型,直接转换为字符串
217+
console.log('Object args:', args);
218+
return JSON.stringify(args, null, 2);
216219
}
217220
} catch (e) {
218221
// 如果解析失败,直接返回原始字符串
222+
console.log('Failed to parse tool arguments as JSON:', args);
219223
}
220224
221225
return args;
@@ -513,7 +517,7 @@ const toggleToolCall = (toolCallId) => {
513517
514518
.tool-params-content {
515519
margin: 0;
516-
font-size: 13px;
520+
font-size: 12px;
517521
overflow-x: auto;
518522
color: var(--gray-700);
519523
line-height: 1.5;

web/src/components/AgentPopover.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
:title="null"
55
placement="bottomRight"
66
trigger="click"
7-
:overlayStyle="{ width: '400px', zIndex: 1030 }"
7+
:overlayStyle="{ width: '400px', zIndex: 999 }"
88
>
99
<template #content>
1010
<div class="popover-content">
@@ -202,6 +202,7 @@ const formatDate = (dateString) => {
202202
try {
203203
const date = new Date(dateString);
204204
return date.toLocaleString('zh-CN', {
205+
year: 'numeric',
205206
month: '2-digit',
206207
day: '2-digit',
207208
hour: '2-digit',
@@ -438,11 +439,11 @@ const emitRefresh = () => {
438439
.file-list {
439440
display: flex;
440441
flex-direction: column;
441-
gap: 6px;
442+
gap: 4px;
442443
}
443444
444445
.file-item {
445-
padding: 12px 14px;
446+
padding: 8px 12px;
446447
background: var(--gray-0);
447448
border: 1px solid var(--gray-150);
448449
border-radius: 6px;
@@ -468,14 +469,13 @@ const emitRefresh = () => {
468469
flex: 1;
469470
display: flex;
470471
flex-direction: column;
471-
gap: 4px;
472+
gap: 2px;
472473
min-width: 0;
473474
}
474475
475476
.file-name {
476477
font-size: 14px;
477478
color: var(--gray-1000);
478-
font-family: 'JetBrains Mono', 'Fira Code', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
479479
font-weight: 500;
480480
flex: 1;
481481
overflow: hidden;

0 commit comments

Comments
 (0)