Demo:修改主题和暗色的关联逻辑
This commit is contained in:
parent
9a8cd1dd24
commit
cdc5c7aa81
@ -30,7 +30,7 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
isZenMode: state => state.localConfig.isZenMode,
|
isZenMode: state => state.localConfig.isZenMode,
|
||||||
isDark: state => state.isDark,
|
isDark: state => state.localConfig.isDark,
|
||||||
activeSidebar: state => state.activeSidebar
|
activeSidebar: state => state.activeSidebar
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1004,7 +1004,11 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['activeSidebar', 'localConfig', 'isDark']),
|
...mapState({
|
||||||
|
activeSidebar: state => state.activeSidebar,
|
||||||
|
localConfig: state => state.localConfig,
|
||||||
|
isDark: state => state.localConfig.isDark
|
||||||
|
}),
|
||||||
lineStyleList() {
|
lineStyleList() {
|
||||||
return lineStyleList[this.$i18n.locale] || lineStyleList.zh
|
return lineStyleList[this.$i18n.locale] || lineStyleList.zh
|
||||||
},
|
},
|
||||||
|
|||||||
@ -45,7 +45,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['isDark']),
|
...mapState({
|
||||||
|
isDark: state => state.localConfig.isDark
|
||||||
|
})
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
color() {
|
color() {
|
||||||
|
|||||||
@ -167,7 +167,7 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
isZenMode: state => state.localConfig.isZenMode,
|
isZenMode: state => state.localConfig.isZenMode,
|
||||||
isDark: state => state.isDark
|
isDark: state => state.localConfig.isDark
|
||||||
}),
|
}),
|
||||||
expandList() {
|
expandList() {
|
||||||
return [
|
return [
|
||||||
|
|||||||
@ -36,7 +36,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['isDark']),
|
...mapState({
|
||||||
|
isDark: state => state.localConfig.isDark
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.$bus.$on('data_change', this.onDataChange)
|
this.$bus.$on('data_change', this.onDataChange)
|
||||||
|
|||||||
@ -113,7 +113,7 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
openNodeRichText: state => state.localConfig.openNodeRichText,
|
openNodeRichText: state => state.localConfig.openNodeRichText,
|
||||||
isDark: state => state.isDark
|
isDark: state => state.localConfig.isDark
|
||||||
}),
|
}),
|
||||||
|
|
||||||
downTypeList() {
|
downTypeList() {
|
||||||
|
|||||||
@ -53,7 +53,11 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['activeSidebar', 'isDark', 'localConfig'])
|
...mapState({
|
||||||
|
activeSidebar: state => state.activeSidebar,
|
||||||
|
isDark: state => state.localConfig.isDark,
|
||||||
|
localConfig: state => state.localConfig
|
||||||
|
})
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
activeSidebar(val) {
|
activeSidebar(val) {
|
||||||
|
|||||||
@ -54,7 +54,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['isDark'])
|
...mapState({
|
||||||
|
isDark: state => state.localConfig.isDark
|
||||||
|
})
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.setSize()
|
this.setSize()
|
||||||
|
|||||||
@ -132,13 +132,16 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['isDark', 'isReadonly'])
|
...mapState({
|
||||||
|
isReadonly: state => state.isReadonly,
|
||||||
|
isDark: state => state.localConfig.isDark
|
||||||
|
})
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.lang = getLang()
|
this.lang = getLang()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations(['setIsDark', 'setIsReadonly']),
|
...mapMutations(['setLocalConfig', 'setIsReadonly']),
|
||||||
|
|
||||||
readonlyChange() {
|
readonlyChange() {
|
||||||
this.setIsReadonly(!this.isReadonly)
|
this.setIsReadonly(!this.isReadonly)
|
||||||
@ -161,7 +164,9 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
toggleDark() {
|
toggleDark() {
|
||||||
this.setIsDark(!this.isDark)
|
this.setLocalConfig({
|
||||||
|
isDark: !this.isDark
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
handleCommand(command) {
|
handleCommand(command) {
|
||||||
|
|||||||
@ -78,7 +78,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['activeSidebar', 'isDark'])
|
...mapState({
|
||||||
|
activeSidebar: state => state.activeSidebar,
|
||||||
|
isDark: state => state.localConfig.isDark
|
||||||
|
})
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
activeSidebar(val) {
|
activeSidebar(val) {
|
||||||
|
|||||||
@ -70,7 +70,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['isDark', 'isReadonly'])
|
...mapState({
|
||||||
|
isReadonly: state => state.isReadonly,
|
||||||
|
isDark: state => state.localConfig.isDark
|
||||||
|
})
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
window.addEventListener('keydown', this.onKeyDown)
|
window.addEventListener('keydown', this.onKeyDown)
|
||||||
|
|||||||
@ -77,7 +77,11 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['isOutlineEdit', 'isDark', 'isReadonly'])
|
...mapState({
|
||||||
|
isReadonly: state => state.isReadonly,
|
||||||
|
isDark: state => state.localConfig.isDark,
|
||||||
|
isOutlineEdit: state => state.isOutlineEdit
|
||||||
|
})
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
isOutlineEdit(val) {
|
isOutlineEdit(val) {
|
||||||
|
|||||||
@ -33,7 +33,11 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['activeSidebar', 'isOutlineEdit', 'isDark'])
|
...mapState({
|
||||||
|
isDark: state => state.localConfig.isDark,
|
||||||
|
isOutlineEdit: state => state.isOutlineEdit,
|
||||||
|
activeSidebar: state => state.activeSidebar
|
||||||
|
})
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
activeSidebar(val) {
|
activeSidebar(val) {
|
||||||
|
|||||||
@ -144,7 +144,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['isDark']),
|
...mapState({
|
||||||
|
isDark: state => state.localConfig.isDark
|
||||||
|
}),
|
||||||
|
|
||||||
fontFamilyList() {
|
fontFamilyList() {
|
||||||
return fontFamilyList[this.$i18n.locale] || fontFamilyList.zh
|
return fontFamilyList[this.$i18n.locale] || fontFamilyList.zh
|
||||||
|
|||||||
@ -47,7 +47,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['isDark'])
|
...mapState({
|
||||||
|
isDark: state => state.localConfig.isDark
|
||||||
|
})
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.setScrollBarWrapSize()
|
this.setScrollBarWrapSize()
|
||||||
|
|||||||
@ -78,7 +78,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['isDark', 'isReadonly'])
|
...mapState({
|
||||||
|
isReadonly: state => state.isReadonly,
|
||||||
|
isDark: state => state.localConfig.isDark
|
||||||
|
})
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
searchText() {
|
searchText() {
|
||||||
|
|||||||
@ -38,7 +38,10 @@ export default {
|
|||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['activeSidebar', 'isDark']),
|
...mapState({
|
||||||
|
isDark: state => state.localConfig.isDark,
|
||||||
|
activeSidebar: state => state.activeSidebar
|
||||||
|
}),
|
||||||
|
|
||||||
shortcutKeyList() {
|
shortcutKeyList() {
|
||||||
return shortcutKeyList[this.$i18n.locale] || shortcutKeyList.zh
|
return shortcutKeyList[this.$i18n.locale] || shortcutKeyList.zh
|
||||||
|
|||||||
@ -39,7 +39,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['isDark'])
|
...mapState({
|
||||||
|
isDark: state => state.localConfig.isDark
|
||||||
|
})
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
show(val, oldVal) {
|
show(val, oldVal) {
|
||||||
|
|||||||
@ -39,7 +39,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['activeSidebar', 'isDark']),
|
...mapState({
|
||||||
|
isDark: state => state.localConfig.isDark,
|
||||||
|
activeSidebar: state => state.activeSidebar
|
||||||
|
}),
|
||||||
|
|
||||||
triggerList() {
|
triggerList() {
|
||||||
return sidebarTriggerList[this.$i18n.locale] || sidebarTriggerList.zh
|
return sidebarTriggerList[this.$i18n.locale] || sidebarTriggerList.zh
|
||||||
|
|||||||
@ -47,7 +47,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['activeSidebar', 'isDark'])
|
...mapState({
|
||||||
|
isDark: state => state.localConfig.isDark,
|
||||||
|
activeSidebar: state => state.activeSidebar
|
||||||
|
})
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
activeSidebar(val) {
|
activeSidebar(val) {
|
||||||
|
|||||||
@ -507,7 +507,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['activeSidebar', 'isDark']),
|
...mapState({
|
||||||
|
isDark: state => state.localConfig.isDark,
|
||||||
|
activeSidebar: state => state.activeSidebar
|
||||||
|
}),
|
||||||
|
|
||||||
fontFamilyList() {
|
fontFamilyList() {
|
||||||
return fontFamilyList[this.$i18n.locale] || fontFamilyList.zh
|
return fontFamilyList[this.$i18n.locale] || fontFamilyList.zh
|
||||||
|
|||||||
@ -58,7 +58,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['activeSidebar', 'isDark']),
|
...mapState({
|
||||||
|
isDark: state => state.localConfig.isDark,
|
||||||
|
activeSidebar: state => state.activeSidebar
|
||||||
|
}),
|
||||||
|
|
||||||
currentList() {
|
currentList() {
|
||||||
return this.groupList.find(item => {
|
return this.groupList.find(item => {
|
||||||
@ -70,7 +73,6 @@ export default {
|
|||||||
activeSidebar(val) {
|
activeSidebar(val) {
|
||||||
if (val === 'theme') {
|
if (val === 'theme') {
|
||||||
this.theme = this.mindMap.getTheme()
|
this.theme = this.mindMap.getTheme()
|
||||||
this.handleDark()
|
|
||||||
this.$refs.sidebar.show = true
|
this.$refs.sidebar.show = true
|
||||||
} else {
|
} else {
|
||||||
this.$refs.sidebar.show = false
|
this.$refs.sidebar.show = false
|
||||||
@ -80,14 +82,13 @@ export default {
|
|||||||
created() {
|
created() {
|
||||||
this.initGroup()
|
this.initGroup()
|
||||||
this.theme = this.mindMap.getTheme()
|
this.theme = this.mindMap.getTheme()
|
||||||
this.handleDark()
|
|
||||||
this.mindMap.on('view_theme_change', this.handleViewThemeChange)
|
this.mindMap.on('view_theme_change', this.handleViewThemeChange)
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
this.mindMap.off('view_theme_change', this.handleViewThemeChange)
|
this.mindMap.off('view_theme_change', this.handleViewThemeChange)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations(['setIsDark']),
|
...mapMutations(['setLocalConfig']),
|
||||||
|
|
||||||
handleViewThemeChange() {
|
handleViewThemeChange() {
|
||||||
this.theme = this.mindMap.getTheme()
|
this.theme = this.mindMap.getTheme()
|
||||||
@ -180,7 +181,9 @@ export default {
|
|||||||
let target = this.themeList.find(item => {
|
let target = this.themeList.find(item => {
|
||||||
return item.value === this.theme
|
return item.value === this.theme
|
||||||
})
|
})
|
||||||
this.setIsDark(target.dark)
|
this.setLocalConfig({
|
||||||
|
isDark: target.dark
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -116,7 +116,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['isHandleLocalFile', 'isDark'])
|
...mapState({
|
||||||
|
isDark: state => state.localConfig.isDark,
|
||||||
|
isHandleLocalFile: state => state.isHandleLocalFile
|
||||||
|
})
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
isHandleLocalFile(val) {
|
isHandleLocalFile(val) {
|
||||||
|
|||||||
@ -188,7 +188,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['isDark']),
|
...mapState({
|
||||||
|
isDark: state => state.localConfig.isDark
|
||||||
|
}),
|
||||||
hasRoot() {
|
hasRoot() {
|
||||||
return (
|
return (
|
||||||
this.activeNodes.findIndex(node => {
|
this.activeNodes.findIndex(node => {
|
||||||
|
|||||||
@ -19,10 +19,11 @@ const store = new Vuex.Store({
|
|||||||
// 是否显示滚动条
|
// 是否显示滚动条
|
||||||
isShowScrollbar: false,
|
isShowScrollbar: false,
|
||||||
// 是否开启手绘风格
|
// 是否开启手绘风格
|
||||||
isUseHandDrawnLikeStyle: false
|
isUseHandDrawnLikeStyle: false,
|
||||||
|
// 是否是暗黑模式
|
||||||
|
isDark: false,
|
||||||
},
|
},
|
||||||
activeSidebar: '', // 当前显示的侧边栏
|
activeSidebar: '', // 当前显示的侧边栏
|
||||||
isDark: false, // 是否是暗黑模式
|
|
||||||
isOutlineEdit: false, // 是否是大纲编辑模式
|
isOutlineEdit: false, // 是否是大纲编辑模式
|
||||||
isReadonly: false // 是否只读
|
isReadonly: false // 是否只读
|
||||||
},
|
},
|
||||||
@ -51,11 +52,6 @@ const store = new Vuex.Store({
|
|||||||
state.activeSidebar = data
|
state.activeSidebar = data
|
||||||
},
|
},
|
||||||
|
|
||||||
// 设置暗黑模式
|
|
||||||
setIsDark(state, data) {
|
|
||||||
state.isDark = data
|
|
||||||
},
|
|
||||||
|
|
||||||
// 设置大纲编辑模式
|
// 设置大纲编辑模式
|
||||||
setIsOutlineEdit(state, data) {
|
setIsOutlineEdit(state, data) {
|
||||||
state.isOutlineEdit = data
|
state.isOutlineEdit = data
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user