index.tsx 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. import { computed, defineComponent, onMounted, reactive, ref } from "vue";
  2. import styles from "./index.module.less";
  3. import iconBack from "./image/icon-back.svg";
  4. import Title from "./title";
  5. import state, { handleChangeSection, handleResetPlay, togglePlay } from "../../state";
  6. import { headImg } from "./image";
  7. import icons from "./image/headerTop.json";
  8. import { Badge, Circle, Popover } from "vant";
  9. import { metronomeData } from "../../helpers/metronome";
  10. import Speed from "./speed";
  11. import { evaluatingData, handleStartEvaluat } from "/src/view/evaluating";
  12. import { Popup } from "@varlet/ui";
  13. import Settting from "./settting";
  14. export const headData = reactive({
  15. speedShow: false,
  16. });
  17. export default defineComponent({
  18. name: "header-top",
  19. setup() {
  20. const headerData = reactive({
  21. settingMode: false,
  22. });
  23. const headRef = ref();
  24. const toggleEvaluat = () => {
  25. handleStartEvaluat();
  26. };
  27. const disabledList = ["evaluating"];
  28. return () => (
  29. <div ref={headRef} class={styles.headerTop}>
  30. <div class={styles.back}>
  31. <img src={iconBack} />
  32. </div>
  33. <Title text={state.examSongName} />
  34. <div class={styles.headRight}>
  35. <div class={styles.btn} id="tips-step-2" onClick={toggleEvaluat}>
  36. <img class={styles.iconBtn} src={state.modeType === "evaluating" ? icons.evaluating2 : icons.evaluating} />
  37. <span>评测</span>
  38. </div>
  39. <div class={[styles.btn, disabledList.includes(state.modeType) && styles.disable]} id="tips-step-4" onClick={() => handleChangeSection()}>
  40. <img class={styles.iconBtn} src={headImg(`section${state.section.length}.svg`)} />
  41. {/* <Button class={styles.button} icon={Icons["section" + state.section.length]} color="#01C1B5" disabled={runtime.isFirstPlay || runtime.evaluatingStatus || isHomework} onClick={this.authBefore("excerpts", RuntimeUtils.sectionChange)} /> */}
  42. <span>选段</span>
  43. </div>
  44. <div class={[styles.btn, disabledList.includes(state.modeType) && styles.disable]} id="tips-step-5" onClick={() => togglePlay()}>
  45. <div class={styles.btnWrap}>
  46. <img style={{ marginTop: "-1px" }} class={styles.iconBtn} src={state.playState === "paused" ? icons.play : icons.pause} />
  47. <Circle class={styles.progress} stroke-width={80} currentRate={state.playProgress} rate={100} layerColor="#01C1B5" color="#FFC830" />
  48. </div>
  49. <span>{state.playState === "play" ? "暂停" : "播放"}</span>
  50. </div>
  51. <div
  52. class={[styles.btn, disabledList.includes(state.modeType) && styles.disable]}
  53. id="tips-step-6"
  54. onClick={() => {
  55. state.playSource = state.playSource === "music" ? "background" : "music";
  56. }}
  57. >
  58. <img class={styles.iconBtn} src={state.playSource === "music" ? icons.music : icons.background} />
  59. <span>{state.playSource === "music" ? "原声" : "伴奏"}</span>
  60. </div>
  61. <div
  62. class={[styles.btn]}
  63. onClick={async () => {
  64. metronomeData.lineShow = !metronomeData.lineShow;
  65. }}
  66. >
  67. <img class={styles.iconBtn} src={headImg("iconStep.png")} />
  68. <span>{metronomeData.lineShow ? "高级" : "初级"}</span>
  69. </div>
  70. <div
  71. class={styles.btn}
  72. onClick={async () => {
  73. metronomeData.disable = !metronomeData.disable;
  74. metronomeData.metro?.initPlayer();
  75. }}
  76. >
  77. <img style={{ display: metronomeData.disable ? "block" : "none" }} class={styles.iconBtn} src={headImg("tickoff.png")} />
  78. <img style={{ display: !metronomeData.disable ? "block" : "none" }} class={styles.iconBtn} src={headImg("tickon.png")} />
  79. <span style={{ whiteSpace: "nowrap" }}>节拍器</span>
  80. </div>
  81. <div class={[styles.btn, disabledList.includes(state.modeType) && styles.disable]} id="tips-step-7" onClick={() => handleResetPlay()}>
  82. <img class={styles.iconBtn} src={headImg("replay.svg")} />
  83. <span>重播</span>
  84. </div>
  85. <Popover trigger="manual" v-model:show={headData.speedShow} placement="bottom" overlay={false}>
  86. {{
  87. reference: () => (
  88. <div
  89. id="tips-step-8"
  90. class={[styles.btn, disabledList.includes(state.modeType) && styles.disable]}
  91. onClick={(e: Event) => {
  92. e.stopPropagation();
  93. headData.speedShow = !headData.speedShow;
  94. }}
  95. >
  96. <Badge class={styles.badge} content={state.speed}>
  97. <img class={styles.iconBtn} src={headImg("speed.svg")} />
  98. </Badge>
  99. <span>速度</span>
  100. </div>
  101. ),
  102. default: () => <Speed />,
  103. }}
  104. </Popover>
  105. <div class={[styles.btn, disabledList.includes(state.modeType) && styles.disable]} onClick={() => (headerData.settingMode = true)}>
  106. <img class={styles.iconBtn} src={headImg("menu.svg")} />
  107. <span>设置</span>
  108. </div>
  109. </div>
  110. <Popup teleport="body" defaultStyle={false} v-model:show={headerData.settingMode}>
  111. <Settting onClose={() => headerData.settingMode = false} />
  112. </Popup>
  113. </div>
  114. );
  115. },
  116. });