fix: 防调试
This commit is contained in:
parent
7bff4abebe
commit
c564ef51ff
@ -116,7 +116,7 @@ const tabsChange = (e: Boolean) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 监听debug开关
|
// 监听debug开关;
|
||||||
const debugControl = new DebugControl();
|
const debugControl = new DebugControl();
|
||||||
watch(
|
watch(
|
||||||
() => debugPrevention.value,
|
() => debugPrevention.value,
|
||||||
|
|||||||
@ -22,7 +22,6 @@ const themeStore = useThemeConfig();
|
|||||||
let { refreshPage, isTabs, watermark, watermarkStyle, watermarkRotate, watermarkGap } = storeToRefs(themeStore);
|
let { refreshPage, isTabs, watermark, watermarkStyle, watermarkRotate, watermarkGap } = storeToRefs(themeStore);
|
||||||
const routerStore = useRoutesConfigStore();
|
const routerStore = useRoutesConfigStore();
|
||||||
const { cacheRoutes } = storeToRefs(routerStore);
|
const { cacheRoutes } = storeToRefs(routerStore);
|
||||||
|
|
||||||
// 水印配置
|
// 水印配置
|
||||||
const watermarkConfig = computed(() => {
|
const watermarkConfig = computed(() => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -64,18 +64,19 @@ class RightMouseControl {
|
|||||||
* 使用debugger关键字阻止打开控制台
|
* 使用debugger关键字阻止打开控制台
|
||||||
*/
|
*/
|
||||||
class DebugProtector {
|
class DebugProtector {
|
||||||
private isActive = false;
|
private isActive = false; // 是否开启防调试
|
||||||
|
private code = "d" + "e" + "b" + "u" + "g" + "g" + "e" + "r"; // 规避静态扫描
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
if (this.isActive) return;
|
if (this.isActive) return;
|
||||||
this.isActive = true;
|
this.isActive = true; // 开启防调试
|
||||||
this.asyncCheck();
|
this.asyncCheck(); // 异步检查
|
||||||
}
|
}
|
||||||
|
|
||||||
private asyncCheck() {
|
private asyncCheck() {
|
||||||
if (!this.isActive) return;
|
if (!this.isActive) return;
|
||||||
|
// 使用eval执行代码
|
||||||
debugger;
|
eval(this.code);
|
||||||
|
|
||||||
// 异步调度避免栈溢出
|
// 异步调度避免栈溢出
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -95,25 +96,22 @@ class DebugProtector {
|
|||||||
* 3、使用debugger关键字阻止打开控制台
|
* 3、使用debugger关键字阻止打开控制台
|
||||||
*/
|
*/
|
||||||
class DebugControl {
|
class DebugControl {
|
||||||
private keydown = new KeydownControl();
|
private modules: any[] = [];
|
||||||
private rightMouse = new RightMouseControl();
|
|
||||||
private protector = new DebugProtector();
|
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.modules.push(new KeydownControl(), new RightMouseControl(), new DebugProtector());
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 开启防调试
|
* 开启防调试
|
||||||
*/
|
*/
|
||||||
start() {
|
start() {
|
||||||
this.keydown.start();
|
this.modules.forEach(m => m.start?.());
|
||||||
this.rightMouse.start();
|
|
||||||
this.protector.start();
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 关闭防调试
|
* 关闭防调试
|
||||||
*/
|
*/
|
||||||
stop() {
|
stop() {
|
||||||
this.keydown.stop();
|
this.modules.forEach(m => m.stop?.());
|
||||||
this.rightMouse.stop();
|
|
||||||
this.protector.stop();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user