🐞 fix: 修复播放历史不展示上下一首的问题

This commit is contained in:
alger
2024-01-02 11:08:02 +08:00
parent adb539fbde
commit ad5d5458f1
3 changed files with 6 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
<template>
<n-drawer :show="show" height="70vh" placement="bottom" :drawer-style="{ backgroundColor: 'transparent' }">
<n-drawer v-model:show="show" height="70vh" placement="bottom" :drawer-style="{ backgroundColor: 'transparent' }">
<div class="music-page">
<i class="iconfont icon-icon_error music-close" @click="close"></i>
<div class="music-title">{{ name }}</div>
@@ -19,7 +19,6 @@
<script setup lang="ts">
import { useStore } from 'vuex'
import { Playlist } from '@/type/listDetail';
import { setAnimationClass, setAnimationDelay } from "@/utils";
import SongItem from "@/components/common/SongItem.vue";
import PlayBottom from './common/PlayBottom.vue';

View File

@@ -46,7 +46,6 @@
import { useStore } from 'vuex'
import type { SongResult } from '@/type/music'
import { getImgUrl } from '@/utils'
import { useMusicHistory } from '@/hooks/MusicHistoryHook'
const props = withDefaults(defineProps<{
item: SongResult
@@ -68,15 +67,12 @@ const isPlaying = computed(() => {
const emits = defineEmits(['play'])
const musicHistory = useMusicHistory()
// 播放音乐 设置音乐详情 打开音乐底栏
const playMusicEvent = (item: any) => {
store.commit('setPlay', item)
store.commit('setIsPlay', true)
store.state.playListIndex = 0
emits('play', item)
musicHistory.addMusic(item)
}
</script>

View File

@@ -3,6 +3,7 @@ import { SongResult } from '@/type/music'
import { getMusicUrl, getParsingMusicUrl } from '@/api/music'
import homeRouter from '@/router/home'
import { getMusicProxyUrl } from '@/utils'
import { useMusicHistory } from '@/hooks/MusicHistoryHook'
interface State {
menus: any[]
@@ -30,6 +31,8 @@ const state: State = {
const windowData = window as any
const musicHistory = useMusicHistory()
const mutations = {
setMenus(state: State, menus: any[]) {
state.menus = menus
@@ -38,6 +41,7 @@ const mutations = {
state.playMusic = playMusic
state.playMusicUrl = await getSongUrl(playMusic.id)
state.play = true
musicHistory.addMusic(playMusic)
},
setIsPlay(state: State, isPlay: boolean) {
state.isPlay = isPlay
@@ -94,6 +98,7 @@ const updatePlayMusic = async (state: State) => {
state.playMusic = state.playList[state.playListIndex]
state.playMusicUrl = await getSongUrl(state.playMusic.id)
state.play = true
musicHistory.addMusic(state.playMusic)
}
const store = createStore({