index.tsx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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) && state.playType === "play" &&
  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" && !state.isCombineRender && !state.isPercussion &&
  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 class={styles.titbtn} onClick={() => state.setting.soundEffect = true}>重新检测</div>
  90. </div>
  91. <div class={[styles.cellBox, state.setting.camera && styles.isCamera]}>
  92. <div class={styles.tit}>摄像头</div>
  93. <Switch
  94. v-model={state.setting.camera}
  95. onChange={ async (value) => {
  96. if (value) {
  97. const res = await api_openCamera();
  98. // 没有授权
  99. if (res?.content?.reson) {
  100. state.setting.camera = false
  101. }
  102. } else {
  103. api_closeCamera();
  104. }
  105. }}
  106. ></Switch>
  107. </div>
  108. <div class={styles.cellBox} style={{ display: state.setting.camera ? "" : "none", paddingTop: 0 }}>
  109. <div class={styles.tit}>不透明度</div>
  110. <div class={styles.spendCon}>
  111. <div class={styles.sliderCon}>
  112. <Slider class={styles.slider} max={100} min={0} v-model={state.setting.cameraOpacity}>
  113. {{
  114. button: () =>
  115. <div class={styles.customButton}>
  116. <div class={styles.speedVal}>{ state.setting.cameraOpacity }</div>
  117. <div class={styles.speedBtn}></div>
  118. </div>
  119. }}
  120. </Slider>
  121. </div>
  122. </div>
  123. </div>
  124. <div class={styles.cellBox}>
  125. <div class={styles.tit}>标准音高</div>
  126. <div class={styles.frequency}>
  127. <img src={headImg("cutImg.png")} class={[styles.btn]} onClick={() => operateHz(1)} />
  128. <div class={styles.frequencyNum}>{state.setting.frequency}HZ</div>
  129. <img src={headImg("addImg.png")} class={[styles.btn]} onClick={() => operateHz(2)} />
  130. </div>
  131. </div>
  132. <div class={styles.cellBox}>
  133. <div class={styles.tit}>反应时间</div>
  134. <div class={styles.reactionTimeBox}>
  135. <Field class={styles.reactionTime} type="digit"
  136. placeholder="最大可输入3000毫秒"
  137. formatter={formatterTimeMs}
  138. input-align={'center'}
  139. v-model:modelValue={state.setting.reactionTimeMs} />
  140. <div class={styles.timeName}>毫秒</div>
  141. </div>
  142. </div>
  143. </>
  144. }
  145. {/** 练习模式才有单行/多行谱切换功能,跟练、评测只有单行谱模式 */}
  146. {
  147. state.modeType === 'practise' ?
  148. <div class={styles.cellBox}>
  149. <div class={styles.tit}>切换谱面</div>
  150. <div class={styles.radioBox}>
  151. {
  152. [{name:'单行谱',value:true},{name:'多行谱',value:false}].map(item=>{
  153. return <div class={ state.isSingleLine===item.value && styles.active } onClick={ ()=>{
  154. if(state.isSingleLine === item.value){
  155. return
  156. }
  157. headTopData.settingMode = false
  158. state.isSingleLine = item.value
  159. // resetRenderMusicScore(state.musicRenderType)
  160. const _time = setTimeout(() => {
  161. clearTimeout(_time)
  162. refreshMusicSvg();
  163. }, 100);
  164. // musicScoreRef.value?.refreshMusicScore()
  165. } }>{item.name}</div>
  166. })
  167. }
  168. </div>
  169. </div> : null
  170. }
  171. {
  172. state.enableNotation || state.specialShowNotation ?
  173. <div class={styles.cellBox}>
  174. <div class={styles.tit}>转谱</div>
  175. <div class={styles.radioBox}>
  176. {
  177. notationList.value.map(item=>{
  178. return <div class={ state.musicRenderType===item.value && styles.active } onClick={ ()=>{
  179. if(state.musicRenderType === item.value){
  180. return
  181. }
  182. headTopData.settingMode = false
  183. state.musicRenderType = item.value as any
  184. // resetRenderMusicScore(state.musicRenderType)
  185. const _time = setTimeout(() => {
  186. clearTimeout(_time)
  187. refreshMusicSvg();
  188. }, 100);
  189. } }>{item.name}</div>
  190. })
  191. }
  192. </div>
  193. </div> : null
  194. }
  195. <div class={styles.cellBtnBox}>
  196. <img src={headImg("tpbz.png")} onClick={() => (helperData.screenModelShow = true)} />
  197. <img src={headImg("yjfk.png")} onClick={() => (helperData.recommendationShow = true)} />
  198. </div>
  199. </div>
  200. </div>
  201. <Popup
  202. v-model:show={helperData.recommendationShow}
  203. class="popup-custom van-scale center-closeBtn recommenBoxClass_drag"
  204. transition="van-scale"
  205. teleport="body"
  206. overlay-style={{background:'rgba(0, 0, 0, 0.3)'}}
  207. >
  208. <Recommendation
  209. onClose={() => {
  210. helperData.recommendationShow = false;
  211. }}
  212. />
  213. </Popup>
  214. <Popup
  215. class={["popup-custom"]}
  216. v-model:show={helperData.screenModelShow}
  217. onClose={() => {
  218. helperData.screenModelShow = false;
  219. }}
  220. position="right"
  221. teleport="body"
  222. >
  223. <ScreenModel
  224. onClose={(open: Boolean) => {
  225. helperData.screenModelShow = false;
  226. }}
  227. />
  228. </Popup>
  229. </div>
  230. );
  231. },
  232. });