Browse Source

设置小节的类型后,再次设置同样的类型还原成初始类型,小节数显示在小节的左上角

liushengqiang 1 year ago
parent
commit
6bdb3e86ea
3 changed files with 42 additions and 24 deletions
  1. 11 11
      src/pc/home/index.module.less
  2. 11 7
      src/pc/home/index.tsx
  3. 20 6
      src/pc/home/runtime.ts

+ 11 - 11
src/pc/home/index.module.less

@@ -168,15 +168,18 @@
 }
 
 :global {
-    .deleteDialog.saveDialog{
+    .deleteDialog.saveDialog {
         width: 338px;
-        .n-dialog__title{
+
+        .n-dialog__title {
             padding-right: 0 !important;
         }
-        .n-dialog__content{
+
+        .n-dialog__content {
             color: #777;
         }
     }
+
     .abcjs-note-hover {
         &:hover {
             fill: #ffe65948;
@@ -184,13 +187,9 @@
         }
     }
 
-    .abcjs-bar {
-        .abcjs-annotation {
-            display: block;
-            font-size: 12px;
-            font-style: italic;
-            transform: translateX(10px);
-        }
+    .abcjs-bar-number {
+        font-size: 12px;
+        transform: translateY(-5px);
     }
 
 
@@ -335,7 +334,8 @@
     align-items: center;
     z-index: 100;
 }
-.exportPng{
+
+.exportPng {
     position: fixed;
     left: 0;
     top: 0;

+ 11 - 7
src/pc/home/index.tsx

@@ -1099,9 +1099,9 @@ export default defineComponent({
 				if (value === "|:") {
 					const prevMeasure = abcData.abc.measures[data.active.measureIndex - 1] || null;
 					if (!prevMeasure) return;
-					prevMeasure.barline = value;
+					prevMeasure.barline = prevMeasure.barline === value ? "|" : value;
 				} else {
-					activeMeasure.barline = value;
+					activeMeasure.barline = activeMeasure.barline === value ? "|" : value;
 				}
 				await handleResetRender();
 			}
@@ -1284,6 +1284,7 @@ export default defineComponent({
 			// 			? item.step
 			// 			: item.step + 12
 			// 		: item.step;
+			console.log(item);
 			abcData.abc.visualTranspose = item.step;
 			abcData.abc.visualKey = item.value;
 			popup.moveKeyShow = false;
@@ -1407,8 +1408,8 @@ export default defineComponent({
 			try {
 				if (query.id) {
 					await api_musicSheetCreationUpdate({
-						name: data.musicName,
-						creator: data.creator,
+						name: data.musicName || "未命名乐谱",
+						creator: data.creator || "未命名乐谱",
 						creationConfig: renderMeasures(abcData.abc, {
 							hiddenIndex: true,
 							showTitle: true,
@@ -1422,8 +1423,8 @@ export default defineComponent({
 					});
 				} else {
 					const res = await api_musicSheetCreationSave({
-						name: data.musicName,
-						creator: data.creator,
+						name: data.musicName || "未命名乐谱",
+						creator: data.creator || "未命名乐谱",
 						creationConfig: renderMeasures(abcData.abc, {
 							hiddenIndex: true,
 							showTitle: true,
@@ -1789,6 +1790,9 @@ export default defineComponent({
 		};
 
 		const handleUpdate = async () => {
+			if (!data.isSave) {
+				await handleSaveMusic();
+			}
 			const query = getQuery();
 			const res = await api_musicSheetCreationDetail(query.id);
 			if (res.data) {
@@ -2737,7 +2741,7 @@ export default defineComponent({
 						if (data.uploadClick) {
 							setTimeout(() => {
 								handleClose();
-							}, 300)
+							}, 300);
 						}
 					}}
 				/>

+ 20 - 6
src/pc/home/runtime.ts

@@ -34,13 +34,13 @@ export const ABC_DATA = {
 	],
 	/** 调号 */
 	key: [
-		{ name: "C大调", value: "K:C", step: 0, icon: "icon-a-diaohao-cdadiaoaxiaodiao1" },
 		{ name: "F#大调", value: "K:F#", step: 6, icon: "icon-a-diaohao-fdadiaodxiaodiao" },
 		{ name: "F大调", value: "K:F", step: 5, icon: "icon-a-diaohao-fdadiaodxiaodiao1" },
 		{ name: "E大调", value: "K:E", step: 4, icon: "icon-a-diaohao-edadiaocxiaodiao" },
 		{ name: "Eb大调", value: "K:Eb", step: 3, icon: "icon-a-diaohao-ebdadiaocxiaodiao" },
 		{ name: "D大调", value: "K:D", step: 2, icon: "icon-a-diaohao-Ddaxiaoexiaodiao" },
 		{ name: "C#大调", value: "K:C#", step: 1, icon: "icon-a-diaohao-cdadiaoaxiaodiao" },
+		{ name: "C大调", value: "K:C", step: 0, icon: "icon-a-diaohao-cdadiaoaxiaodiao1" },
 		{ name: "B大调", value: "K:B", step: -1, icon: "icon-a-diaohao-bdadiaogxiaodiao" },
 		{ name: "Cb大调", value: "K:Cb", step: -1, icon: "icon-a-diaohao-cbdadiaoabxiaodiao" },
 		{ name: "Db大调", value: "K:Db", step: -1, icon: "icon-a-diaohao-dbdadiaobbxiaodiao" },
@@ -202,11 +202,25 @@ export const renderMeasures = (abc: IAbc, option?: IRenderMeasuresOption) => {
 	if (option?.showCreator) {
 		abc.creator && (text += `C:${abc.creator}` + "\n");
 	}
+	if (!option?.hiddenIndex) {
+		text += "%%barnumbers 1" + "\n";
+	}
+
 	abc.celf && (text += abc.celf + "\n");
 	abc.meter && (text += abc.meter + "\n");
 	abc.minUnit && (text += abc.minUnit + "\n");
 	abc.speed && (text += abc.speed + "\n");
-	abc.key && (text += abc.key + "\n");
+	if (abc.key) {
+		text += abc.key + " ";
+		
+		// text += "style=rhythm";
+		// text += "style=harmonic";
+		// text += "style=x";
+		// text += "style=triangle";
+		
+		text += "\n";
+	}
+	text += "V:1 style=jianpu" + "\n";
 
 	const measures = abc.measures;
 	for (let i = 0; i < measures.length; i++) {
@@ -243,10 +257,10 @@ export const renderMeasures = (abc: IAbc, option?: IRenderMeasuresOption) => {
 			}
 			text += note.segno ?? ""; // 分割
 		}
-		let _i = i + 1;
-		if (!option?.hiddenIndex) {
-			text += `"<${_i}"`;
-		}
+		// let _i = i + 1;
+		// if (!option?.hiddenIndex) {
+		// 	text += `"<${_i}"`;
+		// }
 		text += measure.barline ?? "";
 		if (wrap % 4 === 0) {
 			text += "\n";