mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-07-11 21:03:37 +08:00
fix(player): 合并外部贡献后的集成修复
- PlayBar 下载按钮补 isElectron 守卫,Web 端不再显示无效按钮(#708 评审意见) - preloadNextSongs 恢复 800ms 短去抖,避免快速切歌时音源请求风暴(#712 评审意见) - 清理合并后未使用的导入
This commit is contained in:
@@ -151,7 +151,7 @@
|
|||||||
</template>
|
</template>
|
||||||
{{ t('player.playBar.reparse') }}
|
{{ t('player.playBar.reparse') }}
|
||||||
</n-tooltip>
|
</n-tooltip>
|
||||||
<n-tooltip v-if="playMusic?.id" trigger="hover" :z-index="9999999">
|
<n-tooltip v-if="playMusic?.id && isElectron" trigger="hover" :z-index="9999999">
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
<i
|
<i
|
||||||
class="iconfont ri-download-line"
|
class="iconfont ri-download-line"
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import { getMusicLrc, getMusicUrl, getParsingMusicUrl } from '@/api/music';
|
|||||||
import { playbackRequestManager } from '@/services/playbackRequestManager';
|
import { playbackRequestManager } from '@/services/playbackRequestManager';
|
||||||
import { SongSourceConfigManager } from '@/services/SongSourceConfigManager';
|
import { SongSourceConfigManager } from '@/services/SongSourceConfigManager';
|
||||||
import type { ILyric, ILyricText, IWordData, SongResult } from '@/types/music';
|
import type { ILyric, ILyricText, IWordData, SongResult } from '@/types/music';
|
||||||
import { getImgUrl, isElectron } from '@/utils';
|
import { isElectron } from '@/utils';
|
||||||
import { getImageLinearBackground } from '@/utils/linearColor';
|
|
||||||
import { parseLyrics as parseYrcLyrics } from '@/utils/yrcParser';
|
import { parseLyrics as parseYrcLyrics } from '@/utils/yrcParser';
|
||||||
|
|
||||||
const { message } = createDiscreteApi(['message']);
|
const { message } = createDiscreteApi(['message']);
|
||||||
|
|||||||
@@ -107,9 +107,19 @@ export const usePlaylistStore = defineStore(
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 智能预加载下一首歌曲(立即执行,不等待)
|
* 智能预加载下一首歌曲
|
||||||
|
* 短去抖:快速连续切歌时只保留最后一次,避免对音源 API 的请求风暴
|
||||||
*/
|
*/
|
||||||
|
let preloadDebounceTimer: ReturnType<typeof setTimeout> | null = null;
|
||||||
const preloadNextSongs = (currentIndex: number) => {
|
const preloadNextSongs = (currentIndex: number) => {
|
||||||
|
if (preloadDebounceTimer) clearTimeout(preloadDebounceTimer);
|
||||||
|
preloadDebounceTimer = setTimeout(() => {
|
||||||
|
preloadDebounceTimer = null;
|
||||||
|
doPreloadNextSongs(currentIndex);
|
||||||
|
}, 800);
|
||||||
|
};
|
||||||
|
|
||||||
|
const doPreloadNextSongs = (currentIndex: number) => {
|
||||||
if (playList.value.length <= 1) return;
|
if (playList.value.length <= 1) return;
|
||||||
|
|
||||||
let nextIndex: number;
|
let nextIndex: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user