Commit 31e30662 authored by 毛线's avatar 毛线

声音设置

parent 6665bceb
......@@ -6,7 +6,7 @@
<script>
import { mapState, } from 'vuex'
import { mapState, mapMutations, } from 'vuex'
export default {
data() {
const bgAudio = new Audio()
......@@ -54,6 +54,11 @@ export default {
volumeMachine() {},
volumeBg(value) {
this.bgAudio.volume = value / 100
if (value === 0) {
this.SetMute(true)
} else {
this.SetMute(false)
}
},
volumeButton(value) {
this.uiClickAudio.volume = value / 100
......@@ -63,6 +68,9 @@ export default {
this.init()
},
methods: {
...mapMutations('audio', [
'SetMute', // 设置静音状态
]),
init() {
console.log('初始化音频')
this.bgAudio.src = 'https://kuawai.s3.ap-east-1.amazonaws.com/resource/assets/sound/Innovation.mp3' // 背景音乐
......@@ -76,10 +84,16 @@ export default {
if (mute) { // 如果静音
return
}
if (this.volumeBg === 0) {
return
}
this.bgAudio.play()
},
// ui点击音效
playClickAudio() {
if (this.volumeButton === 0) {
return
}
this.uiClickAudio.currentTime = 0
this.uiClickAudio.play()
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment