Преглед изворни кода

禁用右键菜单,禁用鼠标选中,禁止键盘F12键

sunlupeng пре 1 година
родитељ
комит
b9612c4b92
2 измењених фајлова са 22 додато и 1 уклоњено
  1. 21 0
      src/App.vue
  2. 1 1
      src/utils/request.js

+ 21 - 0
src/App.vue

@@ -35,6 +35,27 @@ export default {
   },
   created(){
     this.$store.dispatch('GetUserInfo');
+    this.$nextTick(() => {
+      // 1.禁用右键菜单
+      document.oncontextmenu = new Function("event.returnValue=false");
+      // 2.禁用鼠标选中
+      document.onselectstart = new Function("event.returnValue=false");
+      // 3.禁止键盘F12键
+      document.addEventListener("keydown", function (e) {
+        // 禁止 F12
+        if (e.key === "F12") {
+          e.preventDefault();
+        }
+        // 禁止 Ctrl + Shift + I 打开开发者工具
+        if (e.ctrlKey && e.shiftKey && e.key === 'I') {
+          e.preventDefault();
+        }
+        // 禁止 Ctrl + Shift + C 打开检查元素
+        if (e.ctrlKey && e.shiftKey && e.key === 'C') {
+          e.preventDefault();
+        }
+      });
+    });
   },
   methods:{
     fatherMethod() {

+ 1 - 1
src/utils/request.js

@@ -6,7 +6,7 @@ let prodBaseURL = 'https://xiaoyou.dgtis.com/admin';//正式地址
 
 // let prodBaseURL = 'https://malltest.dgtis.com/admin';//阿里云地址
 
-let devBaseURL = 'https://malltest.dgtis.com/admin';//测试地址
+let devBaseURL = 'https://xiaoyou.dgtis.com/admin';//测试地址
 
 // create an axios instance
 const service = axios.create({