index.tsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. import { defineComponent, reactive, computed } from "vue";
  2. import styles from "./index.module.less"
  3. import { headImg } from "../image";
  4. import { headTopData } from "../index"
  5. import { Switch, showToast, Field, Popup, Slider } from "vant";
  6. import state, { refreshMusicSvg } from "/src/state"
  7. import { api_closeCamera, api_openCamera, api_savePicture } from "/src/helpers/communication";
  8. import { smoothAnimationState} from "/src/page-instrument/view-detail/smoothAnimation"
  9. import Recommendation from "../../custom-plugins/helper-model/recommendation";
  10. import { resetRenderMusicScore } from "/src/view/music-score";
  11. import ScreenModel from "../../custom-plugins/helper-model/screen-model";
  12. import { getQuery } from "/src/utils/queryString";
  13. export default defineComponent({
  14. name: "settting",
  15. setup() {
  16. const query = getQuery();
  17. const helperData = reactive({
  18. screenModelShow: false, // 投屏帮助
  19. recommendationShow: false, // 建议
  20. });
  21. // 加减评测频率
  22. const operateHz = (type: number) => {
  23. const minFrequency = state.baseFrequency - 10, maxFrequency = state.baseFrequency + 10
  24. let currentFrequency = state.setting.frequency
  25. if (type === 1) {
  26. if (currentFrequency - 1 < minFrequency) return showToast({ message: `最低标准音高${minFrequency}HZ` })
  27. currentFrequency = currentFrequency - 1
  28. } else {
  29. if (currentFrequency + 1 > maxFrequency) return showToast({ message: `最高标准音高${maxFrequency}HZ` })
  30. currentFrequency = currentFrequency + 1
  31. }
  32. state.setting.frequency = currentFrequency >= 0 ? currentFrequency : 0
  33. }
  34. const formatterTimeMs = (value: any) => value = String(Math.min(3000, value));
  35. const notationList = computed(() => {
  36. const list = state.enableNotation ? [{name:'五线谱',value:'staff'},{name:'首调',value:'firstTone'},{name:'固定谱',value:'fixedTone'}] : [{name:'首调',value:'firstTone'},{name:'固定谱',value:'fixedTone'}];
  37. return list;
  38. });
  39. return () => (
  40. <div class={[styles.settting, styles[state.modeType]]}>
  41. <div class={styles.head}>
  42. <img class={styles.headTit} src={headImg("settingName.png")} />
  43. <img class={styles.closeImg} src={headImg("closeImg.png")} onClick={()=>{ headTopData.settingMode = false }} />
  44. </div>
  45. <div class={styles.content}>
  46. <div class={styles.conBox}>
  47. {
  48. state.isShowFingering && state.fingeringInfo.name && ["practise", "follow"].includes(state.modeType) &&
  49. <div class={styles.cellBox}>
  50. <div class={styles.tit}>指法</div>
  51. <Switch v-model={state.setting.displayFingering}></Switch>
  52. </div>
  53. }
  54. {
  55. ["practise", "follow"].includes(state.modeType) &&
  56. <div class={styles.cellBox}>
  57. <div class={styles.tit}>循环播放</div>
  58. <Switch v-model={state.setting.repeatAutoPlay}></Switch>
  59. </div>
  60. }
  61. {
  62. state.isSingleLine && state.modeType === "practise" &&
  63. <div class={styles.cellBox}>
  64. <div class={styles.tit}>旋律线</div>
  65. <Switch v-model={smoothAnimationState.isShow.value}></Switch>
  66. </div>
  67. }
  68. {
  69. state.modeType === "evaluating" &&
  70. <>
  71. {
  72. !query.workRecord &&
  73. <div class={styles.cellBox}>
  74. <div class={styles.tit}>评测难度</div>
  75. <div class={styles.radioBox}>
  76. {
  77. [{name:'入门',value:"BEGINNER"},{name:'进阶',value:"ADVANCED"},{name:'大师',value:"PERFORMER"}].map(item=>{
  78. return <div class={ state.setting.evaluationDifficulty===item.value && styles.active } onClick={ ()=>{
  79. state.setting.evaluationDifficulty = item.value as any
  80. } }>{item.name}</div>
  81. })
  82. }
  83. </div>
  84. </div>
  85. }
  86. <div class={styles.cellBox}>
  87. <div class={styles.tit}>延迟检测</div>
  88. <Switch v-model={state.setting.soundEffect}></Switch>
  89. </div>
  90. <div class={[styles.cellBox, state.setting.camera && styles.isCamera]}>
  91. <div class={styles.tit}>摄像头</div>
  92. <Switch
  93. v-model={state.setting.camera}
  94. onChange={ async (value) => {
  95. if (value) {
  96. const res = await api_openCamera();
  97. // 没有授权
  98. if (res?.content?.reson) {
  99. state.setting.camera = false
  100. }
  101. } else {
  102. api_closeCamera();
  103. }
  104. }}
  105. ></Switch>
  106. </div>
  107. <div class={styles.cellBox} style={{ display: state.setting.camera ? "" : "none", paddingTop: 0 }}>
  108. <div class={styles.tit}>不透明度</div>
  109. <div class={styles.spendCon}>
  110. <div class={styles.sliderCon}>
  111. <Slider class={styles.slider} max={100} min={0} v-model={state.setting.cameraOpacity}>
  112. {{
  113. button: () =>
  114. <div class={styles.customButton}>
  115. <div class={styles.speedVal}>{ state.setting.cameraOpacity }</div>
  116. <div class={styles.speedBtn}></div>
  117. </div>
  118. }}
  119. </Slider>
  120. </div>
  121. </div>
  122. </div>
  123. <div class={styles.cellBox}>
  124. <div class={styles.tit}>标准音高</div>
  125. <div class={styles.frequency}>
  126. <img src={headImg("cutImg.png")} class={[styles.btn]} onClick={() => operateHz(1)} />
  127. <div class={styles.frequencyNum}>{state.setting.frequency}HZ</div>
  128. <img src={headImg("addImg.png")} class={[styles.btn]} onClick={() => operateHz(2)} />
  129. </div>
  130. </div>
  131. <div class={styles.cellBox}>
  132. <div class={styles.tit}>反应时间</div>
  133. <div class={styles.reactionTimeBox}>
  134. <Field class={styles.reactionTime} type="digit"
  135. placeholder="最大可输入3000毫秒"
  136. formatter={formatterTimeMs}
  137. input-align={'center'}
  138. v-model:modelValue={state.setting.reactionTimeMs} />
  139. <div class={styles.timeName}>毫秒</div>
  140. </div>
  141. </div>
  142. </>
  143. }
  144. {/** 练习模式才有单行/多行谱切换功能,跟练、评测只有单行谱模式 */}
  145. {
  146. state.modeType === 'practise' ?
  147. <div class={styles.cellBox}>
  148. <div class={styles.tit}>切换谱面</div>
  149. <div class={styles.radioBox}>
  150. {
  151. [{name:'单行谱',value:true},{name:'多行谱',value:false}].map(item=>{
  152. return <div class={ state.isSingleLine===item.value && styles.active } onClick={ ()=>{
  153. state.isSingleLine = item.value
  154. // resetRenderMusicScore(state.musicRenderType)
  155. headTopData.settingMode = false
  156. refreshMusicSvg();
  157. // musicScoreRef.value?.refreshMusicScore()
  158. } }>{item.name}</div>
  159. })
  160. }
  161. </div>
  162. </div> : null
  163. }
  164. {
  165. state.enableNotation || state.specialShowNotation ?
  166. <div class={styles.cellBox}>
  167. <div class={styles.tit}>转谱</div>
  168. <div class={styles.radioBox}>
  169. {
  170. notationList.value.map(item=>{
  171. return <div class={ state.musicRenderType===item.value && styles.active } onClick={ ()=>{
  172. state.musicRenderType = item.value as any
  173. // resetRenderMusicScore(state.musicRenderType)
  174. headTopData.settingMode = false
  175. refreshMusicSvg();
  176. } }>{item.name}</div>
  177. })
  178. }
  179. </div>
  180. </div> : null
  181. }
  182. <div class={styles.cellBtnBox}>
  183. <img src={headImg("tpbz.png")} onClick={() => (helperData.screenModelShow = true)} />
  184. <img src={headImg("yjfk.png")} onClick={() => (helperData.recommendationShow = true)} />
  185. </div>
  186. </div>
  187. </div>
  188. <Popup
  189. v-model:show={helperData.recommendationShow}
  190. class="popup-custom van-scale center-closeBtn recommenBoxClass_drag"
  191. transition="van-scale"
  192. teleport="body"
  193. overlay-style={{background:'rgba(0, 0, 0, 0.3)'}}
  194. >
  195. <Recommendation
  196. onClose={() => {
  197. helperData.recommendationShow = false;
  198. }}
  199. />
  200. </Popup>
  201. <Popup
  202. class={["popup-custom"]}
  203. v-model:show={helperData.screenModelShow}
  204. onClose={() => {
  205. helperData.screenModelShow = false;
  206. }}
  207. position="right"
  208. teleport="body"
  209. >
  210. <ScreenModel
  211. onClose={(open: Boolean) => {
  212. helperData.screenModelShow = false;
  213. }}
  214. />
  215. </Popup>
  216. </div>
  217. );
  218. },
  219. });