* 更新目录中的已读标记 * 在目录已渲染后,根据最新的已读状态更新视觉反馈 * Requirements: 7.4
()
| 1346 | * Requirements: 7.4 |
| 1347 | */ |
| 1348 | function updateTocReadMarkers() { |
| 1349 | // 检查 StorageManager 是否可用 |
| 1350 | if (typeof StorageManager === 'undefined') { |
| 1351 | return; |
| 1352 | } |
| 1353 | |
| 1354 | // 获取已读章节列表 |
| 1355 | const readChapters = StorageManager.getReadChapters(); |
| 1356 | |
| 1357 | // 获取所有目录章节链接 |
| 1358 | const chapterLinks = document.querySelectorAll('.toc-chapter-link'); |
| 1359 | |
| 1360 | chapterLinks.forEach(link => { |
| 1361 | const chapterNumber = parseInt(link.dataset.chapter, 10); |
| 1362 | |
| 1363 | if (readChapters.includes(chapterNumber)) { |
| 1364 | // 添加已读标记 |
| 1365 | if (!link.classList.contains('is-read')) { |
| 1366 | link.classList.add('is-read'); |
| 1367 | } |
| 1368 | } else { |
| 1369 | // 移除已读标记(以防状态被清除) |
| 1370 | link.classList.remove('is-read'); |
| 1371 | } |
| 1372 | }); |
| 1373 | } |
| 1374 | |
| 1375 | /** |
| 1376 | * 隐藏加载动画 |
nothing calls this directly
no outgoing calls
no test coverage detected