From 45571d28d4def9b0e51ea28d2a31df32c62b39c5 Mon Sep 17 00:00:00 2001 From: liuziting <57311725+liu-ziting@users.noreply.github.com> Date: Wed, 21 Jan 2026 19:43:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=A7=BB=E5=8A=A8=E7=AB=AF?= =?UTF-8?q?=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- src/App.vue | 298 +++++++++++++++++++++++++-------------- src/i18n/index.ts | 2 +- src/i18n/locales/en.json | 3 +- src/i18n/locales/zh.json | 5 +- 5 files changed, 201 insertions(+), 109 deletions(-) diff --git a/index.html b/index.html index b3f36cc..2b06b1c 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - ThinkFlow AI - 智能思维发散 + ThinkFlow AI
diff --git a/src/App.vue b/src/App.vue index 3de982f..8d686c0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -27,6 +27,10 @@ import { Maximize2, Terminal, ChevronRight, + ChevronDown, + ChevronUp, + Menu, + MoreHorizontal, LayoutDashboard, Focus, Target, @@ -110,6 +114,7 @@ const { addNodes, addEdges, onConnect, setNodes, setEdges, nodes: flowNodes, edg // 状态管理 const ideaInput = ref('') const isLoading = ref(false) +const isToolsExpanded = ref(false) const hoveredNodeId = ref(null) const focusedNodeId = ref(null) const draggingNodeId = ref(null) @@ -383,18 +388,36 @@ const expandIdea = async (param?: any, customInput?: string) => { if (!text || (parentNode ? parentNode.data.isExpanding : isLoading.value)) return - // 记录父节点加载状态 - if (parentNode) { - const node = flowNodes.value.find(n => n.id === parentNode.id) - if (node) node.data.isExpanding = true - } else { - isLoading.value = true - } + let currentParentId = parentNode?.id - // 如果是第一次生成,清空画布 + // 如果是第一次生成,立即创建根节点并清空画布 if (!parentNode) { + isLoading.value = true setNodes([]) setEdges([]) + + const rootId = 'root-' + Date.now() + currentParentId = rootId + + addNodes({ + id: rootId, + type: 'window', + position: { x: 50, y: 300 }, + data: { + label: text, + description: t('node.coreIdea'), + type: 'root', + isExpanding: true, + followUp: '' + }, + sourcePosition: Position.Right, + targetPosition: Position.Left + }) + + ideaInput.value = '' + } else { + const node = flowNodes.value.find(n => n.id === parentNode.id) + if (node) node.data.isExpanding = true } const systemPrompt = t('prompts.system') @@ -433,45 +456,20 @@ const expandIdea = async (param?: any, customInput?: string) => { const data = await response.json() const result = JSON.parse(data.choices[0].message.content) - // 起始坐标 - const startX = parentNode ? parentNode.position.x + 450 : 50 - const startY = parentNode ? parentNode.position.y : 300 + // 使用最新的节点位置计算子节点位置 + const parentNodeObj = flowNodes.value.find(n => n.id === currentParentId) + const startX = parentNodeObj ? parentNodeObj.position.x : 50 + const startY = parentNodeObj ? parentNodeObj.position.y : 300 - // 创建根节点 (如果是第一次) - if (!parentNode) { - const rootId = 'root-' + Date.now() - addNodes({ - id: rootId, - type: 'window', - position: { x: startX, y: startY }, - data: { - label: text, - description: t('node.coreIdea'), - type: 'root', - isExpanding: false, - followUp: '' - }, - sourcePosition: Position.Right, - targetPosition: Position.Left - }) - - // 为后续子节点计算位置 - processSubNodes(result.nodes, rootId, startX, startY) - } else { - processSubNodes(result.nodes, parentNode.id, startX, startY) - } + processSubNodes(result.nodes, currentParentId, startX, startY) } catch (error) { console.error('Expansion Error:', error) } finally { - if (parentNode) { - const node = flowNodes.value.find(n => n.id === parentNode.id) - if (node) { - node.data.isExpanding = false - // 不再自动清空 followUp,以便用户查看追问的问题 - } - } else { - isLoading.value = false + const node = flowNodes.value.find(n => n.id === currentParentId) + if (node) { + node.data.isExpanding = false } + isLoading.value = false } } @@ -518,102 +516,186 @@ const startNewSession = () => {