diff --git a/src/common/config.js b/src/common/config.js index 6d9d1fb16a7e8858ffa48e5798cf01b325c22f30..13e86fcba702a9b4eb03865068692ea39bd290ca 100644 --- a/src/common/config.js +++ b/src/common/config.js @@ -1,17 +1,17 @@ export const playModeMap = { sequence: { code: "sequence", - icon: "sequence", - name: "顺序播放" + icon: "icn-loop", + name: "循环播放" }, loop: { code: "loop", - icon: "loop", - name: "循环播放" + icon: "icn-one", + name: "单曲循环" }, random: { code: "random", - icon: "random", + icon: "icn-shuffle", name: "随机播放" } }; diff --git a/src/components/common/Player.vue b/src/components/common/Player.vue index e434a82cb046ba6ce9960efc89787ac02a18cd57..09c10247981a67237a8035ff0ecbf8d51237564b 100644 --- a/src/components/common/Player.vue +++ b/src/components/common/Player.vue @@ -61,8 +61,8 @@ -
-
+
+
@@ -93,11 +93,21 @@ >
-
@@ -140,19 +158,24 @@ @@ -600,9 +682,15 @@ i { margin: 11px 2px 0 0; text-indent: -9999px; } +.m-playbar .icn-add:hover { + background-position: -88px -189px; +} .m-playbar .icn-add { background-position: -88px -163px; } +.m-playbar .icn-share:hover { + background-position: -114px -189px; +} .m-playbar .icn-share { background-position: -114px -163px; } @@ -662,6 +750,9 @@ i { .m-playbar .icn-vol { background-position: -2px -248px; } +.m-playbar .icn-vol:hover { + background-position: -31px -248px; +} .m-playbar .icn { float: left; width: 25px; @@ -669,9 +760,24 @@ i { margin: 11px 2px 0 0; text-indent: -9999px; } +.m-playbar .icn-loop:hover { + background-position: -33px -344px; +} .m-playbar .icn-loop { background-position: -3px -344px; } +.m-playbar .icn-one:hover { + background-position: -93px -344px; +} +.m-playbar .icn-one { + background-position: -66px -344px; +} +.m-playbar .icn-shuffle:hover { + background-position: -93px -248px; +} +.m-playbar .icn-shuffle { + background-position: -66px -248px; +} .m-playbar .add { float: left; width: 59px; diff --git a/src/store/module/music/getters.js b/src/store/module/music/getters.js index c7f5a1bd2ea2069f3b2bf4ac803f5b85755af619..277d87502b1182dfe723658c85493cd3319eaa82 100644 --- a/src/store/module/music/getters.js +++ b/src/store/module/music/getters.js @@ -1,22 +1,23 @@ import { isDef } from "common/utils"; import { playModeMap } from "common/config"; +function getRandomIndex(playlist, currentIndex) { + // 防止无限循环 + if (playlist.length === 1) { + return currentIndex; + } + let index = Math.round(Math.random() * (playlist.length - 1)); + if (index === currentIndex) { + index = getRandomIndex(playlist, currentIndex); + } + return index; +} + export default { currentIndex(state) { const { currentSong, playlist } = state; return playlist.findIndex(({ id }) => id === currentSong.id); }, - getRandomIndex(playlist, currentIndex) { - // 防止无限循环 - if (playlist.length === 1) { - return currentIndex; - } - let index = Math.round(Math.random() * (playlist.length - 1)); - if (index === currentIndex) { - index = getRandomIndex(playlist, currentIndex); - } - return index; - }, nextSong(state, getters) { const { playlist, playMode } = state; const nextStratMap = {