|
@@ -1,64 +0,0 @@
|
|
|
-import { computed, defineComponent, onBeforeMount, ref } from "vue"
|
|
|
-import styles from "./index.module.less"
|
|
|
-import state from "/src/state"
|
|
|
-import { headTopData } from "/src/page-instrument/header-top"
|
|
|
-
|
|
|
-export default defineComponent({
|
|
|
- name: "rhythm",
|
|
|
- setup(props, { emit, expose }) {
|
|
|
- type rhythmData = {
|
|
|
- isDot: boolean
|
|
|
- denominator: number
|
|
|
- isRestFlag: boolean
|
|
|
- rhythmImg: string
|
|
|
- }
|
|
|
- const rhythmImgObj: Record<string, any> = {
|
|
|
- "1/1": "1",
|
|
|
- "1/2": "2",
|
|
|
- "1/4": "3",
|
|
|
- "1/8": "4",
|
|
|
- "1/16": "5",
|
|
|
- "1/32": "6",
|
|
|
- "1/1.": "1",
|
|
|
- "1/2.": "2",
|
|
|
- "1/4.": "3",
|
|
|
- "1/8.": "4",
|
|
|
- "1/16.": "5",
|
|
|
- "1/32.": "6",
|
|
|
- rest: "7"
|
|
|
- }
|
|
|
- const rhythmData = ref<rhythmData[]>([])
|
|
|
- const actRhythmData = computed<rhythmData[]>(() => {
|
|
|
- return rhythmData.value.slice(state.activeNoteIndex, state.activeNoteIndex + 7)
|
|
|
- })
|
|
|
- function initRhythmData() {
|
|
|
- rhythmData.value = state.times.map(item => {
|
|
|
- const noteElement = item.noteElement
|
|
|
- const isDot = !!noteElement?.DotsXml
|
|
|
- const denominator = noteElement?.typeLength?.denominator || 4
|
|
|
- const isRestFlag = !!noteElement?.isRestFlag
|
|
|
- return {
|
|
|
- isDot,
|
|
|
- denominator,
|
|
|
- isRestFlag,
|
|
|
- rhythmImg: isRestFlag ? "rest" : `1/${denominator}${isDot ? "." : ""}`
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- initRhythmData()
|
|
|
- return () => {
|
|
|
- return (
|
|
|
- <>
|
|
|
- <div class={[styles.rhythm, headTopData.rhythmModeDirection === "vertical" && styles.vertical]}>
|
|
|
- <div class={styles.titImg}></div>
|
|
|
- <div class={styles.rhythmBox}>
|
|
|
- {actRhythmData.value.map(item => {
|
|
|
- return <div class={[styles.rhythmImg, styles[`rhythm${rhythmImgObj[item.rhythmImg]}`]]}></div>
|
|
|
- })}
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </>
|
|
|
- )
|
|
|
- }
|
|
|
- }
|
|
|
-})
|