YaolongHan 4 years ago
parent
commit
a608454457
2 changed files with 20 additions and 4 deletions
  1. 10 0
      src/components/baseEditer.vue
  2. 10 4
      src/components/mapClass/EditScence.ts

+ 10 - 0
src/components/baseEditer.vue

@@ -30,6 +30,7 @@ import { Message } from "element-ui";
 import { SCircleItem } from "@/lib/items/SCircleItem";
 import menuList from "@/components/edit/menu_list.vue";
 window.FENGMAP = null;
+const isMac = /macintosh|mac os x/i.test(navigator.userAgent);
 //// 底图空间增加字段 isExtracted:boolean true 已被提取过
 export default {
   props: {
@@ -90,6 +91,10 @@ export default {
         // 按 ctrl
         that.scene.isDownCtrl = true;
       }
+      if(e && e.key == "Meta" && isMac){
+        // 如果为苹果键
+        that.scene.isDownCtrl = true;
+      }
     };
     document.onkeyup = function(event) {
       const e = event || window.event || arguments.callee.caller.arguments[0];
@@ -98,6 +103,11 @@ export default {
         that.scene.isDownCtrl = false;
         this.scene.setCmd = "choice";
       }
+      if(e && e.key == "Meta" && isMac){
+        // 如果为苹果键
+        that.scene.isDownCtrl = false;
+        this.scene.setCmd = "choice";
+      }
     };
     // 自动保存(时间差为一分钟)
     this.autoSave = setInterval(() => {

+ 10 - 4
src/components/mapClass/EditScence.ts

@@ -31,10 +31,11 @@ import { SCustomLegendItem } from '@/lib/items/SCustomLegendItem';
  *
  * @author 韩耀龙
  */
-
 export class EditScence extends SGraphScene {
 
     undoStack = new SUndoStack();
+    /** 判断是否为苹果电脑 */
+    public isMac = /macintosh|mac os x/i.test(navigator.userAgent);
     /** 命令 1 绘制直线 */
     private cmd = 'choice';
     /** 获取当前状态 */
@@ -99,7 +100,8 @@ export class EditScence extends SGraphScene {
         ItemColor.columnColor = new SColor("#d4d4d4")
         ItemColor.virtualWallColor = new SColor("#d4d4d4")
         ItemColor.selectColor = new SColor("#f0f0f0")
-        ItemColor.spaceBorderColor = new SColor("#d4d4d4")
+        ItemColor.spaceBorderColor = new SColor("#d4d4d4");
+        console.log('isMac',this.isMac)
     }
     /** 绘制图例样式 */
     _legend: any | null = null;
@@ -1130,8 +1132,12 @@ export class EditScence extends SGraphScene {
         if (event.code == 'Delete') {
             this.deleiteItem()
         }
+        // 删除键功能--兼容苹果mac
+        if (event.code == 'Backspace' && this.isMac){
+            this.deleiteItem()
+        }
         // 复制粘贴
-        if (event.ctrlKey && !event.repeat) { 
+        if (event.ctrlKey && !event.repeat) {
             if (event.code == 'KeyC') {
                 console.log('ctrl c')
                 this.copy()
@@ -1175,7 +1181,7 @@ export class EditScence extends SGraphScene {
             console.log(this.copyString)
         }
     }
-    
+
     /**
      * 粘贴
      *