Skip to content

Commit 19bee05

Browse files
authored
Merge pull request #834 from imsyy/dev-fix
refactor(lyric): 优化歌词解析性能和逻辑 - 重构时间解析函数,使用纯数学运算替代字符串操作以提高性能 - 移除全局正则表达式,改为在函数内局部使用避免状态污染 - 在解析过程中直接计算结束时间,消除二次遍历 - 优化歌词对齐算法,使用双指针实现 O(N) 复杂度 - 改进 QRC 格式解析,提前编译正则并优化 XML 内容提取 - 统一默认单词持续时间处理逻辑
2 parents 83e10e7 + a5eb352 commit 19bee05

5 files changed

Lines changed: 318 additions & 178 deletions

File tree

src/core/resource/DownloadManager.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -393,21 +393,20 @@ class DownloadManager {
393393
this.processQueue();
394394
}
395395

396-
// 移除正在下载的歌曲(取消下载)
397396
public removeDownload(id: number) {
398397
const dataStore = useDataStore();
399-
// 1. 从 dataStore 中移除
400-
dataStore.removeDownloadingSong(id);
401-
402-
// 2. 如果在队列中,移除
403-
this.queue = this.queue.filter((item) => item.id !== id);
404-
405-
// 3. 如果正在下载,尝试取消 (目前 Electron 端没有暴露取消接口,但移除后后续处理会忽略)
398+
// 如果正在下载,尝试取消(目前仅移除任务)
406399
if (this.activeDownloads.has(id)) {
400+
// TODO: 实现取消正在进行的下载任务
401+
// 暂时先从活动集合中移除,以释放下载槽位
407402
this.activeDownloads.delete(id);
408-
// 触发一次队列处理,填补空位
409-
this.processQueue();
410403
}
404+
// 从队列中移除
405+
this.queue = this.queue.filter((task) => task.id !== id);
406+
// 从 store 移除
407+
dataStore.removeDownloadingSong(id);
408+
// 尝试处理下一个任务
409+
this.processQueue();
411410
}
412411

413412
public retryDownload(id: number) {

0 commit comments

Comments
 (0)