|
@@ -20,8 +20,15 @@ import {
|
|
|
api_remove_recordStartTime,
|
|
|
api_startCapture,
|
|
|
api_endCapture,
|
|
|
+ api_getDeviceDelay,
|
|
|
} from "/src/helpers/communication";
|
|
|
-import state, { IPlayState, clearSelection, handleStopPlay, resetPlaybackToStart, togglePlay } from "/src/state";
|
|
|
+import state, {
|
|
|
+ IPlayState,
|
|
|
+ clearSelection,
|
|
|
+ handleStopPlay,
|
|
|
+ resetPlaybackToStart,
|
|
|
+ togglePlay,
|
|
|
+} from "/src/state";
|
|
|
import { IPostMessage } from "/src/utils/native-message";
|
|
|
import { usePageVisibility } from "@vant/use";
|
|
|
import { browser } from "/src/utils";
|
|
@@ -136,31 +143,48 @@ export const connectWebsocket = async (content: any) => {
|
|
|
export const handlePerformDetection = async () => {
|
|
|
// 检测完成不检测了
|
|
|
if (evaluatingData.checkEnd) return;
|
|
|
+ // 延迟检测
|
|
|
if (evaluatingData.checkStep === 0) {
|
|
|
- // 检测耳机
|
|
|
- const erji = await checkUseEarphone();
|
|
|
- evaluatingData.checkStep = 1;
|
|
|
- if (erji) {
|
|
|
- handlePerformDetection();
|
|
|
- } else {
|
|
|
- evaluatingData.earphoneMode = true;
|
|
|
+ evaluatingData.checkStep = 5;
|
|
|
+ // 没有设备延迟数据 或 开启了效音 显示检测组件,并持续检测耳机状态
|
|
|
+ if (state.setting.soundEffect){
|
|
|
+ evaluatingData.soundEffectMode = true
|
|
|
+ return
|
|
|
}
|
|
|
- return;
|
|
|
+ const delayTime = await api_getDeviceDelay()
|
|
|
+ console.log("🚀 ~ delayTime:", delayTime)
|
|
|
+ if (!delayTime){
|
|
|
+ evaluatingData.soundEffectMode = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ handlePerformDetection();
|
|
|
+ return
|
|
|
}
|
|
|
- if (evaluatingData.checkStep === 1) {
|
|
|
- // 效音
|
|
|
- // 是否需要开启效音
|
|
|
+ // 检测耳机
|
|
|
+ if ((evaluatingData.checkStep = 5)) {
|
|
|
evaluatingData.checkStep = 10;
|
|
|
- if (state.setting.soundEffect && !state.isPercussion) {
|
|
|
- evaluatingData.soundEffectMode = true;
|
|
|
- handleStartSoundCheck();
|
|
|
- } else {
|
|
|
- handlePerformDetection();
|
|
|
+ const erji = await checkUseEarphone();
|
|
|
+ if (!erji){
|
|
|
+ evaluatingData.earphoneMode = true;
|
|
|
+ return
|
|
|
}
|
|
|
+ handlePerformDetection();
|
|
|
return;
|
|
|
}
|
|
|
+ // 效音
|
|
|
+ // if (evaluatingData.checkStep === 7) {
|
|
|
+ // // 是否需要开启效音
|
|
|
+ // evaluatingData.checkStep = 10;
|
|
|
+ // if (state.setting.soundEffect && !state.isPercussion) {
|
|
|
+ // evaluatingData.soundEffectMode = true;
|
|
|
+ // handleStartSoundCheck();
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // handlePerformDetection();
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // 效验完成
|
|
|
if (evaluatingData.checkStep === 10) {
|
|
|
- // 连接websocket
|
|
|
evaluatingData.checkEnd = true;
|
|
|
}
|
|
|
};
|
|
@@ -176,7 +200,6 @@ export const addMeasureScore = (measureScore: any, show = true) => {
|
|
|
};
|
|
|
|
|
|
const handleScoreResult = (res?: IPostMessage) => {
|
|
|
- console.log("🚀 ~ 评测返回:", res);
|
|
|
if (res?.content) {
|
|
|
const { header, body } = res.content;
|
|
|
// 效音返回
|
|
@@ -185,10 +208,12 @@ const handleScoreResult = (res?: IPostMessage) => {
|
|
|
}
|
|
|
// 小节评分返回
|
|
|
if (header?.commond === "measureScore") {
|
|
|
+ console.log("🚀 ~ 评测返回:", res);
|
|
|
addMeasureScore(body);
|
|
|
}
|
|
|
// 评测结束返回
|
|
|
if (header?.commond === "overall") {
|
|
|
+ console.log("🚀 ~ 评测返回:", res);
|
|
|
// console.log("评测结束", body);
|
|
|
evaluatingData.resulstMode = true;
|
|
|
evaluatingData.resultData = {
|
|
@@ -214,10 +239,10 @@ export const handleStartBegin = async () => {
|
|
|
evaluatingData.startBegin = false;
|
|
|
return;
|
|
|
}
|
|
|
- if (res?.content?.reson){
|
|
|
+ if (res?.content?.reson) {
|
|
|
showToast(res.content.reson);
|
|
|
evaluatingData.startBegin = false;
|
|
|
- return
|
|
|
+ return;
|
|
|
}
|
|
|
evaluatingData.startBegin = true;
|
|
|
//开始录音
|
|
@@ -253,7 +278,14 @@ const recordStartTimePoint = async (res?: IPostMessage) => {
|
|
|
inteveral *= 1000;
|
|
|
}
|
|
|
evaluatingData.backtime = inteveral || Date.now();
|
|
|
- console.log("🚀 ~ 开始时间点:", evaluatingData.backtime, "已经录的时间:", Date.now() - inteveral, "记录时间点:", Date.now());
|
|
|
+ console.log(
|
|
|
+ "🚀 ~ 开始时间点:",
|
|
|
+ evaluatingData.backtime,
|
|
|
+ "已经录的时间:",
|
|
|
+ Date.now() - inteveral,
|
|
|
+ "记录时间点:",
|
|
|
+ Date.now()
|
|
|
+ );
|
|
|
// 开始播放
|
|
|
playMusic();
|
|
|
|
|
@@ -358,7 +390,10 @@ export const handleCancelEvaluat = () => {
|
|
|
};
|
|
|
|
|
|
/** 查看报告 */
|
|
|
-export const handleViewReport = (key: "recordId" | "recordIdStr", type: "gym" | "colexiu" | "orchestra" | 'instrument') => {
|
|
|
+export const handleViewReport = (
|
|
|
+ key: "recordId" | "recordIdStr",
|
|
|
+ type: "gym" | "colexiu" | "orchestra" | "instrument"
|
|
|
+) => {
|
|
|
const id = evaluatingData.resultData?.[key] || "";
|
|
|
let url = "";
|
|
|
switch (type) {
|