From 164db499bb97ab5a0e26c5767c27194b39a979ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=A3=E9=A1=B6?= Date: Sun, 31 Mar 2024 17:16:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0palyer=20store=20?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/player.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/stores/player.ts diff --git a/src/stores/player.ts b/src/stores/player.ts new file mode 100644 index 0000000..3daae18 --- /dev/null +++ b/src/stores/player.ts @@ -0,0 +1,17 @@ +import { defineStore } from 'pinia' +import { ref, computed } from 'vue' + +export const usePlayerStore = defineStore('playerStore', () => { + // 播放状态 + const playStatus = ref(false) + // 切换播放状态 + function togglePlay(state?: boolean) { + playStatus.value = state === undefined ? !playStatus.value : state + } + // 播放列表 + const playList = ref([]) + // 轨道数 + const trackCount = computed(() => playList.value.length) + + return { playStatus, togglePlay, playList, trackCount } +})