Skip to content

Commit

Permalink
fix: alert bar (nacos-group#703)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hazel0928 authored Jun 25, 2024
1 parent a3f45d7 commit 03dbd2c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/common/Header/Alert.astro
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ const {

<script>
// handleAlertClose函数用于处理提示条的关闭逻辑。
function handleAlertClose(button) {
function handleAlertClose(button, pageFrame) {
button.parentNode.style.display = "none";
window.alertBarClosed = true;
pageFrame.classList.remove('alert-bar-exist')
}

// 检查localStorage中的状态,看是否需要显示提示条。
Expand All @@ -41,13 +42,16 @@ const {
const alertBar = document.querySelector(".alert-bar");
const closeButton = document.querySelector(".close-button");
const isClosed = window.alertBarClosed || false;
const pageFrame = document.querySelector('.sidebar-pane');

if (isClosed === true) {
alertBar.style.display = "none";
pageFrame.classList.remove('alert-bar-exist')
} else {
closeButton.addEventListener("click", function () {
handleAlertClose(closeButton);
handleAlertClose(closeButton,pageFrame);
});
pageFrame.classList.add('alert-bar-exist')
}
} catch (e) {
console.log(e);
Expand Down
3 changes: 3 additions & 0 deletions src/components/starlight/PageFrame.astro
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ const { hasSidebar, labels } = Astro.props;
background-color: var(--sl-color-black);
overflow-y: auto;
}
.alert-bar-exist {
top: 6rem;
}

[aria-expanded="true"] ~ .sidebar-pane {
--sl-sidebar-visibility: visible;
Expand Down

0 comments on commit 03dbd2c

Please sign in to comment.