Skip to content

Commit 2c46d28

Browse files
committed
feat: implement UI styling, back-to-top functionality, and PyTorch development environment configuration
1 parent 7da10a9 commit 2c46d28

File tree

4 files changed

+135
-0
lines changed

4 files changed

+135
-0
lines changed

assets/css/style.css

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,4 +553,61 @@ a:hover {
553553
margin-top: 1.5rem;
554554
order: -1;
555555
}
556+
}
557+
558+
/* Back to Top Button */
559+
.back-to-top {
560+
position: fixed;
561+
bottom: 2rem;
562+
right: 2rem;
563+
width: 3rem;
564+
height: 3rem;
565+
border-radius: 50%;
566+
background-color: var(--accent-color);
567+
color: white;
568+
border: none;
569+
box-shadow: var(--shadow-md);
570+
cursor: pointer;
571+
display: flex;
572+
align-items: center;
573+
justify-content: center;
574+
opacity: 0;
575+
visibility: hidden;
576+
transform: translateY(20px);
577+
transition: all 0.3s ease;
578+
z-index: 100;
579+
}
580+
581+
.back-to-top.show {
582+
opacity: 1;
583+
visibility: visible;
584+
transform: translateY(0);
585+
}
586+
587+
.back-to-top:hover {
588+
background-color: var(--accent-hover);
589+
transform: translateY(-5px);
590+
}
591+
592+
/* TOC Active State */
593+
#toc-list a.active {
594+
color: var(--accent-color);
595+
font-weight: 600;
596+
}
597+
598+
#toc-list li {
599+
position: relative;
600+
margin-bottom: 0.5rem;
601+
}
602+
603+
#toc-list a.active::before {
604+
content: '';
605+
position: absolute;
606+
left: -12px;
607+
top: 50%;
608+
transform: translateY(-50%);
609+
height: 1.2em;
610+
width: 3px;
611+
background-color: var(--accent-color);
612+
border-radius: 2px;
556613
}

assets/js/app.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ document.addEventListener('DOMContentLoaded', () => {
88
const moonIcon = document.getElementById('moon-icon');
99
const sunIcon = document.getElementById('sun-icon');
1010
const githubEditLink = document.getElementById('github-edit-link');
11+
const backToTopBtn = document.getElementById('back-to-top');
1112

1213
const GITHUB_REPO_URL = 'https://github.com/luffydod/ConfigNote/edit/main/';
1314
const APP_BASE_URL = new URL('./', document.baseURI);
@@ -264,6 +265,11 @@ document.addEventListener('DOMContentLoaded', () => {
264265
buildTableOfContents();
265266
addCopyButtons();
266267

268+
const h1 = markdownContent.querySelector('h1');
269+
const fileTitle = typeof notesConfig !== 'undefined' ? notesConfig.find(n => n.path === normalizedNotePath)?.title : undefined;
270+
const noteTitle = h1 ? h1.textContent : (fileTitle || '笔记');
271+
document.title = `${noteTitle} - ConfigNote`;
272+
267273
if (window.location.hash) {
268274
scrollToHeading(window.location.hash.substring(1));
269275
}
@@ -311,6 +317,7 @@ document.addEventListener('DOMContentLoaded', () => {
311317
});
312318

313319
tocList.innerHTML = tocHTML;
320+
setupScrollspy();
314321
}
315322

316323
const tocListDom = document.getElementById('toc-list');
@@ -392,6 +399,61 @@ document.addEventListener('DOMContentLoaded', () => {
392399
});
393400
}
394401

402+
// --- Scrollspy & Back to Top ---
403+
let currentScrollListener = null;
404+
405+
function setupScrollspy() {
406+
const headings = Array.from(markdownContent.querySelectorAll('h1, h2, h3, h4'));
407+
const tocLinks = document.querySelectorAll('#toc-list a');
408+
409+
if (headings.length === 0) return;
410+
411+
if (currentScrollListener) {
412+
window.removeEventListener('scroll', currentScrollListener);
413+
}
414+
415+
currentScrollListener = () => {
416+
let activeId = '';
417+
const scrollPos = window.scrollY + 120;
418+
419+
for (const h of headings) {
420+
if (h.offsetTop <= scrollPos) {
421+
activeId = h.id;
422+
} else {
423+
break;
424+
}
425+
}
426+
427+
if (!activeId && headings.length > 0) {
428+
activeId = headings[0].id;
429+
}
430+
431+
tocLinks.forEach(a => {
432+
a.classList.remove('active');
433+
if (activeId && a.getAttribute('href') === `#${activeId}`) {
434+
a.classList.add('active');
435+
}
436+
});
437+
};
438+
439+
window.addEventListener('scroll', currentScrollListener);
440+
currentScrollListener();
441+
}
442+
443+
if (backToTopBtn) {
444+
window.addEventListener('scroll', () => {
445+
if (window.scrollY > 300) {
446+
backToTopBtn.classList.add('show');
447+
} else {
448+
backToTopBtn.classList.remove('show');
449+
}
450+
});
451+
452+
backToTopBtn.addEventListener('click', () => {
453+
window.scrollTo({ top: 0, behavior: 'smooth' });
454+
});
455+
}
456+
395457
// --- Router ---
396458
function handleRoute() {
397459
const urlParams = new URLSearchParams(window.location.search);
@@ -400,6 +462,7 @@ document.addEventListener('DOMContentLoaded', () => {
400462
if (notePath) {
401463
fetchAndRenderNote(notePath);
402464
} else {
465+
document.title = "ConfigNote - 📝 我的开发工具配置备忘录";
403466
noteView.classList.replace('section-active', 'section-hidden');
404467
homeView.classList.replace('section-hidden', 'section-active');
405468
window.scrollTo(0, 0);

docker/pytorch_dev/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,11 @@ WORKDIR /home/${YOUR_NAME}/workspace
6969
# 暴露 22 端口
7070
EXPOSE 22
7171

72+
# 将用户的 .local/bin 加入环境变量,解决 pip 用户安装报 PATH 警告的问题
73+
ENV PATH="/home/${YOUR_NAME}/.local/bin:${PATH}"
74+
75+
# 允许 pip 全局安装,突破 PEP 668 限制
76+
ENV PIP_BREAK_SYSTEM_PACKAGES=1
77+
7278
# 启动 sshd 服务,并以前台模式 (-D) 运行,这能保持容器一直处于运行状态
7379
CMD ["/usr/sbin/sshd", "-D"]

index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ <h1 class="hero-title">📝 ConfigNote</h1>
101101
<p>ConfigNote &copy; 2026</p>
102102
</footer>
103103

104+
<!-- Back to Top Button -->
105+
<button id="back-to-top" class="back-to-top" aria-label="回到顶部">
106+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none"
107+
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
108+
<line x1="12" y1="19" x2="12" y2="5"></line>
109+
<polyline points="5 12 12 5 19 12"></polyline>
110+
</svg>
111+
</button>
112+
104113
<!-- Scripts -->
105114
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/12.0.1/marked.min.js"></script>
106115
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>

0 commit comments

Comments
 (0)