@@ -899,4 +896,4 @@ watch(() => playQueueStore.currentIndex, () => {
opacity: 1;
transform: translateY(0) scale(1);
}
-
\ No newline at end of file
+
diff --git a/src/stores/usePlayQueueStore.ts b/src/stores/usePlayQueueStore.ts
index d00ea87..8723d3a 100644
--- a/src/stores/usePlayQueueStore.ts
+++ b/src/stores/usePlayQueueStore.ts
@@ -1,217 +1,154 @@
import { defineStore } from 'pinia'
-import { computed, ref } from 'vue'
-import { checkAndRefreshSongResource } from '../utils'
+import { ref, computed } from 'vue'
+import apis from '../apis'
export const usePlayQueueStore = defineStore('queue', () => {
- const list = ref
([])
- const currentIndex = ref(0)
- const isPlaying = ref(false)
+ // 内部状态
+ const queue = ref([])
+ const isShuffle = ref(false)
+ const loopingMode = ref<'single' | 'all' | 'off'>('off')
const queueReplaceLock = ref(false)
- const isBuffering = ref(false)
- const currentTime = ref(0)
- const duration = ref(0)
- const updatedCurrentTime = ref(null)
- const visualizer = ref([0, 0, 0, 0, 0, 0])
- const shuffleList = ref([])
- const playMode = ref<{
- shuffle: boolean
- repeat: 'off' | 'single' | 'all'
- }>({
- shuffle: false,
- repeat: 'off',
+ const currentPlaying = ref(0) // 当前播放指针,指针在 queueOrder 中寻址(无论是否开启了随机播放)
+ const queueOrder = ref([]) // 播放队列顺序
+
+ // 暴露给外部的响应式只读引用
+ const queueState = computed(() =>
+ // 按 queueOrder 的顺序排序输出队列
+ queueOrder.value.map(index => queue.value[index]).filter(Boolean)
+ )
+ const shuffleState = computed(() => isShuffle.value)
+ const loopModeState = computed(() => loopingMode.value)
+
+ // 获取当前播放项
+ const currentTrack = computed(() => {
+ const actualIndex = queueOrder.value[currentPlaying.value]
+ return queue.value[actualIndex] || null
})
- const shuffleCurrent = ref(undefined)
-
- // 预加载相关状态
- const preloadedAudio = ref