From af768553bbc6ee7e425b3df48a1667e991980f40 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 26 Mar 2026 00:53:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A1=B5=E7=AD=BE=E5=85=A8?= =?UTF-8?q?=E5=B1=8F=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/layout/components/TagsView/index.vue | 95 ++++++++++++++++--- 1 file changed, 82 insertions(+), 13 deletions(-) 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; +}