Просмотр исходного кода

Merge branch 'iteration-20240103' into ponline

lex 1 год назад
Родитель
Сommit
12e4ed8bcc
2 измененных файлов с 35 добавлено и 26 удалено
  1. 19 15
      src/tenant/music/music-detail/new-index.tsx
  2. 16 11
      src/views/music/music-detail/index.tsx

+ 19 - 15
src/tenant/music/music-detail/new-index.tsx

@@ -1,6 +1,6 @@
 import TheSticky from '@/components/the-sticky'
 import styles from './new-index.module.less'
-import { useEventListener, useWindowScroll } from '@vueuse/core'
+import { useEventListener, useThrottleFn, useWindowScroll } from '@vueuse/core'
 import { postMessage } from '@/helpers/native-message'
 import iconShare from '../../images/icon-share.png'
 import oStart from '../album-detail/icon-hart.png'
@@ -888,20 +888,24 @@ export default defineComponent({
                     type="primary"
                     color="linear-gradient(270deg, #FF3C81 0%, #FF76A6 100%)"
                     onClick={() => {
-                      player.value && player.value.stop()
-                      const item: any = partColumns.value.find(
-                        (c: any) => c.value === staffData.partIndex
-                      )
-                      const index = staffData.tempPartList.findIndex(
-                        (i: any) => i.track === item?.track
-                      )
-                      musicBuy(musicDetail.value, () => {}, {
-                        'part-index': index || 0,
-                        sett: staff.radio,
-                        // 1:忽略系统节拍器
-                        ignoreSysMetronome:
-                          route.query.subjectType === 'MUSIC' ? 1 : 0
-                      })
+                      const throttleFn = useThrottleFn(() => {
+                        player.value && player.value.stop()
+                        const item: any = partColumns.value.find(
+                          (c: any) => c.value === staffData.partIndex
+                        )
+                        const index = staffData.tempPartList.findIndex(
+                          (i: any) => i.track === item?.track
+                        )
+                        musicBuy(musicDetail.value, () => {}, {
+                          'part-index': index || 0,
+                          sett: staff.radio,
+                          // 1:忽略系统节拍器
+                          ignoreSysMetronome:
+                            route.query.subjectType === 'MUSIC' ? 1 : 0
+                        })
+                      }, 500)
+
+                      throttleFn()
                     }}
                   >
                     立即练习

+ 16 - 11
src/views/music/music-detail/index.tsx

@@ -66,6 +66,7 @@ import Download from './download'
 import { getInstrumentName } from '@/constant/instruments'
 import { getUploadSign, onOnlyFileUpload } from '@/helpers/oss-file-upload'
 import { svgtopng } from '@/tenant/music/music-detail/formatSvgToImg'
+import { useThrottleFn } from '@vueuse/core'
 
 export const getAssetsHomeFile = (fileName: string) => {
   const path = `../component/images/${fileName}`
@@ -992,17 +993,21 @@ export default defineComponent({
                     type="primary"
                     color="linear-gradient(180deg, #59E5D5 0%, #2DC7AA 100%)"
                     onClick={() => {
-                      player.value && player.value.stop()
-                      const item: any = partColumns.value.find(
-                        (c: any) => c.value === staffData.partIndex
-                      )
-                      const index = staffData.tempPartList.findIndex(
-                        (i: any) => i.track === item?.track
-                      )
-                      musicBuy(musicDetail.value, () => {}, {
-                        'part-index': index || 0,
-                        sett: staff.radio
-                      })
+                      const throttleFn = useThrottleFn(() => {
+                        player.value && player.value.stop()
+                        const item: any = partColumns.value.find(
+                          (c: any) => c.value === staffData.partIndex
+                        )
+                        const index = staffData.tempPartList.findIndex(
+                          (i: any) => i.track === item?.track
+                        )
+                        musicBuy(musicDetail.value, () => {}, {
+                          'part-index': index || 0,
+                          sett: staff.radio
+                        })
+                      }, 500)
+
+                      throttleFn()
                     }}
                   >
                     立即练习