feat: 修改音乐列表为页面,优化专辑和歌单详情加载逻辑,支持通过路由跳转展示音乐列表

This commit is contained in:
alger
2025-05-07 22:36:52 +08:00
parent 3ca7e9a271
commit e2527c3fb8
15 changed files with 1208 additions and 259 deletions
+1
View File
@@ -16,5 +16,6 @@ export * from './modules/player';
export * from './modules/search';
export * from './modules/settings';
export * from './modules/user';
export * from './modules/music';
export default pinia;
+45
View File
@@ -0,0 +1,45 @@
import { defineStore } from 'pinia';
interface MusicState {
currentMusicList: any[] | null;
currentMusicListName: string;
currentListInfo: any | null;
canRemoveSong: boolean;
}
export const useMusicStore = defineStore('music', {
state: (): MusicState => ({
currentMusicList: null,
currentMusicListName: '',
currentListInfo: null,
canRemoveSong: false
}),
actions: {
// 设置当前音乐列表
setCurrentMusicList(list: any[], name: string, listInfo: any = null, canRemove = false) {
this.currentMusicList = list;
this.currentMusicListName = name;
this.currentListInfo = listInfo;
this.canRemoveSong = canRemove;
},
// 清除当前音乐列表
clearCurrentMusicList() {
this.currentMusicList = null;
this.currentMusicListName = '';
this.currentListInfo = null;
this.canRemoveSong = false;
},
// 从列表中移除一首歌曲
removeSongFromList(id: number) {
if (!this.currentMusicList) return;
const index = this.currentMusicList.findIndex((song) => song.id === id);
if (index !== -1) {
this.currentMusicList.splice(index, 1);
}
}
}
});