You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
2.4 KiB
85 lines
2.4 KiB
|
6 years ago
|
<script type="text/jsx">
|
||
|
6 years ago
|
import {mutations as mainMutations} from "@/layout/store/main"
|
||
|
|
import {getters as settingGetters} from "@/layout/store/setting"
|
||
|
|
import {mutations as tagsViewMutations} from "@/layout/store/tagsView"
|
||
|
6 years ago
|
import VNavbar from './component/Navbar'
|
||
|
|
import TagsView from './component/TagsView'
|
||
|
6 years ago
|
|
||
|
6 years ago
|
export default {
|
||
|
|
name: "Header",
|
||
|
6 years ago
|
|
||
|
6 years ago
|
components: {VNavbar, TagsView},
|
||
|
|
|
||
|
|
data() {
|
||
|
|
return {
|
||
|
|
mouseOutside: true,
|
||
|
|
navbarMenuShow: false,
|
||
|
6 years ago
|
tagsViewMenuShow: false
|
||
|
6 years ago
|
}
|
||
|
|
},
|
||
|
6 years ago
|
|
||
|
6 years ago
|
computed: {
|
||
|
6 years ago
|
useTagsView: () => settingGetters.useTagsView,
|
||
|
|
headerAutoHidden: () => settingGetters.headerAutoHidden,
|
||
|
6 years ago
|
|
||
|
6 years ago
|
hideHeader() {
|
||
|
|
return this.mouseOutside
|
||
|
|
&& this.headerAutoHidden
|
||
|
|
&& !this.tagsViewMenuShow
|
||
|
|
&& !this.navbarMenuShow
|
||
|
7 years ago
|
},
|
||
|
6 years ago
|
},
|
||
|
6 years ago
|
|
||
|
6 years ago
|
watch: {
|
||
|
|
//多页签停用时清除所有页面缓存
|
||
|
|
useTagsView(v) {
|
||
|
6 years ago
|
!v && tagsViewMutations.delAllViews()
|
||
|
6 years ago
|
},
|
||
|
6 years ago
|
|
||
|
6 years ago
|
hideHeader(v) {
|
||
|
6 years ago
|
mainMutations.hasNav(!v)
|
||
|
6 years ago
|
v ? this.addEvent() : this.removeEvent()
|
||
|
|
}
|
||
|
|
},
|
||
|
6 years ago
|
|
||
|
6 years ago
|
methods: {
|
||
|
|
moveEvent(e) {
|
||
|
|
if (e.clientY <= 15) this.mouseOutside = false
|
||
|
7 years ago
|
},
|
||
|
6 years ago
|
addEvent() {
|
||
|
|
this.appMain.addEventListener('mousemove', this.moveEvent)
|
||
|
|
},
|
||
|
|
removeEvent() {
|
||
|
|
this.appMain.removeEventListener('mousemove', this.moveEvent)
|
||
|
7 years ago
|
}
|
||
|
6 years ago
|
},
|
||
|
|
|
||
|
|
mounted() {
|
||
|
|
this.appMain = document.querySelector('.app-main')
|
||
|
|
if (this.headerAutoHidden) this.addEvent()
|
||
|
|
|
||
|
|
this.$once('hook:beforeDestroy', this.removeEvent)
|
||
|
6 years ago
|
},
|
||
|
6 years ago
|
|
||
|
6 years ago
|
render() {
|
||
|
|
const mouseCtrlFactory = (enter = true) => () => this.mouseOutside = !enter
|
||
|
|
const menuCtrlFactory = key => e => this[key] = e
|
||
|
|
|
||
|
|
return (
|
||
|
|
<el-collapse-transition>
|
||
|
|
<header
|
||
|
|
v-show={!this.hideHeader}
|
||
|
|
class="header-container"
|
||
|
|
on-mouseenter={mouseCtrlFactory()}
|
||
|
|
on-mouseleave={mouseCtrlFactory(false)}
|
||
|
|
>
|
||
|
|
<v-navbar on-menu-show={menuCtrlFactory('navbarMenuShow')}/>
|
||
|
|
|
||
|
|
{this.useTagsView && <tags-view on-menu-show={menuCtrlFactory('tagsViewMenuShow')}/>}
|
||
|
|
</header>
|
||
|
|
</el-collapse-transition>
|
||
|
|
)
|
||
|
7 years ago
|
}
|
||
|
6 years ago
|
}
|
||
|
6 years ago
|
</script>
|