Skip to content

Commit

Permalink
fix: 提升判断变量
Browse files Browse the repository at this point in the history
  • Loading branch information
RSS1102 committed Sep 4, 2024
1 parent 2a0e58b commit 4e0edd2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/layouts/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,17 @@ const appendNewRoute = () => {
tabsRouterStore.appendTabRouterList({ path, query, title: title as string, name, isAlive: true, meta: route.meta });
};
// 在操作监听过程中,如果已经隐藏了,就不再进行隐藏的dom操作// 如果已经显示了,就不再进行显示的dom操作
let alreadyHidden = false;
let alreadyShow = false;
const toggleHeadVisible = () => {
const layoutElement = document.querySelector(`.${prefix}-layout`);
if (layoutElement) {
const { scrollTop } = layoutElement;
const headerMenuFixedElement = document.querySelector(`.${prefix}-header-menu-fixed`);
const headerMenuFixedElementHeight = headerMenuFixedElement.scrollHeight;
// 在操作监听过程中,如果已经隐藏了,就不再进行隐藏的dom操作// 如果已经显示了,就不再进行显示的dom操作
let alreadyHidden = false;
let alreadyShow = false;
// 当面包屑存在时 fixed在头部
if (settingStore.showBreadcrumb) {
Expand Down Expand Up @@ -97,15 +98,16 @@ const toggleHeadVisible = () => {
if (scrollTop > headerMenuFixedElementHeight && settingStore.toggleHeadVisible) {
if (!alreadyHidden) {
headerElement.setAttribute('style', 'display: none;');
(layoutElement as HTMLElement).style.height = '100vh';
// (layoutElement as HTMLElement).style.height = '100vh';
sideNavMixFixedElement?.setAttribute('style', 'top: 0;');
}
alreadyHidden = true;
alreadyShow = false;
} else {
if (!alreadyShow) {
headerElement.setAttribute('style', null);
(layoutElement as HTMLElement).style.height = 'calc(100vh - var(--td-comp-size-xxxl))';
// (layoutElement as HTMLElement).style.height = 'calc(100vh - var(--td-comp-size-xxxl))';
sideNavMixFixedElement?.setAttribute('style', null);
}
alreadyHidden = false;
Expand Down

0 comments on commit 4e0edd2

Please sign in to comment.