Parcourir la source

feat: 摇篮曲(节奏练习),生成图片修改

TIANYONG il y a 1 an
Parent
commit
1748585c24
2 fichiers modifiés avec 11 ajouts et 3 suppressions
  1. 2 2
      src/helpers/customMusicScore.ts
  2. 9 1
      src/view/transfer-to-img/index.tsx

+ 2 - 2
src/helpers/customMusicScore.ts

@@ -156,12 +156,12 @@ export const resetGivenFormate = () => {
 	
 };
 
-const moveGracePosition = () => {
+export const moveGracePosition = (needTrans?: boolean) => {
 	/**
 	 * TODO:曲目:摇篮曲(节奏练习)-倚音位置 特殊处理
 	 */
 	const specialIds = ['1788850864767643649','1788502467554750466'];
-	if (specialIds.includes(state.cbsExamSongId)) {
+	if (specialIds.includes(state.cbsExamSongId) || needTrans) {
 		const lastCurve: any = Array.from(document.getElementsByClassName('vf-curve'))?.last();
 		if (lastCurve) {
 			lastCurve.style.display = 'none';

+ 9 - 1
src/view/transfer-to-img/index.tsx

@@ -5,6 +5,7 @@ import styles from "./index.module.less";
 import { getQuery } from "/src/utils/queryString";
 import { closeToast, showLoadingToast } from "vant";
 import { svg2canvas } from "/src/utils/svg2canvas";
+import { moveGracePosition } from "/src/helpers/customMusicScore"
 
 export default defineComponent({
 	name: "transfer-to-img",
@@ -35,11 +36,16 @@ export default defineComponent({
 					base64: "" as any,
 				},
 			],
+			isSpecialXml: false, // TODO:是否是摇篮曲(节奏练习)的曲子
 		});
 
 		onMounted(() => {
 			(window as any).appName = "colexiu";
 			state.xmlUrl = decodeURIComponent(query.xmlUrl);
+			const specialXmls = ['https://oss.dayaedu.com/MECMP/1715332965751.xml','https://oss.dayaedu.com/MECMP/1715326622946.xml'];
+			if (specialXmls.includes(state.xmlUrl)) {
+				detailData.isSpecialXml = true;
+			}
 			//课堂乐器,默认简谱
 			sessionStorage.setItem(productRenderType, detailData.product[detailData.step].type);
 
@@ -51,7 +57,9 @@ export default defineComponent({
 
 		/** 渲染完成 */
 		const handleRendered = async () => {
-			
+			if (document.getElementById('scrollContainer')) {
+				moveGracePosition(detailData.isSpecialXml);
+			}
 			detailData.product[detailData.step].state = true;
 			detailData.product[detailData.step].base64 = await downPng();