Browse Source

退出保存

liushengqiang 1 year ago
parent
commit
c2fa3dfa95
2 changed files with 34 additions and 8 deletions
  1. 12 0
      src/pc/home/index.module.less
  2. 22 8
      src/pc/home/index.tsx

+ 12 - 0
src/pc/home/index.module.less

@@ -168,6 +168,18 @@
 }
 
 :global {
+    .n-modal-scroll-content .n-modal-mask{
+        background-color: rgba(0, 0, 0, .6);
+    }
+    .deleteDialog.saveDialog{
+        width: 338px;
+        .n-dialog__title{
+            padding-right: 0 !important;
+        }
+        .n-dialog__content{
+            color: #777;
+        }
+    }
     .abcjs-note-hover {
         &:hover {
             fill: #ffe65948;

+ 22 - 8
src/pc/home/index.tsx

@@ -40,6 +40,7 @@ import {
 	NSelect,
 	NSpace,
 	NSpin,
+	useDialog,
 	useMessage,
 } from "naive-ui";
 import { LongArrowAltDown, LongArrowAltUp, GripLinesVertical } from "@vicons/fa";
@@ -102,6 +103,7 @@ function moveNote(note: string, step: number) {
 export default defineComponent({
 	name: "Home",
 	setup() {
+		const dialog = useDialog();
 		const route = useRoute();
 		const message = useMessage();
 		const popup = reactive({
@@ -622,11 +624,22 @@ export default defineComponent({
 
 			if (type === "exit") {
 				if (!data.isSave) {
-					showConfirmDialog({
+					dialog.warning({
+						maskClosable: true,
+						autoFocus: false,
+						class: "deleteDialog saveDialog",
 						title: "温馨提示",
-						message: "还没保存,是否保存?",
-					})
-						.then(async () => {
+						content: '是否保存当前曲谱?',
+						positiveText: "保存",
+						positiveButtonProps: {
+							type: "primary",
+						},
+						negativeText: "不保存",
+						negativeButtonProps: {
+							type: "default",
+							ghost: false,
+						},
+						onPositiveClick: async () => {
 							const msg = message.loading("保存中...");
 							await handleSaveMusic(false);
 							setTimeout(() => {
@@ -637,10 +650,11 @@ export default defineComponent({
 									handleClose();
 								}, 500);
 							}, 300);
-						})
-						.catch(() => {
+						},
+						onNegativeClick: () => {
 							handleClose();
-						});
+						},
+					});
 					return;
 				}
 				handleClose();
@@ -1006,7 +1020,7 @@ export default defineComponent({
 
 			// 移动音符
 			if (type === "move") {
-				const step = value._step ? value._step : value.action === "up" ? -1 : 1;
+				const step = value.action === "drag" ? value.step : value.action === "up" ? -1 : 1;
 				if (!activeNote) return;
 				activeNote.content = moveNote(activeNote.content, step);
 				// arr now contains elements that are either a chord, a decoration, a note name, or anything else. It can be put back to its original string with .join("").