zhangdocs 1.1.27 → 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
|
@@ -52,6 +52,13 @@
|
|
|
52
52
|
</div>
|
|
53
53
|
</div>
|
|
54
54
|
|
|
55
|
+
<!-- 滚动到底部按钮 -->
|
|
56
|
+
<button class="scroll-to-bottom" id="scroll-to-bottom" aria-label="滚动到底部" title="滚动到底部">
|
|
57
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
58
|
+
<path d="M6 9l6 6 6-6"></path>
|
|
59
|
+
</svg>
|
|
60
|
+
</button>
|
|
61
|
+
|
|
55
62
|
<!-- Token输入弹窗 -->
|
|
56
63
|
<div id="token-modal"
|
|
57
64
|
style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 9999; display: none; justify-content: center; align-items: center;">
|
|
@@ -163,12 +170,28 @@ style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background:
|
|
|
163
170
|
// Token正确,立即显示内容
|
|
164
171
|
const mainContainer = document.getElementById('main-container');
|
|
165
172
|
const menuIcon = document.getElementById('menu-icon');
|
|
173
|
+
const scrollToBottomBtn = document.getElementById('scroll-to-bottom');
|
|
166
174
|
if (mainContainer) mainContainer.style.display = 'block';
|
|
167
175
|
if (menuIcon) {
|
|
168
176
|
menuIcon.style.display = 'flex';
|
|
169
177
|
// 菜单图标显示后,初始化菜单功能
|
|
170
178
|
setTimeout(initMenuPopup, 50);
|
|
171
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
|
+
}
|
|
172
195
|
}
|
|
173
196
|
})();
|
|
174
197
|
|
|
@@ -219,6 +242,22 @@ style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background:
|
|
|
219
242
|
// 菜单图标显示后,初始化菜单功能
|
|
220
243
|
setTimeout(initMenuPopup, 50);
|
|
221
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);
|
|
222
261
|
}
|
|
223
262
|
|
|
224
263
|
// 隐藏内容
|
|
@@ -449,5 +488,95 @@ style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background:
|
|
|
449
488
|
}
|
|
450
489
|
});
|
|
451
490
|
})();
|
|
491
|
+
|
|
492
|
+
// 滚动到底部功能
|
|
493
|
+
(function() {
|
|
494
|
+
function initScrollToBottom() {
|
|
495
|
+
var scrollToBottomBtn = document.getElementById('scroll-to-bottom');
|
|
496
|
+
if (!scrollToBottomBtn) {
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
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
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// 立即尝试初始化
|
|
568
|
+
initScrollToBottom();
|
|
569
|
+
|
|
570
|
+
// DOM加载完成后初始化
|
|
571
|
+
if (document.readyState === 'loading') {
|
|
572
|
+
document.addEventListener('DOMContentLoaded', initScrollToBottom);
|
|
573
|
+
} else {
|
|
574
|
+
setTimeout(initScrollToBottom, 100);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// 延迟初始化(处理动态显示的情况)
|
|
578
|
+
setTimeout(initScrollToBottom, 500);
|
|
579
|
+
setTimeout(initScrollToBottom, 1000);
|
|
580
|
+
})();
|
|
452
581
|
</script>
|
|
453
582
|
<% include footer.ejs %>
|
|
@@ -512,4 +512,57 @@ table
|
|
|
512
512
|
|
|
513
513
|
.nav-button
|
|
514
514
|
max-width: 100%
|
|
515
|
-
width: 100%
|
|
515
|
+
width: 100%
|
|
516
|
+
|
|
517
|
+
// 滚动到底部按钮
|
|
518
|
+
.scroll-to-bottom
|
|
519
|
+
position: fixed
|
|
520
|
+
bottom: 30px
|
|
521
|
+
right: 30px
|
|
522
|
+
width: 48px
|
|
523
|
+
height: 48px
|
|
524
|
+
background: #fff
|
|
525
|
+
border: 1px solid $border-color
|
|
526
|
+
border-radius: 50%
|
|
527
|
+
cursor: pointer
|
|
528
|
+
z-index: 999
|
|
529
|
+
display: none
|
|
530
|
+
align-items: center
|
|
531
|
+
justify-content: center
|
|
532
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15)
|
|
533
|
+
transition: all 0.3s ease
|
|
534
|
+
color: $text-color
|
|
535
|
+
padding: 0
|
|
536
|
+
-webkit-tap-highlight-color: transparent
|
|
537
|
+
opacity: 0
|
|
538
|
+
visibility: hidden
|
|
539
|
+
|
|
540
|
+
&:hover
|
|
541
|
+
background: $primary-color
|
|
542
|
+
border-color: $primary-color
|
|
543
|
+
color: #fff
|
|
544
|
+
transform: translateY(-3px)
|
|
545
|
+
box-shadow: 0 4px 12px rgba(74, 144, 226, 0.4)
|
|
546
|
+
|
|
547
|
+
&:active
|
|
548
|
+
transform: translateY(-1px)
|
|
549
|
+
box-shadow: 0 2px 6px rgba(74, 144, 226, 0.3)
|
|
550
|
+
|
|
551
|
+
svg
|
|
552
|
+
width: 20px
|
|
553
|
+
height: 20px
|
|
554
|
+
|
|
555
|
+
&.show
|
|
556
|
+
display: flex
|
|
557
|
+
opacity: 1
|
|
558
|
+
visibility: visible
|
|
559
|
+
|
|
560
|
+
@media mq-mobile
|
|
561
|
+
bottom: 20px
|
|
562
|
+
right: 20px
|
|
563
|
+
width: 44px
|
|
564
|
+
height: 44px
|
|
565
|
+
|
|
566
|
+
svg
|
|
567
|
+
width: 18px
|
|
568
|
+
height: 18px
|