|
@@ -1,4 +1,4 @@
|
|
|
-import { computed, defineComponent, onBeforeMount, ref } from "vue"
|
|
|
+import { computed, defineComponent, onMounted, ref } from "vue"
|
|
|
import styles from "./index.module.less"
|
|
|
import state from "/src/state"
|
|
|
import { headTopData } from "/src/page-instrument/header-top"
|
|
@@ -57,12 +57,26 @@ export default defineComponent({
|
|
|
}, [])
|
|
|
}
|
|
|
initRhythmData()
|
|
|
+ onMounted(() => {
|
|
|
+ // 横屏的时候 当宽度大于屏幕的时候缩小一点
|
|
|
+ if (headTopData.rhythmModeDirection !== "vertical") {
|
|
|
+ const element = document.querySelector(".rhythmBox-scale-element") as HTMLElement | null
|
|
|
+ if (element) {
|
|
|
+ const screenWidth = document.documentElement.clientWidth
|
|
|
+ const originalWidth = element.offsetWidth
|
|
|
+ // 保留一位小数
|
|
|
+ const scale = screenWidth < originalWidth ? Math.floor((screenWidth / originalWidth) * 10) / 10 : 1
|
|
|
+ element.style.transform = `translate(-50%, -50%) scale(${scale})`
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
return () => {
|
|
|
return (
|
|
|
<>
|
|
|
<div class={[styles.rhythm, headTopData.rhythmModeDirection === "vertical" && styles.vertical]}>
|
|
|
- <div class={styles.titImg}></div>
|
|
|
- <div class={styles.rhythmBox}>
|
|
|
+ {headTopData.rhythmModeDirection === "vertical" && <div class={styles.titImg}></div>}
|
|
|
+ <div class={[styles.rhythmBox, "rhythmBox-scale-element"]}>
|
|
|
+ {headTopData.rhythmModeDirection !== "vertical" && <div class={styles.titImg}></div>}
|
|
|
{headTopData.rhythmModeDirection === "vertical" && (
|
|
|
<div
|
|
|
class={[styles.rhythmImg, styles[`rhythm${rhythmImgObj[actRhythmData.value[state.activeNoteIndex % 6].rhythmImg]}`]]}
|