zhangdocs 1.1.28 → 1.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -170,12 +170,28 @@ style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background:
|
|
|
170
170
|
// Token正确,立即显示内容
|
|
171
171
|
const mainContainer = document.getElementById('main-container');
|
|
172
172
|
const menuIcon = document.getElementById('menu-icon');
|
|
173
|
+
const scrollToBottomBtn = document.getElementById('scroll-to-bottom');
|
|
173
174
|
if (mainContainer) mainContainer.style.display = 'block';
|
|
174
175
|
if (menuIcon) {
|
|
175
176
|
menuIcon.style.display = 'flex';
|
|
176
177
|
// 菜单图标显示后,初始化菜单功能
|
|
177
178
|
setTimeout(initMenuPopup, 50);
|
|
178
179
|
}
|
|
180
|
+
// 初始化滚动到底部按钮
|
|
181
|
+
if (scrollToBottomBtn) {
|
|
182
|
+
setTimeout(function() {
|
|
183
|
+
scrollToBottomBtn.style.display = 'flex';
|
|
184
|
+
// 检查是否需要显示按钮
|
|
185
|
+
setTimeout(function() {
|
|
186
|
+
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
187
|
+
var scrollHeight = document.documentElement.scrollHeight;
|
|
188
|
+
var clientHeight = document.documentElement.clientHeight;
|
|
189
|
+
if (scrollHeight - scrollTop - clientHeight > 5) {
|
|
190
|
+
scrollToBottomBtn.classList.add('show');
|
|
191
|
+
}
|
|
192
|
+
}, 200);
|
|
193
|
+
}, 100);
|
|
194
|
+
}
|
|
179
195
|
}
|
|
180
196
|
})();
|
|
181
197
|
|
|
@@ -226,6 +242,22 @@ style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background:
|
|
|
226
242
|
// 菜单图标显示后,初始化菜单功能
|
|
227
243
|
setTimeout(initMenuPopup, 50);
|
|
228
244
|
}
|
|
245
|
+
// 显示内容后,初始化滚动到底部按钮
|
|
246
|
+
setTimeout(function() {
|
|
247
|
+
var scrollToBottomBtn = document.getElementById('scroll-to-bottom');
|
|
248
|
+
if (scrollToBottomBtn) {
|
|
249
|
+
scrollToBottomBtn.style.display = 'flex';
|
|
250
|
+
// 检查是否需要显示按钮
|
|
251
|
+
setTimeout(function() {
|
|
252
|
+
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
253
|
+
var scrollHeight = document.documentElement.scrollHeight;
|
|
254
|
+
var clientHeight = document.documentElement.clientHeight;
|
|
255
|
+
if (scrollHeight - scrollTop - clientHeight > 5) {
|
|
256
|
+
scrollToBottomBtn.classList.add('show');
|
|
257
|
+
}
|
|
258
|
+
}, 100);
|
|
259
|
+
}
|
|
260
|
+
}, 100);
|
|
229
261
|
}
|
|
230
262
|
|
|
231
263
|
// 隐藏内容
|
|
@@ -459,65 +491,92 @@ style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background:
|
|
|
459
491
|
|
|
460
492
|
// 滚动到底部功能
|
|
461
493
|
(function() {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
// 检查是否在页面底部
|
|
468
|
-
function isAtBottom() {
|
|
469
|
-
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
470
|
-
var scrollHeight = document.documentElement.scrollHeight;
|
|
471
|
-
var clientHeight = document.documentElement.clientHeight;
|
|
472
|
-
// 允许5px的误差
|
|
473
|
-
return scrollHeight - scrollTop - clientHeight <= 5;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
// 显示/隐藏按钮
|
|
477
|
-
function toggleButton() {
|
|
478
|
-
if (isAtBottom()) {
|
|
479
|
-
scrollToBottomBtn.classList.remove('show');
|
|
480
|
-
} else {
|
|
481
|
-
scrollToBottomBtn.classList.add('show');
|
|
494
|
+
function initScrollToBottom() {
|
|
495
|
+
var scrollToBottomBtn = document.getElementById('scroll-to-bottom');
|
|
496
|
+
if (!scrollToBottomBtn) {
|
|
497
|
+
return;
|
|
482
498
|
}
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
499
|
+
|
|
500
|
+
// 确保按钮可见(如果内容已显示)
|
|
501
|
+
var mainContainer = document.getElementById('main-container');
|
|
502
|
+
if (mainContainer && mainContainer.style.display !== 'none') {
|
|
503
|
+
scrollToBottomBtn.style.display = 'flex';
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// 检查是否在页面底部
|
|
507
|
+
function isAtBottom() {
|
|
508
|
+
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
509
|
+
var scrollHeight = document.documentElement.scrollHeight;
|
|
510
|
+
var clientHeight = document.documentElement.clientHeight;
|
|
511
|
+
// 允许5px的误差
|
|
512
|
+
return scrollHeight - scrollTop - clientHeight <= 5;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
// 显示/隐藏按钮
|
|
516
|
+
function toggleButton() {
|
|
517
|
+
// 确保按钮可见
|
|
518
|
+
if (mainContainer && mainContainer.style.display !== 'none') {
|
|
519
|
+
scrollToBottomBtn.style.display = 'flex';
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
if (isAtBottom()) {
|
|
523
|
+
scrollToBottomBtn.classList.remove('show');
|
|
524
|
+
} else {
|
|
525
|
+
scrollToBottomBtn.classList.add('show');
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
// 滚动到底部
|
|
530
|
+
function scrollToBottom() {
|
|
531
|
+
window.scrollTo({
|
|
532
|
+
top: document.documentElement.scrollHeight,
|
|
533
|
+
behavior: 'smooth'
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// 绑定点击事件
|
|
538
|
+
scrollToBottomBtn.addEventListener('click', function(e) {
|
|
539
|
+
e.preventDefault();
|
|
540
|
+
scrollToBottom();
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
// 监听滚动事件
|
|
544
|
+
var scrollTimer = null;
|
|
545
|
+
window.addEventListener('scroll', function() {
|
|
546
|
+
// 使用节流,减少频繁检查
|
|
547
|
+
if (scrollTimer) {
|
|
548
|
+
clearTimeout(scrollTimer);
|
|
549
|
+
}
|
|
550
|
+
scrollTimer = setTimeout(toggleButton, 100);
|
|
551
|
+
}, { passive: true });
|
|
552
|
+
|
|
553
|
+
// 初始检查
|
|
554
|
+
setTimeout(toggleButton, 300);
|
|
555
|
+
|
|
556
|
+
// 监听内容变化(处理动态加载的内容)
|
|
557
|
+
var observer = new MutationObserver(function() {
|
|
558
|
+
setTimeout(toggleButton, 100);
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
observer.observe(document.body, {
|
|
562
|
+
childList: true,
|
|
563
|
+
subtree: true
|
|
490
564
|
});
|
|
491
565
|
}
|
|
492
566
|
|
|
493
|
-
//
|
|
494
|
-
|
|
495
|
-
e.preventDefault();
|
|
496
|
-
scrollToBottom();
|
|
497
|
-
});
|
|
498
|
-
|
|
499
|
-
// 监听滚动事件
|
|
500
|
-
var scrollTimer = null;
|
|
501
|
-
window.addEventListener('scroll', function() {
|
|
502
|
-
// 使用节流,减少频繁检查
|
|
503
|
-
if (scrollTimer) {
|
|
504
|
-
clearTimeout(scrollTimer);
|
|
505
|
-
}
|
|
506
|
-
scrollTimer = setTimeout(toggleButton, 100);
|
|
507
|
-
}, { passive: true });
|
|
508
|
-
|
|
509
|
-
// 初始检查
|
|
510
|
-
setTimeout(toggleButton, 500);
|
|
567
|
+
// 立即尝试初始化
|
|
568
|
+
initScrollToBottom();
|
|
511
569
|
|
|
512
|
-
//
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
}
|
|
570
|
+
// DOM加载完成后初始化
|
|
571
|
+
if (document.readyState === 'loading') {
|
|
572
|
+
document.addEventListener('DOMContentLoaded', initScrollToBottom);
|
|
573
|
+
} else {
|
|
574
|
+
setTimeout(initScrollToBottom, 100);
|
|
575
|
+
}
|
|
516
576
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
});
|
|
577
|
+
// 延迟初始化(处理动态显示的情况)
|
|
578
|
+
setTimeout(initScrollToBottom, 500);
|
|
579
|
+
setTimeout(initScrollToBottom, 1000);
|
|
521
580
|
})();
|
|
522
581
|
</script>
|
|
523
582
|
<% include footer.ejs %>
|
|
@@ -534,6 +534,8 @@ table
|
|
|
534
534
|
color: $text-color
|
|
535
535
|
padding: 0
|
|
536
536
|
-webkit-tap-highlight-color: transparent
|
|
537
|
+
opacity: 0
|
|
538
|
+
visibility: hidden
|
|
537
539
|
|
|
538
540
|
&:hover
|
|
539
541
|
background: $primary-color
|
|
@@ -552,6 +554,8 @@ table
|
|
|
552
554
|
|
|
553
555
|
&.show
|
|
554
556
|
display: flex
|
|
557
|
+
opacity: 1
|
|
558
|
+
visibility: visible
|
|
555
559
|
|
|
556
560
|
@media mq-mobile
|
|
557
561
|
bottom: 20px
|