feat: 动态调整 Toast 提示框的顶部偏移量,优化显示效果

This commit is contained in:
QLHazyCoder
2026-04-11 17:28:38 +08:00
parent 5fec876a9f
commit 1283b01a41
2 changed files with 9 additions and 1 deletions
+1 -1
View File
@@ -756,7 +756,7 @@ header {
#toast-container {
position: fixed;
top: 12px;
top: var(--toast-top-offset, 12px);
left: 12px;
right: 12px;
z-index: 1000;
+8
View File
@@ -44,6 +44,7 @@ const btnAutoStartClose = document.getElementById('btn-auto-start-close');
const btnAutoStartCancel = document.getElementById('btn-auto-start-cancel');
const btnAutoStartRestart = document.getElementById('btn-auto-start-restart');
const btnAutoStartContinue = document.getElementById('btn-auto-start-continue');
const pageHeader = document.querySelector('header');
const STEP_DEFAULT_STATUSES = {
1: 'pending',
2: 'pending',
@@ -113,6 +114,13 @@ function dismissToast(toast) {
toast.addEventListener('animationend', () => toast.remove());
}
function updateToastOffset() {
if (!toastContainer) return;
const headerBottom = pageHeader?.getBoundingClientRect().bottom ?? 0;
const offset = Math.max(12, Math.ceil(headerBottom + 8));
document.documentElement.style.setProperty('--toast-top-offset', `${offset}px`);
}
function resetActionModalButtons() {
const buttons = [btnAutoStartCancel, btnAutoStartRestart, btnAutoStartContinue];
buttons.forEach((button) => {