Browse Source

fix: 跟练时长没有动态累计问题修复

TIANYONG 7 months ago
parent
commit
b2c5e78254

+ 10 - 0
src/page-instrument/custom-plugins/ExerciseStatistics/index.tsx

@@ -5,6 +5,7 @@ import request from "/src/utils/request";
 import { getSecondRPM } from "/src/utils";
 import state from '/src/state'
 import { headTopData } from "/src/page-instrument/header-top/index";
+import { followData } from "/src/view/follow-practice/index"
 
 // 练习统计
 export default defineComponent({
@@ -42,6 +43,15 @@ export default defineComponent({
                 handleStop()
             }
         })
+		// 监听跟练播放
+		watch(() => state.hasFollowResult, () => {
+			console.log('跟练录音11111',state.hasFollowResult,followData.start)
+            if (followData.practiceStart && state.hasFollowResult){
+                handleStart()
+            } else if (!followData.practiceStart) {
+                handleStop()
+            }
+        })		
 		onMounted(() => {
 			getTime();
 		});

+ 2 - 0
src/state.ts

@@ -591,6 +591,8 @@ const state = reactive({
   headTopHeight: 0,
   /** 是否是自动重播,练习模式开启自动重播时,播放前不需要再次计算播放倍率了,还是按照上次的播放倍率播放音频 */
   isAutoRePlay: false,
+  /** 跟练,是否收到了录音的回调 */
+  hasFollowResult: false,  
 });
 const browserInfo = browser();
 let offset_duration = 0;

+ 2 - 0
src/view/follow-practice/index.tsx

@@ -115,6 +115,7 @@ export const handleFollowStart = async () => {
 		followData.practiceStart = false;
 	} else {
 		followData.dontAccredit = false;
+		state.hasFollowResult = true;
 		// 从头开始跟练,跟练模式开始前,增加播放系统节拍器
 		if (state.activeNoteIndex === 0) {
 			const tickend = await handleStartTick();
@@ -150,6 +151,7 @@ export const handleFollowEnd = () => {
 	onClear();
 	followData.start = false;
 	followData.practiceStart = false;
+	state.hasFollowResult = false
 	openToggleRecord(false);
 	followData.index = 0;
 	console.log("结束");