index.tsx 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. import { defineComponent, reactive, computed, toRef } 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 } 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. export default defineComponent({
  20. name: "settting",
  21. setup() {
  22. const query = getQuery();
  23. const helperData = reactive({
  24. screenModelShow: false, // 投屏帮助
  25. recommendationShow: false, // 建议
  26. });
  27. const parentClassName = "recommenBoxClass_drag";
  28. const userId = storeData.user?.id ? String(storeData.user?.id) : "";
  29. const positionInfo =
  30. state.platform !== IPlatform.PC
  31. ? {
  32. styleDrag: { value: null },
  33. }
  34. : useDrag([`${parentClassName} .top_draging`, `${parentClassName} .bom_drag`], parentClassName, toRef(helperData, "recommendationShow"), userId);
  35. // 完成拖动弹窗引导页
  36. const handleGuide = async () => {
  37. state.guideInfo.teacherDrag = true;
  38. try {
  39. const res = await setGuidance({ guideTag: "guideInfo", guideValue: JSON.stringify(state.guideInfo) });
  40. } catch (e) {
  41. console.log(e);
  42. }
  43. };
  44. // 加减评测频率
  45. const operateHz = (type: number) => {
  46. const minFrequency = state.baseFrequency - 10, maxFrequency = state.baseFrequency + 10
  47. let currentFrequency = state.setting.frequency
  48. if (type === 1) {
  49. if (currentFrequency - 1 < minFrequency) return showToast({ message: `最低标准音高${minFrequency}HZ` })
  50. currentFrequency = currentFrequency - 1
  51. } else {
  52. if (currentFrequency + 1 > maxFrequency) return showToast({ message: `最高标准音高${maxFrequency}HZ` })
  53. currentFrequency = currentFrequency + 1
  54. }
  55. state.setting.frequency = currentFrequency >= 0 ? currentFrequency : 0
  56. }
  57. const formatterTimeMs = (value: any) => value = String(Math.min(3000, value));
  58. const notationList = computed(() => {
  59. const list = state.enableNotation ? [{name:'五线谱',value:'staff'},{name:'首调',value:'firstTone'},{name:'固定调',value:'fixedTone'}] : [{name:'首调',value:'firstTone'},{name:'固定调',value:'fixedTone'}];
  60. return list;
  61. });
  62. return () => (
  63. <div class={[styles.settting, styles[state.modeType]]}>
  64. <div class={[styles.head, "top_draging"]}>
  65. <img class={styles.headTit} src={headImg("settingName.png")} />
  66. <img class={styles.closeImg} src={headImg("closeImg.png")} onClick={()=>{ headTopData.settingMode = false }} />
  67. </div>
  68. <div class={styles.content}>
  69. <div class={styles.conBox}>
  70. {
  71. state.isShowFingering && state.fingeringInfo.name && ["practise", "follow", "evaluating"].includes(state.modeType) && state.playType === "play" &&
  72. <div class={styles.cellBox}>
  73. <div class={styles.tit}>指法</div>
  74. <Switch v-model={state.setting.displayFingering}></Switch>
  75. </div>
  76. }
  77. {
  78. ["practise", "follow"].includes(state.modeType) &&
  79. <div class={styles.cellBox}>
  80. <div class={styles.tit}>循环播放</div>
  81. <Switch v-model={state.setting.repeatAutoPlay}></Switch>
  82. </div>
  83. }
  84. {
  85. state.isSingleLine && state.modeType === "practise" && !state.isCombineRender && !state.isPercussion &&
  86. <div class={styles.cellBox}>
  87. <div class={styles.tit}>旋律线</div>
  88. <Switch
  89. v-model={smoothAnimationState.isShow.value}
  90. onChange={(value) => {
  91. state.melodyLine = value
  92. }}
  93. ></Switch>
  94. </div>
  95. }
  96. {
  97. state.modeType === 'practise' && state.mingSong && state.mingSongGirl &&
  98. <div class={styles.cellBox}>
  99. <div class={styles.tit}>唱名类型</div>
  100. <div class={styles.radioBox}>
  101. {
  102. [{name:'男声',value:1}, {name:'女声',value:0}].map(item=>{
  103. return <div class={ audioData.mingSongType===item.value && styles.active } onClick={ ()=>{
  104. if(audioData.mingSongType === item.value){
  105. return
  106. }
  107. audioData.mingSongType = item.value as 0|1
  108. changeMingSongType()
  109. } }>{item.name}</div>
  110. })
  111. }
  112. </div>
  113. </div>
  114. }
  115. {
  116. state.modeType === "evaluating" &&
  117. <>
  118. {
  119. !query.workRecord &&
  120. <div class={styles.cellBox}>
  121. <div class={styles.tit}>评测难度</div>
  122. <div class={styles.radioBox}>
  123. {
  124. [{name:'入门',value:"BEGINNER"},{name:'进阶',value:"ADVANCED"},{name:'大师',value:"PERFORMER"}].map(item=>{
  125. return <div class={ state.setting.evaluationDifficulty===item.value && styles.active } onClick={ ()=>{
  126. state.setting.evaluationDifficulty = item.value as any
  127. } }>{item.name}</div>
  128. })
  129. }
  130. </div>
  131. </div>
  132. }
  133. <div class={styles.cellBox}>
  134. <div class={styles.tit}>延迟检测</div>
  135. {/* <Switch v-model={state.setting.soundEffect}></Switch> */}
  136. <div class={styles.titbtn} onClick={() => {
  137. reCheckDelay();
  138. }}>重新检测</div>
  139. </div>
  140. <div class={[styles.cellBox, state.setting.camera && styles.isCamera]}>
  141. <div class={styles.tit}>摄像头</div>
  142. <Switch
  143. // v-model={state.setting.camera}
  144. modelValue={state.setting.camera}
  145. onChange={ async (value) => {
  146. if (value) {
  147. const res = await api_openCamera();
  148. // 没有授权
  149. if (res?.content?.reson) {
  150. state.setting.camera = false
  151. } else {
  152. state.setting.camera = true
  153. }
  154. } else {
  155. api_closeCamera();
  156. state.setting.camera = false;
  157. }
  158. }}
  159. ></Switch>
  160. </div>
  161. <div class={styles.cellBox} style={{ display: state.setting.camera ? "" : "none", paddingTop: 0 }}>
  162. <div class={styles.tit}>不透明度</div>
  163. <div class={styles.spendCon}>
  164. <div class={styles.sliderCon}>
  165. <Slider class={styles.slider} max={100} min={0} v-model={state.setting.cameraOpacity}>
  166. {{
  167. button: () =>
  168. <div class={styles.customButton}>
  169. <div class={styles.speedVal}>{ state.setting.cameraOpacity }</div>
  170. <div class={styles.speedBtn}></div>
  171. </div>
  172. }}
  173. </Slider>
  174. </div>
  175. </div>
  176. </div>
  177. <div class={styles.cellBox}>
  178. <div class={styles.tit}>标准音高</div>
  179. <div class={styles.frequency}>
  180. <img src={headImg("cutImg.png")} class={[styles.btn]} onClick={() => operateHz(1)} />
  181. <div class={styles.frequencyNum}>{state.setting.frequency}HZ</div>
  182. <img src={headImg("addImg.png")} class={[styles.btn]} onClick={() => operateHz(2)} />
  183. </div>
  184. </div>
  185. <div class={styles.cellBox}>
  186. <div class={styles.tit}>反应时间</div>
  187. <div class={styles.reactionTimeBox}>
  188. <Field class={styles.reactionTime} type="digit"
  189. placeholder="最大可输入3000毫秒"
  190. formatter={formatterTimeMs}
  191. input-align={'center'}
  192. v-model:modelValue={state.setting.reactionTimeMs} />
  193. <div class={styles.timeName}>毫秒</div>
  194. </div>
  195. </div>
  196. </>
  197. }
  198. {/** 练习模式才有单行/多行谱切换功能,跟练、评测只有单行谱模式 */}
  199. {
  200. ["practise", "evaluating"].includes(state.modeType) ?
  201. <div class={styles.cellBox}>
  202. <div class={styles.tit}>切换谱面</div>
  203. <div class={styles.radioBox}>
  204. {
  205. [{name:'单行谱',value:true},{name:'多行谱',value:false}].map(item=>{
  206. return <div class={ state.isSingleLine===item.value && styles.active } onClick={ async ()=>{
  207. if(state.isSingleLine === item.value){
  208. return
  209. }
  210. await checkMoveNoSave();
  211. headTopData.settingMode = false
  212. // resetRenderMusicScore(state.musicRenderType)
  213. const _time = setTimeout(() => {
  214. state.isSingleLine = item.value
  215. clearTimeout(_time)
  216. refreshMusicSvg();
  217. }, 100);
  218. // musicScoreRef.value?.refreshMusicScore()
  219. } }>{item.name}</div>
  220. })
  221. }
  222. </div>
  223. </div> : null
  224. }
  225. {
  226. state.enableNotation || state.specialShowNotation ?
  227. <div class={styles.cellBox}>
  228. <div class={styles.tit}>转谱</div>
  229. <div class={styles.radioBox}>
  230. {
  231. notationList.value.map(item=>{
  232. return <div class={ state.musicRenderType===item.value && styles.active } onClick={ async ()=>{
  233. if(state.musicRenderType === item.value){
  234. return
  235. }
  236. await checkMoveNoSave();
  237. headTopData.settingMode = false
  238. // resetRenderMusicScore(state.musicRenderType)
  239. const _time = setTimeout(() => {
  240. state.musicRenderType = item.value as any
  241. clearTimeout(_time)
  242. refreshMusicSvg();
  243. }, 100);
  244. } }>{item.name}</div>
  245. })
  246. }
  247. </div>
  248. </div> : null
  249. }
  250. <div class={styles.cellBtnBox}>
  251. <img src={headImg("tpbz.png")} onClick={() => (helperData.screenModelShow = true)} />
  252. {
  253. !query.isCbs && <img src={headImg("yjfk.png")} onClick={() => (helperData.recommendationShow = true)} />
  254. }
  255. </div>
  256. </div>
  257. </div>
  258. <Popup
  259. v-model:show={helperData.recommendationShow}
  260. class="popup-custom van-scale center-closeBtn recommenBoxClass_drag"
  261. transition="van-scale"
  262. teleport="body"
  263. overlay-style={{background:'rgba(0, 0, 0, 0.3)'}}
  264. style={positionInfo.styleDrag.value}
  265. >
  266. <Recommendation
  267. onClose={() => {
  268. helperData.recommendationShow = false;
  269. }}
  270. />
  271. {state.platform === IPlatform.PC && <Dragbom showGuide={!state.guideInfo?.teacherDrag} onGuideDone={handleGuide} />}
  272. </Popup>
  273. <Popup
  274. class={["popup-custom"]}
  275. v-model:show={helperData.screenModelShow}
  276. onClose={() => {
  277. helperData.screenModelShow = false;
  278. }}
  279. position="right"
  280. teleport="body"
  281. >
  282. <ScreenModel
  283. onClose={(open: Boolean) => {
  284. helperData.screenModelShow = false;
  285. }}
  286. />
  287. </Popup>
  288. </div>
  289. );
  290. },
  291. });