liushengqiang 2 年之前
父節點
當前提交
d50f33322c
共有 2 個文件被更改,包括 10 次插入15 次删除
  1. 1 1
      src/page-orchestra/main.ts
  2. 9 14
      src/view/follow-practice/index.tsx

+ 1 - 1
src/page-orchestra/main.ts

@@ -13,7 +13,7 @@ import "./theme.css";
 (function () {
 	const u = navigator.userAgent;
 	setStoreData({
-		isApp: u.includes("ORCHESTRAAPPI") || u.includes("ORCHESTRAAPPA"),
+		isApp: u.includes("ORCHESTRAAPPI") || u.includes("ORCHESTRAAPPA") || u.includes("Mac OS X") || /(iPhone|iPad|iPod|iOS)/i.test(u) || u.indexOf("Android") > -1 || u.indexOf("Adr") > -1,
 		platformApi: u.includes("ORCHESTRATEACHER") ? "/api-teacher" : u.includes("ORCHESTRASTUDENT") ? "/api-student" : "/api-backend",
 		platformType: u.includes("ORCHESTRATEACHER") ? "TEACHER" : u.includes("ORCHESTRASTUDENT") ? "STUDENT" : "WEB",
 		proxy: import.meta.env.DEV ? "/orchestra" : ""

+ 9 - 14
src/view/follow-practice/index.tsx

@@ -26,8 +26,8 @@ const noteFrequency = ref(0);
 const audioFrequency = ref(0);
 const followTime = ref(0);
 // 切换录音
-const openToggleRecord = async (open: boolean = true) => {
-	await api_cloudToggleFollow(open ? "start" : "end");
+const openToggleRecord = (open: boolean = true) => {
+	api_cloudToggleFollow(open ? "start" : "end");
 	// 记录跟练时长
 	if (open) {
 		followTime.value = Date.now();
@@ -51,7 +51,7 @@ const onClear = () => {
 };
 
 /** 开始跟练 */
-export const handleFollowStart = async () => {
+export const handleFollowStart = () => {
 	if (!storeData.isApp) {
 		Snackbar({
 			content: "请在APP端使用",
@@ -64,7 +64,7 @@ export const handleFollowStart = async () => {
 	followData.index = 0;
 	followData.list = [];
 	resetPlaybackToStart();
-	await openToggleRecord(true);
+	openToggleRecord(true);
 	setStep();
 };
 /** 结束跟练 */
@@ -72,6 +72,7 @@ export const handleFollowEnd = () => {
 	followData.start = false;
 	openToggleRecord(false);
 	followData.index = 0;
+	console.log('结束')
 };
 
 // 下一个
@@ -100,7 +101,6 @@ let checking = false;
 const onFollowTime = (evt?: IPostMessage) => {
 	const frequency: number = evt?.content?.frequency;
 	audioFrequency.value = frequency;
-	// console.log("🚀 ~ frequency:", frequency);
 	followData.list.push(frequency);
 };
 
@@ -109,22 +109,16 @@ const setStep = () => {
 	if (!followData.start) {
 		return;
 	}
-	let startTime = Date.now();
-	requestAnimationFrame(() => {
-		const endTime = Date.now();
-		// 渲染时间大于16.6,就会让页面卡顿, 如果渲染时间大与16.6就下一个渲染帧去计算
-		if (endTime - startTime < 16.6) {
-			checked();
-		}
+	checked();
+	setTimeout(() => {
 		setStep();
-	});
+	}, 50)
 };
 
 const checked = () => {
 	if (checking) return;
 	checking = true;
 	const item = getNoteIndex();
-	// console.log("🚀 ~ item:", item)
 	for (let i = 0; i < followData.list.length; i++) {
 		const frequency = followData.list[i];
 		if (frequency > item.min && frequency < item.max) {
@@ -163,6 +157,7 @@ export default defineComponent({
 		onUnmounted(() => {
 			api_cloudFollowTime(onFollowTime, false);
 			onClear();
+			openToggleRecord(false);
 			console.log("退出跟练模式");
 		});
 		return () => <div></div>;