fix: 防调试

This commit is contained in:
WANGFAN\wangf 2025-04-15 17:09:46 +08:00
parent 7bff4abebe
commit c564ef51ff
3 changed files with 64 additions and 67 deletions

View File

@ -116,7 +116,7 @@ const tabsChange = (e: Boolean) => {
}
};
// debug
// debug;
const debugControl = new DebugControl();
watch(
() => debugPrevention.value,

View File

@ -22,7 +22,6 @@ const themeStore = useThemeConfig();
let { refreshPage, isTabs, watermark, watermarkStyle, watermarkRotate, watermarkGap } = storeToRefs(themeStore);
const routerStore = useRoutesConfigStore();
const { cacheRoutes } = storeToRefs(routerStore);
//
const watermarkConfig = computed(() => {
return {

View File

@ -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?.());
}
}