Ver código fonte

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

TIANYONG 8 meses atrás
pai
commit
7325b217cc

+ 2 - 2
src/page-instrument/evaluat-model/evaluat-result/index.module.less

@@ -145,7 +145,7 @@
             margin-bottom: -2px;
             font-size: 38px;
             font-family: DIN-Bold, DIN;
-            margin-bottom: -4px;
+            margin-bottom: -3px;
         }
 
         .rightBadge {
@@ -318,7 +318,7 @@
         }
         .scoresNum{
             font-family: DIN-Bold, DIN;
-            margin-bottom: -2px;
+            margin-bottom: -1px;
         }
     }
 

+ 11 - 6
src/page-instrument/header-top/index.tsx

@@ -294,7 +294,8 @@ export default defineComponent({
     /** 速度按钮 */
     const speedBtn = computed(() => {
       // 选择模式, 跟练模式  不显示
-      if (headTopData.modeType !== "show" || state.modeType === "follow") return { display: false, disabled: true };
+      //if (headTopData.modeType !== "show" || state.modeType === "follow") return { display: false, disabled: true };
+      if (state.modeType === "follow") return { display: false, disabled: true };
       // 评测模式, 音频播放中 禁用
       if (state.modeType === "evaluating" || state.playState === "play") return { display: true, disabled: true };
 
@@ -306,7 +307,7 @@ export default defineComponent({
     /** 节拍器按钮 */
     const metronomeBtn = computed(() => {
       // 选择模式  不显示
-      if (headTopData.modeType !== "show") return { display: false, disabled: true };
+      //if (headTopData.modeType !== "show") return { display: false, disabled: true };
       // 音频播放中 禁用
       if (state.playState === "play") return { display: true, disabled: true };
       return {
@@ -320,7 +321,8 @@ export default defineComponent({
       // 后台设置不显示指法
       if (!state.isShowFingering) return { display: true, disabled: true };
       // 没有指法 选择模式 评测模式 跟练模式 不显示
-      if (headTopData.modeType !== "show" || !state.fingeringInfo.name || ["evaluating", "follow"].includes(state.modeType)) return { display: false, disabled: true };
+      //if (headTopData.modeType !== "show" || !state.fingeringInfo.name || ["evaluating", "follow"].includes(state.modeType)) return { display: false, disabled: true };
+      if (!state.fingeringInfo.name || ["evaluating", "follow"].includes(state.modeType)) return { display: false, disabled: true };
       // 音频播放中 禁用
       if (state.playState === "play") return { display: true, disabled: true };
 
@@ -346,7 +348,8 @@ export default defineComponent({
     /** 选段按钮 */
     const selectBtn = computed(() => {
       // 选择模式 不显示
-      if (headTopData.modeType !== "show" || ["follow"].includes(state.modeType)) return { display: false, disabled: true };
+      //if (headTopData.modeType !== "show" || ["follow"].includes(state.modeType)) return { display: false, disabled: true };
+      if (["follow"].includes(state.modeType)) return { display: false, disabled: true };
       // 音频播放中 禁用
       if (state.playState === "play" || query.workRecord) return { display: true, disabled: true };
 
@@ -361,7 +364,8 @@ export default defineComponent({
       // 没有音源不显示
       if(state.noMusicSource) return { display: false, disabled: false };
       // 选择模式,跟练模式 不显示
-      if (headTopData.modeType !== "show" || state.modeType === "follow") return { display: false, disabled: false };
+      //if (headTopData.modeType !== "show" || state.modeType === "follow") return { display: false, disabled: false };
+      if (state.modeType === "follow") return { display: false, disabled: false };
       // 评测开始 禁用
       if (state.modeType === "evaluating") return { display: false, disabled: true };
       if (!state.isAppPlay) {
@@ -391,7 +395,8 @@ export default defineComponent({
     /** 播放类型按钮 */
     const playTypeBtn = computed(() => {
       // 选择模式,跟练模式,评测模式 不显示
-      if (headTopData.modeType !== "show" || state.modeType === "follow" || state.modeType === "evaluating" || query.workRecord) return { display: false, disabled: false };
+      //if (headTopData.modeType !== "show" || state.modeType === "follow" || state.modeType === "evaluating" || query.workRecord) return { display: false, disabled: false };
+      if (state.modeType === "follow" || state.modeType === "evaluating" || query.workRecord) return { display: false, disabled: false };
       if (!state.isAppPlay) {
         let index = 0;
         state.music && index++;

BIN
src/page-instrument/view-detail/images/bg2_right_zs.png


+ 2 - 2
src/page-instrument/view-detail/index.tsx

@@ -328,7 +328,7 @@ export default defineComponent({
                 height: state.fingeringInfo.name === "hulusi-flute" ? "86%" : "80%",
                 right: state.playBtnDirection === "right" ? "initial" : 0,
                 left: state.playBtnDirection === "right" ? 0 : "initial",
-                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") ? "40px" : 0,
+                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,
               },
             };
           } else {
@@ -341,7 +341,7 @@ export default defineComponent({
                 width: state.fingeringInfo.width,
                 height: state.fingeringInfo.name === "hulusi-flute" ? "86%" : "80%",
                 left: 0,
-                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") ? "40px" : 0,
+                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,
               },
             };
           }

+ 0 - 1
src/page-instrument/view-detail/intonationLine/index.less

@@ -2,7 +2,6 @@
     .intonationLineBox{
         display: flex;
         align-items: center;
-        height: 2.4rem;
     }
     .intonationLineCon{
         position: relative;

+ 3 - 1
src/page-instrument/view-detail/smoothAnimation/index.less

@@ -9,7 +9,6 @@
     .smoothAnimationBox{
         display: flex;
         align-items: center;
-        height: 2.4rem;
         &.smoothAnimationBoxHide{
             opacity: 0;
             visibility: hidden;
@@ -24,6 +23,9 @@
             left: 0;
             top: 0;
         }
+        .smoothCanvas{
+            display: block;
+        }
     }
     #osmdCanvasPage1{
         top: 0;

+ 8 - 7
src/page-instrument/view-detail/smoothAnimation/index.ts

@@ -27,13 +27,14 @@ type smoothAnimationType = {
 }
 
 const _numberOfSegments = 58 // 中间切割线的个数
+const _canvasDomHeight = 60
 
 export const smoothAnimationState = {
    isShow: ref(false), // 是否显示
    canvasDom: null,
    canvasCtx: null,
    canvasDomWith: 0,
-   canvasDomHeight: 80,
+   canvasDomHeight: _canvasDomHeight,
    smoothAnimationBoxDom: null,
    smoothBotDom: null,
    osmdCanvasPageDom: null,
@@ -104,7 +105,7 @@ function dataFilter(batePos: pointsPosType) {
 
 //给原始数据赋值
 function dataFilter2(batePos1: pointsPosType, batePos2: pointsPosType) {
-   return batePos1.reduce((arr: pointsPosType, { noteId, MeasureNumberXML }, index) => {
+   return batePos1.reduce((arr: pointsPosType, { noteId, MeasureNumberXML }) => {
       const noteIdIndex = batePos2.findIndex(item => {
          return noteId === item.noteId && MeasureNumberXML === item.MeasureNumberXML
       })
@@ -123,7 +124,7 @@ export function destroySmoothAnimation() {
       canvasDom: null,
       canvasCtx: null,
       canvasDomWith: 0,
-      canvasDomHeight: 80,
+      canvasDomHeight: _canvasDomHeight,
       smoothAnimationBoxDom: null,
       smoothBotDom: null,
       osmdCanvasPageDom: null,
@@ -350,7 +351,7 @@ function getPointsPosByBatePos(): pointsPosType {
       return !item.frequency || item.frequency === -1 ? 0 : item.frequency
    })
    // 线性频率数据
-   const frequencyLineData = quantileScale(frequencyData, 6, 74)
+   const frequencyLineData = quantileScale(frequencyData, 8, _canvasDomHeight - 8)
    const pointsPos = state.times.reduce((posArr: any[], item, index) => {
       // 当休止小节,可能当前音符在谱面上没有实际的音符(没有bbox)
       if (item.bbox?.x != null && item.noteId != null) {
@@ -358,7 +359,7 @@ function getPointsPosByBatePos(): pointsPosType {
             noteId: item.noteId,
             MeasureNumberXML: item.MeasureNumberXML,
             x: item.bbox.x,
-            y: 80 - frequencyLineData[index]
+            y: _canvasDomHeight - frequencyLineData[index]
          })
       } else {
          // 连续休止小节 noteId 可能为 null,所以这里取上一个音符的id
@@ -367,7 +368,7 @@ function getPointsPosByBatePos(): pointsPosType {
             noteId: item.noteId != null ? item.noteId : (posArr[posArr.length - 1]?.noteId != null ? posArr[posArr.length - 1]?.noteId : -1) + 0.01, // 这里+0.01 是制造一个假id
             MeasureNumberXML: item.MeasureNumberXML,
             x: item.bbox?.x != null ? item.bbox.x : posArr[posArr.length - 1]?.x || 10,
-            y: 80 - frequencyLineData[index]
+            y: _canvasDomHeight - frequencyLineData[index]
          })
       }
       return posArr
@@ -385,7 +386,7 @@ function getPointsPosByBatePos(): pointsPosType {
 }
 
 // 数据平滑算法
-function quantileScale(data: number[], minRange = 0, maxRange = 80) {
+function quantileScale(data: number[], minRange = 0, maxRange = _canvasDomHeight) {
    const sortedData = [...data].sort((a, b) => a - b)
    return data.map(value => {
       const rank = sortedData.indexOf(value) / (sortedData.length - 1)

+ 58 - 29
src/page-instrument/view-evaluat-report/component/share-top/index.tsx

@@ -104,7 +104,7 @@ export default defineComponent({
 						shareData._plrl.on('pause', () => {
 							pauseVisualDraw()
 						});
-					}, 500); // 弹窗动画是0.25秒 这里用定时器 确保canvas 能获取到宽高
+					}, 600); // 弹窗动画是0.25秒 这里用定时器 确保canvas 能获取到宽高
 				}
 				shareData.isInitPlyr = true;
 			});
@@ -123,10 +123,10 @@ export default defineComponent({
 			canvasDom.width = width
 			canvasDom.height = height
 			// audio
-			let audioCtx : AudioContext | null = null
-			let analyser : AnalyserNode | null = null
-			let source : MediaElementAudioSourceNode | null = null
-			const dataArray = new Uint8Array(fftSize / 2)
+			// let audioCtx : AudioContext | null = null
+			// let analyser : AnalyserNode | null = null
+			// let source : MediaElementAudioSourceNode | null = null
+			// const dataArray = new Uint8Array(fftSize / 2)
 			const draw = (data: Uint8Array, ctx: CanvasRenderingContext2D, { lineGap, canvWidth, canvHeight, canvFillColor, lineColor }: propsType) => {
 				if (!ctx) return
 				const w = canvWidth
@@ -172,30 +172,44 @@ export default defineComponent({
 				ctx.fillRect(0, 0, w, h)
 			}
 			const requestAnimationFrameFun = () => {
-				requestAnimationFrame(() => {
-					analyser?.getByteFrequencyData(dataArray)
-					draw(dataArray, canvasCtx, {
-						lineGap: 2,
-						canvWidth: width,
-						canvHeight: height,
-						canvFillColor: "transparent",
-						lineColor: "rgba(255, 255, 255, 0.3)"
-					})
-					if (!isPause) {
-						requestAnimationFrameFun()
-					}
-				})
+				// requestAnimationFrame(() => {
+				// 	//analyser?.getByteFrequencyData(dataArray)
+				// 	draw(generateMixedData(48), canvasCtx, {
+				// 		lineGap: 2,
+				// 		canvWidth: width,
+				// 		canvHeight: height,
+				// 		canvFillColor: "transparent",
+				// 		lineColor: "rgba(255, 255, 255, 0.3)"
+				// 	})
+				// 	if (!isPause) {
+				// 		requestAnimationFrameFun()
+				// 	}
+				// })
+        const _time = setInterval(() => {
+          if (isPause) {
+            clearInterval(_time)
+            return
+          }
+          //analyser?.getByteFrequencyData(dataArray)
+          draw(generateMixedData(38), canvasCtx, {
+            lineGap: 3,
+            canvWidth: width,
+            canvHeight: height,
+            canvFillColor: "transparent",
+            lineColor: "rgba(255, 255, 255, 0.3)"
+          })
+        }, 300);
 			}
 			let isPause = true
 			const playVisualDraw = () => {
-				if (!audioCtx) {
-					audioCtx = new AudioContext()
-					source = audioCtx.createMediaElementSource(audioDom)
-					analyser = audioCtx.createAnalyser()
-					analyser.fftSize = fftSize
-					source?.connect(analyser)
-					analyser.connect(audioCtx.destination)
-				}
+				// if (!audioCtx) {
+				// 	audioCtx = new AudioContext()
+				// 	source = audioCtx.createMediaElementSource(audioDom)
+				// 	analyser = audioCtx.createAnalyser()
+				// 	analyser.fftSize = fftSize
+				// 	source?.connect(analyser)
+				// 	analyser.connect(audioCtx.destination)
+				// }
 				//audioCtx.resume()  // 重新更新状态   加了暂停和恢复音频音质发生了变化  所以这里取消了
 				isPause = false
 				requestAnimationFrameFun()
@@ -214,7 +228,22 @@ export default defineComponent({
 				pauseVisualDraw
 			}
 		}
-
+    function generateMixedData(size:number) {
+      const dataArray = new Uint8Array(size);
+      const baseNoiseAmplitude = 30;
+      const minFrequency = 0.01;
+      const maxFrequency = 0.2;
+      const minAmplitude = 50;
+      const maxAmplitude = 150;
+      for (let i = 0; i < size; i++) {
+          const frequency = minFrequency + Math.random() * (maxFrequency - minFrequency);
+          const amplitude = minAmplitude + Math.random() * (maxAmplitude - minAmplitude);
+          const wave = amplitude * (0.5 + 0.5 * Math.sin(frequency * i));
+          const noise = Math.floor(Math.random() * baseNoiseAmplitude) - baseNoiseAmplitude / 2;
+          dataArray[i] = Math.min(255, Math.max(0, Math.floor(wave + noise)));
+      }
+      return dataArray;
+    }
     return () => (
       <>
         <div class={[styles.headerTop, browserInfo.android && styles.android]}>
@@ -233,7 +262,7 @@ export default defineComponent({
 
           {/* 音准、节奏、完整度纬度 */}
 
-          <div class={[styles.middle, isPad.value && styles.padMiddle]}>
+          <div class={[styles.middle, isPad && styles.padMiddle]}>
             {state.isPercussion ? null : (
               <div onClick={() => handleChange("intonation")} class={[styles.cItem, "evaluting-report-1", itemType.value === "intonation" && styles.active]}>
                 <span class={styles.mScore}>{scoreData.value.intonation}分</span>
@@ -436,7 +465,7 @@ export default defineComponent({
               shareData._plrl?.pause();
             }}
           >
-            <div class={[styles.playerBox, isPad.value && styles.padPlayerBox]}>
+            <div class={[styles.playerBox, isPad && styles.padPlayerBox]}>
               {mediaType.value === "audio" ? (
                 <div class={styles.audioBox}>
                   <canvas class={styles.audioVisualizer} id="audioVisualizer"></canvas>

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

@@ -125,7 +125,7 @@ export default defineComponent({
 				osmd.EngravingRules.PageBottomMargin = 0;
 			} else {
 				// osmd.EngravingRules.PageTopMargin = state.isEvaluatReport ? 7 : 3; // 顶部间距
-				osmd.EngravingRules.PageTopMargin = 3;
+				osmd.EngravingRules.PageTopMargin = state.isPreView ? 1 : 3;
 				osmd.EngravingRules.PageTopMarginNarrow = 3;
 				osmd.EngravingRules.PageLeftMargin = 3.6;
 				osmd.EngravingRules.PageRightMargin = 3;

+ 1 - 1
vite.config.ts

@@ -76,7 +76,7 @@ export default defineConfig({
         // target: "https://kt.colexiu.com",
         // target: "https://test.lexiaoya.cn",
         // target: "https://kt.colexiu.com",
-        //target: "https://dev.resource.colexiu.com", // 内容平台开发环境,内容平台开发,需在url链接上加上isCbs=true
+        //target: "https://test.resource.colexiu.com", // 内容平台开发环境,内容平台开发,需在url链接上加上isCbs=true
         target: "https://test.kt.colexiu.com",
         //target: "https://mec.colexiu.com",
         changeOrigin: true,