소스 검색

Merge branch 'gyt-feature-tianyong' into online

TIANYONG 1 년 전
부모
커밋
88bc6672e5

+ 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)
             }
         }

+ 4 - 0
osmd-extended/src/MusicalScore/Graphical/VexFlow/VexFlowStaffEntry.ts

@@ -39,6 +39,10 @@ export class VexFlowStaffEntry extends GraphicalStaffEntry {
                     gve.vfStaveNote.setStemDirection(VF.Stem.UP)
                     gve.parentVoiceEntry.StemDirection = StemDirectionType.Up
                 } 
+                // 1线谱 符杆都朝上
+                if (stave && (stave as any).getLines && (stave as any).getLines() === 1) {
+                    ;(window as any).DYMusicalOrientation = 0
+                }
                 if (!gve.vfStaveNote.preFormatted) {
                     continue;
                 }

+ 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);
       });

+ 5 - 2
osmd-extended/src/VexFlowPatch/src/stavenote.js

@@ -416,7 +416,7 @@ export class StaveNote extends StemmableNote {
   constructor(noteStruct) {
     super(noteStruct);
     this.setAttribute('type', 'StaveNote');
-
+    console.log('stavenote.js~')
     this.keys = noteStruct.keys;
     this.clef = noteStruct.clef;
     this.octave_shift = noteStruct.octave_shift;
@@ -463,7 +463,10 @@ export class StaveNote extends StemmableNote {
     if (noteStruct.auto_stem) {
       this.autoStem();
     } else {
-      this.setStemDirection(noteStruct.stem_direction);
+      // 自定义符杆朝向
+      const DYMusicalOrientation = window.DYMusicalOrientation
+      const direction = DYMusicalOrientation !== undefined ? DYMusicalOrientation : noteStruct.stem_direction
+      this.setStemDirection(direction);
     }
     this.reset();
     this.buildFlag();

+ 9 - 2
src/helpers/utils.ts

@@ -144,13 +144,20 @@ export function JavaScriptAnimate({ timing, draw, duration }: IJavaScriptAnimate
 
 /** 格式化当前曲谱缩放比例 */
 export const formatZoom = (num = 1) => {
+  const search = qs.parse(location.search);
   const size = {
     small: 0.5,
     middle: 0.7,
     large: 1,
   }
-  const zoom = size[SettingState.sett.scoreSize]
-  return num * zoom
+  let customZoom = size[SettingState.sett.scoreSize]
+  // 自定义曲谱缩放比例
+  if (search?.zoom) {
+    let userZoom = Number(search?.zoom)
+    userZoom = userZoom < 50 ? 50 : userZoom > 160 ? 160 : userZoom
+    customZoom = userZoom / 100
+  }
+  return num * customZoom
 }
 
 /**

+ 6 - 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,10 @@ export const useOsmdLoader = async (osmd: OpenSheetMusicDisplay, score: string)
   try {
     if (score && osmd) {
       await osmd.load(score)
-      osmd.zoom = formatZoom()
+      // 自定义缩放比例
+      let customZoom = formatZoom()
+      osmd.zoom = customZoom
+
       await osmd.render()
     }
   } catch (error) {}

+ 14 - 2
src/pages/detail/setting-state.ts

@@ -1,6 +1,7 @@
 import { reactive, watch } from 'vue'
 import storejs from 'store'
 import { IMusicScore } from '/osmd-extended/src'
+import qs from 'query-string'
 
 export interface SettingState {
   sett: iSett
@@ -29,6 +30,10 @@ export type iSett = {
   type: IMusicScore
   /** 是否固定调 */
   keySignature: boolean
+  /** 自定义每行小节数开关 */
+  openCustomNodule: boolean
+  /** 自定义每行小节数开关 */
+  customNoduleNum: number
 }
 
 export type IDifficulty = 'BEGINNER' | 'ADVANCED' | 'PERFORMER'
@@ -45,6 +50,7 @@ export type iEva = {
   reactionTimeMs: number
 }
 
+const search = qs.parse(location.search);
 const saveSetting = storejs.get('setting')
 
 let initState: SettingState = {
@@ -58,7 +64,9 @@ let initState: SettingState = {
     hertz: 442,
     scoreSize: 'middle',
     type: 'staff',
-    keySignature: false
+    keySignature: false,
+    openCustomNodule: true,
+    customNoduleNum: 4,
   },
   eva: {
     difficulty: 'ADVANCED',
@@ -68,10 +76,14 @@ let initState: SettingState = {
   },
 }
 if (saveSetting) {
+  const customNoduleInfo = JSON.parse(localStorage.getItem('customNoduleInfo')) || []
+  const matchMusic = customNoduleInfo.find((n: any) => n.id === search?.id)
+  const defaultNum = matchMusic ? matchMusic.customNum : 4
   // 如果有保存的设置,则使用保存的设置
   // 酷乐秀强制440,评测时会重新按照此处配置计算频率
   initState.eva = { ...initState.eva, ...saveSetting.eva }
-  initState.sett = { ...initState.sett, ...saveSetting.sett };
+  initState.sett = { ...initState.sett, ...saveSetting.sett, ...{customNoduleNum: defaultNum} };
+
   (window as any).sett = initState.sett
 }
 

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

@@ -188,3 +188,21 @@
   }
 }
 
+.columnItem {
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  position: relative;
+  z-index: 9;
+  background: #fff;
+  .columnBtn {
+    word-break: keep-all;
+    margin-left: 6px;
+    padding: 2px 6px;
+    border-radius: 8px;
+    background-color: var(--van-primary-color);
+    color: #fff;
+    font-size: 6px;
+    cursor: pointer;
+  }
+}

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

@@ -1,5 +1,5 @@
 import { defineComponent, Ref, ref } from 'vue'
-import { Button, Cell, CellGroup, Col, Dialog, Divider, NoticeBar, Radio, RadioGroup, Row, Switch, Toast } from 'vant'
+import { Button, Cell, CellGroup, Col, Dialog, Divider, NoticeBar, Radio, RadioGroup, Row, Switch, Toast, Field } from 'vant'
 import InfoIcon from './info.svg'
 import iconDown from './icons/down.svg'
 import iconTv from './icons/tv.png'
@@ -113,6 +113,22 @@ export default defineComponent({
       }
     }
 
+    // 自定义每行小节数量
+    const confirmCustomNum = () => {
+      let customNoduleInfo = JSON.parse(localStorage.getItem('customNoduleInfo')) || []
+      const matchIdx = customNoduleInfo.findIndex((n: any) => n.id === detailState.activeDetail?.examSongId)
+      if (matchIdx > -1) {
+        customNoduleInfo[matchIdx].customNum = Number(SettingState.sett.customNoduleNum)
+      } else {
+        customNoduleInfo.push({
+          id: detailState.activeDetail?.examSongId,
+          customNum: Number(SettingState.sett.customNoduleNum)
+        })
+      }
+      localStorage.setItem('customNoduleInfo', JSON.stringify(customNoduleInfo))
+      useReload()
+    }
+
     return () => {
       return (
         <>
@@ -128,6 +144,32 @@ export default defineComponent({
               <Cell center border={false} title="护眼模式">
                 <Switch v-model={SettingState.sett.eyeProtection} {...switchProps}></Switch>
               </Cell>
+              {/** 大雅金唐曲目自定义小节数 */}
+              {/* {
+                detailState.isDaYaCategory && 
+                <>
+                  <Cell center border={false} title="自定义每行小节数">
+                    <Switch v-model={SettingState.sett.openCustomNodule} {...switchProps}></Switch>
+                  </Cell>
+                  {
+                    <div class={styles.columnItem}>
+                      <Cell center border={false} title="每行小节数">
+                        <Field
+                          type="number"
+                          disabled={!SettingState.sett.openCustomNodule}
+                          value={SettingState.sett.customNoduleNum}
+                          v-model={SettingState.sett.customNoduleNum}
+                          inputAlign="right"
+                          maxlength={2}
+                          formatter={(value) => value.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}
+                        />
+                      </Cell>  
+                      <div class={styles.columnBtn} onClick={confirmCustomNum}>确认</div>
+                    </div>
+                  }
+                </>
+              } */}
+
               <Divider />
               {/* <Cell center border={false} title="乐谱大小">
                 <div style={{ display: 'flex' }}>

+ 8 - 2
src/subpages/colexiu/uses/use-app.ts

@@ -184,8 +184,11 @@ export const useDetail = (id: number | string): [Ref<ShaeetStatusType>, Ref<Musi
       // 大雅金唐类目,#9248 优化
       detailState.isDaYaCategory = daYaClassids.includes(res.data.musicSheetCategoriesId)
       if (detailState.isDaYaCategory) {
-        ;(window as any).customSectionAmount = true
-        setGlobalData('wrapNum', 4)
+        ;(window as any).customSectionAmount = SettingState.sett.openCustomNodule
+        const customNoduleInfo = JSON.parse(localStorage.getItem('customNoduleInfo')) || []
+        const matchMusic = customNoduleInfo.find((n: any) => n.id === id)
+        const xjNum = matchMusic ? matchMusic.customNum : 4
+        setGlobalData('wrapNum', xjNum)
       }
       detailState.subjectId = Number(musicInfo.musicSubject)
       // 打击乐声部下的曲目,需要合并展示所有分轨
@@ -203,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'
 
       // 额外配置