浏览代码

评测缓存

liushengqiang 2 年之前
父节点
当前提交
0dd2eadabb
共有 1 个文件被更改,包括 29 次插入24 次删除
  1. 29 24
      src/page-orchestra/evaluat-model/index.tsx

+ 29 - 24
src/page-orchestra/evaluat-model/index.tsx

@@ -33,7 +33,7 @@ type TCriteria = "frequency" | "amplitude" | "decibels";
 export default defineComponent({
 	name: "evaluat-model",
 	setup() {
-		const query = getQuery()
+		const query = getQuery();
 		const evaluatModel = reactive({
 			tips: true,
 			evaluatUpdateAudio: false,
@@ -84,7 +84,7 @@ export default defineComponent({
 				const item = times[index];
 				const note = getNoteByMeasuresSlursStart(item);
 				const rate = state.speed / state.originSpeed;
-				
+
 				const start = difftime + (item.sourceRelativeTime || item.relativeTime) - starTime;
 				const end = difftime + (item.sourceRelaEndtime || item.relaEndtime) - starTime;
 				const isStaccato = note.noteElement.voiceEntry.isStaccato();
@@ -112,9 +112,9 @@ export default defineComponent({
 				// console.log(note.measureOpenIndex, item.measureOpenIndex, note);
 				// console.log("skip", skip)
 				if (note.measureOpenIndex != recordMeasure) {
-					measureIndex++
-					recordMeasure = note.measureOpenIndex
-				  }
+					measureIndex++;
+					recordMeasure = note.measureOpenIndex;
+				}
 				const data = {
 					timeStamp: (start * 1000) / rate,
 					duration: ((end * 1000) / rate - (start * 1000) / rate) * noteRate,
@@ -152,7 +152,7 @@ export default defineComponent({
 				speed: state.speed,
 				heardLevel: state.setting.evaluationDifficulty,
 				beatLength: Math.round((state.fixtime * 1000) / rate),
-				practiceSource: query.unitId ? 'UNIT_TEST' : 'PRACTICE',
+				practiceSource: query.unitId ? "UNIT_TEST" : "PRACTICE",
 				// evaluationCriteria: getEvaluationCriteria(),
 			};
 			await connectWebsocket(content);
@@ -172,7 +172,7 @@ export default defineComponent({
 				return;
 			} else if (type === "look") {
 				// 跳转
-				handleViewReport('recordIdStr');
+				handleViewReport("recordIdStr");
 				return;
 			} else if (type === "practise") {
 				// 去练习
@@ -221,24 +221,29 @@ export default defineComponent({
 			}
 		);
 		/** 监听评测结束 */
-		watch(() => evaluatingData.resulstMode, () => {
-			// 评测结束, 并且完整评测
-			if (evaluatingData.resulstMode && evaluatingData.isComplete){
-				/** 有单元测验时,存储分数缓存 */
-				postMessage({
-					api: 'setCache',
-					content: {
-					  key: 'h5-orchestra-unit',
-					  value: JSON.stringify({
-						musicId: query.id || '',
-						unitId: query.unitId || '',
-						questionId: query.questionId || '',
-						score: evaluatingData.resultData?.score || 0,
-					  }),
-					},
-				  })
+		watch(
+			() => evaluatingData.resulstMode,
+			() => {
+				// 评测结束, 并且完整评测
+				if (evaluatingData.resulstMode && evaluatingData.isComplete) {
+					const body = {
+						key: "h5-orchestra-unit",
+						value: JSON.stringify({
+							musicId: query.id || "",
+							unitId: query.unitId || "",
+							questionId: query.questionId || "",
+							score: evaluatingData.resultData?.score || 0,
+						}),
+					};
+					/** 有单元测验时,存储分数缓存 */
+					postMessage({
+						api: "setCache",
+						content: body,
+					});
+					console.log("setCache", JSON.stringify(body));
+				}
 			}
-		})
+		);
 		return () => (
 			<div>
 				<Transition name="pop-center">