Quellcode durchsuchen

Merge branch 'gyt-feature-tianyong' into gyt-dev

TIANYONG vor 1 Jahr
Ursprung
Commit
8e20df7e6b

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

+ 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'
 
       // 额外配置