Ver Fonte

退出保存

liushengqiang há 1 ano atrás
pai
commit
42296be016
1 ficheiros alterados com 56 adições e 19 exclusões
  1. 56 19
      src/pc/home/index.tsx

+ 56 - 19
src/pc/home/index.tsx

@@ -124,7 +124,7 @@ export default defineComponent({
 		const data = reactive({
 			loading: true,
 			drawCount: 0,
-			isSave: false,
+			isSave: true,
 			musicId: "",
 			musicName: "", // 曲谱名称
 			creator: "", // 创建者
@@ -331,7 +331,7 @@ export default defineComponent({
 						}
 					}
 				}
-				data.activePlayNote = {...ev};
+				data.activePlayNote = { ...ev };
 				var cursor = document.querySelector("#paper svg .ABCJS-cursor");
 				if (cursor) {
 					cursor.setAttribute("x1", ev.left + ev.width / 2);
@@ -406,10 +406,10 @@ export default defineComponent({
 			} else {
 				abcData.synthControl.restart();
 				nextTick(() => {
-					if (!data.playState){
+					if (!data.playState) {
 						abcData.synthControl.play();
 					}
-				})
+				});
 			}
 			// console.log("🚀 ~ abcData.synthControl:", abcData.synthControl.timer.noteTimings);
 		};
@@ -481,7 +481,7 @@ export default defineComponent({
 					data.playState = false;
 				}
 			}
-
+			data.isSave = false;
 			return new Promise((resolve) => {
 				nextTick(() => {
 					data.music = renderMeasures(abcData.abc);
@@ -578,6 +578,21 @@ export default defineComponent({
 			return notes;
 		};
 
+		const handleClose = () => {
+			// 判断是否在应用中
+			if (window.matchMedia("(display-mode: standalone)").matches) {
+				window.onbeforeunload = null;
+				window.parent.postMessage(
+					{
+						api: "notation_exit",
+					},
+					"*"
+				);
+			} else {
+				window.close();
+			}
+		};
+
 		/**
 		 *
 		 * @param key
@@ -595,20 +610,29 @@ export default defineComponent({
 				abcData.abc.measures[data.active?.measureIndex]?.notes[data.active?.noteIndex] || null;
 
 			if (type === "exit") {
-				// 退出时先保存 不提示
-				await handleSaveMusic(false);
-				// 判断是否在应用中
-				if (window.matchMedia("(display-mode: standalone)").matches) {
-					window.onbeforeunload = null;
-					window.parent.postMessage(
-						{
-							api: "notation_exit",
-						},
-						"*"
-					);
-				} else {
-					window.close();
+				if (!data.isSave) {
+					showConfirmDialog({
+						title: "温馨提示",
+						message: "还没保存,是否保存?",
+					})
+						.then(async () => {
+							const msg = message.loading("保存中...");
+							await handleSaveMusic(false);
+							setTimeout(() => {
+								msg.type = "success";
+								msg.content = "保存成功";
+								setTimeout(() => {
+									msg.destroy();
+									handleClose();
+								}, 500);
+							}, 300);
+						})
+						.catch(() => {
+							handleClose();
+						});
+					return;
 				}
+				handleClose();
 			}
 			// console.log(params, activeNote);
 			if (type === "type") {
@@ -1142,6 +1166,10 @@ export default defineComponent({
 				value: index,
 			}));
 		});
+		const instrumentName = computed(() => {
+			const code = ABCJS.synth.instrumentIndexToName[abcData.synthOptions.program];
+			return instrumentsNames[code as keyof typeof instrumentsNames];
+		});
 		const getDetailData = async () => {
 			data.loading = true;
 			const query: any = getQuery();
@@ -1620,7 +1648,16 @@ export default defineComponent({
 											<div class={styles.btnImg} onClick={() => (popup.instrument = true)}>
 												<img class={styles.topBtnIcon} src={getImage("icon_25.png")} />
 											</div>
-											<div>选择声部</div>
+											<div
+												style={{
+													overflow: "hidden",
+													textOverflow: "ellipsis",
+													whiteSpace: "nowrap",
+													maxWidth: "60px",
+												}}
+											>
+												{instrumentName.value}
+											</div>
 										</div>
 									),
 									default: () => (