引入二级大纲功能,新增父子节点关系及子节点排序,同时调整API与UI以支持嵌套大纲管理
This commit is contained in:
@@ -18,23 +18,48 @@ const isSkipped = computed(() => props.group.status === 'skipped')
|
||||
|
||||
// 工具图标(SVG path)
|
||||
const TOOL_ICONS: Record<string, string> = {
|
||||
// 大纲
|
||||
list_outlines: 'M3 4h10M3 8h10M3 12h6',
|
||||
create_outline: 'M8 3v10M3 8h10',
|
||||
update_outline: 'M3 12l2-2 4 4-2 2H3v-4zM9 6l2-2 4 4-2 2-4-4z',
|
||||
delete_outline: 'M3 5h10M5 5V3h6v2M4 5v8h8V5',
|
||||
reorder_outlines: 'M3 4h7M3 8h7M3 12h7M12 3l2 2-2 2M12 9l2 2-2 2',
|
||||
// 世界观
|
||||
get_world_setting: 'M8 1a7 7 0 100 14A7 7 0 008 1zM1 8h14M8 1c2 2 3 4.5 3 7s-1 5-3 7M8 1c-2 2-3 4.5-3 7s1 5 3 7',
|
||||
save_world_setting: 'M8 1a7 7 0 100 14A7 7 0 008 1zM4 8l3 3 5-5',
|
||||
// 角色
|
||||
list_characters: 'M5.5 5a2.5 2.5 0 105 0 2.5 2.5 0 00-5 0zM3 13c0-2.5 2-4 5-4s5 1.5 5 4',
|
||||
create_character: 'M5 5a2.5 2.5 0 105 0 2.5 2.5 0 00-5 0zM2 13c0-2.5 2-4 5-4M12 6v5M9.5 8.5h5',
|
||||
update_character: 'M5 5a2.5 2.5 0 105 0 2.5 2.5 0 00-5 0zM3 13c0-2.5 2-4 5-4M10 10l2-2 2 2-2 2z',
|
||||
delete_character: 'M5 5a2.5 2.5 0 105 0 2.5 2.5 0 00-5 0zM3 13c0-2.5 2-4 5-4M10 8l4 4M14 8l-4 4',
|
||||
// 章节
|
||||
list_chapters: 'M4 2h8v12H4zM6 5h4M6 8h4M6 11h2',
|
||||
create_chapter: 'M3 2h7v12H3zM12 5v5M9.5 7.5h5',
|
||||
update_chapter: 'M4 2h8v12H4zM7 7l2-2 2 2-2 2z',
|
||||
delete_chapter: 'M4 2h8v12H4zM6 6l4 4M10 6l-4 4',
|
||||
}
|
||||
|
||||
// 工具颜色主题
|
||||
const TOOL_COLORS: Record<string, string> = {
|
||||
// 大纲
|
||||
list_outlines: 'var(--bamboo)',
|
||||
create_outline: 'var(--bamboo)',
|
||||
update_outline: '#d4a017',
|
||||
delete_outline: 'var(--danger)',
|
||||
delete_world_setting: 'var(--danger)',
|
||||
reorder_outlines: '#d4a017',
|
||||
// 世界观
|
||||
get_world_setting: 'var(--ink-500)',
|
||||
save_world_setting: 'var(--bamboo)',
|
||||
// 角色
|
||||
list_characters: '#7c6bc4',
|
||||
create_character: '#7c6bc4',
|
||||
update_character: '#d4a017',
|
||||
delete_character: 'var(--danger)',
|
||||
// 章节
|
||||
list_chapters: '#4a90d9',
|
||||
create_chapter: '#4a90d9',
|
||||
update_chapter: '#d4a017',
|
||||
delete_chapter: 'var(--danger)',
|
||||
}
|
||||
|
||||
function getIcon(name: string): string {
|
||||
@@ -57,10 +82,28 @@ function formatArgs(call: ToolCallEntry): string {
|
||||
return `#${args.outline_id}` + (args.summary ? ` → ${args.summary}` : '')
|
||||
case 'delete_outline':
|
||||
return `#${args.outline_id}`
|
||||
case 'reorder_outlines': {
|
||||
const ids = args.ordered_ids as number[]
|
||||
return ids ? `${ids.length} 个节点` + (args.parent_id ? ` (父节点 #${args.parent_id})` : '') : ''
|
||||
}
|
||||
case 'save_world_setting': {
|
||||
const content = (args.content as string) ?? ''
|
||||
return content.length > 80 ? content.slice(0, 80) + '…' : content
|
||||
}
|
||||
// 角色
|
||||
case 'create_character':
|
||||
return args.name as string ?? ''
|
||||
case 'update_character':
|
||||
return `#${args.character_id}` + (args.name ? ` → ${args.name}` : '')
|
||||
case 'delete_character':
|
||||
return `#${args.character_id}`
|
||||
// 章节
|
||||
case 'create_chapter':
|
||||
return args.title as string ?? ''
|
||||
case 'update_chapter':
|
||||
return `#${args.chapter_id}` + (args.title ? ` → ${args.title}` : '')
|
||||
case 'delete_chapter':
|
||||
return `#${args.chapter_id}`
|
||||
default:
|
||||
return ''
|
||||
}
|
||||
@@ -71,7 +114,11 @@ function formatResult(call: ToolCallEntry): string {
|
||||
if (!call.result) return ''
|
||||
try {
|
||||
const data = call.parsedResult ?? JSON.parse(call.result)
|
||||
// 通用错误检查
|
||||
if ((data as { error?: string }).error) return `失败: ${(data as { error: string }).error}`
|
||||
|
||||
switch (call.name) {
|
||||
// 大纲
|
||||
case 'list_outlines': {
|
||||
const items = (data as { outlines: { id: number; summary: string }[] }).outlines
|
||||
if (!items?.length) return '暂无大纲'
|
||||
@@ -80,11 +127,12 @@ function formatResult(call: ToolCallEntry): string {
|
||||
case 'create_outline':
|
||||
return `已创建: ${(data as { summary: string }).summary}`
|
||||
case 'update_outline':
|
||||
if ((data as { error?: string }).error) return `失败: ${(data as { error: string }).error}`
|
||||
return `已更新: ${(data as { summary: string }).summary}`
|
||||
case 'delete_outline':
|
||||
if ((data as { error?: string }).error) return `失败: ${(data as { error: string }).error}`
|
||||
return '已删除'
|
||||
case 'reorder_outlines':
|
||||
return `已调整 ${(data as { count: number }).count} 个节点的排序`
|
||||
// 世界观
|
||||
case 'get_world_setting': {
|
||||
const content = (data as { content: string }).content
|
||||
if (!content) return '暂无世界观设定'
|
||||
@@ -92,6 +140,30 @@ function formatResult(call: ToolCallEntry): string {
|
||||
}
|
||||
case 'save_world_setting':
|
||||
return `已保存 (${(data as { content_length: number }).content_length} 字)`
|
||||
// 角色
|
||||
case 'list_characters': {
|
||||
const chars = (data as { characters: { id: number; name: string }[] }).characters
|
||||
if (!chars?.length) return '暂无角色'
|
||||
return chars.map((c: { id: number; name: string }) => `• ${c.name}`).join('\n')
|
||||
}
|
||||
case 'create_character':
|
||||
return `已创建: ${(data as { name: string }).name}`
|
||||
case 'update_character':
|
||||
return `已更新: ${(data as { name: string }).name}`
|
||||
case 'delete_character':
|
||||
return '已删除'
|
||||
// 章节
|
||||
case 'list_chapters': {
|
||||
const chs = (data as { chapters: { id: number; title: string }[] }).chapters
|
||||
if (!chs?.length) return '暂无章节'
|
||||
return chs.map((c: { id: number; title: string }) => `• ${c.title}`).join('\n')
|
||||
}
|
||||
case 'create_chapter':
|
||||
return `已创建: ${(data as { title: string }).title}`
|
||||
case 'update_chapter':
|
||||
return `已更新: ${(data as { title: string }).title}`
|
||||
case 'delete_chapter':
|
||||
return '已删除'
|
||||
default:
|
||||
return call.result.slice(0, 100)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user