lex 1 year ago
parent
commit
6aabe43d2f

+ 8 - 8
src/views/tempo-practice/setting-modal/index.tsx

@@ -74,10 +74,10 @@ export default defineComponent({
       // 判断是否有数据变化
       handleStop();
       if (status) {
-        setting.element = state.element;
-        setting.beat = state.beat;
-        setting.barLine = state.barLine;
-        setting.tempo = state.tempo;
+        setting.element = JSON.parse(JSON.stringify(state.element));
+        setting.beat = JSON.parse(JSON.stringify(state.beat)); //state.beat;
+        setting.barLine = JSON.parse(JSON.stringify(state.barLine)); // state.barLine;
+        setting.tempo = JSON.parse(JSON.stringify(state.tempo)); // state.tempo;
         renderScore();
       }
 
@@ -93,10 +93,10 @@ export default defineComponent({
           onClick={() => {
             emit('close');
             setTimeout(() => {
-              state.element = setting.element;
-              state.beat = setting.beat;
-              state.barLine = setting.barLine;
-              state.tempo = setting.tempo;
+              state.element = JSON.parse(JSON.stringify(setting.element));
+              state.beat = JSON.parse(JSON.stringify(setting.beat)); //state.beat;
+              state.barLine = JSON.parse(JSON.stringify(setting.barLine)); // state.barLine;
+              state.tempo = JSON.parse(JSON.stringify(setting.tempo)); // state.tempo;
             }, 300);
           }}></i>
 

+ 10 - 8
src/views/tempo-practice/setting.ts

@@ -84,27 +84,29 @@ export const randomScoreElement = (element?: string) => {
 export const elementDirection = (type: string, index: number) => {
   const prefix = setting.element === 'jianpu' ? 'j-' : 'f-';
   let ele = '';
-  let i = Number(index);
+  let i = 0;
   const tempoList = setting.tempo;
+  const toIndex = tempoList.findIndex((t: any) => Number(t) === index);
   if (type === 'up') {
-    if (index <= 0) {
+    if (toIndex <= 0) {
       ele = tempoList[tempoList.length - 1];
       i = tempoList.length - 1;
     } else {
-      ele = tempoList[index - 1];
-      i = index - 1;
+      ele = tempoList[toIndex - 1];
+      i = toIndex - 1;
     }
   } else if (type === 'down') {
-    if (index >= tempoList.length - 1) {
+    // console.log(tempoList, '121212', index);
+    // console.log(toIndex);
+    if (toIndex >= tempoList.length - 1) {
       ele = tempoList[0];
       i = 0;
     } else {
-      ele = tempoList[index + 1];
-      i = index + 1;
+      ele = tempoList[toIndex + 1];
+      i = toIndex + 1;
     }
   }
 
-  console.log(ele, Number(index), type, i);
   return {
     url: prefix + ele + '.png',
     index: Number(ele)