mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-05-17 10:27:30 +08:00
feat: 优化解析功能,添加缓存
This commit is contained in:
@@ -55,11 +55,17 @@ export const textColors = ref<any>(getTextColors());
|
||||
export let playMusic: ComputedRef<SongResult>;
|
||||
export let artistList: ComputedRef<Artist[]>;
|
||||
|
||||
export const musicDB = await useIndexedDB('musicDB', [
|
||||
{ name: 'music', keyPath: 'id' },
|
||||
{ name: 'music_lyric', keyPath: 'id' },
|
||||
{ name: 'api_cache', keyPath: 'id' }
|
||||
]);
|
||||
export const musicDB = await useIndexedDB(
|
||||
'musicDB',
|
||||
[
|
||||
{ name: 'music', keyPath: 'id' },
|
||||
{ name: 'music_lyric', keyPath: 'id' },
|
||||
{ name: 'api_cache', keyPath: 'id' },
|
||||
{ name: 'music_url_cache', keyPath: 'id' },
|
||||
{ name: 'music_failed_cache', keyPath: 'id' }
|
||||
],
|
||||
2
|
||||
);
|
||||
|
||||
// 键盘事件处理器,在初始化后设置
|
||||
const setupKeyboardListeners = () => {
|
||||
|
||||
@@ -19,13 +19,15 @@ export const getSongUrl = async (id: any, songData: any, isDownloaded: boolean =
|
||||
|
||||
const { data } = await getMusicUrl(id, !unlimitedDownload);
|
||||
let url = '';
|
||||
let songDetail = null;
|
||||
let songDetail: any = null;
|
||||
|
||||
try {
|
||||
if (data.data[0].freeTrialInfo || !data.data[0].url) {
|
||||
const res = await getParsingMusicUrl(id, cloneDeep(songData));
|
||||
url = res.data.data.url;
|
||||
songDetail = res.data.data;
|
||||
if (res.data.data?.url) {
|
||||
url = res.data.data.url;
|
||||
songDetail = res.data.data;
|
||||
}
|
||||
} else {
|
||||
songDetail = data.data[0] as any;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user