Skip to content

Commit 6bb323c

Browse files
authored
Merge pull request #140 from opentiny/fix/tools-css
fix: tools css
2 parents aa11080 + 0c95207 commit 6bb323c

5 files changed

Lines changed: 115 additions & 18 deletions

File tree

sites/playground/server/src/chat-genui.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import type { IPlaygroundConfig, LLMConfig, LLMConfigParams, McpServer, McpServe
2121

2222
type StreamTextOptions = Parameters<typeof streamText>[0];
2323

24+
const isDevelopment = process.env.NODE_ENV === 'development';
25+
2426
const initClients = async (
2527
serverName: string,
2628
serverConfig: McpServer,
@@ -175,11 +177,11 @@ const getPlaygroundConfig = (playgroundStr: string) => {
175177
}
176178

177179
const rawAgents = playgroundConfig.agents || [];
178-
// 解析后立刻过滤掉指向本地/内网等不安全目标的 Agent,降低 SSRF 风险
179180
const agents = rawAgents.filter((agent) => {
180181
const url = agent.api?.url;
181182
if (!url) return false;
182-
return isAllowedAgentUrl(url);
183+
// 开发态放开 URL 安全校验,生产态保持 SSRF 防护
184+
return isDevelopment || isAllowedAgentUrl(url);
183185
});
184186

185187
return {

sites/playground/web/src/components/tab-components/mcpTools.vue

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,37 @@ const activePanels = ref(['mcp', 'agent']);
88

99
<template>
1010
<div>
11-
<tiny-collapse v-model="activePanels">
11+
<tiny-collapse class="playground-tools" v-model="activePanels">
1212
<McpServerPanel />
1313
<AgentPanel />
1414
</tiny-collapse>
1515
</div>
1616
</template>
1717

1818
<style scoped lang="less">
19-
::deep(.tiny-collapse-item__header) {
20-
padding-left: 0 !important;
21-
padding-right: 0 !important;
22-
border-bottom: none !important;
23-
}
19+
:deep(.tiny-collapse) {
20+
border-bottom: none;
21+
22+
.tiny-collapse-item {
23+
padding-bottom: 16px;
24+
25+
&:first-of-type {
26+
border-top: none;
27+
}
28+
29+
&:last-of-type {
30+
border-bottom: none;
31+
}
32+
33+
.tiny-collapse-item__header {
34+
padding: 0;
35+
border-bottom: none;
36+
}
2437
25-
::deep(.tiny-collapse-item__content) {
26-
padding: 0 !important;
38+
.tiny-collapse-item__content {
39+
padding: 0 !important;
40+
border: none;
41+
}
42+
}
2743
}
2844
</style>

sites/playground/web/src/components/tab-components/tool-panels/AgentDialog.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const agentCapabilityItems = computed((): AgentCapabilityViewItem[] => {
102102
<tiny-dialog-box
103103
:visible="visible"
104104
:title="agentData.index > -1 ? '编辑 Agent' : '添加 Agent'"
105-
width="520px"
105+
width="540px"
106106
:append-to-body="true"
107107
@update:visible="emit('update:visible', $event)"
108108
@close="handleClose"
@@ -112,7 +112,7 @@ const agentCapabilityItems = computed((): AgentCapabilityViewItem[] => {
112112
<div class="agent-url-action-row">
113113
<tiny-input
114114
:model-value="agentData.agentCardUrl"
115-
placeholder="完整的 Agent Card 地址"
115+
placeholder="http://localhost:3000/agent-card"
116116
@update:model-value="updateField('agentCardUrl', $event)"
117117
/>
118118
<tiny-button type="primary" :loading="agentQueryLoading" @click="emit('queryAgentCard')">

sites/playground/web/src/components/tab-components/tool-panels/AgentPanel.vue

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,11 @@ const updateAgentEnabled = (agent, enabled) => {
233233
</script>
234234
235235
<template>
236-
<tiny-collapse-item name="agent" title="Agent(a2a">
236+
<tiny-collapse-item name="agent" title="Agent(A2A 协议">
237237
<template #title-right>
238238
<tiny-button type="text" :icon="IconPlus" @click.stop="addAgent"> </tiny-button>
239239
</template>
240-
<div class="mcp-server-list">
240+
<div class="mcp-server-list" v-if="llmConfig.agents && llmConfig.agents.length > 0">
241241
<div class="mcp-server-item" v-for="(agent, index) in llmConfig.agents || []" :key="agent.name">
242242
<div class="mcp-server-item-header">
243243
<div class="mcp-server-item-name">{{ agent.name }}</div>
@@ -264,7 +264,16 @@ const updateAgentEnabled = (agent, enabled) => {
264264
</tiny-popover>
265265
</div>
266266
</div>
267-
<div class="mcp-server-item-description">{{ agent.description }}</div>
267+
<div class="mcp-server-item-description" v-if="agent.description">{{ agent.description }}</div>
268+
</div>
269+
</div>
270+
<div v-else class="mcp-server-list-empty">
271+
<div class="mcp-server-item-empty">
272+
<div class="mcp-server-item-empty-icon">
273+
点击右上角
274+
<component :is="IconPlus" class="mcp-server-item-empty-plus-icon" />
275+
添加 Agent
276+
</div>
268277
</div>
269278
</div>
270279
<AgentDialog :visible="showAgentFormDialog" :agent-data="agentData" :agent-card="agentCard"
@@ -317,6 +326,37 @@ const updateAgentEnabled = (agent, enabled) => {
317326
}
318327
}
319328
329+
.mcp-server-list-empty {
330+
margin-top: 12px;
331+
}
332+
333+
.mcp-server-item-empty {
334+
border: 1px dashed #d9d9d9;
335+
border-radius: 8px;
336+
min-height: 72px;
337+
display: flex;
338+
align-items: center;
339+
justify-content: center;
340+
background: #fafafa;
341+
}
342+
343+
.mcp-server-item-empty-icon {
344+
display: inline-flex;
345+
align-items: center;
346+
gap: 4px;
347+
color: #8c8c8c;
348+
font-size: 13px;
349+
line-height: 20px;
350+
text-align: center;
351+
letter-spacing: 0.2px;
352+
}
353+
354+
.mcp-server-item-empty-plus-icon {
355+
width: 12px;
356+
height: 12px;
357+
color: #595959;
358+
}
359+
320360
:deep(.mcp-server-item-actions-popover) {
321361
padding: 0;
322362
border: none;

sites/playground/web/src/components/tab-components/tool-panels/McpServerPanel.vue

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,15 @@ const confirmMCPServer = async () => {
195195
<div class="mcp-server-item-description">{{ server.description }}</div>
196196
</div>
197197
</div>
198+
<div v-if="!llmConfig.mcpServers || llmConfig.mcpServers.length === 0" class="mcp-server-list-empty">
199+
<div class="mcp-server-item-empty">
200+
<div class="mcp-server-item-empty-icon">
201+
点击右上角
202+
<component :is="IconPlus" class="mcp-server-item-empty-plus-icon" />
203+
添加 MCP 服务
204+
</div>
205+
</div>
206+
</div>
198207
<div class="mcp-server-tool-call-context">
199208
<tiny-checkbox :model-value="chatConfig.addToolCallContext" @update:model-value="updateAddToolCallContext">
200209
调用结果添加到上下文
@@ -238,15 +247,14 @@ const confirmMCPServer = async () => {
238247
239248
<style scoped lang="less">
240249
.mcp-server-list {
241-
margin-top: 12px;
242250
display: flex;
243251
flex-direction: column;
244252
gap: 8px;
245253
246254
.mcp-server-item {
247255
border: none;
248256
border-radius: 6px;
249-
padding: 6px 10px;
257+
padding: 10px;
250258
transition: background-color 0.2s ease;
251259
252260
&:hover {
@@ -257,7 +265,6 @@ const confirmMCPServer = async () => {
257265
display: flex;
258266
justify-content: space-between;
259267
align-items: center;
260-
margin-bottom: 4px;
261268
}
262269
263270
&-name {
@@ -270,6 +277,7 @@ const confirmMCPServer = async () => {
270277
font-size: 12px;
271278
color: #999;
272279
overflow-wrap: break-word;
280+
margin-top: 4px;
273281
}
274282
275283
&-enabled {
@@ -278,6 +286,37 @@ const confirmMCPServer = async () => {
278286
}
279287
}
280288
289+
.mcp-server-list-empty {
290+
margin-top: 12px;
291+
}
292+
293+
.mcp-server-item-empty {
294+
border: 1px dashed #d9d9d9;
295+
border-radius: 8px;
296+
min-height: 72px;
297+
display: flex;
298+
align-items: center;
299+
justify-content: center;
300+
background: #fafafa;
301+
}
302+
303+
.mcp-server-item-empty-icon {
304+
display: inline-flex;
305+
align-items: center;
306+
gap: 4px;
307+
color: #8c8c8c;
308+
font-size: 13px;
309+
line-height: 20px;
310+
text-align: center;
311+
letter-spacing: 0.2px;
312+
}
313+
314+
.mcp-server-item-empty-plus-icon {
315+
width: 12px;
316+
height: 12px;
317+
color: #595959;
318+
}
319+
281320
.mcp-server-tool-call-context {
282321
margin-top: 12px;
283322
display: flex;

0 commit comments

Comments
 (0)