Skip to content

Commit 69b1e54

Browse files
committed
✨ feat: 在收藏列表中添加歌曲点赞功能
1 parent 35b84f3 commit 69b1e54

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/renderer/store/modules/player.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { computed, ref } from 'vue';
44

55
import i18n from '@/../i18n/renderer';
66
import { getBilibiliAudioUrl } from '@/api/bilibili';
7-
import { getLikedList, getMusicLrc, getMusicUrl, getParsingMusicUrl } from '@/api/music';
7+
import { getLikedList, getMusicLrc, getMusicUrl, getParsingMusicUrl, likeSong } from '@/api/music';
88
import { useMusicHistory } from '@/hooks/MusicHistoryHook';
99
import { audioService } from '@/services/audioService';
1010
import type { ILyric, ILyricText, SongResult } from '@/type/music';
@@ -984,6 +984,7 @@ export const usePlayerStore = defineStore('player', () => {
984984
if (!isAlreadyInList) {
985985
favoriteList.value.push(id);
986986
localStorage.setItem('favoriteList', JSON.stringify(favoriteList.value));
987+
typeof id === 'number' && likeSong(id, true);
987988
}
988989
};
989990

@@ -993,6 +994,7 @@ export const usePlayerStore = defineStore('player', () => {
993994
favoriteList.value = favoriteList.value.filter(existingId => !isBilibiliIdMatch(existingId, id));
994995
} else {
995996
favoriteList.value = favoriteList.value.filter(existingId => existingId !== id);
997+
likeSong(Number(id), false);
996998
}
997999
localStorage.setItem('favoriteList', JSON.stringify(favoriteList.value));
9981000
};

0 commit comments

Comments
 (0)