|
|
|
@ -1,7 +1,7 @@ |
|
|
|
<template> |
|
|
|
<div |
|
|
|
class="site-wrapper" |
|
|
|
:class="{ 'site-sidebar--fold': sidebarFold }" |
|
|
|
:class="{ 'site-sidebar--fold': sidebarFold, 'site-wrapper--fullscreen': contentFullscreen }" |
|
|
|
v-loading.fullscreen.lock="loading" |
|
|
|
element-loading-text="拼命加载中"> |
|
|
|
<template v-if="!loading"> |
|
|
|
@ -10,6 +10,14 @@ |
|
|
|
<div class="site-content__wrapper" :style="{ 'min-height': documentClientHeight + 'px' }"> |
|
|
|
<main-content v-if="!$store.state.common.contentIsNeedRefresh"/> |
|
|
|
</div> |
|
|
|
<button |
|
|
|
v-if="contentFullscreen" |
|
|
|
type="button" |
|
|
|
class="site-fullscreen-exit" |
|
|
|
@click="setContentFullscreen(false)"> |
|
|
|
<i class="el-icon-c-scale-to-original"></i> |
|
|
|
<span>退出全屏</span> |
|
|
|
</button> |
|
|
|
</template> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
@ -56,6 +64,11 @@ |
|
|
|
return this.$store.state.common.sidebarFold |
|
|
|
} |
|
|
|
}, |
|
|
|
contentFullscreen: { |
|
|
|
get() { |
|
|
|
return this.$store.state.common.contentFullscreen |
|
|
|
} |
|
|
|
}, |
|
|
|
userId: { |
|
|
|
get() { |
|
|
|
return this.$store.state.user.id |
|
|
|
@ -116,10 +129,52 @@ |
|
|
|
created() { |
|
|
|
this.getUserInfo() |
|
|
|
}, |
|
|
|
watch: { |
|
|
|
contentFullscreen() { |
|
|
|
// 顶栏和侧栏收起后,按实际位置重算依赖窗口高度的表格。 |
|
|
|
this.$nextTick(() => { |
|
|
|
window.dispatchEvent(new Event('resize')) |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
this.resetDocumentClientHeight() |
|
|
|
this._onContentFullscreenKeydown = (event) => { |
|
|
|
if (event.key !== 'Escape' || !this.contentFullscreen) { |
|
|
|
return |
|
|
|
} |
|
|
|
// 日期、下拉和弹窗也占用 Esc,先让它们关闭,避免一次按键同时退出全屏。 |
|
|
|
if (this.hasOpenElementLayer()) { |
|
|
|
return |
|
|
|
} |
|
|
|
this.setContentFullscreen(false) |
|
|
|
} |
|
|
|
document.addEventListener('keydown', this._onContentFullscreenKeydown) |
|
|
|
}, |
|
|
|
beforeDestroy() { |
|
|
|
if (this._onContentFullscreenKeydown) { |
|
|
|
document.removeEventListener('keydown', this._onContentFullscreenKeydown) |
|
|
|
this._onContentFullscreenKeydown = null |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
setContentFullscreen(status) { |
|
|
|
this.$store.commit('common/updateContentFullscreen', status) |
|
|
|
}, |
|
|
|
hasOpenElementLayer() { |
|
|
|
const nodes = document.querySelectorAll('.el-dialog__wrapper, .el-message-box__wrapper, .el-picker-panel, .el-select-dropdown, .el-dropdown-menu') |
|
|
|
for (let i = 0; i < nodes.length; i++) { |
|
|
|
const el = nodes[i] |
|
|
|
if (!el) { |
|
|
|
continue |
|
|
|
} |
|
|
|
const style = window.getComputedStyle(el) |
|
|
|
if (style.display !== 'none' && style.visibility !== 'hidden') { |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
return false |
|
|
|
}, |
|
|
|
// 重置窗口可视高度 |
|
|
|
resetDocumentClientHeight() { |
|
|
|
this.documentClientHeight = document.documentElement['clientHeight'] - 1 |
|
|
|
@ -155,3 +210,47 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
<style> |
|
|
|
.site-wrapper.site-wrapper--fullscreen .site-navbar, |
|
|
|
.site-wrapper.site-wrapper--fullscreen .site-sidebar { |
|
|
|
display: none; |
|
|
|
} |
|
|
|
|
|
|
|
.site-wrapper.site-wrapper--fullscreen .site-content__wrapper { |
|
|
|
margin-left: 0; |
|
|
|
padding-top: 0; |
|
|
|
} |
|
|
|
|
|
|
|
.site-wrapper.site-wrapper--fullscreen .site-content--tabs { |
|
|
|
padding-top: 0; |
|
|
|
} |
|
|
|
|
|
|
|
.site-wrapper.site-wrapper--fullscreen .site-content > .el-tabs > .el-tabs__header, |
|
|
|
.site-wrapper.site-wrapper--fullscreen .site-content > .el-tabs > .el-tabs__content > .site-tabs__tools { |
|
|
|
display: none; |
|
|
|
} |
|
|
|
|
|
|
|
.site-fullscreen-exit { |
|
|
|
position: fixed; |
|
|
|
top: 8px; |
|
|
|
right: 12px; |
|
|
|
z-index: 1100; |
|
|
|
display: inline-flex; |
|
|
|
align-items: center; |
|
|
|
height: 28px; |
|
|
|
padding: 0 10px; |
|
|
|
border: 1px solid #dcdfe6; |
|
|
|
border-radius: 4px; |
|
|
|
background: rgba(255, 255, 255, 0.96); |
|
|
|
color: #303133; |
|
|
|
font-size: 12px; |
|
|
|
line-height: 26px; |
|
|
|
cursor: pointer; |
|
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12); |
|
|
|
} |
|
|
|
|
|
|
|
.site-fullscreen-exit i { |
|
|
|
margin-right: 4px; |
|
|
|
} |
|
|
|
</style> |