|
@@ -1,16 +1,16 @@
|
|
|
-import { Transition, defineComponent, onMounted, reactive, watch, defineAsyncComponent, computed } from "vue";
|
|
|
+import { Transition, defineComponent, onMounted, reactive, watch, defineAsyncComponent, computed, onUnmounted } from "vue";
|
|
|
import { connectWebsocket, evaluatingData, handleEndBegin, handleStartBegin, handleStartEvaluat, handleViewReport, startCheckDelay, checkUseEarphone, handleCancelEvaluat } from "/src/view/evaluating";
|
|
|
import Earphone from "./earphone";
|
|
|
import styles from "./index.module.less";
|
|
|
import SoundEffect from "./sound-effect";
|
|
|
-import state, { handleRessetState, resetPlaybackToStart, musicalInstrumentCodeInfo } from "/src/state";
|
|
|
+import state, { handleRessetState, resetPlaybackToStart, musicalInstrumentCodeInfo, clearSelection } from "/src/state";
|
|
|
import { storeData } from "/src/store";
|
|
|
import { browser } from "/src/utils";
|
|
|
import { getNoteByMeasuresSlursStart } from "/src/helpers/formateMusic";
|
|
|
import { Icon, Popup, showToast, closeToast, showLoadingToast } from "vant";
|
|
|
import EvaluatResult from "./evaluat-result";
|
|
|
import EvaluatAudio from "./evaluat-audio";
|
|
|
-import { api_getDeviceDelay, api_openAdjustRecording, api_proxyServiceMessage, api_videoUpdate, getEarphone, api_back, api_startDelayCheck, api_cancelDelayCheck, api_closeDelayCheck, api_finishDelayCheck, api_retryEvaluating } from "/src/helpers/communication";
|
|
|
+import { api_getDeviceDelay, api_openAdjustRecording, api_proxyServiceMessage, api_videoUpdate, getEarphone, api_back, api_startDelayCheck, api_cancelDelayCheck, api_closeDelayCheck, api_finishDelayCheck, api_retryEvaluating, api_remove_finishDelayCheck } from "/src/helpers/communication";
|
|
|
import EvaluatShare from "./evaluat-share";
|
|
|
import { Vue3Lottie } from "vue3-lottie";
|
|
|
import startData from "./data/start.json";
|
|
@@ -38,6 +38,7 @@ type TCriteria = "frequency" | "amplitude" | "decibels";
|
|
|
*/
|
|
|
let actualBeatLength = 0;
|
|
|
let calculateInfo: any = {};
|
|
|
+let checkErjiTimer: any = null
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: "evaluat-model",
|
|
@@ -125,6 +126,8 @@ export default defineComponent({
|
|
|
|
|
|
/** 校验耳机状态 */
|
|
|
const checkEarphoneStatus = async (type?: string) => {
|
|
|
+ clearTimeout(checkErjiTimer);
|
|
|
+ checkErjiTimer = null;
|
|
|
if (type !== "start") {
|
|
|
// const erji = await checkUseEarphone();
|
|
|
const res = await getEarphone();
|
|
@@ -133,9 +136,16 @@ export default defineComponent({
|
|
|
evaluatingData.earphoneMode = true;
|
|
|
evaluatingData.earPhoneType = res?.content?.type || "";
|
|
|
if (evaluatingData.earPhoneType === "有线耳机") {
|
|
|
+ clearTimeout(checkErjiTimer);
|
|
|
+ checkErjiTimer = null;
|
|
|
setTimeout(() => {
|
|
|
evaluatingData.earphoneMode = false;
|
|
|
}, 3000);
|
|
|
+ } else {
|
|
|
+ // 如果没有佩戴有限耳机,需要持续检测耳机状态
|
|
|
+ checkErjiTimer = setTimeout(() => {
|
|
|
+ checkEarphoneStatus();
|
|
|
+ }, 1000);
|
|
|
}
|
|
|
}
|
|
|
console.log("检测结束,生成数据", evaluatingData.websocketState, evaluatingData.startBegin, evaluatingData.checkEnd);
|
|
@@ -357,6 +367,10 @@ export default defineComponent({
|
|
|
};
|
|
|
|
|
|
const startBtnHandle = async () => {
|
|
|
+ // 选段未完成时,清除选段状态
|
|
|
+ if (state.sectionStatus && state.section.length < 2) {
|
|
|
+ clearSelection();
|
|
|
+ }
|
|
|
// 如果是异常状态,先等待500ms再执行后续流程
|
|
|
if (evaluatingData.isErrorState && !state.setting.soundEffect) {
|
|
|
// console.log('异常流程1')
|
|
@@ -431,6 +445,13 @@ export default defineComponent({
|
|
|
api_finishDelayCheck(handleFinishDelayCheck);
|
|
|
api_retryEvaluating(handRetryEvaluating);
|
|
|
});
|
|
|
+
|
|
|
+ onUnmounted(() => {
|
|
|
+ api_remove_finishDelayCheck(handleFinishDelayCheck);
|
|
|
+ clearTimeout(checkErjiTimer);
|
|
|
+ checkErjiTimer = null;
|
|
|
+ });
|
|
|
+
|
|
|
return () => (
|
|
|
<div>
|
|
|
<div class={styles.operatingBtn}>
|
|
@@ -471,6 +492,8 @@ export default defineComponent({
|
|
|
<Earphone
|
|
|
earphoneType={evaluatingData.earPhoneType}
|
|
|
onClose={() => {
|
|
|
+ clearTimeout(checkErjiTimer);
|
|
|
+ checkErjiTimer = null;
|
|
|
evaluatingData.earphoneMode = false;
|
|
|
// handlePerformDetection();
|
|
|
checkEarphoneStatus("start");
|