diff --git a/web/src/lang/en_us.js b/web/src/lang/en_us.js index f78b2dd8..b9eb7e72 100644 --- a/web/src/lang/en_us.js +++ b/web/src/lang/en_us.js @@ -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.' } diff --git a/web/src/lang/zh_cn.js b/web/src/lang/zh_cn.js index 03763ab3..62c73293 100644 --- a/web/src/lang/zh_cn.js +++ b/web/src/lang/zh_cn.js @@ -85,7 +85,8 @@ export default { changeRichTextTip3: '是否切换为非富文本模式?', enableDragImport: '是否允许直接拖拽文件到页面进行导入', imgTextMargin: '节点图片和文本间隔', - textContentMargin: '节点各种内容间隔' + textContentMargin: '节点各种内容间隔', + enableAi: '是否开启AI功能' }, color: { moreColor: '更多颜色' diff --git a/web/src/lang/zh_tw.js b/web/src/lang/zh_tw.js index e1b3cac5..6b2a2366 100644 --- a/web/src/lang/zh_tw.js +++ b/web/src/lang/zh_tw.js @@ -86,7 +86,8 @@ export default { textContentMargin: '節點各種內容間隔', enableAutoEnterTextEditWhenKeydown: '鍵盤輸入時自動進入文本編輯', enableInheritAncestorLineStyle: '節點連線樣式繼承祖先節點的樣式', - alwaysShowExpandBtn: '是否壹直顯示展開收起按鈕' + alwaysShowExpandBtn: '是否壹直顯示展開收起按鈕', + enableAi: '是否開啓AI功能' }, color: { moreColor: '更多顏色' diff --git a/web/src/pages/Edit/components/AiCreate.vue b/web/src/pages/Edit/components/AiCreate.vue index e30220d3..79bec324 100644 --- a/web/src/pages/Edit/components/AiCreate.vue +++ b/web/src/pages/Edit/components/AiCreate.vue @@ -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) diff --git a/web/src/pages/Edit/components/Contextmenu.vue b/web/src/pages/Edit/components/Contextmenu.vue index af18b281..bc00f4e9 100644 --- a/web/src/pages/Edit/components/Contextmenu.vue +++ b/web/src/pages/Edit/components/Contextmenu.vue @@ -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 [ diff --git a/web/src/pages/Edit/components/Edit.vue b/web/src/pages/Edit/components/Edit.vue index b8349223..b98ce6b7 100644 --- a/web/src/pages/Edit/components/Edit.vue +++ b/web/src/pages/Edit/components/Edit.vue @@ -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() }, diff --git a/web/src/pages/Edit/components/Setting.vue b/web/src/pages/Edit/components/Setting.vue index be6f0796..96b35ae5 100644 --- a/web/src/pages/Edit/components/Setting.vue +++ b/web/src/pages/Edit/components/Setting.vue @@ -246,6 +246,16 @@ > + +
+
+ {{ $t('setting.enableAi') }} +
+
@@ -435,7 +445,8 @@ export default { isShowScrollbar: false, isUseHandDrawnLikeStyle: false, isUseMomentum: false, - enableDragImport: false + enableDragImport: false, + enableAi: false } } }, diff --git a/web/src/pages/Edit/components/SidebarTrigger.vue b/web/src/pages/Edit/components/SidebarTrigger.vue index 9a98742c..a721d11b 100644 --- a/web/src/pages/Edit/components/SidebarTrigger.vue +++ b/web/src/pages/Edit/components/SidebarTrigger.vue @@ -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() { diff --git a/web/src/pages/Edit/components/Toolbar.vue b/web/src/pages/Edit/components/Toolbar.vue index cdca10d3..3cb1f8db 100644 --- a/web/src/pages/Edit/components/Toolbar.vue +++ b/web/src/pages/Edit/components/Toolbar.vue @@ -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() { diff --git a/web/src/store.js b/web/src/store.js index 6c820f68..4dcb3708 100644 --- a/web/src/store.js +++ b/web/src/store.js @@ -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: {