Parcourir la source

feat: 自定义谱面缩放比例

TIANYONG il y a 1 an
Parent
commit
6135160d4c

+ 2 - 0
osmd-extended/src/MusicalScore/Graphical/VexFlow/VexFlowConverter.ts

@@ -604,6 +604,7 @@ export class VexFlowConverter {
             // 自定义符杆朝向
             const DYMusicalOrientation = (window as any).DYMusicalOrientation
             wantedStemDirection = DYMusicalOrientation !== undefined ? DYMusicalOrientation : wantedStemDirection
+            console.log(11111,vfnote)
             switch (wantedStemDirection) {
                 case(StemDirectionType.Up):
                     vfnote.setStemDirection(VF.Stem.UP);
@@ -715,6 +716,7 @@ export class VexFlowConverter {
             // 所有叠加音符都超过第三线才朝下
             const stemDirectionNote = (window as any).GYM?.stemDirectionNote
             if(!stemDirectionNote && keyLines.length === keys.length){
+                console.log('👀~111')
                 vfnote.setStemDirection(-1)
             }
         }

+ 3 - 0
osmd-extended/src/VexFlowPatch/src/beam.js

@@ -306,6 +306,9 @@ export class Beam extends Element {
     }
 
     function applyStemDirection(group, direction) {
+      // 自定义符杆朝向
+      const DYMusicalOrientation = window.DYMusicalOrientation
+      direction = DYMusicalOrientation !== undefined ? DYMusicalOrientation : direction
       group.forEach(note => {
         note.setStemDirection(direction);
       });

+ 11 - 1
src/music-sheet/uses.ts

@@ -3,6 +3,8 @@ import { OpenSheetMusicDisplay, EngravingRules, OSMDOptions } from '/osmd-extend
 import { formatZoom } from '/src/helpers/utils'
 import { setEngravingRules } from './helpers'
 import { Toast } from 'vant'
+import qs from 'query-string'
+const search = qs.parse(location.search);
 
 /**
  * 合并规则
@@ -64,7 +66,15 @@ export const useOsmdLoader = async (osmd: OpenSheetMusicDisplay, score: string)
   try {
     if (score && osmd) {
       await osmd.load(score)
-      osmd.zoom = formatZoom()
+      // 自定义缩放比例
+      let customZoom = formatZoom()
+      if (search?.zoom) {
+        let userZoom = Number(search?.zoom)
+        userZoom = userZoom < 50 ? 50 : userZoom > 160 ? 160 : userZoom
+        customZoom = userZoom / 100
+      }
+      osmd.zoom = customZoom
+
       await osmd.render()
     }
   } catch (error) {}

+ 1 - 1
src/pages/detail/setting-state.ts

@@ -65,7 +65,7 @@ let initState: SettingState = {
     scoreSize: 'middle',
     type: 'staff',
     keySignature: false,
-    openCustomNodule: false,
+    openCustomNodule: true,
     customNoduleNum: 4,
   },
   eva: {

+ 3 - 0
src/subpages/colexiu/popups/setting/index.module.less

@@ -192,6 +192,9 @@
   display: flex;
   align-items: center;
   justify-content: space-between;
+  position: relative;
+  z-index: 9;
+  background: #fff;
   .columnBtn {
     word-break: keep-all;
     margin-left: 6px;

+ 1 - 1
src/subpages/colexiu/popups/setting/sett.tsx

@@ -126,7 +126,7 @@ export default defineComponent({
         })
       }
       localStorage.setItem('customNoduleInfo', JSON.stringify(customNoduleInfo))
-      window.location.reload()
+      useReload()
     }
 
     return () => {

+ 3 - 0
src/subpages/colexiu/uses/use-app.ts

@@ -206,6 +206,9 @@ export const useDetail = (id: number | string): [Ref<ShaeetStatusType>, Ref<Musi
       if (id == 904) {
         ;(window as any).DYMusicalOrientation = 1
       }
+      if (id == 829) {
+        ;(window as any).DYMusicalOrientation = 0
+      }
       status.value = 'success'
 
       // 额外配置