feat: 优化解析功能,添加缓存

This commit is contained in:
alger
2025-09-14 01:03:29 +08:00
parent 8f0728d9db
commit 659c9f9a4c
4 changed files with 654 additions and 192 deletions
+11 -5
View File
@@ -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 = () => {
+5 -3
View File
@@ -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;
}