feat:将英文的工具名称映射为中文展示

This commit is contained in:
Roe-xin
2025-12-24 10:43:55 +08:00
parent 0b4ec2ca6e
commit fb1156d24f

View File

@ -491,6 +491,19 @@ export function getMessageAreaStyles(): string {
*/ */
export function getMessageAreaScript(): string { export function getMessageAreaScript(): string {
return ` return `
// 工具名称映射
function getToolDisplayName(toolName) {
const toolNameMap = {
'file_read': '已完成文件读取',
'file_write': '已完成文件写入',
'file_list': '已读取目录',
'syntax_check': '语法检查',
'simulation': '仿真',
'waveform_summary': '波形分析'
};
return toolNameMap[toolName] || toolName;
}
// 添加消息 // 添加消息
function addMessage(text, sender) { function addMessage(text, sender) {
const div = document.createElement('div'); const div = document.createElement('div');
@ -729,7 +742,7 @@ export function getMessageAreaScript(): string {
<div class="tool-segment-header\${shouldCollapse ? ' collapsed' : ''}" data-collapsible="\${shouldCollapse}"> <div class="tool-segment-header\${shouldCollapse ? ' collapsed' : ''}" data-collapsible="\${shouldCollapse}">
\${shouldCollapse ? collapseIconSvg : ''} \${shouldCollapse ? collapseIconSvg : ''}
<span class="tool-segment-icon">\${statusIcon}</span> <span class="tool-segment-icon">\${statusIcon}</span>
<span class="tool-segment-name">\${segment.toolName || '工具'}</span> <span class="tool-segment-name">\${getToolDisplayName(segment.toolName) || '工具'}</span>
\${toolResult && !shouldCollapse ? \`<span class="tool-segment-result">\${toolResult}</span>\` : ''} \${toolResult && !shouldCollapse ? \`<span class="tool-segment-result">\${toolResult}</span>\` : ''}
</div> </div>
\${shouldCollapse ? \`<div class="tool-segment-content collapsed"><span class="tool-segment-result" style="display:block;white-space:pre-wrap;max-width:100%;margin-top:8px;margin-left:18px;">\${toolResult}</span></div>\` : ''} \${shouldCollapse ? \`<div class="tool-segment-content collapsed"><span class="tool-segment-result" style="display:block;white-space:pre-wrap;max-width:100%;margin-top:8px;margin-left:18px;">\${toolResult}</span></div>\` : ''}
@ -920,7 +933,7 @@ export function getMessageAreaScript(): string {
<div class="tool-segment-header\${shouldCollapse ? ' collapsed' : ''}" data-collapsible="\${shouldCollapse}"> <div class="tool-segment-header\${shouldCollapse ? ' collapsed' : ''}" data-collapsible="\${shouldCollapse}">
\${shouldCollapse ? collapseIconSvg : ''} \${shouldCollapse ? collapseIconSvg : ''}
<span class="tool-segment-icon">\${statusIcon}</span> <span class="tool-segment-icon">\${statusIcon}</span>
<span class="tool-segment-name">\${segment.toolName || '工具'}</span> <span class="tool-segment-name">\${getToolDisplayName(segment.toolName) || '工具'}</span>
\${toolResult && !shouldCollapse ? \`<span class="tool-segment-result">\${toolResult}</span>\` : ''} \${toolResult && !shouldCollapse ? \`<span class="tool-segment-result">\${toolResult}</span>\` : ''}
</div> </div>
\${shouldCollapse ? \`<div class="tool-segment-content collapsed"><span class="tool-segment-result" style="display:block;white-space:pre-wrap;max-width:100%;margin-top:8px;margin-left:18px;">\${toolResult}</span></div>\` : ''} \${shouldCollapse ? \`<div class="tool-segment-content collapsed"><span class="tool-segment-result" style="display:block;white-space:pre-wrap;max-width:100%;margin-top:8px;margin-left:18px;">\${toolResult}</span></div>\` : ''}
@ -1054,7 +1067,7 @@ export function getMessageAreaScript(): string {
div.className = \`message tool-status tool-\${status}\`; div.className = \`message tool-status tool-\${status}\`;
div.innerHTML = \` div.innerHTML = \`
<span class="tool-icon">\${statusIcons[status]}</span> <span class="tool-icon">\${statusIcons[status]}</span>
<span class="tool-name">\${toolName}</span> <span class="tool-name">\${getToolDisplayName(toolName)}</span>
<span class="tool-status-text">\${statusTexts[status]}</span> <span class="tool-status-text">\${statusTexts[status]}</span>
\${detail ? \`<div class="tool-detail">\${detail}</div>\` : ''} \${detail ? \`<div class="tool-detail">\${detail}</div>\` : ''}
\`; \`;