MCPcopy Index your code
hub / github.com/iChochy/NCE / renderLyrics

Method renderLyrics

js/ReadingSystem.js:398–423  ·  view source on GitHub ↗

* 渲染歌词列表

()

Source from the content-addressed store, hash-verified

396 * 渲染歌词列表
397 */
398 renderLyrics() {
399 if (!this.dom.lyricsDisplay) return;
400
401 if (this.dom.lyricsContainer) {
402 this.dom.lyricsContainer.scrollTop = 0;
403 }
404
405 if (!this.state.currentLyrics.length) {
406 setHTML(this.dom.lyricsDisplay, '<p class="placeholder">没有歌词数据</p>');
407 return;
408 }
409
410 const html = this.state.currentLyrics
411 .map(
412 (lyric, index) =>
413 `<div class="lyric-line" data-index="${index}" data-time="${lyric.time}" tabindex="0" role="button" aria-label="播放第 ${index + 1} 句">
414 <div class="lyric-text">${lyric.english}</div>
415 ${lyric.chinese ? `<div class="lyric-translation">${lyric.chinese}</div>` : ''}
416 </div>`
417 )
418 .join('');
419
420 setHTML(this.dom.lyricsDisplay, html);
421 this.lyricLineEls = qsa('.lyric-line', this.dom.lyricsDisplay);
422 this.state.currentLyricIndex = -1;
423 }
424
425 /**
426 * 处理歌词行激活

Callers 1

loadUnitByIndexMethod · 0.95

Calls 2

setHTMLFunction · 0.90
qsaFunction · 0.90

Tested by

no test coverage detected