index.tsx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. import { defineComponent, reactive, computed, toRef, ref } 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, IPlatform, checkMoveNoSave, handleGuide, resetCursorPosition } 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. import { reCheckDelay } from "/src/page-instrument/evaluat-model"
  14. import { audioData, changeMingSongType } from "/src/view/audio-list"
  15. import useDrag from "/src/view/plugins/useDrag/index";
  16. import Dragbom from "/src/view/plugins/useDrag/dragbom";
  17. import { storeData } from "/src/store";
  18. import { getGuidance, setGuidance } from "../../custom-plugins/guide-page/api";
  19. import { metronomeData } from "/src/helpers/metronome";
  20. export default defineComponent({
  21. name: "settting",
  22. setup() {
  23. const query = getQuery();
  24. const helperData = reactive({
  25. screenModelShow: false, // 投屏帮助
  26. recommendationShow: false, // 建议
  27. });
  28. const zoomList = [{name:'0.5x',value: 0.5},{name:'0.75x',value: 0.65},{name:'1x',value: 0.8},{name:'1.25x',value: 1.25},{name:'1.5x',value: 1.5},{name:'1.75x',value: 1.75},{name:'2x',value: 2},{name:'2.25x',value: 2.25}]
  29. const parentClassName = "recommenBoxClass_drag";
  30. const userId = storeData.user?.id ? String(storeData.user?.id) : "";
  31. const positionInfo =
  32. state.platform !== IPlatform.PC
  33. ? {
  34. styleDrag: { value: null },
  35. }
  36. : useDrag([`${parentClassName} .top_draging`, `${parentClassName} .bom_drag`], parentClassName, toRef(helperData, "recommendationShow"), userId);
  37. // 加减评测频率
  38. const operateHz = (type: number) => {
  39. const minFrequency = state.baseFrequency - 10, maxFrequency = state.baseFrequency + 10
  40. let currentFrequency = state.setting.frequency
  41. if (type === 1) {
  42. if (currentFrequency - 1 < minFrequency) return showToast({ message: `最低标准音高${minFrequency}HZ` })
  43. currentFrequency = currentFrequency - 1
  44. } else {
  45. if (currentFrequency + 1 > maxFrequency) return showToast({ message: `最高标准音高${maxFrequency}HZ` })
  46. currentFrequency = currentFrequency + 1
  47. }
  48. state.setting.frequency = currentFrequency >= 0 ? currentFrequency : 0
  49. }
  50. const formatterTimeMs = (value: any) => value = String(Math.min(3000, value));
  51. const notationList = computed(() => {
  52. const list = state.enableNotation ? [{name:'五线谱',value:'staff'},{name:'首调',value:'firstTone'},{name:'固定调',value:'fixedTone'}] : [{name:'首调',value:'firstTone'},{name:'固定调',value:'fixedTone'}];
  53. return list;
  54. });
  55. const metronomeList = computed(() => {
  56. const list = state.modeType === 'follow' ? [{name:'音符',value:1},{name:'关闭',value:3}] : [{name:'音符',value:1},{name:'节拍',value:2},{name:'关闭',value:3}];
  57. return list;
  58. });
  59. return () => (
  60. <div class={[styles.settting]}>
  61. <div class={[styles.head, "top_draging"]}>
  62. <img class={styles.headTit} src={headImg("settingName.png")} />
  63. <img class={styles.closeImg} src={headImg("closeImg.png")} onClick={()=>{ headTopData.settingMode = false }} />
  64. </div>
  65. <div class={styles.content}>
  66. <div class={styles.conBox}>
  67. {
  68. state.isShowFingering && state.fingeringInfo.name && ["practise", "follow", "evaluating"].includes(state.modeType) && state.playType === "play" &&
  69. <div class={styles.cellBox}>
  70. <div class={styles.tit}>指法</div>
  71. <Switch v-model={state.setting.displayFingering}></Switch>
  72. </div>
  73. }
  74. {
  75. ["practise", "follow"].includes(state.modeType) &&
  76. <div class={styles.cellBox}>
  77. <div class={styles.tit}>循环播放</div>
  78. <Switch v-model={state.setting.repeatAutoPlay}></Switch>
  79. </div>
  80. }
  81. { !state.isCombineRender &&
  82. <div class={styles.cellBox}>
  83. <div class={styles.tit}>合并休止小节</div>
  84. <Switch
  85. v-model={state.setting.combineMultipleRest}
  86. onChange={ async (value) => {
  87. await checkMoveNoSave();
  88. headTopData.settingMode = false
  89. const _time = setTimeout(() => {
  90. clearTimeout(_time)
  91. refreshMusicSvg();
  92. }, 100);
  93. }}
  94. ></Switch>
  95. </div>
  96. }
  97. {/* {
  98. state.isSingleLine && state.modeType === "practise" && !state.isCombineRender && !state.isPercussion &&
  99. <div class={styles.cellBox}>
  100. <div class={styles.tit}>旋律线</div>
  101. <Switch
  102. v-model={smoothAnimationState.isShow.value}
  103. onChange={(value) => {
  104. state.melodyLine = value
  105. }}
  106. ></Switch>
  107. </div>
  108. } */}
  109. <div class={styles.cellBox} style={{border:"none"}}>
  110. <div class={styles.tit}>指针模式</div>
  111. <div class={styles.radioBox}>
  112. {
  113. metronomeList.value.map(item=>{
  114. return <div class={ metronomeData.cursorMode===item.value && styles.active } onClick={ ()=>{
  115. if (metronomeData.cursorMode === item.value) {
  116. return
  117. }
  118. // 切换光标模式
  119. metronomeData.cursorMode = item.value
  120. resetCursorPosition()
  121. }}>{item.name}</div>
  122. })
  123. }
  124. </div>
  125. </div>
  126. <div class={styles.pointerCon}>
  127. <div class={styles.pointerBox}>
  128. <div>音符:指针跟随音符播放</div>
  129. {
  130. state.modeType !== 'follow' && <div>节拍:指针跟随节拍播放</div>
  131. }
  132. <div>关闭:不显示指针</div>
  133. </div>
  134. </div>
  135. {
  136. state.modeType === 'practise' && state.playType === "sing" && state.mingSong && state.mingSongGirl &&
  137. <div class={styles.cellBox}>
  138. <div class={styles.tit}>唱名类型</div>
  139. <div class={styles.radioBox}>
  140. {
  141. [{name:'男声',value:1}, {name:'女声',value:0}].map(item=>{
  142. return <div class={ audioData.mingSongType===item.value && styles.active } onClick={ ()=>{
  143. if(audioData.mingSongType === item.value){
  144. return
  145. }
  146. audioData.mingSongType = item.value as 0|1
  147. changeMingSongType()
  148. } }>{item.name}</div>
  149. })
  150. }
  151. </div>
  152. </div>
  153. }
  154. {
  155. state.modeType === "evaluating" &&
  156. <>
  157. {
  158. (!query.workRecord && !query.evaluatingRecord) &&
  159. <div class={styles.cellBox}>
  160. <div class={styles.tit}>评测难度</div>
  161. <div class={styles.radioBox}>
  162. {
  163. [{name:'入门',value:"BEGINNER"},{name:'进阶',value:"ADVANCED"},{name:'大师',value:"PERFORMER"}].map(item=>{
  164. return <div class={ state.setting.evaluationDifficulty===item.value && styles.active } onClick={ ()=>{
  165. state.setting.evaluationDifficulty = item.value as any
  166. } }>{item.name}</div>
  167. })
  168. }
  169. </div>
  170. </div>
  171. }
  172. <div class={styles.cellBox}>
  173. <div class={styles.tit}>延迟检测</div>
  174. {/* <Switch v-model={state.setting.soundEffect}></Switch> */}
  175. <div class={styles.titbtn} onClick={() => {
  176. reCheckDelay();
  177. }}>重新检测</div>
  178. </div>
  179. <div class={[styles.cellBox, state.setting.camera && styles.isCamera]}>
  180. <div class={styles.tit}>摄像头</div>
  181. <Switch
  182. // v-model={state.setting.camera}
  183. modelValue={state.setting.camera}
  184. onChange={ async (value) => {
  185. if (value) {
  186. const res = await api_openCamera();
  187. // 没有授权
  188. if (res?.content?.reson) {
  189. state.setting.camera = false
  190. } else {
  191. state.setting.camera = true
  192. }
  193. } else {
  194. api_closeCamera();
  195. state.setting.camera = false;
  196. }
  197. }}
  198. ></Switch>
  199. </div>
  200. <div class={styles.cellBox} style={{ display: state.setting.camera ? "" : "none" }}>
  201. <div class={styles.tit}>不透明度</div>
  202. <div class={styles.spendCon}>
  203. <div class={styles.sliderCon}>
  204. <Slider class={styles.slider} max={100} min={0} v-model={state.setting.cameraOpacity}>
  205. {{
  206. button: () =>
  207. <div class={styles.customButton}>
  208. <div class={styles.speedVal}>{ state.setting.cameraOpacity }</div>
  209. <div class={styles.speedBtn}></div>
  210. </div>
  211. }}
  212. </Slider>
  213. </div>
  214. </div>
  215. </div>
  216. <div class={styles.cellBox}>
  217. <div class={styles.tit}>标准音高</div>
  218. <div class={styles.frequency}>
  219. <img src={headImg("cutImg.png")} class={[styles.btn]} onClick={() => operateHz(1)} />
  220. <div class={styles.frequencyNum}>{state.setting.frequency}HZ</div>
  221. <img src={headImg("addImg.png")} class={[styles.btn]} onClick={() => operateHz(2)} />
  222. </div>
  223. </div>
  224. <div class={styles.cellBox}>
  225. <div class={styles.tit}>反应时间</div>
  226. <div class={styles.reactionTimeBox}>
  227. <Field class={styles.reactionTime} type="digit"
  228. placeholder="最大可输入3000毫秒"
  229. formatter={formatterTimeMs}
  230. input-align={'center'}
  231. v-model:modelValue={state.setting.reactionTimeMs} />
  232. <div class={styles.timeName}>毫秒</div>
  233. </div>
  234. </div>
  235. </>
  236. }
  237. {/** 练习模式才有单行/多行谱切换功能,跟练、评测只有单行谱模式 */}
  238. {
  239. ["practise", "evaluating"].includes(state.modeType) ?
  240. <div class={styles.cellBox}>
  241. <div class={styles.tit}>切换谱面</div>
  242. <div class={[styles.radioBox, styles.qhBox]}>
  243. {
  244. [{name:'单行谱',value:true},{name:'多行谱',value:false}].map(item=>{
  245. return <div class={ state.isSingleLine===item.value && styles.active } onClick={ async ()=>{
  246. if(state.isSingleLine === item.value){
  247. return
  248. }
  249. await checkMoveNoSave();
  250. headTopData.settingMode = false
  251. // resetRenderMusicScore(state.musicRenderType)
  252. const _time = setTimeout(() => {
  253. state.isSingleLine = item.value
  254. clearTimeout(_time)
  255. refreshMusicSvg();
  256. }, 100);
  257. // musicScoreRef.value?.refreshMusicScore()
  258. } }>{item.name}</div>
  259. })
  260. }
  261. </div>
  262. </div> : null
  263. }
  264. {
  265. state.enableNotation || state.specialShowNotation ?
  266. <div class={styles.cellBox}>
  267. <div class={styles.tit}>转谱</div>
  268. <div class={styles.radioBox}>
  269. {
  270. notationList.value.map(item=>{
  271. return <div class={ state.musicRenderType===item.value && styles.active } onClick={ async ()=>{
  272. if(state.musicRenderType === item.value){
  273. return
  274. }
  275. await checkMoveNoSave();
  276. headTopData.settingMode = false
  277. // resetRenderMusicScore(state.musicRenderType)
  278. const _time = setTimeout(() => {
  279. state.musicRenderType = item.value as any
  280. clearTimeout(_time)
  281. refreshMusicSvg();
  282. }, 100);
  283. } }>{item.name}</div>
  284. })
  285. }
  286. </div>
  287. </div> : null
  288. }
  289. {
  290. <div class={styles.cellBox}>
  291. <div class={styles.tit}>谱面大小</div>
  292. <div class={[styles.radioBox, styles.speBox]}>
  293. {
  294. zoomList.map(item=>{
  295. return <div class={ state.zoom===item.value && styles.active } onClick={ async ()=>{
  296. if(state.zoom === item.value){
  297. return
  298. }
  299. await checkMoveNoSave();
  300. headTopData.settingMode = false
  301. // resetRenderMusicScore(state.musicRenderType)
  302. const _time = setTimeout(() => {
  303. state.zoom = item.value as any
  304. localStorage.setItem('scoreZoom',String(state.zoom))
  305. clearTimeout(_time)
  306. refreshMusicSvg();
  307. }, 100);
  308. } }>{item.name}</div>
  309. })
  310. }
  311. </div>
  312. </div>
  313. }
  314. <div class={styles.cellBtnBox}>
  315. <img src={headImg("tpbz.png")} onClick={() => (helperData.screenModelShow = true)} />
  316. {
  317. !query.isCbs && <img src={headImg("yjfk.png")} onClick={() => (helperData.recommendationShow = true)} />
  318. }
  319. </div>
  320. </div>
  321. </div>
  322. <Popup
  323. v-model:show={helperData.recommendationShow}
  324. class="popup-custom van-scale center-closeBtn recommenBoxClass_drag"
  325. transition="van-scale"
  326. teleport="body"
  327. overlay-style={{background:'rgba(0, 0, 0, 0.7)'}}
  328. style={positionInfo.styleDrag.value}
  329. >
  330. <Recommendation
  331. onClose={() => {
  332. helperData.recommendationShow = false;
  333. }}
  334. />
  335. {state.platform === IPlatform.PC && <Dragbom showGuide={!state.guideInfo?.teacherDrag} onGuideDone={handleGuide} />}
  336. </Popup>
  337. <Popup
  338. class={["popup-custom"]}
  339. v-model:show={helperData.screenModelShow}
  340. onClose={() => {
  341. helperData.screenModelShow = false;
  342. }}
  343. position="right"
  344. teleport="body"
  345. >
  346. <ScreenModel
  347. onClose={(open: Boolean) => {
  348. helperData.screenModelShow = false;
  349. }}
  350. />
  351. </Popup>
  352. </div>
  353. );
  354. },
  355. });