diff --git a/src/layout/navBars/breadcrumb/user.vue b/src/layout/navBars/breadcrumb/user.vue index aa1499fa..93aefc72 100644 --- a/src/layout/navBars/breadcrumb/user.vue +++ b/src/layout/navBars/breadcrumb/user.vue @@ -242,6 +242,14 @@ export default { initI18n(); initComponentSize(); } + document.onkeydown = (event) => { + var e = event || window.event || arguments.callee.caller.arguments[0]; + // 阻止F11全屏 + if (e && e.keyCode === 122 && !state.isScreenfull) { + e.preventDefault(); + onScreenfullClick(); + } + }; }); return { getUserInfos, diff --git a/src/layout/navBars/tagsView/tagsView.vue b/src/layout/navBars/tagsView/tagsView.vue index 0e82c7db..8b8336ae 100644 --- a/src/layout/navBars/tagsView/tagsView.vue +++ b/src/layout/navBars/tagsView/tagsView.vue @@ -190,7 +190,7 @@ export default { const { meta, name, params, query } = currentRouteInfo; if (meta.isDynamic) router.push({ name, params }); else router.push({ path, query }); - store.dispatch('tagsViewRoutes/setCurrenFullscreen'); + store.dispatch('tagsViewRoutes/setCurrenFullscreen', 500); }); }; // 当前项右键菜单点击,拿当前点击的路由路径对比 浏览器缓存中的 tagsView 路由数组,取当前点击项的详细路由信息 diff --git a/src/store/modules/tagsViewRoutes.ts b/src/store/modules/tagsViewRoutes.ts index e30c8d48..8779904f 100644 --- a/src/store/modules/tagsViewRoutes.ts +++ b/src/store/modules/tagsViewRoutes.ts @@ -4,6 +4,8 @@ import screenfull from 'screenfull'; import { Local } from '/@/utils/storage'; // 此处加上 `.ts` 后缀报错,具体原因不详 import { TagsViewRoutesState, RootStateTypes } from '/@/store/interface/index'; +import { ElMessage } from 'element-plus'; +import screenfull from 'screenfull'; const tagsViewRoutesModule: Module = { namespaced: true, @@ -27,33 +29,34 @@ const tagsViewRoutesModule: Module = { commit('getTagsViewRoutes', data); }, // 设置卡片全屏 - setCurrenFullscreen({ commit }) { + setCurrenFullscreen({ commit }, timeout: number = 0) { const screenfulls: any = screenfull; if (!screenfulls.isEnabled) { ElMessage.warning('暂不不支持全屏'); return false; } - screenfulls.toggle(); - const currenFullscreenChange = () => { - const layoutViewBgWhite = document.querySelector('.layout-view-bg-white') as HTMLElement; - if (screenfulls.isFullscreen) { - commit('getCurrenFullscreen', true); - // 设置全屏时,设置有 `layout-view-bg-white` 类的高度 - if (layoutViewBgWhite) layoutViewBgWhite.style.height = `calc(100vh - 30px)`; - } else { - screenfulls.off('change', currenFullscreenChange); - commit('getCurrenFullscreen', false); - if (!layoutViewBgWhite) return false; - const getThemeConfig = Local.get('themeConfig'); - if (getThemeConfig) { - let { isTagsview } = getThemeConfig; - if (isTagsview) layoutViewBgWhite.style.height = `calc(100vh - 114px)`; - else layoutViewBgWhite.style.height = `calc(100vh - 80px)`; + setTimeout(() => { + const currenFullscreenChange = () => { + const layoutViewBgWhite = document.querySelector('.layout-view-bg-white') as HTMLElement; + if (screenfulls.isFullscreen) { + commit('getCurrenFullscreen', true); + // 设置全屏时,设置有 `layout-view-bg-white` 类的高度 + if (layoutViewBgWhite) layoutViewBgWhite.style.height = `calc(100vh - 30px)`; + } else { + screenfulls.off('change', currenFullscreenChange); + commit('getCurrenFullscreen', false); + if (!layoutViewBgWhite) return false; + const getThemeConfig = Local.get('themeConfig'); + if (getThemeConfig) { + let { isTagsview } = getThemeConfig; + if (isTagsview) layoutViewBgWhite.style.height = `calc(100vh - 114px)`; + else layoutViewBgWhite.style.height = `calc(100vh - 80px)`; + } } - } - }; - screenfulls.on('change', currenFullscreenChange); - commit('getCurrenFullscreen', true); + }; + screenfulls.on('change', currenFullscreenChange); + screenfulls.toggle(); + }, timeout); }, }, };