-
+
+ {{changePlayModeText}}
+
+
+
+
已更新歌单
-
+
+
+
+
+
@@ -109,12 +133,13 @@ import { mapState, mapMutations, mapGetters, mapActions } from "@/store/helper/m
import ProgressBar from "@/base/progress-bar"
import Volume from '@/base/volume'
import Storage from 'good-storage'
-import { VOLUME_KEY } from '@/utils/config'
+import { VOLUME_KEY, playModeMap } from '@/utils'
export default {
data() {
return {
songReady: false,
+ isPlayModePromptShow: false,
volume: Storage.get(VOLUME_KEY, 1),
}
},
@@ -165,6 +190,24 @@ export default {
this.audio.volume = percent
Storage.set(VOLUME_KEY, percent)
},
+ onChangePlayMode() {
+ const modeKeys = Object.keys(playModeMap)
+ const currentModeIndex = modeKeys.findIndex(key => playModeMap[key].code === this.playMode)
+ const nextIndex = (currentModeIndex + 1) % modeKeys.length
+ const nextModeKey = modeKeys[nextIndex]
+ const nextMode = playModeMap[nextModeKey]
+ this.setPlayMode(nextMode.code)
+ this.showPlayModePrompt()
+ },
+ showPlayModePrompt() {
+ this.isPlayModePromptShow = true
+ if (this.playModePromptTimer) {
+ clearTimeout(this.playModePromptTimer)
+ }
+ this.playModePromptTimer = setTimeout(() => {
+ this.isPlayModePromptShow = false
+ }, 1000);
+ },
togglePlaylistShow() {
this.setPlaylistShow(!this.isPlaylistShow)
},
@@ -174,7 +217,7 @@ export default {
goGitHub() {
window.open('https://github.com/sl1673495/vue-netease-music')
},
- ...mapMutations(["setCurrentTime", "setPlayingState", "setPlaylistShow", "setPlayerShow"]),
+ ...mapMutations(["setCurrentTime", "setPlayingState", "setPlayMode", "setPlaylistShow", "setPlayerShow"]),
...mapActions(["startSong"])
},
watch: {
@@ -215,6 +258,15 @@ export default {
playIcon() {
return this.playing ? "pause" : "play"
},
+ currentMode() {
+ return playModeMap[this.playMode]
+ },
+ modeIcon() {
+ return this.currentMode.icon
+ },
+ changePlayModeText() {
+ return `切换播放模式:${this.currentMode.name}`
+ },
audio() {
return this.$refs.audio
},
@@ -226,7 +278,7 @@ export default {
playControlIcon() {
return this.isPlayerShow ? 'shrink' : 'open'
},
- ...mapState(["currentSong", "currentTime", "playing", "isPlaylistShow", "isPlaylistPromptShow", "isPlayerShow"]),
+ ...mapState(["currentSong", "currentTime", "playing", "playMode", "isPlaylistShow", "isPlaylistPromptShow", "isPlayerShow"]),
...mapGetters(["prevSong", "nextSong"])
},
components: {
@@ -355,7 +407,7 @@ export default {
justify-content: flex-end;
flex: 6;
- .icon {
+ .mode-item {
margin-right: 16px;
}
}
diff --git a/src/components/player.vue b/src/components/player.vue
index 27f2026..1ab9371 100644
--- a/src/components/player.vue
+++ b/src/components/player.vue
@@ -17,13 +17,13 @@
src="@/assets/image/play-bar.png"
/>
@@ -32,9 +32,7 @@
-
- {{currentSong.name}}
-
+
{{currentSong.name}}
歌手:
@@ -44,33 +42,28 @@
- 还没有歌词哦~
-
+ >还没有歌词哦~
-
- {{content}}
-
+ v-for="(content, contentIndex) in l.contents"
+ >{{content}}
@@ -79,8 +72,8 @@
-
- 包含这首歌的歌单
-
+
包含这首歌的歌单
{{$utils.formatNumber(simiPlaylist.playCount)}}
@@ -122,16 +113,14 @@
class="simi-songs"
v-if="simiSongs.length"
>
-
- 相似歌曲
-
+ 相似歌曲
@@ -144,7 +133,6 @@
-