chore: change store data

This commit is contained in:
zyronon
2023-09-19 12:35:03 +08:00
parent b82fffc883
commit cbbb760eac
17 changed files with 1308 additions and 2315 deletions

42
src/hooks/sound.ts Normal file
View File

@@ -0,0 +1,42 @@
import {onMounted} from "vue"
import {useBaseStore} from "@/stores/base.ts";
export function useSound(srcList?: string[], num?: number) {
let audioList: HTMLAudioElement[] = $ref([])
let audioLength = $ref(1)
const setAudio = (srcList2: string[], num2?: number) => {
if (num2) audioLength = num2
audioList = []
for (let i = 0; i < audioLength; i++) {
srcList2.map(src => {
audioList.push(new Audio(src))
})
}
index = 0
}
onMounted(() => {
if (srcList) setAudio(srcList, num)
})
let index = $ref(0)
const play: Function = () => {
index++
if (audioList.length > 1 && audioList.length !== audioLength) {
audioList[index % audioList.length].play()
} else {
audioList[index % audioLength].play()
}
}
return [
play,
setAudio
]
}
export function playKeyboardSound() {
const store = useBaseStore()
}