index.tsx 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759
  1. import { Popup, Skeleton } from "vant";
  2. import { computed, defineComponent, nextTick, onBeforeMount, onBeforeUnmount, onMounted, reactive, Transition, watch, watchEffect, defineAsyncComponent, ref } from "vue";
  3. import { formateTimes } from "../../helpers/formateMusic";
  4. import Metronome, { metronomeData } from "../../helpers/metronome";
  5. import state, { EnumMusicRenderType, evaluatCreateMusicPlayer, handleSetSpeed, IAudioState, IPlatform, isRhythmicExercises, resetPlaybackToStart, togglePlay, getMusicDetail, addNoteBBox } from "/src/state";
  6. import { browser, setGlobalData } from "../../utils";
  7. import AudioList from "../../view/audio-list";
  8. import MusicScore from "../../view/music-score";
  9. import TestCheck from "/src/view/music-score/testCheck";
  10. import { sysMusicScoreAccompanimentQueryPage } from "../api";
  11. import EvaluatModel from "../evaluat-model";
  12. import HeaderTop, { handlerModeChange, headTopData } from "../header-top";
  13. import styles from "./index.module.less";
  14. import { api_cloudAccompanyMessage, api_cloudLoading, api_keepScreenLongLight, api_openCamera, api_openWebView, api_setEventTracking, api_setRequestedOrientation, api_setStatusBarVisibility, isSpecialShapedScreen } from "/src/helpers/communication";
  15. import { getQuery } from "/src/utils/queryString";
  16. import Evaluating, { evaluatingData } from "/src/view/evaluating";
  17. import MeasureSpeed from "/src/view/plugins/measure-speed";
  18. import { mappingVoicePart, subjectFingering } from "/src/view/fingering/fingering-config";
  19. import Fingering from "/src/view/fingering";
  20. import Rhythm from "/src/view/rhythm";
  21. import store from "store";
  22. import Tick, { handleInitTick } from "/src/view/tick";
  23. import FollowPractice, { followData } from "/src/view/follow-practice";
  24. import FollowModel from "../follow-model";
  25. import RecordingTime from "../custom-plugins/recording-time";
  26. import WorkIndex, { resetSection } from "../custom-plugins/work-index";
  27. import TheMusicList, { isMusicList } from "../component/the-music-list";
  28. import { storeData } from "/src/store";
  29. import ViewFigner from "../view-figner";
  30. import { recalculateNoteData } from "/src/view/selection";
  31. import ToggleMusicSheet from "/src/view/plugins/toggleMusicSheet";
  32. import { setCustomGradual, setCustomNoteRealValue } from "/src/helpers/customMusicScore";
  33. import { usePageVisibility } from "@vant/use";
  34. import { initMidi } from "/src/helpers/midiPlay";
  35. import TheAudio from "/src/components/the-audio";
  36. import tickWav from "/src/assets/tick.mp3";
  37. import AuthorName from "../component/authorName";
  38. import { initSmoothAnimation } from "./smoothAnimation";
  39. import EmptyMusic, { isEmptyMusicShow } from "./emptyMusic";
  40. import { position } from "html2canvas/dist/types/css/property-descriptors/position";
  41. import Loading from "./loading"
  42. import LoadingCss from "./loadingCss"
  43. import { getSvgPngToSize } from "/src/helpers/svgToPng"
  44. import { uploadErrorLog } from '/src/hooks/errorLog/uploadLog'
  45. // import bgJson from "./images/index.json";
  46. // const DelayCheck = defineAsyncComponent(() =>
  47. // import('/src/page-instrument/evaluat-model/delay-check')
  48. // )
  49. /**
  50. * 特殊教材分类id
  51. */
  52. export const classids = [1, 2, 6, 7, 8, 9, 3, 10, 11, 12, 13, 4, 14, 15, 16, 17, 30, 31, 35, 36, 46, 108]; // 大雅金唐, 竖笛教程, 声部训练展开的分类ID
  53. const calcCeilFrequency = (frequency: number) => {
  54. if (frequency < 0) return frequency;
  55. if (frequency) return (frequency * 1000 * 2) / 1000;
  56. return 0;
  57. };
  58. /** 需要处理频率的乐器
  59. */
  60. const resetFrequency = (list: any[]) => {
  61. // const instrumentNames = ["ocarina", "pan-flute", "piccolo", "hulusi-flute"];
  62. const instrumentNames = ["ocarina", "pan-flute", "hulusi-flute"];
  63. if (!state.fingeringInfo?.name || !instrumentNames.includes(state.fingeringInfo.name)) return list;
  64. // console.log(state.subjectId, state.fingeringInfo.name, instrumentNames);
  65. for (let i = 0; i < list.length; i++) {
  66. if (list[i].prevFrequency) list[i].prevFrequency = calcCeilFrequency(list[i].prevFrequency);
  67. if (list[i].frequency) list[i].frequency = calcCeilFrequency(list[i].frequency);
  68. if (list[i].nextFrequency) list[i].nextFrequency = calcCeilFrequency(list[i].nextFrequency);
  69. }
  70. return list;
  71. };
  72. /**
  73. * 乐器指法处理
  74. */
  75. const setNoteHalfTone = (list: any[]) => {
  76. const instrumentNames = ["hulusi-flute"]; // ["ocarina", "pan-flute", "piccolo"];
  77. if (!state.fingeringInfo?.name || !instrumentNames.includes(state.fingeringInfo.name)) return list;
  78. for (let i = 0; i < list.length; i++) {
  79. const note = list[i];
  80. if (note.realKey === 0) continue;
  81. note.realKey = note.realKey + 12;
  82. }
  83. return list;
  84. };
  85. export const musicScoreRef = ref();
  86. export const fingerRef = ref();
  87. export const headerColumnHide = ref(false); // 是否隐藏功能按钮,播放时自动隐藏
  88. export default defineComponent({
  89. name: "music-list",
  90. setup() {
  91. const browsInfo = browser();
  92. const query: any = getQuery();
  93. const detailData = reactive({
  94. isLoading: true,
  95. skeletonLoading: true,
  96. paddingLeft: "0px",
  97. headerHide: false,
  98. fingerPreView: false,
  99. fingerPreViewAnimation: false,
  100. orientation: 0,
  101. fingerPreViewGuide: false,
  102. });
  103. const getAPPData = async () => {
  104. const screenData = await isSpecialShapedScreen();
  105. if (screenData?.content) {
  106. // console.log("🚀 ~ screenData:", screenData.content);
  107. const { isSpecialShapedScreen, notchHeight } = screenData.content;
  108. if (isSpecialShapedScreen) {
  109. // 安卓取刘海值
  110. detailData.paddingLeft = 27 + "px";
  111. }
  112. }
  113. };
  114. console.time('加载过程')
  115. onBeforeMount(async () => {
  116. // console.time("渲染加载耗时");
  117. api_keepScreenLongLight();
  118. getAPPData();
  119. api_setStatusBarVisibility();
  120. const settting = store.get("musicscoresetting");
  121. if (settting) {
  122. //state.setting = settting;
  123. Object.assign(state.setting, settting);
  124. //state.setting.beatVolume = state.setting.beatVolume || 50
  125. state.setting.beatVolume = 50;
  126. // 默认进来不需要开启摄像头,进入评测页面才需要判断是否开启摄像头
  127. // if (state.setting.camera) {
  128. // const res = await api_openCamera();
  129. // // 没有授权
  130. // if (res?.content?.reson) {
  131. // state.setting.camera = false;
  132. // store.set("musicscoresetting", state.setting);
  133. // }
  134. // }
  135. }
  136. });
  137. //给app传伴奏
  138. const pushAppMusic = () => {
  139. api_cloudAccompanyMessage(state.accompany);
  140. };
  141. // console.log(route.params, query)
  142. // 动态加载json背景
  143. const bgJsonData: any = ref(null);
  144. const jsonFiles: any = {
  145. data: () => import('./images/index.json'),
  146. };
  147. const loadJson = async (fileKey: any) => {
  148. try {
  149. const data = await jsonFiles[fileKey]();
  150. bgJsonData.value = data.default;
  151. } catch (error) {
  152. console.error('👀~json背景加载失败', error);
  153. }
  154. };
  155. onMounted(async () => {
  156. (window as any).appName = "colexiu";
  157. const id = query.id || "43554";
  158. state.isCbsView = query.isCbs;
  159. // 如果是纯预览模式,0.65倍缩放谱面
  160. state.isPreView = query.isPreView;
  161. if (state.isPreView) {
  162. state.zoom = query.zoom || 0.65
  163. }
  164. if (id == "1814218144844087298" && state.isSingleLine) {
  165. state.zoom = 0.7;
  166. }
  167. // 只有总控平台和预览 默认是多行谱
  168. //(state.isPreView || query.isCbs) && (state.isSingleLine = false)
  169. // Promise.all([sysMusicScoreAccompanimentQueryPage(id)]).then((values) => {
  170. // getMusicInfo(values[0]);
  171. // });
  172. loadJson('data');
  173. try {
  174. await getMusicDetail(id);
  175. } catch (err: any) {
  176. console.error(err);
  177. const contentError = `reason: ${err?.message || ''};stack: ${err?.stack || ''};bizId: ${state.examSongId || query.id || ''};partIndex: ${query["part-index"] || state.partIndex || 0};partName: ${decodeURIComponent(query["part-name"] || '') || ''};`;
  178. uploadErrorLog(contentError)
  179. state.isLoading = false;
  180. isEmptyMusicShow.value = true
  181. // 需要向外面(iframe)派发计时器数据的时候触发
  182. if(query.isbeatTimes){
  183. console.log("webApi_beatTimes",err)
  184. window.parent.postMessage(
  185. {
  186. api: "webApi_beatTimes",
  187. data: "节拍器时值错误!!"
  188. },
  189. "*"
  190. );
  191. }
  192. return
  193. }
  194. detailData.isLoading = false;
  195. // 如果后台设置了不显示指法,关闭指法开关 如果默认进来是演奏模式 不显示指法开关
  196. if (!state.isShowFingering || state.playType === "sing") {
  197. state.setting.displayFingering = false;
  198. }
  199. // api_setEventTracking();
  200. });
  201. /** 渲染完成 */
  202. const handleRendered = (osmd: any) => {
  203. state.isLoading = false
  204. api_cloudLoading();
  205. console.timeEnd("渲染加载耗时");
  206. console.timeLog('加载过程','谱面渲染完成')
  207. detailData.skeletonLoading = false;
  208. state.osmd = osmd;
  209. // 预览模式不需要往下执行
  210. if (state.isPreView) {
  211. // 管乐迷曲谱详情页,需要下载A4尺寸的图片
  212. setTimeout(() => {
  213. if (query.downPng === 'A4' && state.partIndex != 999) {
  214. const imgList = getSvgPngToSize(state.osmd)
  215. console.log('A4', imgList)
  216. window.parent.postMessage({
  217. api: 'musicStaffRender',
  218. loading: false,
  219. osmdImg: imgList
  220. }, '*');
  221. }
  222. }, 100);
  223. return;
  224. }
  225. // 没有设置速度使用读取的速度
  226. if (state.originSpeed === 0) {
  227. state.originSpeed = state.speed = (osmd as any).bpm || osmd.Sheet.userStartTempoInBPM || 100;
  228. // console.log('速度',9,state.speed)
  229. }
  230. // const saveSpeed = (store.get("speeds") || {})[state.examSongId] || state.speed || (osmd as any).bpm || osmd.Sheet.userStartTempoInBPM;
  231. // // 加载本地缓存的速度
  232. // if (saveSpeed) {
  233. // handleSetSpeed(saveSpeed);
  234. // }
  235. // setCustomGradual();
  236. // setCustomNoteRealValue();
  237. state.times = formateTimes(osmd);
  238. // state.times = resetFrequency(state.times);
  239. state.times = setNoteHalfTone(state.times);
  240. state.xmlHasLyric = state.times.some((item: any) => item?.formatLyricsEntries?.length);
  241. console.log("🚀 ~ state.times:", state.times, state.subjectId, state);
  242. nextTick(() => {
  243. state.activeMeasureIndex = state.times[0].MeasureNumberXML;
  244. });
  245. // 一行谱
  246. if (state.isSingleLine) {
  247. // 音符添加位置信息bbox
  248. addNoteBBox(state.times);
  249. // 一行谱创建 动画
  250. initSmoothAnimation();
  251. }
  252. // 初始化midi音频信息
  253. const songEndTime = state.times[state.times.length - 1 || 0]?.endtime || 0;
  254. if (state.isAppPlay) {
  255. const durationNum = songEndTime;
  256. initMidi(durationNum, state.midiUrl);
  257. }
  258. state.measureTime = state.times[0]?.measureLength || 0;
  259. try {
  260. metronomeData.metro = new Metronome();
  261. metronomeData.metro.init(state.times);
  262. } catch (error) {
  263. console.log(error, "err")
  264. }
  265. // 需要向外面(iframe)派发计时器数据的时候触发
  266. if (query.isbeatTimes) {
  267. const { isOpenMetronome, isSingOpenMetronome } = state;
  268. const { xmlMp3BeatFixTime, difftime } = state.times[0];
  269. const singBeatTime: number[][] = [];
  270. const beatTime = metronomeData.metroMeasure.map((metroMeasure) => {
  271. const singBeat: number[] = [];
  272. const beatTimeItem = metroMeasure.map((item: any) => {
  273. let singTime = item.time;
  274. if (isSingOpenMetronome && !isOpenMetronome) {
  275. singTime += xmlMp3BeatFixTime;
  276. } else if (!isSingOpenMetronome && isOpenMetronome) {
  277. singTime -= xmlMp3BeatFixTime;
  278. }
  279. singBeat.push(singTime);
  280. return item.time;
  281. });
  282. singBeatTime.push(singBeat);
  283. return beatTimeItem;
  284. });
  285. //改为唱名
  286. state.fixtime = difftime;
  287. state.times.map((item) => {
  288. item.time = item.xmlNoteTime + difftime;
  289. item.endtime = item.xmlNoteEndTime + difftime;
  290. item.fixtime = difftime;
  291. });
  292. metronomeData.metro.calculation(state.times);
  293. const mingBeatTime: number[][] = metronomeData.metroMeasure.map((metroMeasure) => {
  294. const beatTimeItem = metroMeasure.map((item: any) => {
  295. return item.time;
  296. });
  297. return beatTimeItem;
  298. });
  299. const webApi_beatTimes = { beatTime, singBeatTime, mingBeatTime, isBeatTime:!state.isEvxml, isSingBeatTime:!state.isEvxml, isMingBeatTime:!state.isEvxml }
  300. console.log("webApi_beatTimes", webApi_beatTimes);
  301. window.parent.postMessage(
  302. {
  303. api: "webApi_beatTimes",
  304. data: JSON.stringify(webApi_beatTimes),
  305. },
  306. "*"
  307. );
  308. return
  309. }
  310. // 刷新时值
  311. handlerModeChange("play", "music");
  312. /**
  313. * 2024.1.25
  314. * 设置节拍器,跟练需要播放系统节拍器,所以不需要判断needTick状态
  315. */
  316. // if (state.needTick) {
  317. handleInitTick();
  318. // }
  319. // api_cloudLoading();
  320. // state.playBtnDirection = query.imagePos === 'left' ? 'left' : 'right';
  321. // state.isAttendClass = (query.imagePos === 'left' || query.imagePos === 'right') ? true : false;
  322. // if (state.fingeringInfo.direction === "vertical" && state.setting.displayFingering) {
  323. // state.musicScoreBtnDirection = state.playBtnDirection === 'right' ? 'left' : 'right';
  324. // } else {
  325. // state.musicScoreBtnDirection = state.playBtnDirection;
  326. // }
  327. // 曲谱详情页,需要下载A4尺寸的图片
  328. setTimeout(() => {
  329. if (query.downPng === 'A4' && state.partIndex != 999) {
  330. const imgList = getSvgPngToSize(state.osmd)
  331. console.log('A4', imgList)
  332. window.parent.postMessage({
  333. api: 'musicStaffRender',
  334. loading: false,
  335. osmdImg: imgList
  336. }, '*');
  337. }
  338. }, 100);
  339. state.musicScoreBtnDirection = state.playBtnDirection;
  340. state.musicRendered = true;
  341. evaluatCreateMusicPlayer();
  342. resetPlaybackToStart();
  343. // 需要重新设置作业选段
  344. if (state.workSectionNeedReset) {
  345. resetSection();
  346. }
  347. // pushAppMusic();
  348. // console.timeEnd("渲染加载耗时");
  349. };
  350. function handleOnRendered(osmd: any) {
  351. try{
  352. handleRendered(osmd)
  353. }catch(err:any){
  354. console.log(err, "err")
  355. const contentError = `reason: ${err?.message || ''};stack: ${err?.stack || ''};bizId: ${state.examSongId || query.id || ''};partIndex: ${query["part-index"] || state.partIndex || 0};partName: ${decodeURIComponent(query["part-name"] || '') || ''};`;
  356. uploadErrorLog(contentError)
  357. // 需要向外面(iframe)派发计时器数据的时候触发
  358. if(query.isbeatTimes){
  359. console.log("webApi_beatTimes",err)
  360. window.parent.postMessage(
  361. {
  362. api: "webApi_beatTimes",
  363. data: "节拍器时值错误!!"
  364. },
  365. "*"
  366. );
  367. }
  368. }
  369. }
  370. /** 指法配置 */
  371. const fingerConfig = computed<any>(() => {
  372. if (state.setting.displayFingering && state.fingeringInfo?.name) {
  373. if (state.fingeringInfo.direction === "transverse") {
  374. console.log("横向指法", state.fingeringInfo.name);
  375. return {
  376. container: {
  377. //paddingBottom: headerColumnHide.value ? state.fingeringInfo.height : state.fingeringInfo.scaleData?.offset
  378. paddingBottom: state.fingeringInfo.height
  379. },
  380. // 横向指法,跟练&评测模式,默认展示贴底展示
  381. // fingerBox: headerColumnHide.value ? {
  382. // height: state.fingeringInfo.height
  383. // } : {
  384. // height: state.fingeringInfo.height,
  385. // transform: `scale(${state.fingeringInfo.scaleData?.scale})`
  386. // }
  387. fingerBox: {
  388. height: state.fingeringInfo.height
  389. }
  390. };
  391. } else {
  392. console.log("竖向指法", state.fingeringInfo.name, state.playBtnDirection, state.platform);
  393. // 老师端,竖向指法,需要根据功能按钮方向进行设置
  394. if (state.platform === IPlatform.PC) {
  395. return {
  396. container: {
  397. paddingRight: state.playBtnDirection === "right" ? "initial" : state.fingeringInfo.width,
  398. paddingLeft: state.playBtnDirection === "right" ? state.fingeringInfo.width : "initial",
  399. },
  400. fingerBox: {
  401. position: "absolute",
  402. width: state.fingeringInfo.width,
  403. height: state.fingeringInfo.name === "hulusi-flute" ? "86%" : "80%",
  404. right: state.playBtnDirection === "right" ? "initial" : 0,
  405. left: state.playBtnDirection === "right" ? 0 : "initial",
  406. top: (state.fingeringInfo.name === "ocarina" || state.fingeringInfo.name === "whistling") ? "60px" : state.fingeringInfo.name === "hulusi-flute" ? "10px" : (state.fingeringInfo.name === "baroque-recorder" || state.fingeringInfo.name === "piccolo") ? "36px" : 0,
  407. },
  408. };
  409. } else {
  410. return {
  411. container: {
  412. paddingLeft: state.fingeringInfo.width,
  413. },
  414. fingerBox: {
  415. position: "absolute",
  416. width: state.fingeringInfo.width,
  417. height: state.fingeringInfo.name === "hulusi-flute" ? "86%" : "80%",
  418. left: 0,
  419. top: (state.fingeringInfo.name === "ocarina" || state.fingeringInfo.name === "whistling") ? "60px" : state.fingeringInfo.name === "hulusi-flute" ? "10px" : (state.fingeringInfo.name === "baroque-recorder" || state.fingeringInfo.name === "piccolo") ? "36px" : 0,
  420. },
  421. };
  422. }
  423. }
  424. }
  425. return {
  426. container: {},
  427. fingerBox: {},
  428. };
  429. });
  430. /** 节奏律动配置 */
  431. const rhythmConfig = computed<any>(()=>{
  432. if(headTopData.rhythmMode){
  433. if(headTopData.rhythmModeDirection === "vertical"){
  434. if(state.platform === IPlatform.PC && state.playBtnDirection === "left") {
  435. return {
  436. container: {
  437. paddingLeft: "4.6rem"
  438. },
  439. rhythmBox: {
  440. width: "4.6rem",
  441. position: "absolute",
  442. height: "100%",
  443. left: 0,
  444. top: 0
  445. },
  446. };
  447. }else{
  448. return {
  449. container: {
  450. paddingRight: "4.6rem"
  451. },
  452. rhythmBox: {
  453. width: "4.6rem",
  454. position: "absolute",
  455. height: "100%",
  456. right: 0,
  457. top: 0
  458. },
  459. };
  460. }
  461. }else{
  462. return {
  463. container: {
  464. paddingBottom: "2.5rem"
  465. },
  466. rhythmBox: {
  467. height: "2.5rem",
  468. position: "absolute",
  469. width: "100%",
  470. left: 0,
  471. bottom: 0,
  472. },
  473. };
  474. }
  475. }
  476. return {
  477. container: {},
  478. rhythmBox: {},
  479. };
  480. })
  481. // 监听指法显示
  482. watch(
  483. () => state.setting.displayFingering,
  484. () => {
  485. if (state.fingeringInfo.direction === "vertical") {
  486. // if (state.setting.displayFingering) {
  487. // state.musicScoreBtnDirection = state.playBtnDirection === 'left' ? 'right' : 'left'
  488. // } else {
  489. // state.musicScoreBtnDirection = state.playBtnDirection
  490. // }
  491. state.musicScoreBtnDirection = state.playBtnDirection;
  492. }
  493. }
  494. );
  495. watch(
  496. () => state.setting.soundEffect,
  497. () => {
  498. store.set("musicscoresetting", state.setting);
  499. }
  500. );
  501. /**播放状态改变时,向父页面发送事件 */
  502. const sendParentMessage = (playState: IAudioState) => {
  503. window.parent.postMessage(
  504. {
  505. api: "headerTogge",
  506. playState: playState,
  507. },
  508. "*"
  509. );
  510. };
  511. // 监听播放状态
  512. watch(
  513. () => state.playState,
  514. () => {
  515. // if (state.platform != IPlatform.PC) {
  516. // headerColumnHide.value = state.playState === "play" ? true : false;
  517. // }
  518. headerColumnHide.value = state.playState === "play" ? true : false;
  519. sendParentMessage(state.playState);
  520. }
  521. );
  522. // 监听跟练的开启状态
  523. watch(
  524. () => followData.practiceStart,
  525. () => {
  526. headerColumnHide.value = followData.practiceStart;
  527. }
  528. );
  529. // 监听开始评测状态
  530. watch(
  531. () => evaluatingData.startBegin,
  532. () => {
  533. headerColumnHide.value = evaluatingData.startBegin;
  534. }
  535. );
  536. /** 指法预览切换 */
  537. watch(
  538. () => detailData.fingerPreView,
  539. () => {
  540. console.log(2342);
  541. window.parent.postMessage(
  542. {
  543. api: "api_fingerPreView",
  544. state: detailData.fingerPreView,
  545. },
  546. "*"
  547. );
  548. }
  549. );
  550. const pageVisible = usePageVisibility();
  551. watch(
  552. () => pageVisible.value,
  553. (val) => {
  554. if (val === "hidden") {
  555. // 如果是播放状态,需要暂停播放
  556. // console.log("页面隐藏停止播放");
  557. if (state.playState === "play") {
  558. togglePlay("paused");
  559. }
  560. }
  561. }
  562. );
  563. const handleOpenFignerView = () => {
  564. if (!query.modelType) {
  565. detailData.orientation = state.fingeringInfo.orientation || 0;
  566. api_setRequestedOrientation(detailData.orientation);
  567. }
  568. // const url = `${
  569. // /(192|localhost)/.test(location.origin)
  570. // ? "http://192.168.3.114:3000/instrument.html"
  571. // : location.origin + location.pathname
  572. // }#/view-figner`;
  573. // console.log("🚀 ~ url:", url);
  574. // api_openWebView({
  575. // url: url,
  576. // orientation: state.fingeringInfo.orientation || 0,
  577. // });
  578. if (state.playState === "play") {
  579. togglePlay("paused");
  580. setTimeout(() => {
  581. detailData.fingerPreView = true;
  582. }, 500);
  583. return;
  584. }
  585. detailData.fingerPreView = true;
  586. };
  587. const handleCloseFignerView = () => {
  588. if (!query.modelType && detailData.orientation == 1) {
  589. api_setRequestedOrientation(0);
  590. }
  591. detailData.fingerPreView = false;
  592. detailData.fingerPreViewGuide = false;
  593. };
  594. return () => (
  595. <div
  596. class={[styles.detail, styles[state.modeType], state.setting.eyeProtection && "eyeProtection", state.platform === IPlatform.PC && state.zoom > 0.8 && styles.PC, state.isPreView && styles.preViewDetail, state.isCbsView && styles.cbsViewDetail]}
  597. style={{
  598. "--detailDataPaddingLeft": detailData.paddingLeft,
  599. paddingLeft: detailData.paddingLeft,
  600. background: state.setting.camera && state.modeType === 'evaluating' ? `rgba(${state.setting.eyeProtection ? "253,244,229" : "255,255,255"} ,${state.setting.cameraOpacity / 100}) !important` : "",
  601. }}
  602. >
  603. {bgJsonData.value ?
  604. <img
  605. style={{opacity: state.setting.camera && state.modeType === 'evaluating' ? state.setting.cameraOpacity / 100 : 1}}
  606. class={styles.pageBg}
  607. src={state.modeType === 'practise' ? bgJsonData.value[1] : state.modeType === 'evaluating' ? bgJsonData.value[2] : state.modeType === 'follow' ? bgJsonData.value[3] : ''}
  608. /> : <div
  609. style={{opacity: state.setting.camera && state.modeType === 'evaluating' ? state.setting.cameraOpacity / 100 : 1}}
  610. class={[styles.pageBg]} >
  611. </div>
  612. }
  613. {/* 骨架屏 */}
  614. {/* <Transition name="van-fade">
  615. {detailData.skeletonLoading && (
  616. <div class={styles.skeleton}>
  617. <Skeleton row={8} />
  618. </div>
  619. )}
  620. </Transition> */}
  621. {/* 曲目加载错误的缺省 */}
  622. <EmptyMusic></EmptyMusic>
  623. {/** 功能按钮 */}
  624. {!state.isPreView && <div class={["headHeight", styles.headHeight, headerColumnHide.value && styles.headHide]}>{state.musicRendered && <HeaderTop />}</div>}
  625. <div
  626. id="scrollContainer"
  627. style={{ ...fingerConfig.value.container, ...rhythmConfig.value.container }}
  628. class={[styles.container, !state.setting.displayCursor && "hideCursor", browsInfo.xiaomi && styles.xiaomi, state.platform === IPlatform.PC && styles.pcContainer]}
  629. onClick={(e: Event) => {
  630. e.stopPropagation();
  631. // if (state.playState === "play" && state.platform != IPlatform.PC) {
  632. // headerColumnHide.value = !headerColumnHide.value;
  633. // }
  634. // 点击谱面跟练也需要切换显示按钮栏
  635. if (state.playState === "play" || followData.start || evaluatingData.startBegin) {
  636. headerColumnHide.value = !headerColumnHide.value;
  637. }
  638. }}
  639. >
  640. {/* 曲谱渲染 */}
  641. {!detailData.isLoading &&
  642. <MusicScore
  643. ref={musicScoreRef}
  644. musicColor={'#000000'}
  645. showPartNames={state.isCombineRender}
  646. onRendered={handleOnRendered}
  647. >
  648. {/* 旋律线关闭时候的 标题和作者 */}
  649. <AuthorName></AuthorName>
  650. {/* 节拍器 */}
  651. {!detailData.isLoading && !detailData.skeletonLoading && <Tick />}
  652. </MusicScore>
  653. }
  654. {/* {
  655. state.musicRendered &&
  656. <TestCheck />
  657. } */}
  658. {/* 指法 */}
  659. {state.setting.displayFingering && state.fingeringInfo?.name && !state.isPreView && state.isShowFingering && (
  660. <div style={{ ...fingerConfig.value.fingerBox }} class={styles.fingeringCon}>
  661. <Fingering
  662. ref={fingerRef}
  663. style={{
  664. background: state.setting.camera ? `rgba(${state.setting.eyeProtection ? "253,244,229" : "255,255,255"} ,${state.setting.cameraOpacity / 100})` : "",
  665. }}
  666. onOpen={() => handleOpenFignerView()}
  667. />
  668. </div>
  669. )}
  670. {/* 节奏律动 */}
  671. {
  672. headTopData.rhythmMode &&
  673. <div style={{ ...rhythmConfig.value.rhythmBox}}>
  674. <Rhythm></Rhythm>
  675. </div>
  676. }
  677. </div>
  678. {/* 曲目渲染时,同步下载mp3资源 */}
  679. {!detailData.isLoading && <AudioList />}
  680. {/* {!detailData.isLoading && !detailData.skeletonLoading && <AudioList />} */}
  681. {/* {!detailData.isLoading && <TheAudio src={tickWav} />} */}
  682. {/* 预加载延迟检测组建 */}
  683. {/* {!detailData.isLoading && !detailData.skeletonLoading && evaluatingData.preloadJson && !evaluatingData.jsonLoadDone && (
  684. <div class={styles.preJson}>
  685. <DelayCheck isPreLoad={true} />
  686. </div>
  687. )} */}
  688. {/* 评测 */}
  689. {state.modeType === "evaluating" && (
  690. <>
  691. <Evaluating />
  692. {evaluatingData.rendered && <EvaluatModel />}
  693. </>
  694. )}
  695. {/* 跟练模式 */}
  696. {state.modeType === "follow" && (
  697. <>
  698. <FollowPractice />
  699. <FollowModel />
  700. </>
  701. )}
  702. {/* 切换曲谱 */}
  703. {!query.lessonTrainingId && !query.questionId && state.isConcert && <ToggleMusicSheet />}
  704. {state.musicRendered && !state.isPreView && (
  705. <>
  706. {/* 统计训练时长 */}
  707. {storeData.isApp && <RecordingTime />}
  708. {/* 作业 */}
  709. {query.workRecord && <WorkIndex />}
  710. {/* 曲谱列表 */}
  711. {isMusicList.value && <TheMusicList />}
  712. </>
  713. )}
  714. <Loading tipText={state.loadingText} />
  715. <LoadingCss />
  716. <Popup
  717. zIndex={5050}
  718. teleport="body"
  719. v-model:show={detailData.fingerPreView}
  720. position="bottom"
  721. onClosed={() => {
  722. detailData.fingerPreViewAnimation = false;
  723. }}
  724. onOpen={() => {
  725. detailData.fingerPreViewAnimation = true;
  726. }}
  727. onOpened={() => {
  728. detailData.fingerPreViewGuide = true;
  729. }}
  730. >
  731. {detailData.fingerPreViewAnimation && <ViewFigner show={detailData.fingerPreViewGuide} subject={state.fingeringInfo.name} isComponent={true} onClose={handleCloseFignerView} />}
  732. </Popup>
  733. </div>
  734. );
  735. },
  736. });