@@ -15,7 +15,7 @@ document.addEventListener('DOMContentLoaded', () => {
1515 function initTheme ( ) {
1616 const savedTheme = localStorage . getItem ( 'theme' ) ;
1717 const systemDark = window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches ;
18-
18+
1919 if ( savedTheme === 'dark' || ( ! savedTheme && systemDark ) ) {
2020 document . documentElement . setAttribute ( 'data-theme' , 'dark' ) ;
2121 moonIcon . classList . add ( 'hidden' ) ;
@@ -30,10 +30,10 @@ document.addEventListener('DOMContentLoaded', () => {
3030 themeToggle . addEventListener ( 'click' , ( ) => {
3131 const currentTheme = document . documentElement . getAttribute ( 'data-theme' ) ;
3232 const newTheme = currentTheme === 'dark' ? 'light' : 'dark' ;
33-
33+
3434 document . documentElement . setAttribute ( 'data-theme' , newTheme ) ;
3535 localStorage . setItem ( 'theme' , newTheme ) ;
36-
36+
3737 if ( newTheme === 'dark' ) {
3838 moonIcon . classList . add ( 'hidden' ) ;
3939 sunIcon . classList . remove ( 'hidden' ) ;
@@ -48,7 +48,7 @@ document.addEventListener('DOMContentLoaded', () => {
4848 if ( ! notesConfig || notesConfig . length === 0 ) {
4949 notesGrid . innerHTML = `
5050 <div style="grid-column: 1 / -1; text-align: center; color: var(--text-secondary); padding: 2rem;">
51- 没有发现笔记。请运行 <code>python3 update_notes.py</code> 来生成配置。
51+ 没有发现笔记。请运行 <code>python3 scripts/ update_notes.py</code> 来生成配置。
5252 </div>` ;
5353 return ;
5454 }
@@ -104,23 +104,23 @@ document.addEventListener('DOMContentLoaded', () => {
104104 <div class="spinner"></div>
105105 <p>加载笔记中...</p>
106106 </div>` ;
107-
107+
108108 githubEditLink . href = `${ GITHUB_REPO_URL } ${ notePath } ` ;
109109
110110 try {
111111 // Append a unique query param to bypass cache during development
112112 const resp = await fetch ( notePath + '?v=' + new Date ( ) . getTime ( ) ) ;
113113 if ( ! resp . ok ) throw new Error ( `HTTP error! status: ${ resp . status } ` ) ;
114114 const text = await resp . text ( ) ;
115-
115+
116116 // Parse Markdown to HTML
117117 const html = marked . parse ( text ) ;
118118 markdownContent . innerHTML = html ;
119-
119+
120120 markdownContent . querySelectorAll ( 'pre code' ) . forEach ( ( block ) => {
121121 hljs . highlightElement ( block ) ;
122122 } ) ;
123-
123+
124124 buildTableOfContents ( ) ;
125125 addCopyButtons ( ) ;
126126 } catch ( error ) {
@@ -129,7 +129,7 @@ document.addEventListener('DOMContentLoaded', () => {
129129 <div style="color: #ef4444; padding: 2rem; text-align: center;">
130130 <h2>无法加载笔记 😢</h2>
131131 <p style="margin-top: 1rem;">找不到文件: <code>${ notePath } </code></p>
132- <p style="margin-top: 0.5rem; font-size: 0.9em; color: var(--text-secondary);">请检查路径是否正确,或重新生成 config.js。</p>
132+ <p style="margin-top: 0.5rem; font-size: 0.9em; color: var(--text-secondary);">请检查路径是否正确,或重新生成 assets/js/ config.js。</p>
133133 </div>
134134 ` ;
135135 }
@@ -139,10 +139,10 @@ document.addEventListener('DOMContentLoaded', () => {
139139 function buildTableOfContents ( ) {
140140 const tocList = document . getElementById ( 'toc-list' ) ;
141141 if ( ! tocList ) return ;
142-
142+
143143 tocList . innerHTML = '' ;
144144 const headings = markdownContent . querySelectorAll ( 'h1, h2, h3, h4' ) ;
145-
145+
146146 if ( headings . length === 0 ) {
147147 tocList . innerHTML = '<li style="color: var(--text-secondary); font-size: 0.875rem;">无目录结构</li>' ;
148148 return ;
@@ -155,13 +155,13 @@ document.addEventListener('DOMContentLoaded', () => {
155155 if ( ! id ) id = `heading-${ index } ` ;
156156 let uniqueId = id ;
157157 let counter = 1 ;
158- while ( document . getElementById ( uniqueId ) ) {
158+ while ( document . getElementById ( uniqueId ) ) {
159159 uniqueId = `${ id } -${ counter } ` ;
160160 counter ++ ;
161161 }
162162 heading . id = uniqueId ;
163163 }
164-
164+
165165 const level = parseInt ( heading . tagName . substring ( 1 ) ) ;
166166 tocHTML += `<li class="toc-h${ level } "><a href="#${ heading . id } ">${ heading . textContent } </a></li>` ;
167167 } ) ;
@@ -177,15 +177,14 @@ document.addEventListener('DOMContentLoaded', () => {
177177 const targetId = e . target . getAttribute ( 'href' ) . substring ( 1 ) ;
178178 const targetElement = document . getElementById ( targetId ) ;
179179 if ( targetElement ) {
180- const yOffset = - 80 ;
180+ const yOffset = - 80 ;
181181 const y = targetElement . getBoundingClientRect ( ) . top + window . pageYOffset + yOffset ;
182- window . scrollTo ( { top : y , behavior : 'smooth' } ) ;
182+ window . scrollTo ( { top : y , behavior : 'smooth' } ) ;
183183 }
184184 }
185185 } ) ;
186186 }
187187
188-
189188 // --- Code Copy ---
190189 function addCopyButtons ( ) {
191190 const preBlocks = markdownContent . querySelectorAll ( 'pre' ) ;
@@ -194,16 +193,16 @@ document.addEventListener('DOMContentLoaded', () => {
194193 button . className = 'copy-btn' ;
195194 button . title = 'Copy code' ;
196195 button . innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>' ;
197-
196+
198197 button . addEventListener ( 'click' , async ( ) => {
199198 const codeBlock = pre . querySelector ( 'code' ) ;
200199 if ( ! codeBlock ) return ;
201-
200+
202201 try {
203202 await navigator . clipboard . writeText ( codeBlock . innerText ) ;
204203 button . classList . add ( 'copied' ) ;
205204 button . innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>' ;
206-
205+
207206 setTimeout ( ( ) => {
208207 button . classList . remove ( 'copied' ) ;
209208 button . innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>' ;
@@ -212,7 +211,7 @@ document.addEventListener('DOMContentLoaded', () => {
212211 console . error ( 'Failed to copy text: ' , err ) ;
213212 }
214213 } ) ;
215-
214+
216215 pre . appendChild ( button ) ;
217216 } ) ;
218217 }
@@ -237,4 +236,4 @@ document.addEventListener('DOMContentLoaded', () => {
237236 // Bootstrap
238237 initTheme ( ) ;
239238 handleRoute ( ) ;
240- } ) ;
239+ } ) ;
0 commit comments