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

声音设置

parent 6665bceb
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<script> <script>
import { mapState, } from 'vuex' import { mapState, mapMutations, } from 'vuex'
export default { export default {
data() { data() {
const bgAudio = new Audio() const bgAudio = new Audio()
...@@ -54,6 +54,11 @@ export default { ...@@ -54,6 +54,11 @@ export default {
volumeMachine() {}, volumeMachine() {},
volumeBg(value) { volumeBg(value) {
this.bgAudio.volume = value / 100 this.bgAudio.volume = value / 100
if (value === 0) {
this.SetMute(true)
} else {
this.SetMute(false)
}
}, },
volumeButton(value) { volumeButton(value) {
this.uiClickAudio.volume = value / 100 this.uiClickAudio.volume = value / 100
...@@ -63,6 +68,9 @@ export default { ...@@ -63,6 +68,9 @@ export default {
this.init() this.init()
}, },
methods: { methods: {
...mapMutations('audio', [
'SetMute', // 设置静音状态
]),
init() { init() {
console.log('初始化音频') console.log('初始化音频')
this.bgAudio.src = 'https://kuawai.s3.ap-east-1.amazonaws.com/resource/assets/sound/Innovation.mp3' // 背景音乐 this.bgAudio.src = 'https://kuawai.s3.ap-east-1.amazonaws.com/resource/assets/sound/Innovation.mp3' // 背景音乐
...@@ -76,10 +84,16 @@ export default { ...@@ -76,10 +84,16 @@ export default {
if (mute) { // 如果静音 if (mute) { // 如果静音
return return
} }
if (this.volumeBg === 0) {
return
}
this.bgAudio.play() this.bgAudio.play()
}, },
// ui点击音效 // ui点击音效
playClickAudio() { playClickAudio() {
if (this.volumeButton === 0) {
return
}
this.uiClickAudio.currentTime = 0 this.uiClickAudio.currentTime = 0
this.uiClickAudio.play() 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