diff --git a/src/components/PlayQueueItem.vue b/src/components/PlayQueueItem.vue index 46dafdb..c15bf70 100644 --- a/src/components/PlayQueueItem.vue +++ b/src/components/PlayQueueItem.vue @@ -18,6 +18,79 @@ const playQueueStore = usePlayQueueStore() const hover = ref(false) +function moveUp() { + if (props.index === 0) return + + playQueueStore.queueReplaceLock = true + const queue = [...playQueueStore.list] + + if (!playQueueStore.playMode.shuffle) { + // 非shuffle模式:直接交换位置 + const temp = queue[props.index] + queue[props.index] = queue[props.index - 1] + queue[props.index - 1] = temp + playQueueStore.list = queue + + // 更新currentIndex + if (props.index === playQueueStore.currentIndex) { + playQueueStore.currentIndex-- + } else if (props.index - 1 === playQueueStore.currentIndex) { + playQueueStore.currentIndex++ + } + } else { + // Shuffle模式:交换shuffle列表中的索引 + const shuffleList = [...playQueueStore.shuffleList] + const temp = shuffleList[props.index] + shuffleList[props.index] = shuffleList[props.index - 1] + shuffleList[props.index - 1] = temp + playQueueStore.shuffleList = shuffleList + + // 更新currentIndex + if (props.index === playQueueStore.currentIndex) { + playQueueStore.currentIndex-- + } else if (props.index - 1 === playQueueStore.currentIndex) { + playQueueStore.currentIndex++ + } + } +} + +function moveDown() { + const listLength = playQueueStore.playMode.shuffle ? playQueueStore.shuffleList.length : playQueueStore.list.length + if (props.index === listLength - 1) return + + playQueueStore.queueReplaceLock = true + const queue = [...playQueueStore.list] + + if (!playQueueStore.playMode.shuffle) { + // 非shuffle模式:直接交换位置 + const temp = queue[props.index] + queue[props.index] = queue[props.index + 1] + queue[props.index + 1] = temp + playQueueStore.list = queue + + // 更新currentIndex + if (props.index === playQueueStore.currentIndex) { + playQueueStore.currentIndex++ + } else if (props.index + 1 === playQueueStore.currentIndex) { + playQueueStore.currentIndex-- + } + } else { + // Shuffle模式:交换shuffle列表中的索引 + const shuffleList = [...playQueueStore.shuffleList] + const temp = shuffleList[props.index] + shuffleList[props.index] = shuffleList[props.index + 1] + shuffleList[props.index + 1] = temp + playQueueStore.shuffleList = shuffleList + + // 更新currentIndex + if (props.index === playQueueStore.currentIndex) { + playQueueStore.currentIndex++ + } else if (props.index + 1 === playQueueStore.currentIndex) { + playQueueStore.currentIndex-- + } + } +} + function removeItem() { playQueueStore.queueReplaceLock = true @@ -103,13 +176,15 @@ function removeItem() {