index.tsx 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930
  1. import { Transition, computed, defineComponent, onMounted, onUnmounted, reactive, ref, watch, toRef, ComputedRef, nextTick } from "vue";
  2. import styles from "./index.module.less";
  3. import iconBack from "./image/icon-back.png";
  4. import listImg from "./image/list.png";
  5. import iconMode from "./image/mode.png";
  6. import { headImg } from "./image";
  7. import { Badge, Circle, Popover, Popup, showConfirmDialog, showToast, NoticeBar } from "vant";
  8. import Speed from "./speed";
  9. import { evaluatingData, handleStartEvaluat } from "/src/view/evaluating";
  10. import Settting from "./settting";
  11. import state, { IPlatform, handleChangeSection, handleResetPlay, handleRessetState, togglePlay, IPlayState, refreshMusicSvg } from "/src/state";
  12. import { getAudioCurrentTime } from "/src/view/audio-list";
  13. import { followData, toggleFollow } from "/src/view/follow-practice";
  14. import { api_back } from "/src/helpers/communication";
  15. import MusicType from "./music-type";
  16. import ModeTypeMode from "../component/mode-type-mode";
  17. import { getQuery } from "/src/utils/queryString";
  18. import { storeData } from "/src/store";
  19. import TeacherTop from "../custom-plugins/guide-page/teacher-top";
  20. import StudentTop from "../custom-plugins/guide-page/student-top";
  21. import { HANDLE_WORK_ADD } from "../custom-plugins/work-index";
  22. import { browser } from "/src/utils";
  23. import store from "store";
  24. import "../component/the-modal-tip/index.module.less";
  25. import { metronomeData } from "../../helpers/metronome";
  26. import { toggleMusicSheet } from "/src/view/plugins/toggleMusicSheet";
  27. import useDrag from "/src/view/plugins/useDrag/index";
  28. import Dragbom from "/src/view/plugins/useDrag/dragbom";
  29. import { getGuidance, setGuidance } from "../custom-plugins/guide-page/api";
  30. import ModeView from "./modeView";
  31. import { smoothAnimationState } from "../view-detail/smoothAnimation";
  32. import { isMusicList, musicListShow } from "../component/the-music-list";
  33. import { EvaluatingDriver, FollowDriver, PractiseDriver } from "../custom-plugins/guide-driver";
  34. /** 头部数据和方法 */
  35. export const headTopData = reactive({
  36. /** 模式 */
  37. modeType: "" as "init" | "show",
  38. /** 显示返回按钮 */
  39. showBack: true,
  40. /** 设置弹窗 */
  41. settingMode: false,
  42. /** 切换模式 */
  43. handleChangeModeType(value: "practise" | "follow" | "evaluating") {
  44. // 后台设置为不能评测
  45. if (value === "evaluating" && !state.enableEvaluation) return;
  46. // 打击乐&节奏练习不支持跟练模式
  47. if (value === "follow" && state.isPercussion) return;
  48. // 跟练模式,光标只有音符模式,无节拍模式
  49. if (value === "follow" && metronomeData.cursorMode === 2) {
  50. metronomeData.cursorMode = 1;
  51. }
  52. if (value === "practise") {
  53. // state.playIngSpeed = state.speed
  54. }
  55. if (value === "evaluating") {
  56. // 如果延迟检测资源还在加载中,给出提示
  57. if (!evaluatingData.jsonLoadDone) {
  58. evaluatingData.jsonLoading = true;
  59. state.audioDone && showToast("资源加载中,请稍后"); //音频资源加载完之后才提示
  60. return;
  61. }
  62. // 如果是pc端, 评测模式暂不可用
  63. if (state.platform === IPlatform.PC) {
  64. showConfirmDialog({
  65. className: "modalTip",
  66. title: "温馨提示",
  67. message: "该功能暂未开放,敬请期待!",
  68. showCancelButton: false,
  69. });
  70. return;
  71. }
  72. // 评测模式,只有一行谱模式
  73. if (!state.isSingleLine) {
  74. state.isSingleLine = true;
  75. refreshMusicSvg();
  76. }
  77. smoothAnimationState.isShow.value = false; // 隐藏旋律线
  78. state.playIngSpeed = state.originSpeed;
  79. handleStartEvaluat();
  80. // 开发模式,把此处打开
  81. // state.modeType = "evaluating";
  82. // evaluatingData.rendered = true;
  83. // evaluatingData.soundEffectMode = true;
  84. } else if (value === "follow") {
  85. // 跟练模式,只有一行谱模式
  86. if (!state.isSingleLine) {
  87. state.isSingleLine = true;
  88. refreshMusicSvg();
  89. }
  90. smoothAnimationState.isShow.value = false;
  91. toggleFollow();
  92. }
  93. headTopData.modeType = "show";
  94. },
  95. // 改变模式之前的状态
  96. oldPlayType: "play"
  97. });
  98. export const headData = reactive({
  99. speedShow: false,
  100. musicTypeShow: false,
  101. });
  102. let resetBtn: ComputedRef<{
  103. display: boolean;
  104. disabled: boolean;
  105. }>;
  106. /**
  107. * 处理模式切换
  108. * @param oldPlayType 没改变之前的播放模式
  109. * @param oldPlaySource 没改变之前的播放类型
  110. * @param isforceReset 是否强制刷新播放状态 模式times时值改变时候也刷新
  111. */
  112. export function handlerModeChange(oldPlayType: "play" | "sing", oldPlaySource: IPlayState, isforceReset?: boolean) {
  113. const isModeChange = modeChangeHandleTimes(oldPlayType, oldPlaySource);
  114. // 没有切换的时候 不处理下面的
  115. if (isModeChange) {
  116. try {
  117. metronomeData.metro.calculation(state.times);
  118. } catch (error) {}
  119. console.log("重新之后的times", state.times, state.fixtime);
  120. }
  121. if (isModeChange || isforceReset) {
  122. // 重置播放状态
  123. handleRessetState();
  124. // 隐藏重播按钮
  125. resetBtn && (resetBtn.value.display = false);
  126. }
  127. // 当模式改变的时候 放在这里是因为需要等谱面加载完成之后再提示
  128. if(headTopData.oldPlayType !== state.playType){
  129. showToast({
  130. message: state.playType === "play" ? "已切换为演奏场景" : "已切换为演唱场景",
  131. position: "top",
  132. className: "selectionToast",
  133. });
  134. }
  135. }
  136. // 模式切换之后重新给times赋值
  137. function modeChangeHandleTimes(oldPlayType: "play" | "sing", oldPlaySource: IPlayState) {
  138. const playType = state.playType;
  139. const playSource = state.playSource;
  140. const { notBeatFixtime, xmlMp3BeatFixTime, difftime } = state.times[0];
  141. const { isOpenMetronome, isSingOpenMetronome } = state;
  142. // 演奏向演唱切
  143. if (oldPlayType === "play" && playType === "sing") {
  144. if (playSource === "mingSong") {
  145. // 唱名文件也要加上弱起时间 他们制作曲子加了弱起时间
  146. state.fixtime = difftime;
  147. state.times.map((item) => {
  148. item.time = item.xmlNoteTime + difftime;
  149. item.endtime = item.xmlNoteEndTime + difftime;
  150. item.fixtime = difftime;
  151. });
  152. return true;
  153. } else {
  154. //演奏开了节拍器,演唱没开节拍器
  155. if (isOpenMetronome && !isSingOpenMetronome) {
  156. state.fixtime = notBeatFixtime;
  157. state.times.map((item) => {
  158. item.time = item.notBeatTime;
  159. item.endtime = item.notBeatEndTime;
  160. item.fixtime = notBeatFixtime;
  161. });
  162. return true;
  163. } else if (!isOpenMetronome && isSingOpenMetronome) {
  164. state.fixtime = notBeatFixtime + xmlMp3BeatFixTime;
  165. state.times.map((item) => {
  166. item.time = item.notBeatTime + xmlMp3BeatFixTime;
  167. item.endtime = item.notBeatEndTime + xmlMp3BeatFixTime;
  168. item.fixtime = notBeatFixtime + xmlMp3BeatFixTime;
  169. });
  170. return true;
  171. }
  172. }
  173. } else if (oldPlayType === "sing" && playType === "play") {
  174. // 演唱向演奏切
  175. if (oldPlaySource === "mingSong") {
  176. // 有节拍器
  177. if (isOpenMetronome) {
  178. state.fixtime = notBeatFixtime + xmlMp3BeatFixTime;
  179. state.times.map((item) => {
  180. item.time = item.notBeatTime + xmlMp3BeatFixTime;
  181. item.endtime = item.notBeatEndTime + xmlMp3BeatFixTime;
  182. item.fixtime = notBeatFixtime + xmlMp3BeatFixTime;
  183. });
  184. return true;
  185. } else {
  186. state.fixtime = notBeatFixtime;
  187. state.times.map((item) => {
  188. item.time = item.notBeatTime;
  189. item.endtime = item.notBeatEndTime;
  190. item.fixtime = notBeatFixtime;
  191. });
  192. return true;
  193. }
  194. }
  195. // 演奏开了节拍器,演唱没开节拍器
  196. if (isOpenMetronome && !isSingOpenMetronome) {
  197. state.fixtime = notBeatFixtime + xmlMp3BeatFixTime;
  198. state.times.map((item) => {
  199. item.time = item.notBeatTime + xmlMp3BeatFixTime;
  200. item.endtime = item.notBeatEndTime + xmlMp3BeatFixTime;
  201. item.fixtime = notBeatFixtime + xmlMp3BeatFixTime;
  202. });
  203. return true;
  204. } else if (!isOpenMetronome && isSingOpenMetronome) {
  205. state.fixtime = notBeatFixtime;
  206. state.times.map((item) => {
  207. item.time = item.notBeatTime;
  208. item.endtime = item.notBeatEndTime;
  209. item.fixtime = notBeatFixtime;
  210. });
  211. return true;
  212. }
  213. } else if (oldPlayType === "sing" && playType === "sing") {
  214. // 演唱之间切换
  215. // 切到唱名时候
  216. if (playSource === "mingSong") {
  217. // 唱名文件也要加上弱起时间 他们制作曲子加了弱起时间
  218. state.fixtime = difftime;
  219. state.times.map((item) => {
  220. item.time = item.xmlNoteTime + difftime;
  221. item.endtime = item.xmlNoteEndTime + difftime;
  222. item.fixtime = difftime;
  223. });
  224. return true;
  225. } else if (oldPlaySource === "mingSong") {
  226. // 有节拍器
  227. if (isSingOpenMetronome) {
  228. state.fixtime = notBeatFixtime + xmlMp3BeatFixTime;
  229. state.times.map((item) => {
  230. item.time = item.notBeatTime + xmlMp3BeatFixTime;
  231. item.endtime = item.notBeatEndTime + xmlMp3BeatFixTime;
  232. item.fixtime = notBeatFixtime + xmlMp3BeatFixTime;
  233. });
  234. return true;
  235. } else {
  236. state.fixtime = notBeatFixtime;
  237. state.times.map((item) => {
  238. item.time = item.notBeatTime;
  239. item.endtime = item.notBeatEndTime;
  240. item.fixtime = notBeatFixtime;
  241. });
  242. return true;
  243. }
  244. }
  245. }
  246. return false;
  247. }
  248. export default defineComponent({
  249. name: "header-top",
  250. emits: ["close"],
  251. setup(props, { emit }) {
  252. const query = getQuery();
  253. // 是否显示引导
  254. const showGuide = ref(false);
  255. const showStudentGuide = ref(false);
  256. let displayFingeringCache = false // 指法缓存
  257. /** 设置按钮 */
  258. const settingBtn = computed(() => {
  259. // 音频播放中 禁用
  260. if (state.playState === "play") return { display: true, disabled: true };
  261. // 评测开始 禁用, 跟练开始 禁用
  262. if (evaluatingData.startBegin || followData.start) return { display: true, disabled: true };
  263. return {
  264. display: true,
  265. disabled: false,
  266. };
  267. });
  268. /** 转谱按钮 */
  269. const converBtn = computed(() => {
  270. // 音频播放中 禁用
  271. if (state.playState === "play") return { display: true, disabled: true };
  272. // 评测开始 禁用
  273. if (evaluatingData.startBegin || followData.start) return { display: true, disabled: true };
  274. return {
  275. disabled: false,
  276. display: true,
  277. };
  278. });
  279. /** 速度按钮 */
  280. const speedBtn = computed(() => {
  281. // 选择模式, 跟练模式 不显示
  282. if (headTopData.modeType !== "show" || state.modeType === "follow") return { display: false, disabled: true };
  283. // 评测模式, 音频播放中 禁用
  284. if (state.modeType === "evaluating" || state.playState === "play") return { display: true, disabled: true };
  285. return {
  286. disabled: false,
  287. display: true,
  288. };
  289. });
  290. /** 节拍器按钮 */
  291. const metronomeBtn = computed(() => {
  292. // 选择模式 不显示
  293. if (headTopData.modeType !== "show") return { display: false, disabled: true };
  294. // 音频播放中 禁用
  295. if (state.playState === "play") return { display: true, disabled: true };
  296. return {
  297. disabled: false,
  298. display: true,
  299. };
  300. });
  301. /** 指法按钮 */
  302. const fingeringBtn = computed(() => {
  303. // 后台设置不显示指法
  304. if (!state.isShowFingering) return { display: true, disabled: true };
  305. // 没有指法 选择模式 评测模式 跟练模式 不显示
  306. if (headTopData.modeType !== "show" || !state.fingeringInfo.name || ["evaluating", "follow"].includes(state.modeType)) return { display: false, disabled: true };
  307. // 音频播放中 禁用
  308. if (state.playState === "play") return { display: true, disabled: true };
  309. return {
  310. disabled: false,
  311. display: true,
  312. };
  313. });
  314. /** 摄像头按钮 */
  315. const cameraBtn = computed(() => {
  316. // 选择模式 不显示
  317. if (headTopData.modeType !== "show" || state.modeType !== "evaluating") return { display: false, disabled: true };
  318. // 音频播放中 禁用
  319. if (state.playState === "play") return { display: true, disabled: true };
  320. return {
  321. disabled: false,
  322. display: true,
  323. };
  324. });
  325. /** 选段按钮 */
  326. const selectBtn = computed(() => {
  327. // 选择模式 不显示
  328. if (headTopData.modeType !== "show" || ["follow"].includes(state.modeType)) return { display: false, disabled: true };
  329. // 音频播放中 禁用
  330. if (state.playState === "play") return { display: true, disabled: true };
  331. return {
  332. disabled: false,
  333. display: true,
  334. };
  335. });
  336. /** 原声按钮 */
  337. const originBtn = computed(() => {
  338. // 选择模式,跟练模式 不显示
  339. if (headTopData.modeType !== "show" || state.modeType === "follow") return { display: false, disabled: false };
  340. // 评测开始 禁用
  341. if (state.modeType === "evaluating") return { display: false, disabled: true };
  342. if (!state.isAppPlay) {
  343. if (state.playType === "play") {
  344. // 原声, 伴奏 少一个,就不能切换
  345. if (state.music && state.accompany) return { display: true, disabled: false };
  346. } else {
  347. // 播放过程中不能切换
  348. if (state.playState === "play") {
  349. return { display: true, disabled: true };
  350. }
  351. // 范唱
  352. let index = 0;
  353. state.fanSong && index++;
  354. state.banSong && index++;
  355. state.mingSong && index++;
  356. if (index > 1) {
  357. return { display: true, disabled: false };
  358. }
  359. }
  360. }
  361. return {
  362. disabled: true,
  363. display: true,
  364. };
  365. });
  366. /** 播放类型按钮 */
  367. const playTypeBtn = computed(() => {
  368. // 选择模式,跟练模式,评测模式 不显示
  369. if (headTopData.modeType !== "show" || state.modeType === "follow" || state.modeType === "evaluating") return { display: false, disabled: false };
  370. if (!state.isAppPlay) {
  371. let index = 0;
  372. state.music && index++;
  373. state.accompany && index++;
  374. let songIndex = 0;
  375. state.fanSong && songIndex++;
  376. state.banSong && songIndex++;
  377. state.mingSong && songIndex++;
  378. // 演唱和演奏 都有数据的时间不禁用
  379. if (songIndex > 0 && index > 0) {
  380. // 音频播放中 禁用
  381. if(state.playState === "play"){
  382. return { display: true, disabled: true }
  383. }
  384. return { display: true, disabled: false };
  385. }
  386. }
  387. return {
  388. disabled: false,
  389. display: false,
  390. };
  391. });
  392. /** 模式切换按钮 */
  393. const toggleBtn = computed(() => {
  394. // 不是演奏模式 影藏
  395. if(state.playType !== "play") return { display: false, disabled: false }
  396. // 选择模式, url设置模式 不显示
  397. if (headTopData.modeType !== "show" || !headTopData.showBack) return { display: false, disabled: false };
  398. // 跟练开始, 评测开始 播放开始 隐藏
  399. if (state.playState == "play" || followData.start || evaluatingData.startBegin) return { display: false, disabled: false };
  400. return {
  401. display: true,
  402. disabled: false,
  403. };
  404. });
  405. /** 播放按钮 */
  406. const playBtn = computed(() => {
  407. // 选择模式 不显示
  408. if (headTopData.modeType !== "show") return { display: false, disabled: false };
  409. // 评测模式 不显示,跟练模式 不显示
  410. if (["evaluating", "follow"].includes(state.modeType)) return { display: false, disabled: true };
  411. // midi音频未初始化完成不可点击
  412. if (state.isAppPlay && state.midiPlayIniting) return { display: true, disabled: true };
  413. return {
  414. display: true,
  415. disabled: false,
  416. };
  417. });
  418. /** 重播按钮 */
  419. resetBtn = computed(() => {
  420. // 选择模式 不显示
  421. if (headTopData.modeType !== "show") return { display: false, disabled: false };
  422. // 评测模式 不显示,跟练模式 不显示
  423. if (["evaluating", "follow"].includes(state.modeType)) return { display: false, disabled: true };
  424. // 播放状态 不显示
  425. if (state.playState === "play") return { display: false, disabled: true };
  426. // 播放进度为0 不显示
  427. const currentTime = getAudioCurrentTime();
  428. // midi音频未初始化完成不可点击
  429. if (state.isAppPlay && state.midiPlayIniting) return { display: false, disabled: true };
  430. if (!currentTime) return { display: false, disabled: true };
  431. return {
  432. display: true,
  433. disabled: false,
  434. };
  435. });
  436. const isAllBtns = computed(() => {
  437. const flag = converBtn.value.display && speedBtn.value.display && selectBtn.value.display && originBtn.value.display && toggleBtn.value.display && showGuide.value;
  438. return flag;
  439. });
  440. const isAllBtnsStudent = computed(() => {
  441. const flag = converBtn.value.display && speedBtn.value.display && selectBtn.value.display && originBtn.value.display && toggleBtn.value.display && showStudentGuide.value;
  442. return flag;
  443. });
  444. const showGuideIndex = computed(() => {
  445. // 从课堂乐器学生端课件预览默认不显示会员
  446. if (storeData.user.vipMember || state.paymentType === "FREE" || query.showCourseMember === "true") {
  447. // 学生端
  448. return true;
  449. } else {
  450. // vip
  451. return false;
  452. }
  453. });
  454. const browInfo = browser();
  455. /** 返回 */
  456. const handleBack = () => {
  457. HANDLE_WORK_ADD();
  458. // 不在APP中,
  459. if (!storeData.isApp) {
  460. window.close();
  461. return;
  462. }
  463. if ((browInfo.iPhone || browInfo.ios) && query.workRecord) {
  464. setTimeout(() => {
  465. api_back();
  466. }, 550);
  467. return;
  468. }
  469. api_back();
  470. };
  471. /** 根据参数设置模式 */
  472. const getQueryModelSetModelType = () => {
  473. /** 作业模式 start, 如果为作业模式不处理,让作业模块处理 */
  474. if (query.workRecord) {
  475. return;
  476. }
  477. /** 作业模式 end */
  478. if (state.defaultModeType == 1) {
  479. headTopData.handleChangeModeType("practise");
  480. // if (state.platform === IPlatform.PC || state.isPreView) {
  481. // headTopData.showBack = false;
  482. // }
  483. if (state.isPreView) {
  484. headTopData.showBack = false;
  485. }
  486. } else {
  487. if (query.modelType) {
  488. if (query.modelType === "practise") {
  489. headTopData.handleChangeModeType("practise");
  490. } else if (query.modelType === "evaluating") {
  491. headTopData.handleChangeModeType("evaluating");
  492. }
  493. headTopData.showBack = false;
  494. } else {
  495. setTimeout(() => {
  496. headTopData.modeType = "init";
  497. }, 500);
  498. }
  499. }
  500. };
  501. /** 课件播放 */
  502. const changePlay = (res: any) => {
  503. // console.log('监听上课页面message',res)
  504. if (res?.data?.api === "setPlayState") {
  505. togglePlay("paused", "courseware");
  506. }
  507. // 上课页面,按钮方向
  508. if (res?.data?.api === "imagePos") {
  509. if (res?.data.data) {
  510. state.playBtnDirection = res.data.data === "right" ? "right" : "left";
  511. // if (state.fingeringInfo.direction === "vertical" && state.setting.displayFingering) {
  512. // state.musicScoreBtnDirection = state.playBtnDirection === 'right' ? 'left' : 'right';
  513. // } else {
  514. // state.musicScoreBtnDirection = state.playBtnDirection;
  515. // }
  516. state.musicScoreBtnDirection = state.playBtnDirection;
  517. }
  518. }
  519. };
  520. const parentClassName = "settingBoxClass_drag";
  521. const userId = storeData.user?.id ? String(storeData.user?.id) : "";
  522. const positionInfo =
  523. state.platform !== IPlatform.PC
  524. ? {
  525. styleDrag: { value: null },
  526. }
  527. : useDrag([`${parentClassName} .top_drag`, `${parentClassName} .bom_drag`], parentClassName, toRef(headTopData, "settingMode"), userId);
  528. onMounted(() => {
  529. getQueryModelSetModelType();
  530. window.addEventListener("message", changePlay);
  531. if (state.platform === IPlatform.PC) {
  532. showGuide.value = true;
  533. } else {
  534. showStudentGuide.value = true;
  535. }
  536. });
  537. onUnmounted(() => {
  538. window.removeEventListener("message", changePlay);
  539. });
  540. const noticeBarWidth = ref<number>()
  541. watch(()=>smoothAnimationState.isShow.value, ()=>{
  542. // NoticeBar能不能滚动
  543. if(smoothAnimationState.isShow.value && isMusicList.value){
  544. nextTick(()=>{
  545. const widthCon = (document.querySelector("#noticeBarRollDom .van-notice-bar__content") as any)?.offsetWidth || undefined
  546. noticeBarWidth.value = widthCon
  547. })
  548. }
  549. },{ immediate: true })
  550. // 设置改变触发
  551. watch(state.setting, () => {
  552. console.log(state.setting, "state.setting");
  553. store.set("musicscoresetting", state.setting);
  554. });
  555. // 获取引导页信息
  556. const getAllGuidance = async () => {
  557. let guideInfo: any = null;
  558. try {
  559. const res = await getGuidance({ guideTag: "guideInfo" });
  560. if (res.data) {
  561. guideInfo = JSON.parse(res.data?.guideValue) || null;
  562. } else {
  563. guideInfo = {};
  564. }
  565. state.guideInfo = guideInfo;
  566. } catch (e) {
  567. console.log(e);
  568. }
  569. };
  570. getAllGuidance();
  571. // 完成拖动弹窗引导页
  572. const handleGuide = async () => {
  573. state.guideInfo.teacherDrag = true;
  574. try {
  575. const res = await setGuidance({ guideTag: "guideInfo", guideValue: JSON.stringify(state.guideInfo) });
  576. } catch (e) {
  577. console.log(e);
  578. }
  579. };
  580. return () => (
  581. <>
  582. <div
  583. class={[styles.headerTop, state.platform === IPlatform.PC && state.musicScoreBtnDirection === "left" ? styles.headerTopRight : ""]}
  584. onClick={(e: Event) => {
  585. e.stopPropagation();
  586. if (state.platform === IPlatform.PC) {
  587. // 显示隐藏菜单
  588. window.parent.postMessage(
  589. {
  590. api: "onAttendToggleMenu",
  591. },
  592. "*"
  593. );
  594. }
  595. }}
  596. >
  597. {/* 返回和标题 */}
  598. {
  599. !(state.playState == "play" || followData.start || evaluatingData.startBegin) &&
  600. <div id="noticeBarRollDom" class={styles.headTopLeftBox}>
  601. <img src={iconBack} class={['headTopBackBtn', styles.img, !headTopData.showBack && styles.hidenBack]} onClick={handleBack} />
  602. {
  603. smoothAnimationState.isShow.value ?
  604. <div
  605. style={
  606. noticeBarWidth.value ? {
  607. "--noticeBarWidth":noticeBarWidth.value + "px"
  608. } : {}
  609. }
  610. class={[styles.title,isMusicList.value && styles.isMusicList, "driver-8"]}
  611. onClick={()=>{
  612. isMusicList.value && (musicListShow.value = true)
  613. }}>
  614. <NoticeBar
  615. text={state.examSongName}
  616. background="none"
  617. />
  618. </div> :
  619. isMusicList.value &&
  620. <img src={listImg} class={[styles.img, styles.listImg, "driver-8"]} onClick={()=>{
  621. musicListShow.value = true
  622. }} />
  623. }
  624. </div>
  625. }
  626. {/* 模式切换 */}
  627. {
  628. <div
  629. id={state.platform === IPlatform.PC ? "teacherTop-0" : "studnetT-0"}
  630. style={{ display: toggleBtn.value.display ? "" : "none" }}
  631. class={["driver-9", styles.modeChangeBox, toggleBtn.value.disabled && styles.disabled]}
  632. onClick={() => {
  633. handleRessetState();
  634. headTopData.modeType = "init";
  635. }}
  636. >
  637. <img class={styles.img} src={iconMode} />
  638. <div class={styles.title}>{state.modeType==="practise" ? '练习模式' : state.modeType==="follow" ? "跟练模式" : state.modeType==="evaluating" ? "评测模式" : ""}</div>
  639. </div>
  640. }
  641. {/* 模式提醒 */}
  642. {
  643. state.modeType === "practise" &&
  644. <div class={[styles.modeWarn, "practiseModeWarn", state.platform === IPlatform.PC && state.musicScoreBtnDirection === "left" ? styles.modeWarnRight : ""]}>
  645. <img src={state.playType === "play" ? headImg("perform1.png") : headImg("sing1.png")} />
  646. <div>{state.playType === "play" ? "演奏场景" : "演唱场景"}</div>
  647. </div>
  648. }
  649. {/* 功能按钮 */}
  650. <div
  651. class={[styles.headRight]}
  652. onClick={(e: Event) => {
  653. e.stopPropagation();
  654. }}
  655. >
  656. {/* 一行谱模式,暂不支持节拍指针 */}
  657. {/* {!state.isSingleLine ? (
  658. <div
  659. class={[styles.btn, state.platform === IPlatform.PC ? styles.pcBtn : ""]}
  660. onClick={() => {
  661. // 切换光标模式
  662. let mode = metronomeData.cursorMode;
  663. if (["follow"].includes(state.modeType)) {
  664. mode = metronomeData.cursorMode === 1 ? 3 : 1;
  665. } else {
  666. mode = metronomeData.cursorMode === 3 ? 1 : metronomeData.cursorMode + 1;
  667. }
  668. metronomeData.cursorMode = mode;
  669. }}
  670. >
  671. <img class={styles.iconBtn} src={headImg(metronomeData.cursorMode === 1 ? "cursor-icon-1.svg" : metronomeData.cursorMode === 2 ? "cursor-icon-2.svg" : metronomeData.cursorMode === 3 ? "cursor-icon-3.svg" : "")} />
  672. <span class={styles.iconContent}>
  673. {metronomeData.cursorMode === 1 ? "音符指针" : metronomeData.cursorMode === 2 ? "节拍指针" : metronomeData.cursorMode === 3 ? "关闭指针" : ""}
  674. {metronomeData.cursorTips && (
  675. <>
  676. <i class={styles.arrowIcon}></i>
  677. <div class={[styles["botton-tips"], metronomeData.cursorMode === 3 ? styles.tipSpec : ""]}>{metronomeData.cursorTips}</div>
  678. </>
  679. )}
  680. </span>
  681. </div>
  682. ) : null} */}
  683. <div
  684. style={{ display: playTypeBtn.value.display ? "" : "none" }}
  685. class={["driver-2", styles.btn, playTypeBtn.value.disabled && styles.disabled,styles.playType]}
  686. onClick={() => {
  687. const oldPlayType = state.playType;
  688. headTopData.oldPlayType = oldPlayType
  689. const oldPlaySource = state.playSource;
  690. if (state.playType === "play") {
  691. state.playType = "sing";
  692. state.playSource = state.fanSong ? "music" : state.banSong ? "background" : "mingSong";
  693. } else {
  694. state.playType = "play";
  695. state.playSource = state.music ? "music" : "background";
  696. }
  697. // 有指法并且显示指法的时候 切换到演唱模式 需要影藏指法
  698. let isRefresh = false;
  699. if (state.isShowFingering && state.fingeringInfo.name && (state.setting.displayFingering || displayFingeringCache)) {
  700. if (state.playType === "sing") {
  701. state.setting.displayFingering = false;
  702. displayFingeringCache = true;
  703. } else {
  704. state.setting.displayFingering = displayFingeringCache;
  705. displayFingeringCache = false;
  706. }
  707. // 如果是竖屏指法和一行谱的时候 改变指法值的时候state 会调用刷新 refreshMusicSvg 所以下面不调用
  708. if (state.fingeringInfo.direction === "vertical" && !state.isSingleLine) {
  709. isRefresh = true;
  710. }
  711. }
  712. // 有歌词的时候,切换播放模式,需要重新渲染谱面 指法不刷新谱面的时候
  713. if (state.xmlHasLyric && !isRefresh) {
  714. refreshMusicSvg();
  715. } else if (!isRefresh) {
  716. handlerModeChange(oldPlayType, oldPlaySource, true);
  717. }
  718. }}
  719. >
  720. <img style={{ display: state.playType === "play" ? "" : "none" }} class={styles.iconBtn} src={headImg(`perform.png`)} />
  721. <img style={{ display: state.playType === "play" ? "none" : "" }} class={styles.iconBtn} src={headImg(`sing.png`)} />
  722. <span>{state.playType === "play" ? "演奏" : "演唱"}</span>
  723. </div>
  724. <div
  725. id={state.platform === IPlatform.PC ? "teacherTop-1" : "studnetT-1"}
  726. style={{ display: originBtn.value.display ? "" : "none" }}
  727. class={["driver-3", styles.btn, originBtn.value.disabled && styles.disabled,state.playType === "play"?styles.playSource:styles.songSource]}
  728. onClick={() => {
  729. const oldPlayType = state.playType;
  730. const oldPlaySource = state.playSource;
  731. if (state.playType === "play") {
  732. state.playSource = state.playSource === "music" ? "background" : "music";
  733. } else {
  734. if (state.playSource === "music") {
  735. state.playSource = state.banSong ? "background" : "mingSong";
  736. } else if (state.playSource === "background") {
  737. state.playSource = state.mingSong ? "mingSong" : "music";
  738. } else {
  739. state.playSource = state.fanSong ? "music" : "background";
  740. }
  741. }
  742. handlerModeChange(oldPlayType, oldPlaySource);
  743. showToast({
  744. message: state.playType === "play" ? (state.playSource === "music" ? "已切换为原声" : "已切换为伴奏") : state.playSource === "music" ? "已切换为范唱" : state.playSource === "background" ? "已切换为伴唱" : "已切换为唱名",
  745. position: "top",
  746. className: "selectionToast",
  747. });
  748. }}
  749. >
  750. <img style={{ display: state.playSource === "music" ? "" : "none" }} class={styles.iconBtn} src={state.playType === "play" ? headImg(`music.png`) : headImg(`music1.png`)} />
  751. <img style={{ display: state.playSource === "background" ? "" : "none" }} class={styles.iconBtn} src={state.playType === "play" ? headImg(`background.png`) : headImg(`background1.png`)} />
  752. <img style={{ display: state.playSource === "mingSong" ? "" : "none" }} class={styles.iconBtn} src={headImg(`mingsong.png`)} />
  753. <span>{state.playSource === "music" ? (state.playType === "play" ? "原声" : "范唱") : state.playSource === "background" ? (state.playType === "play" ? "伴奏" : "伴唱") : "唱名"}</span>
  754. </div>
  755. <div id={state.platform === IPlatform.PC ? "teacherTop-2" : "studnetT-2"} style={{ display: selectBtn.value.display ? "" : "none" }} class={["driver-4", styles.btn, selectBtn.value.disabled && styles.disabled, styles.section, state.sectionStatus && styles.isSection]} onClick={() => handleChangeSection()}>
  756. <img style={{ display: state.section.length === 0 ? "" : "none" }} class={styles.iconBtn} src={headImg(`section0.png`)} />
  757. <img style={{ display: state.section.length === 1 ? "" : "none" }} class={styles.iconBtn} src={headImg(`section1.png`)} />
  758. <img style={{ display: state.section.length === 2 ? "" : "none" }} class={styles.iconBtn} src={headImg(`section2.png`)} />
  759. <span>选段</span>
  760. </div>
  761. {(
  762. <>
  763. <div
  764. style={{ display: metronomeBtn.value.display ? "" : "none" }}
  765. class={["driver-5", styles.btn, styles.metronomeBtn, metronomeBtn.value.disabled && styles.disabled,headData.speedShow && styles.isSpeed,styles.speed]}
  766. onClick={async () => {
  767. headData.speedShow = !headData.speedShow;
  768. }}
  769. >
  770. <img style={{ display: metronomeData.disable ? "block" : "none" }} class={styles.iconBtn} src={headImg("tickon.png")} />
  771. <img style={{ display: !metronomeData.disable ? "block" : "none" }} class={styles.iconBtn} src={headImg("tickoff.png")} />
  772. <span style={{ whiteSpace: "nowrap" }}>节拍</span>
  773. <div class={styles.speedCon}>
  774. <img src={headImg("speed.png")} />
  775. <div>{Math.floor(state.speed)}</div>
  776. </div>
  777. </div>
  778. {
  779. <Popup v-model:show={headData.speedShow} class="popup-custom van-scale center-closeBtn settingBoxClass_drag" transition="van-scale" teleport="body" style={positionInfo.styleDrag.value} overlay-style={{ background: "rgba(0, 0, 0, 0.3)" }}>
  780. <Speed />
  781. {state.platform === IPlatform.PC && <Dragbom showGuide={!state.guideInfo?.teacherDrag} onGuideDone={handleGuide} />}
  782. </Popup>
  783. }
  784. </>
  785. )}
  786. {/* {state.enableNotation ? (
  787. <Popover trigger="manual" v-model:show={headData.musicTypeShow} class={state.platform === IPlatform.PC && styles.pcTransPop} placement={state.platform === IPlatform.PC ? "top-end" : "bottom-end"} overlay={false} offset={state.platform === IPlatform.PC ? [0, 40] : [0, 8]}>
  788. {{
  789. reference: () => (
  790. <div
  791. id={state.platform === IPlatform.PC ? "teacherTop-5" : "studnetT-5"}
  792. style={{ display: converBtn.value.display ? "" : "none" }}
  793. class={[styles.btn, converBtn.value.disabled && styles.disabled]}
  794. onClick={(e: Event) => {
  795. e.stopPropagation();
  796. headData.musicTypeShow = !headData.musicTypeShow;
  797. }}
  798. >
  799. <img class={styles.iconBtn} src={headImg("icon_zhuanpu.svg")} />
  800. <span>{state.musicRenderType === "staff" ? "转简谱" : "转五线谱"}</span>
  801. </div>
  802. ),
  803. default: () => <MusicType />,
  804. }}
  805. </Popover>
  806. ) : null} */}
  807. {state.musicRendered && !query.lessonTrainingId && !query.questionId && state.isConcert && (
  808. <div
  809. class={[styles.btn, state.playState === "play" && fingeringBtn.value.disabled && styles.disabled,toggleMusicSheet.show&&styles.isMusicSheet,styles.musicSheet]}
  810. onClick={() => {
  811. toggleMusicSheet.toggle(true);
  812. }}
  813. >
  814. <img class={styles.iconBtn} src={headImg(`shenggui.png`)} />
  815. <span>声部</span>
  816. </div>
  817. )}
  818. <div id={state.platform === IPlatform.PC ? "teacherTop-6" : "studnetT-6"} style={{ display: settingBtn.value.display ? "" : "none" }} class={["driver-6", styles.btn, settingBtn.value.disabled && styles.disabled,headTopData.settingMode&&styles.isSettingMode,styles.settingMode]} onClick={() => (headTopData.settingMode = true)}>
  819. <img class={styles.iconBtn} src={headImg("icon_menu.png")} />
  820. <span>设置</span>
  821. </div>
  822. </div>
  823. </div>
  824. {/* 播放按钮 */}
  825. <div
  826. id="studnetT-7"
  827. style={{ display: playBtn.value.display ? "" : "none" }}
  828. class={[
  829. // 引导使用的类
  830. "driver-1",
  831. styles.playBtn,
  832. playBtn.value.disabled && styles.disabled,
  833. state.platform === IPlatform.PC && state.musicScoreBtnDirection === "left" ? styles.playLeftButton : state.platform === IPlatform.PC && state.musicScoreBtnDirection === "right" ? styles.playRightButton : "",
  834. ]}
  835. onClick={() => togglePlay(state.playState === "play" ? "paused" : "play")}
  836. >
  837. <div class={styles.btnWrap}>
  838. <img style={{ display: state.playState === "play" ? "none" : "" }} class={styles.iconBtn} src={headImg("icon_play.png")} />
  839. <img style={{ display: state.playState === "play" ? "" : "none" }} class={styles.iconBtn} src={headImg("icon_pause.png")} />
  840. <Circle style={{ opacity: state.playState === "play" ? 1 : 0 }} class={styles.progress} stroke-width={60} stroke-linecap={"square"} currentRate={state.playProgress} rate={100} color="#FFED78" layer-color="rgba(0,0,0,0)" />
  841. </div>
  842. </div>
  843. {/* 重播按钮 */}
  844. <div
  845. id="tips-step-9"
  846. style={{ display: resetBtn.value.display ? "" : "none" }}
  847. class={[styles.resetBtn, resetBtn.value.disabled && styles.disabled, state.platform === IPlatform.PC && state.musicScoreBtnDirection === "left" ? styles.pauseLeftButton : state.platform === IPlatform.PC && state.musicScoreBtnDirection === "right" ? styles.pauseRightButton : ""]}
  848. onClick={() => handleResetPlay()}
  849. >
  850. <img class={styles.iconBtn} src={headImg("icon_reset.png")} />
  851. </div>
  852. <Popup v-model:show={headTopData.settingMode} class="popup-custom van-scale center-closeBtn settingBoxClass_drag" transition="van-scale" teleport="body" style={positionInfo.styleDrag.value} overlay-style={{ background: "rgba(0, 0, 0, 0.3)" }}>
  853. <Settting />
  854. {state.platform === IPlatform.PC && <Dragbom showGuide={!state.guideInfo?.teacherDrag} onGuideDone={handleGuide} />}
  855. </Popup>
  856. {/* 模式切换 */}
  857. {/* <ModeTypeMode /> */}
  858. <ModeView></ModeView>
  859. {/* isAllBtns */}
  860. {/* {isAllBtns.value && !query.isCbs && showGuideIndex.value && <TeacherTop></TeacherTop>}
  861. {isAllBtnsStudent.value && !query.isCbs && showGuideIndex.value && <StudentTop></StudentTop>} */}
  862. {/* 练习模式功能引导 加载音频完成 不是会员 */}
  863. {state.modeType === "practise" && headTopData.modeType !== "init" && !query.isCbs && state.audioDone && !state.isLoading && !state.isVip && (
  864. <PractiseDriver
  865. statusAll={{
  866. subjectStatus: state.musicRendered && !query.lessonTrainingId && !query.questionId && state.isConcert,
  867. modelTypeStatus: toggleBtn.value.display,
  868. playType: playTypeBtn.value.display,
  869. }}
  870. />
  871. )}
  872. {/* 跟练模式功能引导 加载音频完成 不是会员 */}
  873. {state.modeType === "follow" && headTopData.modeType !== "init" && !query.isCbs && state.audioDone && !state.isLoading && !state.isVip && (
  874. <FollowDriver
  875. statusAll={{
  876. subjectStatus: state.musicRendered && !query.lessonTrainingId && !query.questionId && state.isConcert,
  877. }}
  878. />
  879. )}
  880. {/* 评测模式功能引导 加载音频完成 不是会员 */}
  881. {state.modeType === "evaluating" && headTopData.modeType !== "init" && !evaluatingData.earphoneMode && !query.isCbs && state.audioDone && !state.isLoading && !state.isVip && evaluatingData.websocketState && !evaluatingData.startBegin && evaluatingData.checkEnd && (
  882. <EvaluatingDriver
  883. statusAll={{
  884. subjectStatus: state.musicRendered && !query.lessonTrainingId && !query.questionId && state.isConcert,
  885. }}
  886. />
  887. )}
  888. </>
  889. );
  890. },
  891. });