diff --git a/src/App.vue b/src/App.vue index 59f2191..7dde63b 100644 --- a/src/App.vue +++ b/src/App.vue @@ -119,6 +119,9 @@ const focusedNodeId = ref(null) const draggingNodeId = ref(null) const previewImageUrl = ref(null) const showResetConfirm = ref(false) +const showSummaryModal = ref(false) +const isSummarizing = ref(false) +const summaryContent = ref('') // 画布控制状态 const panOnDrag = ref(true) @@ -352,6 +355,58 @@ const exportMarkdown = () => { URL.revokeObjectURL(url) } +/** + * 生成全篇总结 + */ +const generateSummary = async () => { + if (flowNodes.value.length === 0) return + + showSummaryModal.value = true + isSummarizing.value = true + summaryContent.value = '' + + // 收集所有节点信息 + const nodesInfo = flowNodes.value.map(n => ({ + label: n.data.label, + description: n.data.description, + type: n.data.type + })) + + const useConfig = apiConfig.mode === 'default' ? DEFAULT_CONFIG.chat : apiConfig.chat + const finalApiKey = apiConfig.mode === 'default' ? useConfig.apiKey || API_KEY : useConfig.apiKey + + try { + const response = await fetch(useConfig.baseUrl, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${finalApiKey}` + }, + body: JSON.stringify({ + model: useConfig.model, + messages: [ + { + role: 'user', + content: t('prompts.summaryPrompt', { + nodes: JSON.stringify(nodesInfo, null, 2) + }) + } + ] + }) + }) + + if (!response.ok) throw new Error('Summary request failed') + + const data = await response.json() + summaryContent.value = data.choices[0].message.content + } catch (error) { + console.error('Summary Generation Error:', error) + summaryContent.value = t('common.error.unknown') + } finally { + isSummarizing.value = false + } +} + /** * 调用智谱AI生成图片 */ @@ -720,6 +775,12 @@ const startNewSession = () => {
+ + + + + + + + +
+
+ +

{{ t('common.summarizing') }}

+
+
+
+ {{ summaryContent }} +
+
+
+ +
+ +
+ + + + diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index ee3e7be..63e56d7 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -6,8 +6,12 @@ "save": "Save & Close", "cancel": "Cancel", "confirm": "Confirm", + "close": "Close", "loading": "Loading...", "generating": "Generating...", + "summarizing": "Generating session summary...", + "summaryTitle": "Session Summary", + "aiGenerated": "AI Generated", "expanding": "Expanding Idea...", "active": "Active", "signin": "SIGN IN", @@ -36,6 +40,7 @@ "lines": "LINES", "dots": "DOTS", "map": "MAP", + "summary": "SUMMARY", "export": "EXPORT" }, "settings": { @@ -71,6 +76,7 @@ "contextPath": "Thinking Context Path", "selectedNode": "Current Selected Node", "newRequirement": "User Follow-up/New Requirement", - "deepDivePrompt": "Please provide a deep and detailed analysis of 【{topic}】. Requirements:\n1. Clear structure, including background, core principles, key elements, and practical applications.\n2. Professional yet easy-to-understand language.\n3. Total length around 300-500 words.\n4. Output the body text directly, do not use JSON format, and do not include any opening or closing remarks." + "deepDivePrompt": "Please provide a deep and detailed analysis of 【{topic}】. Requirements:\n1. Clear structure, including background, core principles, key elements, and practical applications.\n2. Professional yet easy-to-understand language.\n3. Total length around 300-500 words.\n4. Output the body text directly, do not use JSON format, and do not include any opening or closing remarks.", + "summaryPrompt": "You are a thinking summary expert. Please generate a structured summary based on the provided mind map node information (including the core idea and all branched sub-ideas).\n\nNode data:\n{nodes}\n\nRequirements:\n1. Extract the core theme and its underlying logic.\n2. Summarize several main dimensions or branch directions.\n3. Conclude with final insights or conclusions.\n4. Language should be concise, professional, and inspiring.\n5. Output the summary content directly, do not use JSON format, and do not include any opening remarks." } } \ No newline at end of file diff --git a/src/i18n/locales/zh.json b/src/i18n/locales/zh.json index f166a4c..4497195 100644 --- a/src/i18n/locales/zh.json +++ b/src/i18n/locales/zh.json @@ -6,9 +6,13 @@ "save": "保存并关闭", "cancel": "取消", "confirm": "确定", + "close": "关闭", "loading": "加载中...", "generating": "生成中...", - "expanding": "发散中...", + "summarizing": "正在生成全篇总结...", + "summaryTitle": "思维全篇总结", + "aiGenerated": "AI 智能生成", + "expanding": "思考中...", "active": "激活", "signin": "登录", "tools": "工具箱", @@ -36,6 +40,7 @@ "lines": "网格", "dots": "点阵", "map": "地图", + "summary": "总结", "export": "导出" }, "settings": { @@ -71,6 +76,7 @@ "contextPath": "思考上下文路径", "selectedNode": "当前选择节点", "newRequirement": "用户追问/新要求", - "deepDivePrompt": "请针对【{topic}】提供一个深度且详细的解析。要求:\n1. 结构清晰,包含背景、核心原理、关键要素和实际应用。\n2. 语言专业且易懂。\n3. 总字数控制在 300-500 字左右。\n4. 直接输出正文内容,不要包含 JSON 格式,也不要包含任何开场白或结束语。" + "deepDivePrompt": "请针对【{topic}】提供一个深度且详细的解析。要求:\n1. 结构清晰,包含背景、核心原理、关键要素和实际应用。\n2. 语言专业且易懂。\n3. 总字数控制在 300-500 字左右。\n4. 直接输出正文内容,不要包含 JSON 格式,也不要包含任何开场白或结束语。", + "summaryPrompt": "你是一个思维总结专家。请根据以下提供的思维导图节点信息(包含核心想法及其发散出的所有子想法),生成一份结构化的全篇总结。\n\n节点数据如下:\n{nodes}\n\n要求:\n1. 提炼出核心主题及其背后的核心逻辑。\n2. 归纳出几个主要的维度或分支方向。\n3. 总结最终达成的洞察或结论。\n4. 语言要精炼、专业,富有启发性。\n5. 直接输出总结内容,不要包含 JSON 格式,不要有任何开场白。" } } \ No newline at end of file