lex пре 8 месеци
родитељ
комит
0af8e93b0d
2 измењених фајлова са 144 додато и 123 уклоњено
  1. 128 114
      src/pages/detail/helpers.ts
  2. 16 9
      src/pages/detail/tv-popup/index.tsx

+ 128 - 114
src/pages/detail/helpers.ts

@@ -194,7 +194,7 @@ export const getAllNodes = (osmd: any) => {
   if (osmd?.cursor) {
     try {
       osmd.cursor.reset()
-    } catch (error) {}
+    } catch (error) { }
     const iterator = osmd.cursor.iterator
     let i = 0
     let si = 0
@@ -236,7 +236,7 @@ export const getAllNodes = (osmd: any) => {
       if (state.isCombineRender) {
         for (let index = 0; index < iterator.currentVoiceEntries.length; index++) {
           const element = iterator.currentVoiceEntries[index];
-          /** 
+          /**
            * 曲谱:合奏2-14,1752154261147389954,跳过倚音
            */
           if (element.isGrace) {
@@ -251,7 +251,7 @@ export const getAllNodes = (osmd: any) => {
           elRealValue = element.notes[0].length.realValue
         }
       }
-      
+
       let voiceEntries = iterator.currentVoiceEntries?.[0] ? [iterator.currentVoiceEntries?.[0]] : []
       const voiceEntries2 = iterator.currentVoiceEntries?.[1]
       if (state.isCombineRender) {
@@ -270,7 +270,7 @@ export const getAllNodes = (osmd: any) => {
               .flat()
               .sort((a: any, b: any) => a.Length.realValue - b.Length.realValue)
             note = _notes[0]
-          } catch (error) {}
+          } catch (error) { }
         }
         if (note) {
           if (si === 0) {
@@ -315,7 +315,7 @@ export const getAllNodes = (osmd: any) => {
           //   (state.isSpecialBookCategory
           //     ? getTimeByBeatUnit(beatUnit, measureSpeed, iterator.currentMeasure.activeTimeSignature.Denominator)
           //     : baseSpeed) || 1
-          // #8456 光标和节拍对应不上等bug修复, 
+          // #8456 光标和节拍对应不上等bug修复,
           let beatSpeed = (state.isSpecialBookCategory ? measureSpeed : baseSpeed) || 1;
 
           let speed = (state.isSpecialBookCategory ? measureSpeed : baseSpeed) || 1
@@ -395,10 +395,10 @@ export const getAllNodes = (osmd: any) => {
               speed = allNotes[i - 1]?.speed
             }
             beatSpeed =
-            (state.isSpecialBookCategory
-              ? getTimeByBeatUnit(beatUnit, speed, iterator.currentMeasure.activeTimeSignature.Denominator)
-              : baseSpeed) || 1
-              const isEnd = !(gradualChangeIndex < noteDiff) && !(resetXmlNoteIndex > gradualChangeIndex)
+              (state.isSpecialBookCategory
+                ? getTimeByBeatUnit(beatUnit, speed, iterator.currentMeasure.activeTimeSignature.Denominator)
+                : baseSpeed) || 1
+            const isEnd = !(gradualChangeIndex < noteDiff) && !(resetXmlNoteIndex > gradualChangeIndex)
             gradualChangeIndex++
             // console.log(gradualChangeIndex)
             if (isEnd) {
@@ -432,13 +432,13 @@ export const getAllNodes = (osmd: any) => {
           }
 
           /**
-           * 
+           *
            * bug修复说明
            * 曲目:'我和我的祖国’,
            * 从第32节点后播放异常,进和管乐迷endtime值对比,发现是noteLength计算不一致导致
            * 不一致的原因是:noteLength值计算,多了下面这段逻辑,故先注释掉
            * 20.23.10.13
-           * 
+           *
            */
 
           // 如果是休止符并且整个小节休止,休止符的时值小于小节时值,取小节的时值
@@ -504,7 +504,7 @@ export const getAllNodes = (osmd: any) => {
             const staffEntries = note.sourceMeasure.verticalMeasureList?.[0]?.staffEntries || []
             //计算第一个小节里面的音符时值是否等于整个小节的时值
             staffEntries.forEach((_a: any) => {
-              if(_a?.sourceStaffEntry?.voiceEntries?.[0]?.notes?.[0]?.length?.realValue){
+              if (_a?.sourceStaffEntry?.voiceEntries?.[0]?.notes?.[0]?.length?.realValue) {
                 _firstMeasureRealValue += _a.sourceStaffEntry.voiceEntries[0].notes[0].length.realValue
               }
             })
@@ -560,19 +560,19 @@ export const getAllNodes = (osmd: any) => {
               ornamentContainer: note.voiceEntry.ornamentContainer ? { ...note.voiceEntry.ornamentContainer } : '',
             },
             noteElement: {
-			  ...note.SourceMeasure,	
+              ...note.SourceMeasure,
               NoteToGraphicalNoteObjectId: note.NoteToGraphicalNoteObjectId,
               notehead: note.notehead
                 ? {
-                    filled: note.notehead.filled,
-                    shape: note.notehead.shape,
-                    sourceNote: note.notehead.sourceNote?.NoteToGraphicalNoteObjectId,
-                  }
+                  filled: note.notehead.filled,
+                  shape: note.notehead.shape,
+                  sourceNote: note.notehead.sourceNote?.NoteToGraphicalNoteObjectId,
+                }
                 : '',
               noteheadColor: note.noteheadColor,
               isRestFlag: note.isRestFlag,
               sourceMeasure: {
-				...note.SourceMeasure,
+                ...note.SourceMeasure,
                 measureListIndex: note?.SourceMeasure?.measureListIndex,
                 MeasureNumberXML: note?.SourceMeasure?.MeasureNumberXML,
                 allRests: note?.SourceMeasure?.allRests,
@@ -580,57 +580,57 @@ export const getAllNodes = (osmd: any) => {
                 multipleRestMeasures: note?.SourceMeasure?.multipleRestMeasures,
                 verticalMeasureList: Array.isArray(note?.SourceMeasure?.verticalMeasureList)
                   ? note.SourceMeasure.verticalMeasureList.map((v: any) => {
-                      const { x, y, width, height, start_x, end_x } = v?.stave || {}
-                      return v
-                        ? {
-                            stave: {
-                              x,
-                              y,
-                              width,
-                              height,
-                              start_x,
-                              end_x,
-                            },
-                            boundingBox:
-                              v && v.boundingBox
-                                ? {
-                                    absolutePosition: { ...v.boundingBox.absolutePosition },
-                                    size: { ...v.boundingBox.size },
-                                  }
-                                : '',
-                          }
-                        : undefined
-                    })
+                    const { x, y, width, height, start_x, end_x } = v?.stave || {}
+                    return v
+                      ? {
+                        stave: {
+                          x,
+                          y,
+                          width,
+                          height,
+                          start_x,
+                          end_x,
+                        },
+                        boundingBox:
+                          v && v.boundingBox
+                            ? {
+                              absolutePosition: { ...v.boundingBox.absolutePosition },
+                              size: { ...v.boundingBox.size },
+                            }
+                            : '',
+                      }
+                      : undefined
+                  })
                   : [],
                 activeTimeSignature: note.sourceMeasure?.activeTimeSignature,
-				ActiveTimeSignature: note.sourceMeasure?.activeTimeSignature
+                ActiveTimeSignature: note.sourceMeasure?.activeTimeSignature
               },
               tie: note.tie
                 ? {
-                    StartNote: {
-                      NoteToGraphicalNoteObjectId: note.tie.StartNote.NoteToGraphicalNoteObjectId,
-                    },
-                    notes:
-                      (Array.isArray(note.tie.notes) &&
-                        note.tie.notes?.map((_tie: any) => {
-                          return {
-                            NoteToGraphicalNoteObjectId: _tie.NoteToGraphicalNoteObjectId,
-                          }
-                        })) ||
-                      [],
-                  }
+                  StartNote: {
+                    NoteToGraphicalNoteObjectId: note.tie.StartNote.NoteToGraphicalNoteObjectId,
+                  },
+                  notes:
+                    (Array.isArray(note.tie.notes) &&
+                      note.tie.notes?.map((_tie: any) => {
+                        return {
+                          NoteToGraphicalNoteObjectId: _tie.NoteToGraphicalNoteObjectId,
+                        }
+                      })) ||
+                    [],
+                }
                 : '',
               slurs: Array.isArray(note.slurs)
                 ? note.slurs.map((slur: any) => {
-                    return {
-                      startNote: {
-                        NoteToGraphicalNoteObjectId: slur.startNote.NoteToGraphicalNoteObjectId,
-                      },
-                      endNote: {
-                        NoteToGraphicalNoteObjectId: slur.endNote.NoteToGraphicalNoteObjectId,
-                      },
-                    }
-                  })
+                  return {
+                    startNote: {
+                      NoteToGraphicalNoteObjectId: slur.startNote.NoteToGraphicalNoteObjectId,
+                    },
+                    endNote: {
+                      NoteToGraphicalNoteObjectId: slur.endNote.NoteToGraphicalNoteObjectId,
+                    },
+                  }
+                })
                 : [],
               pitch: {
                 prevFrequency: note.pitch?.prevFrequency,
@@ -650,8 +650,8 @@ export const getAllNodes = (osmd: any) => {
             stave:
               activeVerticalMeasureList[0] && activeVerticalMeasureList[0].stave
                 ? {
-                    attrs: activeVerticalMeasureList[0].stave ? { ...activeVerticalMeasureList[0].stave.attrs } : {},
-                  }
+                  attrs: activeVerticalMeasureList[0].stave ? { ...activeVerticalMeasureList[0].stave.attrs } : {},
+                }
                 : '',
             firstVerticalMeasure: { measureNumber: activeVerticalMeasureList?.[0]?.measureNumber },
             noteLength: 1,
@@ -685,7 +685,7 @@ export const getAllNodes = (osmd: any) => {
     }
     try {
       osmd.cursor.reset()
-    } catch (error) {}
+    } catch (error) { }
   }
   // 按照时间轴排序
   // console.log('看看👀', allNotes)
@@ -786,32 +786,32 @@ export const setStepIndex = (osmd: any, num: number, prev?: number) => {
 }
 
 export const getIndex = (times: any[], currentTime: Number) => {
-	// console.log(currentTime)
-	if (currentTime > state.times[state.times.length - 1].endtime) {
-		return state.times.length - 1;
-	}
-	let index = 0;
+  // console.log(currentTime)
+  if (currentTime > state.times[state.times.length - 1].endtime) {
+    return state.times.length - 1;
+  }
+  let index = 0;
   // js计算有精度问题,增加0.2毫秒误差范围
   currentTime = Number(currentTime) + 0.0002;
   // console.log('时间',currentTime)
-	for (let i = 0; i < times.length; i++) {
-		const item = times[i];
-		const prevItem = times[i - 1];
-		if (currentTime >= item.time) {
-			if (!prevItem || item.time != prevItem.time) {
-				index = item.i;
-			}
-		} else {
-			break;
-		}
-	}
-	if (state.sectionStatus && state.section.length === 2) {
-		// 限制不超过此范围
-		const startSection = state.befireSection || state.section[0];
-		index = Math.min(Math.max(index, startSection.i), state.section[1].i);
-		// console.log('endIndex', index)
-	}
-	return index;
+  for (let i = 0; i < times.length; i++) {
+    const item = times[i];
+    const prevItem = times[i - 1];
+    if (currentTime >= item.time) {
+      if (!prevItem || item.time != prevItem.time) {
+        index = item.i;
+      }
+    } else {
+      break;
+    }
+  }
+  if (state.sectionStatus && state.section.length === 2) {
+    // 限制不超过此范围
+    const startSection = state.befireSection || state.section[0];
+    index = Math.min(Math.max(index, startSection.i), state.section[1].i);
+    // console.log('endIndex', index)
+  }
+  return index;
 };
 
 export const getSlursNote = (_note: any, pos?: 'start' | 'end') => {
@@ -883,18 +883,18 @@ export const getNoteByMeasuresSlursStart = (note: any) => {
 }
 
 export const getActtiveNoteByTimes = (evt: MouseEvent) => {
-	const el = (evt.target as HTMLDivElement)?.dataset;
-	// console.log(state)
-
-	const data: any = {};
-	for (const time of state.times) {
-		if (time.id && !data[time.id]) {
-			data[time.id] = time;
-		}
-	}
-	const activeNote = data[el.id || ""];
-	// state.timesById = data
-	return activeNote;
+  const el = (evt.target as HTMLDivElement)?.dataset;
+  // console.log(state)
+
+  const data: any = {};
+  for (const time of state.times) {
+    if (time.id && !data[time.id]) {
+      data[time.id] = time;
+    }
+  }
+  const activeNote = data[el.id || ""];
+  // state.timesById = data
+  return activeNote;
 };
 
 const getPrevHasSourceNote = (note: any) => {
@@ -1082,21 +1082,35 @@ export const getMeasureRealBpm = (measure: SourceMeasure) => {
 }
 
 export const getEnvHostname = () => {
-  if (location.origin.indexOf('online') > -1) {
-    return 'https://mstuonline.dayaedu.com'
-  } else if (location.origin.indexOf('dev') > -1) {
-    return 'http://mstudev.dayaedu.com'
+  // if (location.origin.indexOf('online') > -1) {
+  //   return 'https://mstuonline.dayaedu.com'
+  // } else if (location.origin.indexOf('dev') > -1) {
+  //   return 'http://mstudev.dayaedu.com'
+  // }
+  // return 'https://mstutest.dayaedu.com'
+
+  if (location.hostname === 'gym.lexiaoya.cn') {
+    return 'https://gym.lexiaoya.cn/mdaya'
+  } else if (location.hostname === 'dev.gym.lexiaoya.cn') {
+    return 'http://dev.gym.lexiaoya.cn/mdaya'
   }
-  return 'https://mstutest.dayaedu.com'
+  return 'https://test.gym.lexiaoya.cn/mdaya'
 }
 
 export const getTvIconUrl = () => {
-  if (location.origin.indexOf('online') > -1) {
-    return 'https://mteaonline.dayaedu.com/#/guide'
-  } else if (location.origin.indexOf('dev') > -1) {
-    return 'http://mteadev.dayaedu.com/#/guide'
+  // if (location.origin.indexOf('online') > -1) {
+  //   return 'https://mteaonline.dayaedu.com/#/guide'
+  // } else if (location.origin.indexOf('dev') > -1) {
+  //   return 'http://mteadev.dayaedu.com/#/guide'
+  // }
+  // return 'https://mteatest.dayaedu.com/#/guide'
+
+  if (location.hostname === 'gym.lexiaoya.cn') {
+    return 'https://gym.lexiaoya.cn/mteacher/#/guide'
+  } else if (location.hostname === 'dev.gym.lexiaoya.cn') {
+    return 'http://dev.gym.lexiaoya.cn/mteacher/#/guide'
   }
-  return 'https://mteatest.dayaedu.com/#/guide'
+  return 'https://test.gym.lexiaoya.cn/mteacher/#/guide'
 }
 
 export const setPrefix = (url: string): string => {
@@ -1304,10 +1318,10 @@ export const onlyVisible = (xml: string, partIndex: number): string => {
   const rehearsals = [...parts[0]?.getElementsByTagName('rehearsal')]
 
   /** 第一分谱如果是约定的配置分谱则跳过 */
-	if (partListNames[0]?.toLocaleUpperCase?.() === "COMMON") {
-		partIndex++;
-		partListNames.shift();
-	}
+  if (partListNames[0]?.toLocaleUpperCase?.() === "COMMON") {
+    partIndex++;
+    partListNames.shift();
+  }
   const visiblePartInfo = partList[partIndex]
   state.partListNames = partListNames
   if (visiblePartInfo) {
@@ -1621,4 +1635,4 @@ export const setSettionBackground = () => {
     item.height = Math.max(...heights)
     return item
   })
-}
+}

+ 16 - 9
src/pages/detail/tv-popup/index.tsx

@@ -33,7 +33,7 @@ export default defineComponent({
       this.tvShowed = false
     },
     loaded() {
-      (iframeRef.value?.contentWindow as any).IFrameShowImage = (item: any) => {
+      ;(iframeRef.value?.contentWindow as any).IFrameShowImage = (item: any) => {
         ImagePreview([item.src])
       }
     },
@@ -41,7 +41,7 @@ export default defineComponent({
   render() {
     return (
       <>
-        {getTvIconUrl() ? <img id="tips-step-0" class={styles.icon} src={TVIcon} onClick={this.open}/> : null}
+        {getTvIconUrl() ? <img id="tips-step-0" class={styles.icon} src={TVIcon} onClick={this.open} /> : null}
         <Popup
           show={this.tvShow}
           round
@@ -50,7 +50,7 @@ export default defineComponent({
           position="right"
           closeIcon="arrow-left"
           lazyRender={false}
-          class={{[styles.android]: browserInfo.android, [styles.tvPopup]: true}}
+          class={{ [styles.android]: browserInfo.android, [styles.tvPopup]: true }}
           style={{ height: '100%', width: '50%' }}
           closeOnPopstate={true}
           onClickCloseIcon={this.close}
@@ -59,14 +59,21 @@ export default defineComponent({
         >
           {this.opened ? (
             <Tabs line-height={2} title-active-color="#01C1B5" color="#01C1B5">
-              <Tab title="投屏" style={{ height: '100%'}}>
-                <iframe src={getTvIconUrl()}/>
+              <Tab title="投屏" style={{ height: '100%' }}>
+                <iframe src={getTvIconUrl()} />
               </Tab>
-              <Tab title="帮助" style={{ height: '100%'}}>
+              <Tab title="帮助" style={{ height: '100%' }}>
                 <div class={styles.wraper}>
-                  <iframe onLoad={this.loaded} ref={iframeRef} class={styles.iframe} src={getEnvHostname() + '/#/KeepRepaire?mode=accompany'}/>
+                  <iframe
+                    onLoad={this.loaded}
+                    ref={iframeRef}
+                    class={styles.iframe}
+                    src={getEnvHostname() + '/#/KeepRepaire?mode=accompany'}
+                  />
                   <SettingFbcPopup>
-                    <Button class={styles.btn} plain size="small" color="#01C1B5">意见反馈 &gt;</Button>
+                    <Button class={styles.btn} plain size="small" color="#01C1B5">
+                      意见反馈 &gt;
+                    </Button>
                   </SettingFbcPopup>
                 </div>
               </Tab>
@@ -75,5 +82,5 @@ export default defineComponent({
         </Popup>
       </>
     )
-  }
+  },
 })