diff --git a/src/main.ts b/src/main.ts
index 3face27..7a5c2c1 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -1,6 +1,8 @@
import { createApp } from 'vue'
import { createWebHashHistory, createRouter } from 'vue-router'
import './style.css'
+import { createPinia } from 'pinia'
+
import App from './App.vue'
import HomePage from './pages/Home.vue'
import AlbumDetailView from './pages/AlbumDetail.vue'
@@ -15,4 +17,7 @@ const router = createRouter({
routes
})
-; createApp(App).use(router).mount('#app')
+const pinia = createPinia()
+
+createApp(App).use(router).use(pinia).mount('#app')
+
diff --git a/src/pages/AlbumDetail.vue b/src/pages/AlbumDetail.vue
index 1fdcfb8..7a07e19 100644
--- a/src/pages/AlbumDetail.vue
+++ b/src/pages/AlbumDetail.vue
@@ -2,17 +2,19 @@
import { ref, onMounted } from 'vue'
import apis from '../apis'
import { useRoute } from 'vue-router'
+import { usePlayQueueStore } from '../stores/usePlayQueueStore'
const album = ref
()
const route = useRoute()
const albumId = route.params.albumId
+const playQueue = usePlayQueueStore()
+
onMounted(async () => {
try {
const res = await apis.getAlbum(albumId as string)
album.value = res
- console.log(res)
} catch (error) {
console.log(error)
}
@@ -24,6 +26,24 @@ function artistsOrganize(list: string[]) {
return artist
}).join(' / ')
}
+
+function playTheAlbum() {
+ if (playQueue.queueReplaceLock) {
+ if (!confirm("当前操作会将你的待播列表清空、放入这张专辑所有曲目,并从新待播清单的开头播放。继续吗?")) { return }
+ playQueue.queueReplaceLock = false
+ }
+
+ let newPlayQueue = []
+ for (const track of album.value?.songs ?? []) {
+ newPlayQueue.push({
+ song: track,
+ album: album.value
+ })
+ }
+ playQueue.list = newPlayQueue
+ playQueue.currentIndex = 0
+ playQueue.isPlaying = true
+}
@@ -46,7 +66,9 @@ function artistsOrganize(list: string[]) {