liushengqiang 1 year ago
parent
commit
2b022298d1
2 changed files with 9 additions and 5 deletions
  1. 4 4
      src/page-instrument/view-product-img/index.tsx
  2. 5 1
      src/view/music-score/index.tsx

+ 4 - 4
src/page-instrument/view-product-img/index.tsx

@@ -10,7 +10,7 @@ export default defineComponent({
 	name: "music-list",
 	setup() {
 		const query: any = getQuery();
-
+		const productRenderType = "productRenderType"
 		const detailData = reactive({
 			isLoading: true,
 			isProductLoading: false,
@@ -41,7 +41,7 @@ export default defineComponent({
 			(window as any).appName = "colexiu";
 			state.xmlUrl = query.xmlUrl;
 			//课堂乐器,默认简谱
-			state.musicRenderType = detailData.product[detailData.step].type;
+			sessionStorage.setItem(productRenderType, detailData.product[detailData.step].type);
 
 			showLoadingToast({ message: "生成中", duration: 0 });
 			setTimeout(() => {
@@ -63,7 +63,7 @@ export default defineComponent({
 
 			if (detailData.step !== detailData.product.length) {
 				//课堂乐器,默认简谱
-				state.musicRenderType = detailData.product[detailData.step].type;
+				sessionStorage.setItem(productRenderType, detailData.product[detailData.step].type);
 				nextTick(() => {
 					detailData.isLoading = true;
 					setTimeout(() => {
@@ -115,7 +115,7 @@ export default defineComponent({
 			<div class={styles.detail}>
 				<div id="scrollContainer" class={[styles.container, "hideCursor"]}>
 					{/* 曲谱渲染 */}
-					{!detailData.isLoading && <MusicScore showSelection={false} onRendered={handleRendered} />}
+					{!detailData.isLoading && <MusicScore renderTypeKey={productRenderType} showSelection={false} onRendered={handleRendered} />}
 				</div>
 			</div>
 		);

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

@@ -42,11 +42,15 @@ export default defineComponent({
 			type: Boolean,
 			default: true,
 		},
+		renderTypeKey: {
+			type: String,
+			default: "",
+		},
 	},
 	setup(props, { emit }) {
 		/** 设置 曲谱模式,五线谱还是简谱 */
 		const setRenderType = () => {
-			const musicRenderType: any = sessionStorage.getItem(musicRenderTypeKey);
+			const musicRenderType: any = sessionStorage.getItem(props.renderTypeKey || musicRenderTypeKey);
 			if (musicRenderType in EnumMusicRenderType) {
 				state.musicRenderType = musicRenderType;
 			}