修复: AI工具OOM/路径遍历+续跑锁收敛+UX交互批
This commit is contained in:
@@ -45,8 +45,8 @@ import { useI18n } from 'vue-i18n'
|
||||
import ToolCard from './ToolCard.vue'
|
||||
import type { AiToolCallInfo } from '@/api/types'
|
||||
|
||||
// useI18n needed for $t() in template (collapseAll / expandAll)
|
||||
useI18n()
|
||||
// useI18n needed for $t() in template (collapseAll / expandAll) + groupDisplayName(i18n key)
|
||||
const { t } = useI18n()
|
||||
|
||||
const props = defineProps<{
|
||||
/** 当前消息的工具调用列表 */
|
||||
@@ -166,6 +166,34 @@ function toggleAllGroups(): void {
|
||||
collapsedGroups.value = next
|
||||
}
|
||||
|
||||
/**
|
||||
* 分组显示名:工具名 → i18n 友好标签(英文化,原硬编码中文)。
|
||||
* UX-260617-17:用 aiTool.toolGroup.* 子键查表;未命中的工具回退 _ → 空格风格。
|
||||
*/
|
||||
// tool.name → aiTool.toolGroup.* 子键(与后端 tool_registry 工具名一一对应)
|
||||
const TOOL_GROUP_I18N_KEY: Record<string, string> = {
|
||||
read_file: 'readFile',
|
||||
write_file: 'writeFile',
|
||||
list_directory: 'listDirectory',
|
||||
create_task: 'createTask',
|
||||
create_project: 'createProject',
|
||||
create_idea: 'createIdea',
|
||||
list_tasks: 'listTasks',
|
||||
list_projects: 'listProjects',
|
||||
list_ideas: 'listIdeas',
|
||||
delete_project: 'deleteProject',
|
||||
restore_project: 'restoreProject',
|
||||
purge_project: 'purgeProject',
|
||||
update_project: 'updateProject',
|
||||
run_workflow: 'runWorkflow',
|
||||
}
|
||||
|
||||
function groupDisplayName(group: ToolCallGroup): string {
|
||||
const subKey = TOOL_GROUP_I18N_KEY[group.name]
|
||||
if (subKey) return t(`aiTool.toolGroup.${subKey}`)
|
||||
return group.name.replace(/_/g, ' ')
|
||||
}
|
||||
|
||||
/**
|
||||
* 单卡是否展开:
|
||||
* - 分组未折叠 → 用户手动 expandedCards 或首卡默认展开
|
||||
@@ -253,28 +281,6 @@ function groupIcon(name: string): string {
|
||||
if (name.includes('delete')) return '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"/></svg>'
|
||||
return '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>'
|
||||
}
|
||||
|
||||
/** 分组显示名:工具名 + 数量提示 */
|
||||
function groupDisplayName(group: ToolCallGroup): string {
|
||||
const nameMap: Record<string, string> = {
|
||||
read_file: '读取文件',
|
||||
write_file: '写入文件',
|
||||
list_directory: '列出目录',
|
||||
create_task: '创建任务',
|
||||
create_project: '创建项目',
|
||||
create_idea: '创建灵感',
|
||||
list_tasks: '列出任务',
|
||||
list_projects: '列出项目',
|
||||
list_ideas: '列出灵感',
|
||||
delete_project: '删除项目',
|
||||
restore_project: '恢复项目',
|
||||
purge_project: '彻底删除项目',
|
||||
update_project: '更新项目',
|
||||
run_workflow: '运行工作流',
|
||||
}
|
||||
const label = nameMap[group.name] || group.name.replace(/_/g, ' ')
|
||||
return label
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user