90 lines
2.3 KiB
JavaScript
90 lines
2.3 KiB
JavaScript
import { defineStore } from 'pinia'
|
|
|
|
export const usePlayerStore = defineStore('player', {
|
|
state: () => ({
|
|
// 音乐播放状态
|
|
isMusicPlaying: false,
|
|
// 视频播放状态
|
|
isVideoPlaying: false,
|
|
// 鼓声播放状态
|
|
isDrumPlaying: false,
|
|
// webview打开状态
|
|
isWebviewOpening: false,
|
|
// 视频打开前的BGM状态
|
|
wasMusicPlayingBeforeVideo: false,
|
|
// 鼓声开始前的BGM状态
|
|
wasMusicPlayingBeforeDrum: false,
|
|
// webview打开前的BGM状态
|
|
wasMusicPlayingBeforeWebview: false
|
|
}),
|
|
|
|
getters: {
|
|
// 计算是否禁用BGM控制按钮
|
|
isBgmButtonDisabled: (state) => {
|
|
return state.isVideoPlaying || state.isDrumPlaying
|
|
}
|
|
},
|
|
|
|
actions: {
|
|
// 设置音乐播放状态
|
|
setMusicPlaying(status) {
|
|
this.isMusicPlaying = status
|
|
},
|
|
|
|
// 设置视频播放状态
|
|
setVideoPlaying(status) {
|
|
this.isVideoPlaying = status
|
|
},
|
|
|
|
// 设置鼓声播放状态
|
|
setDrumPlaying(status) {
|
|
this.isDrumPlaying = status
|
|
},
|
|
|
|
// 设置webview打开状态
|
|
setWebviewOpening(status) {
|
|
this.isWebviewOpening = status
|
|
},
|
|
|
|
// 保存视频打开前的BGM状态
|
|
saveMusicStateBeforeVideo() {
|
|
this.wasMusicPlayingBeforeVideo = this.isMusicPlaying
|
|
},
|
|
|
|
// 保存鼓声开始前的BGM状态
|
|
saveMusicStateBeforeDrum() {
|
|
this.wasMusicPlayingBeforeDrum = this.isMusicPlaying
|
|
},
|
|
|
|
// 保存webview打开前的BGM状态
|
|
saveMusicStateBeforeWebview() {
|
|
this.wasMusicPlayingBeforeWebview = this.isMusicPlaying
|
|
},
|
|
|
|
// 恢复视频关闭后的BGM状态
|
|
restoreMusicStateAfterVideo() {
|
|
return this.wasMusicPlayingBeforeVideo
|
|
},
|
|
|
|
// 恢复鼓声结束后的BGM状态
|
|
restoreMusicStateAfterDrum() {
|
|
return this.wasMusicPlayingBeforeDrum
|
|
},
|
|
|
|
// 恢复webview关闭后的BGM状态
|
|
restoreMusicStateAfterWebview() {
|
|
return this.wasMusicPlayingBeforeWebview
|
|
},
|
|
|
|
// 重置所有状态
|
|
resetState() {
|
|
this.isMusicPlaying = false
|
|
this.isVideoPlaying = false
|
|
this.isDrumPlaying = false
|
|
this.isWebviewOpening = false
|
|
this.wasMusicPlayingBeforeVideo = false
|
|
this.wasMusicPlayingBeforeDrum = false
|
|
this.wasMusicPlayingBeforeWebview = false
|
|
}
|
|
}
|
|
}) |