Browse Source

Merge branch 'feature-tianyong-newVersion' of http://git.dayaedu.com/liushengqiang/music-score into hqyDevNewVersion

黄琪勇 11 months ago
parent
commit
5dc54f9846

+ 33 - 1
src/helpers/customMusicScore.ts

@@ -236,6 +236,38 @@ export const moveGracePosition = (needTrans?: boolean) => {
 	}
 }
 
+// 处理一行谱高度太高的问题
+export const limitSingleSvgPageHeight = () => {
+	if (state.isSingleLine && !state.isCombineRender) {
+		// 获取生成的 SVG 元素
+		const osmdSvgPage = document.getElementById('osmdSvgPage1');
+		if (osmdSvgPage) {
+			// 获取当前的 viewBox 值
+			const viewBox = osmdSvgPage.getAttribute('viewBox');
+			if (viewBox) {
+				// 分割 viewBox 的值,viewBox 形式为 "min-x min-y width height"
+				const viewBoxValues = viewBox.split(' ');
+				// 修改 viewBox 高度
+				const newHeight = 300;
+				const staffHeight = osmdSvgPage.querySelector('.staffline')?.getBoundingClientRect()?.height;
+				if (viewBoxValues[3] > 300 && staffHeight && staffHeight < 240) {
+					const originY = state.isSimplePage ? 0 : 0.25;
+					let transY = (240 - staffHeight * state.zoom) / staffHeight;
+					transY = state.isSimplePage ? transY / 2 : transY;
+					const realY = (originY + transY) * 100 + '%';
+					viewBoxValues[3] = newHeight; // 这是第四个值,代表高度
+					// 设置新的 viewBox 值
+					osmdSvgPage.setAttribute('viewBox', viewBoxValues.join(' '));
+					osmdSvgPage.setAttribute('height','240');
+					// @ts-ignore
+					osmdSvgPage.querySelector('.staffline').style.transform = `translateY(-${realY})`
+				}
+			}
+		}
+	}
+
+}
+
 // 谱面优化
 export const resetFormate = () => {
 	container.value = document.getElementById('scrollContainer')
@@ -594,7 +626,7 @@ const transSinglePage = () => {
 	if (state.isSingleLine && !state.isSimplePage) {
 		const svgPage = document?.getElementById('osmdSvgPage1')?.getBoundingClientRect();
 		const staffLine = document?.querySelector('.staffline')?.getBoundingClientRect();
-		if (svgPage && staffLine && svgPage.height > 200 && state.platform !== 'PC') {
+		if (svgPage && staffLine && svgPage.height > 200) {
 			// 需要上移的距离
 			// console.log('need',svgPage.height,staffLine.height)
 			const rate = svgPage.height > 400 ? 1.2 : 2;

+ 1 - 1
src/page-instrument/header-top/settting/index.tsx

@@ -50,7 +50,7 @@ export default defineComponent({
                 <div class={styles.content}>
                     <div class={styles.conBox}>
                         {
-                            state.isShowFingering && state.fingeringInfo.name && ["practise", "follow"].includes(state.modeType) && state.playType === "play" &&
+                            state.isShowFingering && state.fingeringInfo.name && ["practise", "follow", "evaluating"].includes(state.modeType) && state.playType === "play" &&
                                 <div class={styles.cellBox}>
                                 <div class={styles.tit}>指法</div>
                                     <Switch v-model={state.setting.displayFingering}></Switch>

+ 2 - 2
src/page-instrument/header-top/speed/index.tsx

@@ -100,8 +100,8 @@ export default defineComponent({
 			} catch (error) {
 			  console.log(error)
 			} finally {
-				state.isLoading = false;
-				switchLoading.value = false;
+				// state.isLoading = false;
+				// switchLoading.value = false;
 			}
 		};
 		return () => (

+ 22 - 22
src/utils/index.ts

@@ -5,31 +5,31 @@ import { getQuery } from "./queryString";
 export const browser = () => {
 	const u = navigator.userAgent;
 	const isAndroid = /(?:Android)/.test(u);
- 	const isFireFox = /(?:Firefox)/.test(u);
+  	const isFireFox = /(?:Firefox)/.test(u);
 	function isIpadFun() {
-		const ua = window.navigator.userAgent;
-		let IsIPad = false;
-		if (/ipad/i.test(ua)) {
-			IsIPad = true;
-		}
-		// iPad from IOS13
-		const macApp = ua.match(/Macintosh/i) != null;
-		if (macApp) {
-			// need to distinguish between Macbook and iPad
-			const canvas = document.createElement('canvas');
-			if (canvas != null) {
-			const context: any =
-				canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
-			if (context) {
-				const info = context.getExtension('WEBGL_debug_renderer_info');
-				if (info) {
-				const renderer = context.getParameter(info.UNMASKED_RENDERER_WEBGL);
-				if (renderer.indexOf('Apple') != -1) IsIPad = true;
-				}
-			}
+	const ua = window.navigator.userAgent;
+	let IsIPad = false;
+	if (/ipad/i.test(ua)) {
+		IsIPad = true;
+	}
+	// iPad from IOS13
+	const macApp = ua.match(/Macintosh/i) != null;
+	if (macApp) {
+		// need to distinguish between Macbook and iPad
+		const canvas = document.createElement('canvas');
+		if (canvas != null) {
+		const context: any =
+			canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
+		if (context) {
+			const info = context.getExtension('WEBGL_debug_renderer_info');
+			if (info) {
+			const renderer = context.getParameter(info.UNMASKED_RENDERER_WEBGL);
+			if (renderer.indexOf('Apple') != -1) IsIPad = true;
 			}
 		}
-		return IsIPad;
+		}
+	}
+	return IsIPad;
 	}	
 	return {
 		trident: u.indexOf("Trident") > -1, //IE内核

+ 3 - 2
src/view/audio-list/index.tsx

@@ -86,8 +86,8 @@ export const setAudioPlaybackRate = (rate: number) => {
 
 /** 获取当前播放的时间 */
 export const getAudioCurrentTime = () => {
-	// 如果是midi播放
-	if (state.isAppPlay) {
+	// 如果是midi播放,或者是评测
+	if (state.isAppPlay || state.modeType === 'evaluating') {
 		// const c = getMidiCurrentTime();
 		return audioData.progress;
 	}
@@ -277,6 +277,7 @@ export default defineComponent({
 				res?.content?.totalDuration > 1000 &&
 				currentTime >= total
 			) {
+				console.log('播放结束1111',evaluatingData.isAudioPlayEnd,currentTime,total)
 				if (evaluatingData.isAudioPlayEnd) return
 				evaluatingData.isAudioPlayEnd = true
 				onEnded();

+ 3 - 4
src/view/evaluating/index.tsx

@@ -421,13 +421,12 @@ export const handleStartBegin = async (preTimes?: number) => {
 	// 	accompanimentState: state.setting.enableAccompaniment ? 1 : 0,
 	// 	firstNoteTime: preTimes || 0,
 	// });
-	let rate = state.speed / state.originSpeed;
-	rate = parseFloat(rate.toFixed(2));
+  const rate = state.basePlayRate * state.originAudioPlayRate; // 播放倍率
 	await api_startRecordingCb({
 		// accompanimentState: state.setting.enableAccompaniment ? 1 : 0,
 		accompanimentState: !state.accompany ? 0 : 1, // 评测没有伴奏时,静音播放
 		firstNoteTime: preTimes || 0,
-		speedRate: rate, // 播放倍率
+    speedRate: parseFloat(rate.toFixed(2)), // 播放倍率
 	}, () => {
 		if (state.isAppPlay) {
 			setTimeout(() => {
@@ -633,6 +632,7 @@ export const handleViewReport = (key: "recordId" | "recordIdStr", type: "gym" |
     statusBarTextColor: false,
     isOpenLight: true,
     c_orientation: 0,
+    showLoadingAnim: true
   });
 };
 
@@ -651,7 +651,6 @@ const handleAccompanyError = (res?: IPostMessage) => {
   if (res?.content) {
     const { type, reson } = res.content;
     state.playState = 'paused'
-    evaluatingData.startBegin = false
     switch (type) {
       case "enterBackground":
       // App退到后台

+ 6 - 0
src/view/fingering/index.tsx

@@ -2,6 +2,8 @@ import { computed, defineComponent, onBeforeMount, reactive } from "vue";
 import styles from "./index.module.less";
 import state from "/src/state";
 import { getFingeringConfig, ITypeFingering } from "./fingering-config";
+import { evaluatingData } from "/src/view/evaluating";
+import { followData } from "/src/view/follow-practice/index"
 
 export default defineComponent({
   name: "fingering",
@@ -34,6 +36,10 @@ export default defineComponent({
     });
 
     const doubeClick = () => {
+      // 如果在评测和跟练中,双击指法不跳转
+      if ((state.modeType === 'evaluating' && evaluatingData.startBegin) || (state.modeType === 'follow' && followData.start)) {
+        return;
+      }
       const nowTime = Date.now();
       if (nowTime - fingerData.delay < 300) {
         emit("open");

+ 1 - 1
src/view/music-score/index.tsx

@@ -7,7 +7,7 @@ import Selection from "../selection";
 import styles from "./index.module.less";
 import queryString from "query-string";
 import { getGradualLengthByXml } from "/src/helpers/calcSpeed";
-import { resetFormate, resetGivenFormate, setGlobalMusicSheet } from "/src/helpers/customMusicScore"
+import { resetFormate, resetGivenFormate, setGlobalMusicSheet, limitSingleSvgPageHeight } from "/src/helpers/customMusicScore"
 import { setGlobalData } from "/src/utils";
 import Loading from "/src/view/audio-list/loading"
 import { storeData } from "/src/store";