Browse Source

登录页面,密码框禁止复制和右键

niuheng 2 years ago
parent
commit
da57d5446f
1 changed files with 17 additions and 0 deletions
  1. 17 0
      src/components/frame/login.vue

+ 17 - 0
src/components/frame/login.vue

@@ -18,6 +18,8 @@
               v-model="userPass"
               @keyup.stop="passTxtKeyUp($event)"
               v-loading.fullscreen.lock="fullscreenLoading"
+              @contextmenu="passTextContextmenuEvent($event)"
+              @keydown="passTxtKeyDown($event)"
             />
           </div>
         </div>
@@ -84,6 +86,21 @@ export default {
     passTxtKeyUp: function (event) {
       if (event.keyCode == 13) this.startLogin();
     },
+    //密码框鼠标右键事件
+    passTextContextmenuEvent: function (event) {
+      event.preventDefault();
+      return false;
+    },
+    //密码框键盘按下事件
+    passTxtKeyDown: function (event) {
+      var keycode = event.keyCode;
+      var key = String.fromCharCode(keycode).toLowerCase();
+      //禁止复制
+      if (event.ctrlKey && key == "c") {
+        event.preventDefault();
+        return false;
+      }
+    },
   },
   created() {},
   mounted() {},