mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-17 14:04:47 +08:00
Demo:支持扩展侧边主题列表
This commit is contained in:
@@ -102,7 +102,8 @@ import Checkbox from 'simple-mind-map-plugin-checkbox'
|
|||||||
import LineFlow from 'simple-mind-map-plugin-lineflow'
|
import LineFlow from 'simple-mind-map-plugin-lineflow'
|
||||||
import Momentum from 'simple-mind-map-plugin-momentum'
|
import Momentum from 'simple-mind-map-plugin-momentum'
|
||||||
import RightFishbone from 'simple-mind-map-plugin-right-fishbone'
|
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 OutlineSidebar from './OutlineSidebar.vue'
|
||||||
import Style from './Style.vue'
|
import Style from './Style.vue'
|
||||||
import BaseStyle from './BaseStyle.vue'
|
import BaseStyle from './BaseStyle.vue'
|
||||||
@@ -171,6 +172,10 @@ MindMap.usePlugin(MiniMap)
|
|||||||
|
|
||||||
// 注册主题
|
// 注册主题
|
||||||
Themes.init(MindMap)
|
Themes.init(MindMap)
|
||||||
|
// 扩展主题列表
|
||||||
|
if (typeof MoreThemes !== 'undefined') {
|
||||||
|
MoreThemes.init(MindMap)
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -697,6 +702,24 @@ export default {
|
|||||||
this.mindMap.addPlugin(LineFlow)
|
this.mindMap.addPlugin(LineFlow)
|
||||||
this.$store.commit('setSupportLineFlow', true)
|
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中是否存在要打开的文件
|
// url中是否存在要打开的文件
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
:class="{ active: item.value === theme }"
|
:class="{ active: item.value === theme }"
|
||||||
>
|
>
|
||||||
<div class="imgBox">
|
<div class="imgBox">
|
||||||
<img :src="themeImgMap[item.value]" alt="" />
|
<img :src="item.img || themeImgMap[item.value]" alt="" />
|
||||||
</div>
|
</div>
|
||||||
<div class="name">{{ item.name }}</div>
|
<div class="name">{{ item.name }}</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -59,15 +59,20 @@ export default {
|
|||||||
themeImgMap,
|
themeImgMap,
|
||||||
theme: '',
|
theme: '',
|
||||||
activeName: '',
|
activeName: '',
|
||||||
groupList: []
|
defaultGroupList: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
isDark: state => state.localConfig.isDark,
|
isDark: state => state.localConfig.isDark,
|
||||||
activeSidebar: state => state.activeSidebar
|
activeSidebar: state => state.activeSidebar,
|
||||||
|
extendThemeGroupList: state => state.extendThemeGroupList
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
groupList() {
|
||||||
|
return [...this.defaultGroupList, ...this.extendThemeGroupList]
|
||||||
|
},
|
||||||
|
|
||||||
currentList() {
|
currentList() {
|
||||||
return this.groupList.find(item => {
|
return this.groupList.find(item => {
|
||||||
return item.name === this.activeName
|
return item.name === this.activeName
|
||||||
@@ -101,7 +106,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
initGroup() {
|
initGroup() {
|
||||||
let baiduThemes = [
|
const baiduThemes = [
|
||||||
'default',
|
'default',
|
||||||
'skyGreen',
|
'skyGreen',
|
||||||
'classic2',
|
'classic2',
|
||||||
@@ -117,8 +122,8 @@ export default {
|
|||||||
'pinkGrape',
|
'pinkGrape',
|
||||||
'mint'
|
'mint'
|
||||||
]
|
]
|
||||||
let baiduList = []
|
const baiduList = []
|
||||||
let classicsList = []
|
const classicsList = []
|
||||||
this.themeList.forEach(item => {
|
this.themeList.forEach(item => {
|
||||||
if (baiduThemes.includes(item.value)) {
|
if (baiduThemes.includes(item.value)) {
|
||||||
baiduList.push(item)
|
baiduList.push(item)
|
||||||
@@ -126,7 +131,7 @@ export default {
|
|||||||
classicsList.push(item)
|
classicsList.push(item)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.groupList = [
|
this.defaultGroupList = [
|
||||||
{
|
{
|
||||||
name: this.$t('theme.classics'),
|
name: this.$t('theme.classics'),
|
||||||
list: classicsList
|
list: classicsList
|
||||||
@@ -142,7 +147,7 @@ export default {
|
|||||||
list: baiduList
|
list: baiduList
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
this.activeName = this.groupList[0].name
|
this.activeName = this.defaultGroupList[0].name
|
||||||
},
|
},
|
||||||
|
|
||||||
useTheme(theme) {
|
useTheme(theme) {
|
||||||
@@ -184,7 +189,11 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleDark() {
|
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
|
return item.value === this.theme
|
||||||
})
|
})
|
||||||
this.setLocalConfig({
|
this.setLocalConfig({
|
||||||
@@ -213,7 +222,9 @@ export default {
|
|||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
padding-bottom: 20px;
|
padding-bottom: 20px;
|
||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
border: 1px solid transparent;
|
border: 3px solid transparent;
|
||||||
|
border-radius: 5px;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
&:last-of-type {
|
&:last-of-type {
|
||||||
border: none;
|
border: none;
|
||||||
@@ -225,7 +236,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
border: 1px solid #67c23a;
|
border: 3px solid rgb(154, 198, 250);
|
||||||
}
|
}
|
||||||
|
|
||||||
.imgBox {
|
.imgBox {
|
||||||
|
|||||||
@@ -45,7 +45,9 @@ const store = new Vuex.Store({
|
|||||||
model: '',
|
model: '',
|
||||||
port: 3456,
|
port: 3456,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
}
|
},
|
||||||
|
// 扩展主题列表
|
||||||
|
extendThemeGroupList: []
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
// 设置操作本地文件标志位
|
// 设置操作本地文件标志位
|
||||||
@@ -137,6 +139,11 @@ const store = new Vuex.Store({
|
|||||||
// 设置树节点拖拽
|
// 设置树节点拖拽
|
||||||
setIsDragOutlineTreeNode(state, data) {
|
setIsDragOutlineTreeNode(state, data) {
|
||||||
state.isDragOutlineTreeNode = data
|
state.isDragOutlineTreeNode = data
|
||||||
|
},
|
||||||
|
|
||||||
|
// 扩展主题列表
|
||||||
|
setExtendThemeGroupList(state, data) {
|
||||||
|
state.extendThemeGroupList = data
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {}
|
actions: {}
|
||||||
|
|||||||
Reference in New Issue
Block a user