ソースを参照

超过五次处理多余的历史记录

tangning 19 時間 前
コミット
60ee5b7b0c

+ 1 - 1
src/view/case/photos/canvas-photo-editor.js

@@ -1399,7 +1399,7 @@ export class CanvasPhotoEditor {
     console.log("saveHistory", this.history, this.currentIndex);
     if (this.history.length > 5) {
       this.history.shift(); // 删除最早的一条
-      // this.currentIndex--;
+      this.currentIndex--;
     }
     this.updata({
       selectedPageItem: this._selectedPageItem,

+ 13 - 2
src/view/case/photos/index.vue

@@ -25,7 +25,7 @@
           ><ArrowLeft
         /></el-icon>
         <span
-          >{{ title || "照片制卷" }}</span
+          >{{ title || "照片制卷" }}{{ historylength }}{{currentIndex }}</span
         >
       </div>
       <div class="header-main">
@@ -464,7 +464,18 @@ watch(
   }
 );
 const backPageHandler = () => {
-  router.back();
+  let history = editor.value?.history;
+  if(history.length > 1) {
+    ElMessageBox.confirm("编辑内容尚未保存,确定要离开吗?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      }).then(async () => {
+        router.back();
+      });
+  }else{
+    router.back();
+  }
 };
 // 撤销
 const undo = (type) => {