Former-commit-id: f08b7ba521a8338abff254905997bdb3d5f8b051 [formerly f08b7ba521a8338abff254905997bdb3d5f8b051 [formerly f08b7ba521a8338abff254905997bdb3d5f8b051 [formerly f08b7ba521a8338abff254905997bdb3d5f8b051 [formerly 95b51a0e9b3be340f8dc6b285a66317f5899fe71 [formerly 37fe09545b11607d94cdf89ec62429c0a68f1f03]]]]] Former-commit-id: 4d0f8841b17942ec75fc5c6468836c31b26a5981 Former-commit-id: 5a4e3cca1b5e16f0a908af6bd341047963d27805 Former-commit-id: 293aa17f542d733777d05c0023aff252b46bebab [formerly 5ad3d0e6fa7cb27407093ca254e8c9898f31fce1] Former-commit-id: fb90e6ede3a6548cf989404fb648472b17e7fde0 Former-commit-id: 9569f37f5b93fd5e95178a2dbcba878fc91f6c2e Former-commit-id: b0328b0a52e939aef0fb65c3b30b50c9c72ce625 Former-commit-id: 9e3c51f9afb99d8a67d83c44b2e2fd1f9738abde Former-commit-id: a21f8109b4c1ce4233054240b1eeba9248df3955
173 lines
5.5 KiB
Vue
173 lines
5.5 KiB
Vue
<template>
|
|
<div
|
|
class="d2-layout-header-aside-group"
|
|
:style="styleLayoutMainGroup"
|
|
:class="{grayMode: grayActive}">
|
|
<!-- 半透明遮罩 -->
|
|
<div class="d2-layout-header-aside-mask"></div>
|
|
<!-- 主体内容 -->
|
|
<div class="d2-layout-header-aside-content" flex="dir:top">
|
|
<!-- 顶栏 -->
|
|
<div class="d2-theme-header" flex-box="0">
|
|
<div class="logo-group" :style="{width: asideCollapse ? asideWidthCollapse : asideWidth}">
|
|
<img v-if="asideCollapse" :src="`${$baseUrl}image/theme/${themeActiveSetting.name}/logo/icon-only.png`">
|
|
<img v-else :src="`${$baseUrl}image/theme/${themeActiveSetting.name}/logo/all.png`">
|
|
</div>
|
|
<div class="toggle-aside-btn" @click="handleToggleAside">
|
|
<d2-icon name="bars"/>
|
|
</div>
|
|
<d2-menu-header/>
|
|
<!-- 顶栏右侧 -->
|
|
<div class="d2-header-right">
|
|
<!-- 如果你只想在开发环境显示这个按钮请添加 v-if="$env === 'development'" -->
|
|
<d2-header-search @click="handleSearchClick"/>
|
|
<d2-header-error-log/>
|
|
<d2-header-fullscreen/>
|
|
<d2-header-theme/>
|
|
<d2-header-user/>
|
|
</div>
|
|
</div>
|
|
<!-- 下面 主体 -->
|
|
<div class="d2-theme-container" flex-box="1" flex>
|
|
<!-- 主体 侧边栏 -->
|
|
<div
|
|
flex-box="0"
|
|
ref="aside"
|
|
class="d2-theme-container-aside"
|
|
:style="{width: asideCollapse ? asideWidthCollapse : asideWidth}">
|
|
<d2-menu-side/>
|
|
</div>
|
|
<!-- 主体 -->
|
|
<div class="d2-theme-container-main" flex-box="1" flex>
|
|
<transition name="fade-scale">
|
|
<div v-show="searchActive" class="d2-theme-container-main-layer" flex="dir:top">
|
|
<d2-panel-search
|
|
ref="panelSearch"
|
|
@close="searchPanelClose"/>
|
|
</div>
|
|
</transition>
|
|
<transition name="fade-scale">
|
|
<div v-show="!searchActive" class="d2-theme-container-main-layer" flex="dir:top">
|
|
<div class="d2-theme-container-main-header" flex-box="0">
|
|
<d2-tabs/>
|
|
</div>
|
|
<div class="d2-theme-container-main-body" flex-box="1">
|
|
<transition :name="transitionActive ? 'fade-transverse' : ''">
|
|
<keep-alive :include="keepAlive">
|
|
<router-view/>
|
|
</keep-alive>
|
|
</transition>
|
|
</div>
|
|
</div>
|
|
</transition>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import { mapState, mapGetters, mapMutations } from 'vuex'
|
|
import hotkeys from 'hotkeys-js'
|
|
export default {
|
|
name: 'd2-layout-header-aside',
|
|
components: {
|
|
'd2-menu-side': () => import('./components/menu-side'),
|
|
'd2-menu-header': () => import('./components/menu-header'),
|
|
'd2-tabs': () => import('./components/tabs'),
|
|
'd2-header-fullscreen': () => import('./components/header-fullscreen'),
|
|
'd2-header-search': () => import('./components/header-search'),
|
|
'd2-header-theme': () => import('./components/header-theme'),
|
|
'd2-header-user': () => import('./components/header-user'),
|
|
'd2-header-error-log': () => import('./components/header-error-log'),
|
|
'd2-panel-search': () => import('./components/panel-search')
|
|
},
|
|
data () {
|
|
return {
|
|
// [侧边栏宽度] 正常状态
|
|
asideWidth: '200px',
|
|
// [侧边栏宽度] 折叠状态
|
|
asideWidthCollapse: '65px'
|
|
}
|
|
},
|
|
mounted () {
|
|
// 绑定搜索功能快捷键 [ 打开 ]
|
|
hotkeys(this.searchHotkey.open, event => {
|
|
event.preventDefault()
|
|
this.searchPanelOpen()
|
|
})
|
|
// 绑定搜索功能快捷键 [ 关闭 ]
|
|
hotkeys(this.searchHotkey.close, event => {
|
|
event.preventDefault()
|
|
this.searchPanelClose()
|
|
})
|
|
},
|
|
beforeDestroy () {
|
|
// 解绑搜索功能快捷键
|
|
hotkeys.unbind('esc')
|
|
},
|
|
computed: {
|
|
...mapState('d2admin', {
|
|
grayActive: state => state.gray.active,
|
|
searchActive: state => state.search.active,
|
|
searchHotkey: state => state.search.hotkey,
|
|
transitionActive: state => state.transition.active,
|
|
asideCollapse: state => state.menu.asideCollapse
|
|
}),
|
|
...mapGetters('d2admin', {
|
|
keepAlive: 'page/keepAlive',
|
|
themeActiveSetting: 'theme/activeSetting'
|
|
}),
|
|
/**
|
|
* @description 最外层容器的背景图片样式
|
|
*/
|
|
styleLayoutMainGroup () {
|
|
return {
|
|
...this.themeActiveSetting.backgroundImage ? {
|
|
backgroundImage: `url('${this.$baseUrl}${this.themeActiveSetting.backgroundImage}')`
|
|
} : {}
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
...mapMutations({
|
|
menuAsideCollapseToggle: 'd2admin/menu/asideCollapseToggle',
|
|
searchToggle: 'd2admin/search/toggle',
|
|
searchSet: 'd2admin/search/set'
|
|
}),
|
|
/**
|
|
* 接收点击切换侧边栏的按钮
|
|
*/
|
|
handleToggleAside () {
|
|
this.menuAsideCollapseToggle()
|
|
},
|
|
/**
|
|
* 接收点击搜索按钮
|
|
*/
|
|
handleSearchClick () {
|
|
this.searchToggle()
|
|
if (this.searchActive) {
|
|
this.$refs.panelSearch.focus()
|
|
}
|
|
},
|
|
searchPanelOpen () {
|
|
if (!this.searchActive) {
|
|
this.searchSet(true)
|
|
this.$refs.panelSearch.focus()
|
|
}
|
|
},
|
|
// 关闭搜索面板
|
|
searchPanelClose () {
|
|
if (this.searchActive) {
|
|
this.searchSet(false)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
// 注册主题
|
|
@import '~@/assets/style/theme/register.scss';
|
|
</style>
|