优化 mcp 服务器命名呈现

This commit is contained in:
锦恢 2025-04-21 21:42:34 +08:00
parent 299bb30df7
commit 7414a905d4
3 changed files with 43 additions and 8 deletions

View File

@ -55,11 +55,29 @@ const fullDisplayServerName = computed(() => {
});
const displayServerName = computed(() => {
if (connectionResult.serverInfo.name.length > 20) {
return connectionResult.serverInfo.name.substring(0, 20);
} else {
return connectionResult.serverInfo.name;
const name = connectionResult.serverInfo.name;
if (name.length <= 3) return name;
//
const chineseMatch = name.match(/[\u4e00-\u9fa5]/g);
if (chineseMatch && chineseMatch.length >= 2) {
return chineseMatch.slice(0, 3).join('');
}
//
const words = name
.replace(/([a-z])([A-Z])/g, '$1 $2') //
.split(/[\s\-_]+/) // 线
.filter(word => word.length > 0);
if (words.length === 1 && words[0].length > 3) {
return words[0].substring(0, 3).toUpperCase();
}
return words
.map(word => word[0].toUpperCase())
.slice(0, 3)
.join('');
});
function toggleConnectionPanel() {
@ -132,7 +150,7 @@ function toggleConnectionPanel() {
max-width: 60px;
white-space: wrap;
background-color: #f39a6d;
padding: 5px;
padding: 5px 12px;
border-radius: .5em;
color: #1e1e1e;
}

View File

@ -1,6 +1,8 @@
<template>
<div class="mcp-title">
<div class="simple-logo">
<div class="simple-logo"
@click="clickLogo"
>
<span class="iconfont icon-openmcp"></span>
<span style="font-size: 12px;">openmcp</span>
</div>
@ -11,6 +13,12 @@
import { defineComponent } from 'vue';
defineComponent({ name: 'mcp-title' });
function clickLogo() {
window.open('https://kirigaya.cn/blog/article?seq=311', '_blank');
}
</script>
<style>
@ -28,9 +36,18 @@ defineComponent({ name: 'mcp-title' });
height: 73px;
display: flex;
flex-direction: column;
user-select: none;
-webkit-user-drag: none;
transition: var(--animation-3s);
cursor: pointer;
}
.simple-logo:hover {
color: var(--main-color);
}
.simple-logo .iconfont {
font-size: 48px;
}
</style>

View File

@ -2,7 +2,7 @@
"currentIndex": 0,
"tabs": [
{
"name": "Interactive Test",
"name": "交互测试",
"icon": "icon-robot",
"type": "blank",
"componentIndex": 3,