优化next页面,删除无用代码

master
qier222 4 years ago
parent 6ce6f6b167
commit e11ad6bf46

@ -174,9 +174,9 @@ export default {
}, },
methods: { methods: {
...mapMutations([ ...mapMutations([
"updateShuffleStatus",
"updatePlayerList", "updatePlayerList",
"turnOnShuffleMode", "turnOnShuffleMode",
"turnOffShuffleMode",
"updatePlayerState", "updatePlayerState",
"updateRepeatStatus", "updateRepeatStatus",
"updateLikedSongs", "updateLikedSongs",
@ -211,8 +211,7 @@ export default {
}, },
shuffle() { shuffle() {
if (this.player.shuffle === true) { if (this.player.shuffle === true) {
this.updateShuffleStatus(false); this.turnOffShuffleMode();
this.updatePlayerList(this.player.notShuffledList);
} else { } else {
this.turnOnShuffleMode(); this.turnOnShuffleMode();
} }

@ -7,12 +7,6 @@ export default {
getTrackDetail(basicTrack.id).then((data) => { getTrackDetail(basicTrack.id).then((data) => {
let track = data.songs[0]; let track = data.songs[0];
track.sort = basicTrack.sort; track.sort = basicTrack.sort;
console.log(track);
if (track.playable === false) {
dispatch("nextTrack");
return;
}
let time = state.howler.seek(); let time = state.howler.seek();
scrobble({ scrobble({
@ -27,6 +21,11 @@ export default {
updateMediaSessionMetaData(track); updateMediaSessionMetaData(track);
document.title = `${track.name} · ${track.ar[0].name} - YesPlayMusic`; document.title = `${track.name} · ${track.ar[0].name} - YesPlayMusic`;
if (track.playable === false) {
dispatch("nextTrack");
return;
}
commit( commit(
"replaceMP3", "replaceMP3",
`https://music.163.com/song/media/outer/url?id=${track.id}` `https://music.163.com/song/media/outer/url?id=${track.id}`

@ -25,9 +25,6 @@ export default {
updateListInfo(state, info) { updateListInfo(state, info) {
state.player.listInfo = info; state.player.listInfo = info;
}, },
updateShuffleStatus(state, status) {
state.player.shuffle = status;
},
updateRepeatStatus(state, status) { updateRepeatStatus(state, status) {
state.player.repeat = status; state.player.repeat = status;
}, },
@ -66,13 +63,24 @@ export default {
return track; return track;
}); });
}, },
turnOffShuffleMode(state) {
state.player.shuffle = false;
state.player.list = JSON.parse(
JSON.stringify(state.player.notShuffledList)
);
state.player.currentTrack.sort = state.player.list.find(
(t) => t.id === state.player.currentTrack.id
).sort;
},
shuffleTheListBeforePlay(state) { shuffleTheListBeforePlay(state) {
state.player.notShuffledList = JSON.parse(
JSON.stringify(state.player.list)
);
let newSorts = shuffleAList(state.player.list); let newSorts = shuffleAList(state.player.list);
state.player.list = state.player.list.map((track) => { state.player.list = state.player.list.map((track) => {
track.sort = newSorts[track.id]; track.sort = newSorts[track.id];
return track; return track;
}); });
console.table(state.player.list);
}, },
updateUser(state, user) { updateUser(state, user) {
state.settings.user = user; state.settings.user = user;

@ -131,11 +131,7 @@ export default {
}, },
}, },
methods: { methods: {
...mapMutations([ ...mapMutations(["appendTrackToPlayerList"]),
"updatePlayerList",
"appendTrackToPlayerList",
"shuffleTheList",
]),
...mapActions(["playFirstTrackOnList", "playTrackOnListByID"]), ...mapActions(["playFirstTrackOnList", "playTrackOnListByID"]),
playAlbumByID(id, trackID = "first") { playAlbumByID(id, trackID = "first") {
if (this.tracks.find((t) => t.playable !== false) === undefined) { if (this.tracks.find((t) => t.playable !== false) === undefined) {

@ -140,11 +140,7 @@ export default {
}, },
}, },
methods: { methods: {
...mapMutations([ ...mapMutations(["appendTrackToPlayerList"]),
"updatePlayerList",
"appendTrackToPlayerList",
"shuffleTheList",
]),
...mapActions(["playFirstTrackOnList", "playTrackOnListByID"]), ...mapActions(["playFirstTrackOnList", "playTrackOnListByID"]),
loadData(id, next = undefined) { loadData(id, next = undefined) {
getArtist(id).then((data) => { getArtist(id).then((data) => {

@ -29,7 +29,6 @@ export default {
data() { data() {
return { return {
tracks: [], tracks: [],
showTracks: [],
}; };
}, },
computed: { computed: {
@ -37,6 +36,9 @@ export default {
currentTrack() { currentTrack() {
return this.player.currentTrack; return this.player.currentTrack;
}, },
playerShuffle() {
return this.player.shuffle;
},
sortedTracks() { sortedTracks() {
function compare(property) { function compare(property) {
return function(obj1, obj2) { return function(obj1, obj2) {
@ -45,16 +47,21 @@ export default {
return value1 - value2; return value1 - value2;
}; };
} }
let tracks = this.tracks return this.tracks
.filter((t) => t.sort > this.player.currentTrack.sort) .filter((t) => t.sort > this.player.currentTrack.sort)
.sort(compare("sort")); .sort(compare("sort"));
return tracks;
}, },
}, },
watch: { watch: {
currentTrack() { currentTrack() {
this.loadTracks(); this.loadTracks();
}, },
playerShuffle() {
this.tracks = this.tracks.map((t) => {
t.sort = this.player.list.find((t2) => t.id === t2.id).sort;
return t;
});
},
}, },
methods: { methods: {
...mapActions(["playTrackOnListByID"]), ...mapActions(["playTrackOnListByID"]),
@ -97,101 +104,4 @@ h1 {
margin-bottom: 18px; margin-bottom: 18px;
cursor: default; cursor: default;
} }
.track-list {
user-select: none;
.track {
display: flex;
align-items: center;
padding: 8px;
border-radius: 12px;
img {
border-radius: 8px;
height: 56px;
margin-right: 20px;
}
.title-and-artist {
flex: 1;
display: flex;
.container {
display: flex;
flex-direction: column;
}
.title {
font-size: 18px;
font-weight: 600;
color: rgba(0, 0, 0, 0.88);
cursor: default;
}
.artist {
margin-top: 2px;
font-size: 13px;
color: rgba(0, 0, 0, 0.68);
a {
span {
margin-right: 3px;
color: rgba(0, 0, 0, 0.8);
}
&:hover {
text-decoration: underline;
cursor: pointer;
}
}
}
}
.album {
flex: 1;
display: flex;
.container {
display: flex;
flex-direction: column;
&:hover {
text-decoration: underline;
cursor: pointer;
}
}
font-size: 16px;
color: rgba(0, 0, 0, 0.88);
}
.time {
font-size: 16px;
width: 50px;
cursor: default;
display: flex;
justify-content: flex-end;
margin-right: 10px;
font-variant-numeric: tabular-nums;
}
&:hover {
transition: all 0.3s;
background: #f5f5f7;
}
}
.track.playing {
background: #eaeffd;
.title,
.time,
.album {
color: #335eea;
}
.artist {
color: rgba(51, 94, 234, 0.88);
}
}
.track.disable {
img {
filter: grayscale(1) opacity(0.6);
}
.title,
.artist,
.time,
.album {
color: rgba(0, 0, 0, 0.28);
}
&:hover {
background: none;
}
}
}
</style> </style>

Loading…
Cancel
Save