|
@@ -0,0 +1,50 @@
|
|
|
+import { defineComponent, reactive, watch } from "vue";
|
|
|
+import state from "/src/state";
|
|
|
+import { sysMusicRecordAdd } from "../../api";
|
|
|
+import { browser, getBehaviorId, getCampId } from "/src/utils";
|
|
|
+
|
|
|
+const recordData = reactive({
|
|
|
+ starTime: 0,
|
|
|
+});
|
|
|
+const handleRecord = () => {
|
|
|
+ // 不是练习模式不记录
|
|
|
+ if (state.modeType !== "practise") return;
|
|
|
+ let total = Date.now() - recordData.starTime;
|
|
|
+ recordData.starTime = Date.now();
|
|
|
+ if (total < 0) total = 0;
|
|
|
+ const body = {
|
|
|
+ musicSheetId: state.examSongId,
|
|
|
+ sysMusicScoreId: state.examSongId,
|
|
|
+ feature: "CLOUD_STUDY_TRAIN",
|
|
|
+ playTime: total / 1000,
|
|
|
+ deviceType: browser().android ? "ANDROID" : "IOS",
|
|
|
+ behaviorId: getBehaviorId()
|
|
|
+ };
|
|
|
+ sysMusicRecordAdd(body);
|
|
|
+};
|
|
|
+
|
|
|
+export const handleNoEndExit = () => {
|
|
|
+ if (state.playState === 'play') {
|
|
|
+ handleRecord()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 记录练习时长, 仅记录练习模式的时长
|
|
|
+ */
|
|
|
+export default defineComponent({
|
|
|
+ name: "recordingTime",
|
|
|
+ setup() {
|
|
|
+ watch(
|
|
|
+ () => state.playState,
|
|
|
+ () => {
|
|
|
+ if (state.playState === "play") {
|
|
|
+ recordData.starTime = Date.now();
|
|
|
+ } else {
|
|
|
+ handleRecord();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+ return () => <div></div>;
|
|
|
+ },
|
|
|
+});
|