From 2577da10d0a7ec5d57a8f2a7d67917de6993b86b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A1=97=E8=A7=92=E5=B0=8F=E6=9E=97?= <1013335014@qq.com> Date: Thu, 20 Feb 2025 09:29:20 +0800 Subject: [PATCH] =?UTF-8?q?Demo=EF=BC=9A=E4=BC=98=E5=8C=96AI=E7=94=9F?= =?UTF-8?q?=E6=88=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/lang/en_us.js | 33 ++++++++++++------- web/src/lang/zh_cn.js | 3 +- web/src/lang/zh_tw.js | 3 +- web/src/pages/Edit/components/AiCreate.vue | 15 +++++---- web/src/pages/Edit/components/Contextmenu.vue | 2 +- web/src/pages/Edit/components/Edit.vue | 9 +---- web/src/pages/Edit/components/Setting.vue | 13 +++++++- .../pages/Edit/components/SidebarTrigger.vue | 2 +- web/src/pages/Edit/components/Toolbar.vue | 2 +- web/src/store.js | 12 +++---- 10 files changed, 55 insertions(+), 39 deletions(-) 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 @@ > + +