Conversation
- 将 watchEffect 替换为 watch 以更好地控制时间变化响应 - 添加跳转检测逻辑,当时间变化超过 1000ms 时视为跳转操作 - 针对 v0.2.0 版本实现临时修复,手动处理跳转时的滚动状态重置 - 强制重置缓冲行和滚动位置以确保正确的歌词显示 - 保留非跳转情况下的正常时间设置逻辑
Summary of ChangesHello @laoshuikaixue, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此拉取请求旨在解决 AM 歌词页在播放时间跳转时滚动位置不准确的问题。通过将时间监听器从 Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
| () => props.currentTime, | ||
| (time, oldTime) => { | ||
| if (time === undefined) return; | ||
| const isSeek = oldTime !== undefined && Math.abs(time - oldTime) > 1000; |
| const player = playerRef.value as any; | ||
| if (player) { | ||
| player.setCurrentTime(time, true); | ||
|
|
||
| // 强制重置缓冲行和滚动位置 | ||
| if (player.bufferedLines && player.hotLines && player.processedLines) { | ||
| player.bufferedLines.clear(); | ||
| for (const v of player.hotLines) { | ||
| player.bufferedLines.add(v); | ||
| } | ||
|
|
||
| if (player.bufferedLines.size > 0) { | ||
| player.scrollToIndex = Math.min(...player.bufferedLines); | ||
| } else { | ||
| const foundIndex = player.processedLines.findIndex( | ||
| (line: any) => line.startTime >= time |
There was a problem hiding this comment.
在多处使用了 as any (L296) 和 (line: any) (L311),这会完全绕过 TypeScript 的类型检查,降低代码的可维护性。虽然注释说明这是临时修复,但最好还是提供一个更具体的类型。
建议在组件顶部定义一个接口来描述这些额外的属性,例如:
interface PatchedLyricPlayer extends CoreLyricPlayer {
bufferedLines: Set<number>;
hotLines: Set<number>;
processedLines: (LyricLine & { startTime: number })[];
scrollToIndex: number;
resetScroll: () => void;
calcLayout: () => void;
}然后使用 const player = playerRef.value as PatchedLyricPlayer。这能增强类型安全,并能移除对 (line: any) 的需要,让 TypeScript 正确推断 line 的类型。
|
现在是针对npm未发版的解决方案,后续npm更新修复了内部的 Seek 逻辑后,可以移除本 PR 中 if (isSeek) { ... } 块内的手动重置逻辑,直接调用 playerRef.value?.setCurrentTime(time, isSeek) 即可 |
2026-02-16.19-58-05.mp4 |
Closed #889