Demo:1.支持通过图标调出搜索;2.支持通过图标切换暗黑模式

This commit is contained in:
wanglin2 2023-07-28 17:45:53 +08:00
parent cd4f1b1bd8
commit ad6085890e
6 changed files with 45 additions and 17 deletions

View File

@ -1,8 +1,8 @@
@font-face { @font-face {
font-family: "iconfont"; /* Project id 2479351 */ font-family: "iconfont"; /* Project id 2479351 */
src: url('iconfont.woff2?t=1690506335310') format('woff2'), src: url('iconfont.woff2?t=1690537337895') format('woff2'),
url('iconfont.woff?t=1690506335310') format('woff'), url('iconfont.woff?t=1690537337895') format('woff'),
url('iconfont.ttf?t=1690506335310') format('truetype'); url('iconfont.ttf?t=1690537337895') format('truetype');
} }
.iconfont { .iconfont {
@ -13,6 +13,14 @@
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
} }
.iconlieri:before {
content: "\e60b";
}
.iconmoon_line:before {
content: "\e745";
}
.iconsousuo:before { .iconsousuo:before {
content: "\e693"; content: "\e693";
} }

View File

@ -15,6 +15,9 @@
/> />
</el-select> </el-select>
</div> </div>
<div class="item">
<div class="btn iconfont iconsousuo" @click="showSearch"></div>
</div>
<div class="item"> <div class="item">
<MouseAction :isDark="isDark" :mindMap="mindMap"></MouseAction> <MouseAction :isDark="isDark" :mindMap="mindMap"></MouseAction>
</div> </div>
@ -28,10 +31,7 @@
" "
placement="top" placement="top"
> >
<div <div class="btn iconfont icondaohang1" @click="toggleMiniMap"></div>
class="btn iconfont icondaohang1"
@click="toggleMiniMap"
></div>
</el-tooltip> </el-tooltip>
</div> </div>
<div class="item"> <div class="item">
@ -64,6 +64,13 @@
<div class="item"> <div class="item">
<Scale :isDark="isDark" :mindMap="mindMap"></Scale> <Scale :isDark="isDark" :mindMap="mindMap"></Scale>
</div> </div>
<div class="item">
<div
class="btn iconfont"
:class="[isDark ? 'iconmoon_line' : 'iconlieri']"
@click="toggleDark"
></div>
</div>
<div class="item"> <div class="item">
<a href="https://github.com/wanglin2/mind-map" target="_blank"> <a href="https://github.com/wanglin2/mind-map" target="_blank">
<span class="iconfont icongithub"></span> <span class="iconfont icongithub"></span>
@ -79,7 +86,7 @@ import MouseAction from './MouseAction.vue'
import { langList } from '@/config' import { langList } from '@/config'
import i18n from '@/i18n' import i18n from '@/i18n'
import { storeLang, getLang } from '@/api' import { storeLang, getLang } from '@/api'
import { mapState } from 'vuex' import { mapState, mapMutations } from 'vuex'
/** /**
* @Author: 王林 * @Author: 王林
@ -107,9 +114,11 @@ export default {
} }
}, },
computed: { computed: {
...mapState(['isDark']), ...mapState(['isDark'])
}, },
methods: { methods: {
...mapMutations(['setIsDark']),
readonlyChange() { readonlyChange() {
this.isReadonly = !this.isReadonly this.isReadonly = !this.isReadonly
this.mindMap.setMode(this.isReadonly ? 'readonly' : 'edit') this.mindMap.setMode(this.isReadonly ? 'readonly' : 'edit')
@ -123,6 +132,14 @@ export default {
onLangChange(lang) { onLangChange(lang) {
i18n.locale = lang i18n.locale = lang
storeLang(lang) storeLang(lang)
},
showSearch() {
this.$bus.$emit('show_search')
},
toggleDark() {
this.setIsDark(!this.isDark)
} }
} }
} }
@ -147,11 +164,11 @@ export default {
.item { .item {
a { a {
color: hsla(0,0%,100%,.6); color: hsla(0, 0%, 100%, 0.6);
} }
.btn { .btn {
color: hsla(0,0%,100%,.6); color: hsla(0, 0%, 100%, 0.6);
} }
} }
} }

View File

@ -83,20 +83,23 @@ export default {
} }
}, },
created() { created() {
this.$bus.$on('show_search', this.showSearch)
this.mindMap.on('search_info_change', data => { this.mindMap.on('search_info_change', data => {
this.currentIndex = data.currentIndex + 1 this.currentIndex = data.currentIndex + 1
this.total = data.total this.total = data.total
this.showSearchInfo = true this.showSearchInfo = true
}) })
this.mindMap.keyCommand.addShortcut('Control+f', () => { this.mindMap.keyCommand.addShortcut('Control+f', this.showSearch)
this.$bus.$emit('closeSideBar')
this.show = true
this.$refs.input.focus()
})
}, },
methods: { methods: {
isUndef, isUndef,
showSearch() {
this.$bus.$emit('closeSideBar')
this.show = true
this.$refs.input.focus()
},
hideReplaceInput() { hideReplaceInput() {
this.showReplaceInput = false this.showReplaceInput = false
this.replaceText = '' this.replaceText = ''