From c564ef51ff8f5e7c15b620635c5e747cb3b1da31 Mon Sep 17 00:00:00 2001
From: "WANGFAN\\wangf" <15871339963@163.com>
Date: Tue, 15 Apr 2025 17:09:46 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E9=98=B2=E8=B0=83=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../components/system-settings/index.vue | 2 +-
src/layout/components/Main/index.vue | 103 +++++++++---------
src/utils/debug-prevention.ts | 26 ++---
3 files changed, 64 insertions(+), 67 deletions(-)
diff --git a/src/layout/components/Header/components/system-settings/index.vue b/src/layout/components/Header/components/system-settings/index.vue
index 234b8aa..5c814f8 100644
--- a/src/layout/components/Header/components/system-settings/index.vue
+++ b/src/layout/components/Header/components/system-settings/index.vue
@@ -116,7 +116,7 @@ const tabsChange = (e: Boolean) => {
}
};
-// 监听debug开关
+// 监听debug开关;
const debugControl = new DebugControl();
watch(
() => debugPrevention.value,
diff --git a/src/layout/components/Main/index.vue b/src/layout/components/Main/index.vue
index acd41b4..c98eec7 100644
--- a/src/layout/components/Main/index.vue
+++ b/src/layout/components/Main/index.vue
@@ -1,52 +1,51 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/utils/debug-prevention.ts b/src/utils/debug-prevention.ts
index e3b3da1..a2445c4 100644
--- a/src/utils/debug-prevention.ts
+++ b/src/utils/debug-prevention.ts
@@ -64,18 +64,19 @@ class RightMouseControl {
* 使用debugger关键字阻止打开控制台
*/
class DebugProtector {
- private isActive = false;
+ private isActive = false; // 是否开启防调试
+ private code = "d" + "e" + "b" + "u" + "g" + "g" + "e" + "r"; // 规避静态扫描
start() {
if (this.isActive) return;
- this.isActive = true;
- this.asyncCheck();
+ this.isActive = true; // 开启防调试
+ this.asyncCheck(); // 异步检查
}
private asyncCheck() {
if (!this.isActive) return;
-
- debugger;
+ // 使用eval执行代码
+ eval(this.code);
// 异步调度避免栈溢出
setTimeout(() => {
@@ -95,25 +96,22 @@ class DebugProtector {
* 3、使用debugger关键字阻止打开控制台
*/
class DebugControl {
- private keydown = new KeydownControl();
- private rightMouse = new RightMouseControl();
- private protector = new DebugProtector();
+ private modules: any[] = [];
+ constructor() {
+ this.modules.push(new KeydownControl(), new RightMouseControl(), new DebugProtector());
+ }
/**
* 开启防调试
*/
start() {
- this.keydown.start();
- this.rightMouse.start();
- this.protector.start();
+ this.modules.forEach(m => m.start?.());
}
/**
* 关闭防调试
*/
stop() {
- this.keydown.stop();
- this.rightMouse.stop();
- this.protector.stop();
+ this.modules.forEach(m => m.stop?.());
}
}