Jelajahi Sumber

Merge branch 'feature-patch' into gym-test

TIANYONG 1 bulan lalu
induk
melakukan
58d8d68223
3 mengubah file dengan 12 tambahan dan 1 penghapusan
  1. 5 1
      src/state.ts
  2. 5 0
      src/utils/index.ts
  3. 2 0
      src/view/evaluating/index.tsx

+ 5 - 1
src/state.ts

@@ -8,7 +8,7 @@ import { IFingering, mappingVoicePart, subjectFingering, matchVoicePart } from "
 import { handleStartTick, closeTick } from "./view/tick";
 import { audioListStart, getAudioCurrentTime, getAudioDuration, setAudioCurrentTime, setAudioPlaybackRate, audioData } from "./view/audio-list";
 import { toggleFollow } from "./view/follow-practice";
-import { browser, setStorageSpeed, setGlobalData } from "./utils";
+import { browser, setStorageSpeed, setGlobalData, checkDecimal } from "./utils";
 import { api_cloudGetMediaStatus, api_createMusicPlayer, api_cloudChangeSpeed, api_cloudSuspend, api_cloudSetCurrentTime, api_cloudDestroy } from "./helpers/communication";
 import { verifyCanRepeat, getDuration, xmlAddPartName } from "./helpers/formateMusic";
 import { getMusicSheetDetail, getInstrumentCode } from "./utils/baseApi"
@@ -616,6 +616,10 @@ export const skipNotePlay = async (itemIndex: number, isStart = false, handType?
     if (item.measureSpeed && state.section.length < 2) {
       // console.log('速度3')
       state.speed = state.basePlayRate * 10000 * item.measureSpeed / 10000
+      // 如果是接近整数的小数,则取整
+      if ( checkDecimal(state.speed) ) {
+        state.speed = Math.round(state.speed)
+      }
     }
     setAudioCurrentTime(itemTime, itemIndex);
     // 一行谱,点击音符,或者播放完成,需要跳转音符位置

+ 5 - 0
src/utils/index.ts

@@ -158,4 +158,9 @@ export const debounce = (fn: Function, ms = 0) => {
 	  // @ts-ignore
 	  timeoutId = setTimeout(() => fn.apply(this, args), ms);
 	}
+}
+
+// 使用正则表达式匹配小数点后第一位数字是否是 0 或 9
+export const checkDecimal = (num: number | string) => {
+	return /^\d*\.(0|9)/.test(num.toString());
 }

+ 2 - 0
src/view/evaluating/index.tsx

@@ -35,6 +35,7 @@ import {
   api_startDelayCheck,
   api_closeDelayCheck,
   api_openCamera,
+  api_closeCamera,
 } from "/src/helpers/communication";
 import state, { IPlayState, clearSelection, handleStopPlay, onPlay, resetPlaybackToStart, togglePlay, initSetPlayRate, resetBaseRate, scrollViewNote } from "/src/state";
 import { IPostMessage } from "/src/utils/native-message";
@@ -840,6 +841,7 @@ export default defineComponent({
       } else {
         removeSocketStatus(handleSocketStatus);
       }
+      api_closeCamera();
       api_disconnectSocket();
       console.log("卸载评测模块成功");
     });