Browse Source

feat: 图片下载支持A4尺寸

TIANYONG 4 months ago
parent
commit
f7696ee667
2 changed files with 19 additions and 1 deletions
  1. 13 0
      src/page-instrument/view-detail/index.tsx
  2. 6 1
      src/view/music-score/index.tsx

+ 13 - 0
src/page-instrument/view-detail/index.tsx

@@ -40,6 +40,7 @@ import Loading from "./loading"
 import ExerciseStatistics from "../custom-plugins/ExerciseStatistics"
 import { musicData } from "/src/view/music-score"
 import Vip from "/src/page-instrument/component/vip"
+import { getSvgPngToSize } from "/src/helpers/svgToPng"
 // import bgJson from "./images/index.json";
 
 // const DelayCheck = defineAsyncComponent(() =>
@@ -312,6 +313,18 @@ export default defineComponent({
       // } else {
       //   state.musicScoreBtnDirection = state.playBtnDirection;
       // }
+
+      // 管乐迷曲谱详情页,需要下载A4尺寸的图片
+      if (query.downPng === 'A4') {
+        const imgList = getSvgPngToSize(state.osmd)
+        console.log('A4', imgList)
+        window.parent.postMessage({
+          api: 'musicStaffRender',
+          loading: false,
+          osmdImg: imgList
+        }, '*');
+      }
+
       state.musicScoreBtnDirection = state.playBtnDirection;
       state.musicRendered = true;
 

+ 6 - 1
src/view/music-score/index.tsx

@@ -172,7 +172,12 @@ export default defineComponent({
 					osmd.Sheet.Instruments[i].Visible = canSelectTracks.includes(trackName)
 				}
 			}
-			osmd.zoom = state.zoom;
+			if (query.downPng === 'A4') {
+				osmd.setPageFormat('794x1070')
+				osmd.zoom = 0.3;
+			} else {
+				osmd.zoom = state.zoom;
+			}
 			osmd.render();
 			console.log("🚀 ~ osmd:", osmd)
 			emit("rendered", osmd);