Demo:优化AI生成逻辑

This commit is contained in:
街角小林 2025-02-20 09:29:20 +08:00
parent 4f2d4f8e36
commit 2577da10d0
10 changed files with 55 additions and 39 deletions

View File

@ -80,13 +80,17 @@ export default {
enableAutoEnterTextEditWhenKeydown: 'Auto enter text edit when keydown',
confirm: 'Confirm',
cancel: 'Cancel',
changeRichTextTip: 'This operation will clear all historical modification records and modify the mind map data. Do you want to continue?',
changeRichTextTip:
'This operation will clear all historical modification records and modify the mind map data. Do you want to continue?',
changeRichTextTip2: 'Do you want to switch to rich text mode?',
changeRichTextTip3: 'Do you want to switch to non rich text mode?',
enableDragImport: 'Is it allowed to directly drag and drop files to the page for import',
enableDragImport:
'Is it allowed to directly drag and drop files to the page for import',
imgTextMargin: 'Node image and text margin',
textContentMargin: 'Node contents margin',
enableInheritAncestorLineStyle: 'Node connection style inherits the style of ancestor nodes',
enableInheritAncestorLineStyle:
'Node connection style inherits the style of ancestor nodes',
enableAi: 'Is enable AI function'
},
color: {
moreColor: 'More color'
@ -275,7 +279,7 @@ export default {
bottom: 'Bottom',
left: 'Left',
right: 'Right',
tag: 'Tag',
tag: 'Tag'
},
theme: {
title: 'Theme',
@ -345,7 +349,8 @@ export default {
exportError: 'Export failed',
dragTip: 'Release here to import the file',
deleteNodeImgTip: 'Are you sure to delete the node image?',
autoOpenNodeRichTextTip: 'Detected imported rich text content, automatically enabled rich text mode'
autoOpenNodeRichTextTip:
'Detected imported rich text content, automatically enabled rich text mode'
},
mouseAction: {
tip1:
@ -430,16 +435,20 @@ export default {
connectFailedTip: 'Client connection failed, please check:',
connectFailedCheckTip1:
'1. Have you installed the mind mapping client? If not, please click here to install:',
connectFailedCheckTip2: '2. If the client is installed, please confirm if the client is opened.',
connectFailedCheckTip2:
'2. If the client is installed, please confirm if the client is opened.',
connectFailedCheckTip3:
'If it has already been installed and started, you can try closing and restarting it.',
connectFailedCheckTip4: 'After completing the above steps, you can click on:',
connectFailedCheckTip4:
'After completing the above steps, you can click on:',
baiduNetdisk: 'Baidu Netdisk',
createMindMapTitle: 'One click generation of mind maps',
createTip:
'Please enter a theme, and AI will generate a mind map based on your theme, such as: Hangzhou weekend travel plan.',
importantTip: 'Important note: One click generation will overwrite existing data. It is recommended to export the current data first.',
wantModifyAiConfigTip: 'Do you want to modify the AI configuration? Please click on:',
importantTip:
'Important note: One click generation will overwrite existing data. It is recommended to export the current data first.',
wantModifyAiConfigTip:
'Do you want to modify the AI configuration? Please click on:',
modifyAIConfiguration: 'Modify AI configuration',
chatInputPlaceholder: 'Enter to send, Shift+Enter to wrap.',
send: 'Send',
@ -449,7 +458,8 @@ export default {
stoppedGenerating: 'Stopped generating',
AIConfiguration: 'AI configuration',
VolcanoArkLargeModelConfiguration: 'Volcano Ark Large Model Configuration:',
configTip: 'At present, only the Volcano Ark model is supported, and you need to obtain the key yourself. For detailed operation steps, please refer to:',
configTip:
'At present, only the Volcano Ark model is supported, and you need to obtain the key yourself. For detailed operation steps, please refer to:',
course: 'Course',
inferenceAccessPoint: 'Inference access point',
mindMappingClientConfiguration: 'Mind mapping client configuration:',
@ -472,7 +482,8 @@ export default {
aiCreateMsgPostfix:
'】. It needs to be returned in Markdown format and can only use two syntax: Markdown title and unordered list. It can support multiple layers of nesting. Just return the content.',
aiCreatePartMsgPrefix: 'I have a theme for【',
aiCreatePartMsgCenter: '】Can you help me continue writing one of the contents of the mind map【',
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.'
}

View File

@ -85,7 +85,8 @@ export default {
changeRichTextTip3: '是否切换为非富文本模式?',
enableDragImport: '是否允许直接拖拽文件到页面进行导入',
imgTextMargin: '节点图片和文本间隔',
textContentMargin: '节点各种内容间隔'
textContentMargin: '节点各种内容间隔',
enableAi: '是否开启AI功能'
},
color: {
moreColor: '更多颜色'

View File

@ -86,7 +86,8 @@ export default {
textContentMargin: '節點各種內容間隔',
enableAutoEnterTextEditWhenKeydown: '鍵盤輸入時自動進入文本編輯',
enableInheritAncestorLineStyle: '節點連線樣式繼承祖先節點的樣式',
alwaysShowExpandBtn: '是否壹直顯示展開收起按鈕'
alwaysShowExpandBtn: '是否壹直顯示展開收起按鈕',
enableAi: '是否開啓AI功能'
},
color: {
moreColor: '更多顏色'

View File

@ -238,15 +238,15 @@ export default {
]
},
content => {
if (content && /\n$/.test(content)) {
this.aiCreatingContent = content
if (content) {
const arr = content.split(/\n+/)
this.aiCreatingContent = arr.splice(0, arr.length - 1).join('\n')
}
this.loopRenderOnAiCreating()
},
content => {
this.aiCreatingContent = content
this.resetOnAiCreatingStop()
this.$message.success(this.$t('ai.aiGenerationSuccess'))
},
() => {
this.resetOnAiCreatingStop()
@ -319,6 +319,7 @@ export default {
//
this.mindMap.updateData(treeData)
this.resetOnRenderEnd()
this.$message.success(this.$t('ai.aiGenerationSuccess'))
}
}
this.mindMap.on('node_tree_render_end', onRenderEnd)
@ -401,15 +402,16 @@ export default {
]
},
content => {
if (content && /\n$/.test(content)) {
this.aiCreatingContent = content
if (content) {
const arr = content.split(/\n+/)
this.aiCreatingContent = arr.splice(0, arr.length - 1).join('\n')
}
this.loopRenderOnAiCreatingPart()
},
content => {
this.aiCreatingContent = content
this.resetOnAiCreatingStop()
this.$message.success(this.$t('ai.aiGenerationSuccess'))
},
() => {
this.resetOnAiCreatingStop()
@ -482,6 +484,7 @@ export default {
} else {
this.mindMap.updateData(treeData)
this.resetOnRenderEnd()
this.$message.success(this.$t('ai.aiGenerationSuccess'))
}
}
this.mindMap.on('node_tree_render_end', onRenderEnd)

View File

@ -258,7 +258,7 @@ export default {
isDark: state => state.localConfig.isDark,
supportNumbers: state => state.supportNumbers,
supportCheckbox: state => state.supportCheckbox,
enableAi: state => state.enableAi
enableAi: state => state.localConfig.enableAi
}),
expandList() {
return [

View File

@ -218,7 +218,7 @@ export default {
isUseMomentum: state => state.localConfig.isUseMomentum,
extraTextOnExport: state => state.extraTextOnExport,
isDragOutlineTreeNode: state => state.isDragOutlineTreeNode,
enableAi: state => state.enableAi
enableAi: state => state.localConfig.enableAi
})
},
watch: {
@ -251,11 +251,6 @@ export default {
}
}
},
created() {
if (this.$route.query && this.$route.query.ai) {
this.setEnableAi(true)
}
},
mounted() {
showLoading()
// this.showNewFeatureInfo()
@ -288,8 +283,6 @@ export default {
this.mindMap.destroy()
},
methods: {
...mapMutations(['setEnableAi']),
handleStartTextEdit() {
this.mindMap.renderer.startTextEdit()
},

View File

@ -246,6 +246,16 @@
>
</div>
</div>
<!-- 是否开启ai功能 -->
<div class="row">
<div class="rowItem">
<el-checkbox
v-model="localConfigs.enableAi"
@change="updateLocalConfig('enableAi', $event)"
>{{ $t('setting.enableAi') }}</el-checkbox
>
</div>
</div>
<!-- 是否开启手绘风格 -->
<div class="row" v-if="supportHandDrawnLikeStyle">
<div class="rowItem">
@ -435,7 +445,8 @@ export default {
isShowScrollbar: false,
isUseHandDrawnLikeStyle: false,
isUseMomentum: false,
enableDragImport: false
enableDragImport: false,
enableAi: false
}
}
},

View File

@ -45,7 +45,7 @@ export default {
isDark: state => state.localConfig.isDark,
activeSidebar: state => state.activeSidebar,
isReadonly: state => state.isReadonly,
enableAi: state => state.enableAi
enableAi: state => state.localConfig.enableAi
}),
triggerList() {

View File

@ -219,7 +219,7 @@ export default {
isDark: state => state.localConfig.isDark,
isHandleLocalFile: state => state.isHandleLocalFile,
openNodeRichText: state => state.localConfig.openNodeRichText,
enableAi: state => state.enableAi
enableAi: state => state.localConfig.enableAi
}),
btnLit() {

View File

@ -23,7 +23,9 @@ const store = new Vuex.Store({
// 是否开启动量效果
isUseMomentum: true,
// 是否是暗黑模式
isDark: false
isDark: false,
// 是否开启AI功能
enableAi: true
},
activeSidebar: '', // 当前显示的侧边栏
isOutlineEdit: false, // 是否是大纲编辑模式
@ -45,8 +47,7 @@ const store = new Vuex.Store({
model: '',
port: 3456,
method: 'POST'
},
enableAi: false // 是否开启AI功能
}
},
mutations: {
// 设置思维导图数据
@ -143,11 +144,6 @@ const store = new Vuex.Store({
// 设置树节点拖拽
setIsDragOutlineTreeNode(state, data) {
state.isDragOutlineTreeNode = data
},
// 设置是否启用AI功能
setEnableAi(state, data) {
state.enableAi = data
}
},
actions: {