From ea733cad0459e58ad5bc11c7a61d12a72b8c2fef Mon Sep 17 00:00:00 2001 From: QiuLiang-99 <1297829693@qq.com> Date: Fri, 2 May 2025 23:43:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E4=BA=86=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E7=9A=84=E9=80=BB=E8=BE=91=E5=A4=84=E7=90=86=EF=BC=8C=E4=BD=86?= =?UTF-8?q?=E5=8F=AA=E6=8E=A5=E7=AE=A1=E4=BA=86=E2=80=9C=E6=88=91=E7=9A=84?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E2=80=9D=E7=9A=84=E6=92=AD=E6=94=BE=E8=A1=8C?= =?UTF-8?q?=E4=B8=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layout/PlayListWindow/index.vue | 34 ------------------- src/renderer/core/player/action.ts | 9 ++--- src/renderer/store/player/action.ts | 3 +- src/renderer/store/player/state.ts | 2 +- src/renderer/views/List/MusicList/usePlay.js | 33 +++++++----------- 5 files changed, 20 insertions(+), 61 deletions(-) diff --git a/src/renderer/components/layout/PlayListWindow/index.vue b/src/renderer/components/layout/PlayListWindow/index.vue index 60adbdf0..c5279694 100644 --- a/src/renderer/components/layout/PlayListWindow/index.vue +++ b/src/renderer/components/layout/PlayListWindow/index.vue @@ -33,41 +33,7 @@ const songs = computed(() => album: music.musicInfo.meta.albumName, })), ) -// const showPlaylist = () => { -// if (tempPlayList.length) { // 如果稍后播放列表存在歌曲则直接播放改列表的歌曲 -// for (let music of tempPlayList) { -// songs.value.push( -// { -// title: music.musicInfo.name, -// artist: music.musicInfo.singer, -// album: music.musicInfo.meta.albumName, -// }, -// ) -// } -// return -// } -// if (playMusicInfo.musicInfo == null) { -// handleToggleStop() -// console.log('musicInfo empty') -// return -// } - -// // console.log(playInfo.playerListId) -// const currentListId = playInfo.playerListId -// if (!currentListId) { -// handleToggleStop() -// console.log('currentListId empty') -// return -// } -// // const currentList = getList(currentListId) -// // songs.value.push({ -// // title: music.musicInfo.name, -// // artist: music.musicInfo.singer, -// // album: music.musicInfo.meta.albumName, -// // }) -// } -// showPlaylist() const emitClose = () => { emit('close') } diff --git a/src/renderer/core/player/action.ts b/src/renderer/core/player/action.ts index d29d243c..0649ee68 100644 --- a/src/renderer/core/player/action.ts +++ b/src/renderer/core/player/action.ts @@ -1,5 +1,5 @@ import { isEmpty, setPause, setPlay, setResource, setStop } from '@renderer/plugins/player' -import { isPlay, playedList, playInfo, playMusicInfo, tempPlayList, musicInfo as _musicInfo } from '@renderer/store/player/state' +import { isPlay, playedList, playInfo, playMusicInfo, tempPlayList, musicInfo as _musicInfo, currentPlayIndex } from '@renderer/store/player/state' import { getList, clearPlayedList, @@ -376,14 +376,15 @@ const handlePlayNext = (playMusicInfo: LX.Player.PlayMusicInfo) => { */ export const playNext = async(isAutoToggle = false): Promise => { console.log('skip next', isAutoToggle) + //todo 需要修改逻辑,不要删除 if (tempPlayList.length) { // 如果稍后播放列表存在歌曲则直接播放改列表的歌曲 - const playMusicInfo = tempPlayList[0] - removeTempPlayList(0) + const playMusicInfo = tempPlayList[++(currentPlayIndex.value) ] + // removeTempPlayList(0) handlePlayNext(playMusicInfo) console.log('play temp list') return } - + ////////////预计此处往下的代码失去作用(被接管)///////////// if (playMusicInfo.musicInfo == null) { handleToggleStop() console.log('musicInfo empty') diff --git a/src/renderer/store/player/action.ts b/src/renderer/store/player/action.ts index be4343df..d578e80a 100644 --- a/src/renderer/store/player/action.ts +++ b/src/renderer/store/player/action.ts @@ -241,7 +241,8 @@ export const addTempPlayList = (list: LX.Player.TempPlayListItem[]) => { if (topList.length) arrUnshift(tempPlayList, topList.map(({ musicInfo, listId }) => ({ musicInfo, listId, isTempPlay: true }))) if (bottomList.length) arrPush(tempPlayList, bottomList.map(({ musicInfo, listId }) => ({ musicInfo, listId, isTempPlay: true }))) - if (!playMusicInfo.musicInfo) void playNext() + // if (!playMusicInfo.musicInfo) void playNext() + // 造成了奇怪的bug } /** * 从稍后播放列表移除歌曲 diff --git a/src/renderer/store/player/state.ts b/src/renderer/store/player/state.ts index e75bd7e4..518a08b9 100644 --- a/src/renderer/store/player/state.ts +++ b/src/renderer/store/player/state.ts @@ -71,7 +71,7 @@ export const playedList = window.lxData.playedList = shallowReactive([])//todo -export const PlayList = shallowReactive([]) +export const currentPlayIndex = ref(0) window.lxData.playInfo = playInfo diff --git a/src/renderer/views/List/MusicList/usePlay.js b/src/renderer/views/List/MusicList/usePlay.js index 5cf9f768..dae75e90 100644 --- a/src/renderer/views/List/MusicList/usePlay.js +++ b/src/renderer/views/List/MusicList/usePlay.js @@ -1,11 +1,6 @@ -import { addTempPlayList } from '@renderer/store/player/action' -import { playList } from '@renderer/core/player' -// import { tempPlayList } from '@renderer/store/player/state' - -import useMusicAdd from '@renderer/views/List/MusicList/useMusicAdd' -import { LIST_IDS } from '@common/constants' -import { getList } from '@renderer/store/player/action' - +import { addTempPlayList, clearTempPlayeList, getList } from '@renderer/store/player/action' +import { tempPlayList, currentPlayIndex } from '@renderer/store/player/state' +import { playNext } from '@renderer/core/player' // setup 函数或组件初始化中 @@ -13,25 +8,21 @@ export default ({ props, selectedList, list, removeAllSelect }) => { let clickTime = 0 let clickIndex = -1 - // 处理添加音乐到歌单的逻辑 - const { - // handleShowMusicAddModal, - // handleShowMusicMoveModal, - } = useMusicAdd({ selectedList, list }) - const handlePlayMusic = (index) => { + currentPlayIndex.value = index + // todo 播放选中的歌曲 // todo 修改播放歌曲逻辑 // playList(props.listId, index) // handlePlayMusicLater(index, true) - // todo 若为空,则添加整个歌单 // todo 歌单本身就有乱序排序功能 - addTempPlayList([{ listId: props.listId, musicInfo: list.value[index] }]) - // playList(LIST_IDS.TEMP, index) - // const testlist =getList(props.listId) - const testlist =getList(LIST_IDS.TEMP) - for (let i=0; i 0 ) {// 双击操作会切换到当前歌单 + clearTempPlayeList() } + const currentchooselist = getList(props.listId) + for(let music of currentchooselist) { + addTempPlayList([{ listId: props.listId, musicInfo: music }]) + } + playNext() } const handlePlayMusicLater = (index, single) => {