From 121eba17999edf71522f3b651743494c1fa4261f Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Sat, 5 Apr 2025 20:48:00 +0800 Subject: [PATCH] =?UTF-8?q?Demo:=E6=94=AF=E6=8C=81=E6=89=A9=E5=B1=95?= =?UTF-8?q?=E4=BE=A7=E8=BE=B9=E4=B8=BB=E9=A2=98=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/pages/Edit/components/Edit.vue | 25 ++++++++++++++++++- web/src/pages/Edit/components/Theme.vue | 33 ++++++++++++++++--------- web/src/store.js | 9 ++++++- 3 files changed, 54 insertions(+), 13 deletions(-) diff --git a/web/src/pages/Edit/components/Edit.vue b/web/src/pages/Edit/components/Edit.vue index 3cf85626..c0db03a5 100644 --- a/web/src/pages/Edit/components/Edit.vue +++ b/web/src/pages/Edit/components/Edit.vue @@ -102,7 +102,8 @@ import Checkbox from 'simple-mind-map-plugin-checkbox' import LineFlow from 'simple-mind-map-plugin-lineflow' import Momentum from 'simple-mind-map-plugin-momentum' import RightFishbone from 'simple-mind-map-plugin-right-fishbone' -// npm link simple-mind-map-plugin-excel simple-mind-map-plugin-freemind simple-mind-map-plugin-numbers simple-mind-map-plugin-notation simple-mind-map-plugin-handdrawnlikestyle simple-mind-map-plugin-checkbox simple-mind-map simple-mind-map-plugin-themes simple-mind-map-plugin-lineflow simple-mind-map-plugin-momentum simple-mind-map-plugin-right-fishbone +import MoreThemes from 'simple-mind-map-plugin-more-themes' +// npm link simple-mind-map-plugin-excel simple-mind-map-plugin-freemind simple-mind-map-plugin-numbers simple-mind-map-plugin-notation simple-mind-map-plugin-handdrawnlikestyle simple-mind-map-plugin-checkbox simple-mind-map simple-mind-map-plugin-themes simple-mind-map-plugin-lineflow simple-mind-map-plugin-momentum simple-mind-map-plugin-right-fishbone simple-mind-map-plugin-more-themes import OutlineSidebar from './OutlineSidebar.vue' import Style from './Style.vue' import BaseStyle from './BaseStyle.vue' @@ -171,6 +172,10 @@ MindMap.usePlugin(MiniMap) // 注册主题 Themes.init(MindMap) +// 扩展主题列表 +if (typeof MoreThemes !== 'undefined') { + MoreThemes.init(MindMap) +} export default { components: { @@ -697,6 +702,24 @@ export default { this.mindMap.addPlugin(LineFlow) this.$store.commit('setSupportLineFlow', true) } + // 扩展侧边主题列表 + if (typeof MoreThemes !== 'undefined') { + const extendThemeGroupList = [ + { + name: '带背景', // 主题组名称 + // 主题列表 + list: [...MoreThemes.lightList, ...MoreThemes.darkList].map( + item => { + return { + ...item, + img: MoreThemes.themeImgMap[item.value] + } + } + ) + } + ] + this.$store.commit('setExtendThemeGroupList', extendThemeGroupList) + } }, // url中是否存在要打开的文件 diff --git a/web/src/pages/Edit/components/Theme.vue b/web/src/pages/Edit/components/Theme.vue index 70841666..1e0c364f 100644 --- a/web/src/pages/Edit/components/Theme.vue +++ b/web/src/pages/Edit/components/Theme.vue @@ -17,7 +17,7 @@ :class="{ active: item.value === theme }" >
- +
{{ item.name }}
@@ -59,15 +59,20 @@ export default { themeImgMap, theme: '', activeName: '', - groupList: [] + defaultGroupList: [] } }, computed: { ...mapState({ isDark: state => state.localConfig.isDark, - activeSidebar: state => state.activeSidebar + activeSidebar: state => state.activeSidebar, + extendThemeGroupList: state => state.extendThemeGroupList }), + groupList() { + return [...this.defaultGroupList, ...this.extendThemeGroupList] + }, + currentList() { return this.groupList.find(item => { return item.name === this.activeName @@ -101,7 +106,7 @@ export default { }, initGroup() { - let baiduThemes = [ + const baiduThemes = [ 'default', 'skyGreen', 'classic2', @@ -117,8 +122,8 @@ export default { 'pinkGrape', 'mint' ] - let baiduList = [] - let classicsList = [] + const baiduList = [] + const classicsList = [] this.themeList.forEach(item => { if (baiduThemes.includes(item.value)) { baiduList.push(item) @@ -126,7 +131,7 @@ export default { classicsList.push(item) } }) - this.groupList = [ + this.defaultGroupList = [ { name: this.$t('theme.classics'), list: classicsList @@ -142,7 +147,7 @@ export default { list: baiduList } ] - this.activeName = this.groupList[0].name + this.activeName = this.defaultGroupList[0].name }, useTheme(theme) { @@ -184,7 +189,11 @@ export default { }, handleDark() { - let target = this.themeList.find(item => { + const extendThemeList = [] + this.extendThemeGroupList.forEach(group => { + extendThemeList.push(...group.list) + }) + let target = [...this.themeList, ...extendThemeList].find(item => { return item.value === this.theme }) this.setLocalConfig({ @@ -213,7 +222,9 @@ export default { margin-bottom: 20px; padding-bottom: 20px; transition: all 0.2s; - border: 1px solid transparent; + border: 3px solid transparent; + border-radius: 5px; + overflow: hidden; &:last-of-type { border: none; @@ -225,7 +236,7 @@ export default { } &.active { - border: 1px solid #67c23a; + border: 3px solid rgb(154, 198, 250); } .imgBox { diff --git a/web/src/store.js b/web/src/store.js index 8e022955..0c3fed49 100644 --- a/web/src/store.js +++ b/web/src/store.js @@ -45,7 +45,9 @@ const store = new Vuex.Store({ model: '', port: 3456, method: 'POST' - } + }, + // 扩展主题列表 + extendThemeGroupList: [] }, mutations: { // 设置操作本地文件标志位 @@ -137,6 +139,11 @@ const store = new Vuex.Store({ // 设置树节点拖拽 setIsDragOutlineTreeNode(state, data) { state.isDragOutlineTreeNode = data + }, + + // 扩展主题列表 + setExtendThemeGroupList(state, data) { + state.extendThemeGroupList = data } }, actions: {}