|
@@ -22,6 +22,11 @@ import {
|
|
api_endCapture,
|
|
api_endCapture,
|
|
api_getDeviceDelay,
|
|
api_getDeviceDelay,
|
|
hideComplexButton,
|
|
hideComplexButton,
|
|
|
|
+ api_checkSocketStatus,
|
|
|
|
+ addAccompanyError,
|
|
|
|
+ removeAccompanyError,
|
|
|
|
+ addSocketStatus,
|
|
|
|
+ removeSocketStatus,
|
|
} from "/src/helpers/communication";
|
|
} from "/src/helpers/communication";
|
|
import state, {
|
|
import state, {
|
|
IPlayState,
|
|
IPlayState,
|
|
@@ -64,14 +69,24 @@ export const evaluatingData = reactive({
|
|
isComplete: false,
|
|
isComplete: false,
|
|
/** */
|
|
/** */
|
|
isDisabledPlayMusic: false,
|
|
isDisabledPlayMusic: false,
|
|
|
|
+ /** socket异常状态弹窗 */
|
|
|
|
+ socketErrorPop: false,
|
|
});
|
|
});
|
|
|
|
|
|
/** 点击开始评测按钮 */
|
|
/** 点击开始评测按钮 */
|
|
-export const handleStartEvaluat = () => {
|
|
|
|
|
|
+export const handleStartEvaluat = async () => {
|
|
if (state.modeType === "evaluating") {
|
|
if (state.modeType === "evaluating") {
|
|
handleCancelEvaluat();
|
|
handleCancelEvaluat();
|
|
} else {
|
|
} else {
|
|
- handleStopPlay();
|
|
|
|
|
|
+ // 评测前先检查APP端的websocket状态
|
|
|
|
+ const res = await api_checkSocketStatus();
|
|
|
|
+ if (res?.content?.status === "connected") {
|
|
|
|
+ handleStopPlay();
|
|
|
|
+ } else {
|
|
|
|
+ // socket未连接
|
|
|
|
+ evaluatingData.socketErrorPop = true
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
state.modeType = state.modeType === "evaluating" ? "practise" : "evaluating";
|
|
state.modeType = state.modeType === "evaluating" ? "practise" : "evaluating";
|
|
if (state.modeType !== "evaluating") {
|
|
if (state.modeType !== "evaluating") {
|
|
@@ -430,6 +445,41 @@ const handleComplexButton = (res?: IPostMessage) => {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+// 检测到APP发送的异常信息
|
|
|
|
+const handleAccompanyError = (res?: IPostMessage) => {
|
|
|
|
+ console.log('异常信息返回', res)
|
|
|
|
+ if (res?.content) {
|
|
|
|
+ const { type, reson } = res.content;
|
|
|
|
+ switch (type) {
|
|
|
|
+ case "playError":
|
|
|
|
+ // 播放异常
|
|
|
|
+ break;
|
|
|
|
+ case "enterBackground":
|
|
|
|
+ // App退到后台
|
|
|
|
+ break;
|
|
|
|
+ case "socketError":
|
|
|
|
+ // socket连接断开,评测中,则取消评测
|
|
|
|
+ if (state.modeType === "evaluating") {
|
|
|
|
+ handleCancelEvaluat();
|
|
|
|
+ evaluatingData.socketErrorPop = true
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case "recordError":
|
|
|
|
+ // 录音异常
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+// 检测socket状态
|
|
|
|
+const handleSocketStatus = (res?: IPostMessage) => {
|
|
|
|
+ if (res?.content?.status === "connected") {
|
|
|
|
+ evaluatingData.socketErrorPop = false
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
export default defineComponent({
|
|
export default defineComponent({
|
|
name: "evaluating",
|
|
name: "evaluating",
|
|
setup() {
|
|
setup() {
|
|
@@ -491,6 +541,8 @@ export default defineComponent({
|
|
sendResult(handleScoreResult);
|
|
sendResult(handleScoreResult);
|
|
hideComplexButton(handleComplexButton, true);
|
|
hideComplexButton(handleComplexButton, true);
|
|
api_recordStartTime(recordStartTimePoint);
|
|
api_recordStartTime(recordStartTimePoint);
|
|
|
|
+ addAccompanyError(handleAccompanyError);
|
|
|
|
+ addSocketStatus(handleSocketStatus);
|
|
// 不是选段模式评测, 就清空已选段
|
|
// 不是选段模式评测, 就清空已选段
|
|
if (!state.isSelectMeasureMode) {
|
|
if (!state.isSelectMeasureMode) {
|
|
clearSelection();
|
|
clearSelection();
|
|
@@ -505,8 +557,18 @@ export default defineComponent({
|
|
hideComplexButton(() => {}, false);
|
|
hideComplexButton(() => {}, false);
|
|
api_remove_recordStartTime(recordStartTimePoint);
|
|
api_remove_recordStartTime(recordStartTimePoint);
|
|
handle_reduction();
|
|
handle_reduction();
|
|
|
|
+ removeAccompanyError(handleAccompanyError);
|
|
|
|
+ removeSocketStatus(handleSocketStatus);
|
|
console.log("卸载评测模块成功");
|
|
console.log("卸载评测模块成功");
|
|
});
|
|
});
|
|
- return () => <div></div>;
|
|
|
|
|
|
+ return () => <div>
|
|
|
|
+ {
|
|
|
|
+ evaluatingData.socketErrorPop &&
|
|
|
|
+ <div class={styles.tipBox}>
|
|
|
|
+ <div class={styles.tipContent}>网络异常,正在重新链接...</div>
|
|
|
|
+ {/* <div class={styles.tipBtn} onClick={resetCheck}>再来一次</div> */}
|
|
|
|
+ </div>
|
|
|
|
+ }
|
|
|
|
+ </div>;
|
|
},
|
|
},
|
|
});
|
|
});
|