Skip to content

Commit 9f98f97

Browse files
committed
refactor(ui): 优化模型图标加载和样式调整
移除模型选择弹窗中的冗余标题,调整模型图标样式为白色背景和边框 重构模型图标加载逻辑,改为从远程CDN获取图标资源 在消息加载逻辑中添加延迟参数以避免频繁请求
1 parent 6d064d3 commit 9f98f97

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

web/src/components/AgentChatComponent.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ const _processStreamChunk = (chunk, threadId) => {
614614
}
615615
616616
// Reload messages to show any partial content saved by the backend
617-
fetchThreadMessages({ agentId: currentAgentId.value, threadId: threadId });
617+
fetchThreadMessages({ agentId: currentAgentId.value, threadId: threadId, delay: 500 });
618618
resetOnGoingConv(threadId);
619619
return true;
620620
case 'human_approval_required':
@@ -643,7 +643,7 @@ const _processStreamChunk = (chunk, threadId) => {
643643
}
644644
}
645645
// 异步加载历史记录,保持当前消息显示直到历史记录加载完成
646-
fetchThreadMessages({ agentId: currentAgentId.value, threadId: threadId })
646+
fetchThreadMessages({ agentId: currentAgentId.value, threadId: threadId, delay: 500 })
647647
.finally(() => {
648648
// 历史记录加载完成后,安全地清空当前进行中的对话
649649
resetOnGoingConv(threadId, true);
@@ -658,7 +658,7 @@ const _processStreamChunk = (chunk, threadId) => {
658658
if (chunkMessage) {
659659
message.info(chunkMessage);
660660
}
661-
fetchThreadMessages({ agentId: currentAgentId.value, threadId: threadId })
661+
fetchThreadMessages({ agentId: currentAgentId.value, threadId: threadId, delay: 1000 })
662662
.finally(() => {
663663
resetOnGoingConv(threadId, true);
664664
});
@@ -1116,7 +1116,7 @@ const handleSendOrStop = async () => {
11161116
11171117
// 中断后刷新消息历史,确保显示最新的状态
11181118
try {
1119-
await fetchThreadMessages({ agentId: currentAgentId.value, threadId: threadId, delay: 100 });
1119+
await fetchThreadMessages({ agentId: currentAgentId.value, threadId: threadId, delay: 500 });
11201120
message.info('已中断对话生成');
11211121
} catch (error) {
11221122
console.error('刷新消息历史失败:', error);

web/src/components/ModelProvidersComponent.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@
174174
</div>
175175
<div v-else class="modal-config-content">
176176
<div class="modal-config-header">
177-
<h3>选择 {{ providerConfig.providerName }} 的模型</h3>
178177
<p class="description">勾选您希望在系统中启用的模型,请注意,列表中可能包含非对话模型,请仔细甄别。</p>
179178
</div>
180179

@@ -1096,12 +1095,14 @@ const testCustomProvider = async (providerId, modelName) => {
10961095
filter: grayscale(100%);
10971096
transition: filter 0.2s ease;
10981097
flex-shrink: 0;
1098+
background-color: white;
1099+
border: 1px solid var(--gray-200);
10991100
11001101
img {
11011102
width: 100%;
11021103
height: 100%;
1103-
object-fit: cover;
1104-
border: 1px solid var(--gray-100);
1104+
object-fit: contain;
1105+
padding: 4px;
11051106
border-radius: 6px;
11061107
}
11071108

web/src/utils/modelIcon.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
import openaiIcon from '@/assets/providers/openai.png'
2-
import dashscopeIcon from '@/assets/providers/dashscope.png'
3-
import togetherIcon from '@/assets/providers/together.ai.png'
4-
import deepseekIcon from '@/assets/providers/deepseek.png'
5-
import zhipuIcon from '@/assets/providers/zhipuai.png'
6-
import siliconflowIcon from '@/assets/providers/siliconflow.png'
71
import arkIcon from '@/assets/providers/ark.png'
8-
import openrouterIcon from '@/assets/providers/openrouterai.png'
9-
import defaultIcon from '@/assets/providers/default.png'
10-
import modelscopeIcon from '@/assets/providers/modelscope.png'
2+
3+
4+
// 获取图标URL的函数
5+
const getIconUrl = (provider) => {
6+
return `https://models.dev/logos/${provider}.svg`;
7+
};
8+
9+
// 默认图标URL
10+
const defaultIconUrl = 'https://models.dev/logos/default.svg';
1111

1212
export const modelIcons = {
13-
openai: openaiIcon,
14-
dashscope: dashscopeIcon,
15-
together: togetherIcon,
16-
deepseek: deepseekIcon,
17-
zhipu: zhipuIcon,
18-
siliconflow: siliconflowIcon,
13+
openai: getIconUrl('openai'),
14+
dashscope: getIconUrl('alibaba'),
15+
together: getIconUrl('together'),
16+
deepseek: getIconUrl('deepseek'),
17+
zhipu: getIconUrl('zhipuai'),
18+
siliconflow: getIconUrl('siliconflow'),
1919
ark: arkIcon,
20-
'together.ai': togetherIcon,
21-
openrouter: openrouterIcon,
22-
modelscope: modelscopeIcon,
23-
default: defaultIcon // 添加默认图标
20+
'together.ai': getIconUrl('togetherai'),
21+
openrouter: getIconUrl('openrouter'),
22+
modelscope: getIconUrl('modelscope'),
23+
default: defaultIconUrl
2424
}

0 commit comments

Comments
 (0)