diff --git a/ruoyi-ui/src/layout/components/TagsView/index.vue b/ruoyi-ui/src/layout/components/TagsView/index.vue
index 055fe0bff..3392999f3 100644
--- a/ruoyi-ui/src/layout/components/TagsView/index.vue
+++ b/ruoyi-ui/src/layout/components/TagsView/index.vue
@@ -41,7 +41,10 @@
关闭左侧
关闭右侧
全部关闭
- 全屏显示
+
+ 全屏显示
+ 退出全屏
+
@@ -77,7 +80,8 @@ export default {
affixTags: [],
canScrollLeft: false,
canScrollRight: false,
- isFullscreen: false
+ isFullscreen: false,
+ hiddenElements: []
}
},
computed: {
@@ -119,13 +123,19 @@ export default {
this.initTags()
this.addTags()
window.addEventListener('resize', this.updateArrowState)
- document.addEventListener('fullscreenchange', this.onFullscreenChange)
+ window.addEventListener('keydown', this.handleKeyDown)
},
beforeDestroy() {
window.removeEventListener('resize', this.updateArrowState)
- document.removeEventListener('fullscreenchange', this.onFullscreenChange)
+ window.removeEventListener('keydown', this.handleKeyDown)
},
methods: {
+ handleKeyDown(event) {
+ // 当按下Esc键且处于全屏状态时,退出全屏
+ if (event.key === 'Escape' && this.isFullscreen) {
+ this.toggleFullscreen()
+ }
+ },
isActive(route) {
return route.path === this.$route.path
},
@@ -225,18 +235,40 @@ export default {
})
},
toggleFullscreen() {
- if (!document.fullscreenElement) {
- const appMain = document.querySelector('.app-main')
- if (appMain) {
- appMain.requestFullscreen()
- }
+ const mainContainer = document.querySelector('.main-container')
+ const navbar = document.querySelector('.navbar')
+ const sidebar = document.querySelector('.sidebar-container')
+ if (!mainContainer) return
+
+ if (!this.isFullscreen) {
+ mainContainer.classList.add('fullscreen-mode')
+ document.body.style.overflow = 'hidden'
+ const elementsToHide = [
+ { el: navbar, originalDisplay: (navbar && navbar.style.display) || '' },
+ { el: sidebar, originalDisplay: (sidebar && sidebar.style.display) || '' }
+ ]
+ elementsToHide.forEach(item => {
+ if (item.el && item.el.style.display !== 'none') {
+ item.originalDisplay = item.el.style.display
+ item.el.style.display = 'none'
+ this.hiddenElements.push(item)
+ }
+ })
+ this.isFullscreen = true
} else {
- document.exitFullscreen()
+ mainContainer.classList.remove('fullscreen-mode')
+ document.body.style.overflow = ''
+ this.hiddenElements.forEach(item => {
+ if (item.el) {
+ item.el.style.display = item.originalDisplay
+ }
+ })
+ this.hiddenElements = []
+ const btn = document.querySelector('.tags-action-btn')
+ if (btn) btn.blur()
+ this.isFullscreen = false
}
},
- onFullscreenChange() {
- this.isFullscreen = !!document.fullscreenElement
- },
handleDropdownCommand(command) {
const tag = this.selectedDropdownTag
this.selectedTag = tag
@@ -505,4 +537,41 @@ export default {
}
}
}
+
+/* 页签全屏模式样式 */
+.main-container.fullscreen-mode {
+ position: fixed;
+ top: 0;
+ left: 0;
+ width: 100vw;
+ height: 100vh;
+ overflow: hidden;
+}
+
+.main-container.fullscreen-mode .fixed-header {
+ display: block !important;
+ position: fixed;
+ top: 0;
+ left: 0;
+ right: 0;
+ width: 100% !important;
+ z-index: 1000;
+}
+
+.main-container.fullscreen-mode .fixed-header .navbar {
+ display: none !important;
+}
+
+.main-container.fullscreen-mode .app-main {
+ position: fixed;
+ top: 34px;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ margin: 0 !important;
+ padding: 0 !important;
+ height: calc(100vh - 34px) !important;
+ min-height: calc(100vh - 34px) !important;
+ overflow: auto;
+}