diff --git a/web/src/lang/en_us.js b/web/src/lang/en_us.js
index e303ae82..3f10d685 100644
--- a/web/src/lang/en_us.js
+++ b/web/src/lang/en_us.js
@@ -511,7 +511,10 @@ export default {
aiCreatePartMsgCenter:
'】Can you help me continue writing one of the contents of the mind map【',
aiCreatePartMsgPostfix:
- '】The subordinate content of the node needs to be returned in Markdown format and can only use two syntax: Markdown title and unordered list. It can support multi-level nesting. Just return the content.'
+ '】The subordinate content of the node',
+ aiCreatePartMsgHelp:
+ '. Needs to be returned in Markdown format and can only use two syntax: Markdown title and unordered list. It can support multi-level nesting. Just return the content.',
+ aiCreatePart: 'AI Continuation'
},
note: {
title: 'Note'
diff --git a/web/src/lang/zh_cn.js b/web/src/lang/zh_cn.js
index 5892ef54..dcc2e9f1 100644
--- a/web/src/lang/zh_cn.js
+++ b/web/src/lang/zh_cn.js
@@ -491,8 +491,10 @@ export default {
'】,需要以Markdown格式返回,并且只能使用Markdown的标题和无序列表两种语法,可以支持多层嵌套。只需返回内容即可。',
aiCreatePartMsgPrefix: '我有一个主题为【',
aiCreatePartMsgCenter: '】的思维导图,帮我续写其中一个内容为【',
- aiCreatePartMsgPostfix:
- '】的节点的下级内容,需要以Markdown格式返回,并且只能使用Markdown的标题和无序列表两种语法,可以支持多层嵌套。只需返回内容即可。'
+ aiCreatePartMsgPostfix: '】的节点的下级内容',
+ aiCreatePartMsgHelp:
+ '。需要以Markdown格式返回,并且只能使用Markdown的标题和无序列表两种语法,可以支持多层嵌套。只需返回内容即可。',
+ aiCreatePart: 'AI续写'
},
note: {
title: '备注'
diff --git a/web/src/lang/zh_tw.js b/web/src/lang/zh_tw.js
index 7e316615..7f546340 100644
--- a/web/src/lang/zh_tw.js
+++ b/web/src/lang/zh_tw.js
@@ -492,7 +492,10 @@ export default {
aiCreatePartMsgPrefix: '我有一個主題爲【',
aiCreatePartMsgCenter: '】的思維導圖,幫我續寫其中一個內容爲【',
aiCreatePartMsgPostfix:
- '】的節點的下級內容,需要以Markdown格式返回,並且只能使用Markdown的標題和無序列表兩種語法,可以支持多層嵌套。只需返回內容即可。'
+ '】的節點的下級內容',
+ aiCreatePartMsgHelp:
+ '。需要以Markdown格式返回,並且只能使用Markdown的標題和無序列表兩種語法,可以支持多層嵌套。只需返回內容即可。',
+ aiCreatePart: 'AI續寫'
},
note: {
title: '備註'
diff --git a/web/src/pages/Edit/components/AiConfigDialog.vue b/web/src/pages/Edit/components/AiConfigDialog.vue
index 0924fbd0..42094335 100644
--- a/web/src/pages/Edit/components/AiConfigDialog.vue
+++ b/web/src/pages/Edit/components/AiConfigDialog.vue
@@ -33,10 +33,10 @@
-->
-
{{ $t('ai.mindMappingClientConfiguration') }}
+
+
+
+
+
+
+
+
@@ -119,7 +139,11 @@ export default {
aiConfigDialogVisible: false,
mindMapDataCache: '',
- beingAiCreateNodeUid: ''
+ beingAiCreateNodeUid: '',
+
+ createPartDialogVisible: false,
+ aiPartInput: '',
+ beingCreatePartNode: null
}
},
computed: {
@@ -127,7 +151,7 @@ export default {
},
created() {
this.$bus.$on('ai_create_all', this.aiCrateAll)
- this.$bus.$on('ai_create_part', this.aiCreatePart)
+ this.$bus.$on('ai_create_part', this.showAiCreatePartDialog)
this.$bus.$on('ai_chat', this.aiChat)
this.$bus.$on('ai_chat_stop', this.aiChatStop)
this.$bus.$on('showAiConfigDialog', this.showAiConfigDialog)
@@ -137,7 +161,7 @@ export default {
},
beforeDestroy() {
this.$bus.$off('ai_create_all', this.aiCrateAll)
- this.$bus.$off('ai_create_part', this.aiCreatePart)
+ this.$bus.$off('ai_create_part', this.showAiCreatePartDialog)
this.$bus.$off('ai_chat', this.aiChat)
this.$bus.$off('ai_chat_stop', this.aiChatStop)
this.$bus.$off('showAiConfigDialog', this.showAiConfigDialog)
@@ -372,11 +396,47 @@ export default {
walk(data)
},
+ // 显示AI续写弹窗
+ showAiCreatePartDialog(node) {
+ this.beingCreatePartNode = node
+ const currentMindMapData = this.mindMap.getData()
+ // 填充默认内容
+ this.aiPartInput = `${this.$t(
+ 'ai.aiCreatePartMsgPrefix'
+ )}${getStrWithBrFromHtml(currentMindMapData.data.text)}${this.$t(
+ 'ai.aiCreatePartMsgCenter'
+ )}${getStrWithBrFromHtml(node.getData('text'))}${this.$t(
+ 'ai.aiCreatePartMsgPostfix'
+ )}`
+ this.createPartDialogVisible = true
+ },
+
+ // 关闭AI续写弹窗
+ closeAiCreatePartDialog() {
+ this.createPartDialogVisible = false
+ },
+
+ // 复位AI续写弹窗数据
+ resetAiCreatePartDialog() {
+ this.beingCreatePartNode = null
+ this.aiPartInput = ''
+ },
+
+ // 确认AI续写
+ confirmAiCreatePart() {
+ if (!this.aiPartInput.trim()) return
+ this.closeAiCreatePartDialog()
+ this.aiCreatePart()
+ },
+
// AI生成部分
- async aiCreatePart(node) {
+ async aiCreatePart() {
try {
+ if (!this.beingCreatePartNode) {
+ return
+ }
await this.aiTest()
- this.beingAiCreateNodeUid = node.getData('uid')
+ this.beingAiCreateNodeUid = this.beingCreatePartNode.getData('uid')
const currentMindMapData = this.mindMap.getData()
this.mindMapDataCache = JSON.stringify(currentMindMapData)
this.aiCreatingMaskVisible = true
@@ -391,13 +451,8 @@ export default {
messages: [
{
role: 'user',
- content: `${this.$t(
- 'ai.aiCreatePartMsgPrefix'
- )}${getStrWithBrFromHtml(
- currentMindMapData.data.text
- )}${this.$t('ai.aiCreatePartMsgCenter')}${getStrWithBrFromHtml(
- node.getData('text')
- )}${this.$t('ai.aiCreatePartMsgPostfix')}`
+ content:
+ this.aiPartInput.trim() + this.$t('ai.aiCreatePartMsgHelp')
}
]
},
@@ -412,9 +467,11 @@ export default {
content => {
this.aiCreatingContent = content
this.resetOnAiCreatingStop()
+ this.resetAiCreatePartDialog()
},
() => {
this.resetOnAiCreatingStop()
+ this.resetAiCreatePartDialog()
this.resetOnRenderEnd()
this.$message.error(this.$t('ai.generationFailed'))
}