fix: 防调试
This commit is contained in:
parent
7bff4abebe
commit
c564ef51ff
@ -116,7 +116,7 @@ const tabsChange = (e: Boolean) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 监听debug开关
|
||||
// 监听debug开关;
|
||||
const debugControl = new DebugControl();
|
||||
watch(
|
||||
() => debugPrevention.value,
|
||||
|
||||
@ -1,52 +1,51 @@
|
||||
<template>
|
||||
<a-watermark :content="watermark" v-bind="watermarkConfig">
|
||||
<a-layout-content class="layout-main-content">
|
||||
<Tabs v-if="isTabs" />
|
||||
<router-view v-slot="{ Component, route }">
|
||||
<MainTransition>
|
||||
<keep-alive :include="cacheRoutes">
|
||||
<component :is="Component" :key="route.name" v-if="refreshPage" />
|
||||
</keep-alive>
|
||||
</MainTransition>
|
||||
</router-view>
|
||||
</a-layout-content>
|
||||
</a-watermark>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import Tabs from "@/layout/components/Tabs/index.vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useThemeConfig } from "@/store/modules/theme-config";
|
||||
import { useRoutesConfigStore } from "@/store/modules/route-config";
|
||||
const themeStore = useThemeConfig();
|
||||
let { refreshPage, isTabs, watermark, watermarkStyle, watermarkRotate, watermarkGap } = storeToRefs(themeStore);
|
||||
const routerStore = useRoutesConfigStore();
|
||||
const { cacheRoutes } = storeToRefs(routerStore);
|
||||
|
||||
// 水印配置
|
||||
const watermarkConfig = computed(() => {
|
||||
return {
|
||||
font: watermarkStyle.value,
|
||||
rotate: watermarkRotate.value,
|
||||
gap: watermarkGap.value
|
||||
};
|
||||
});
|
||||
|
||||
watch(watermarkConfig, newv => {
|
||||
console.log(newv);
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.layout-main-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
// 修改左侧滚动条宽度-主要针对main窗口内的滚动条
|
||||
:deep(.arco-scrollbar-thumb-direction-vertical .arco-scrollbar-thumb-bar) {
|
||||
width: 4px;
|
||||
margin-left: 8px;
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<a-watermark :content="watermark" v-bind="watermarkConfig">
|
||||
<a-layout-content class="layout-main-content">
|
||||
<Tabs v-if="isTabs" />
|
||||
<router-view v-slot="{ Component, route }">
|
||||
<MainTransition>
|
||||
<keep-alive :include="cacheRoutes">
|
||||
<component :is="Component" :key="route.name" v-if="refreshPage" />
|
||||
</keep-alive>
|
||||
</MainTransition>
|
||||
</router-view>
|
||||
</a-layout-content>
|
||||
</a-watermark>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import Tabs from "@/layout/components/Tabs/index.vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useThemeConfig } from "@/store/modules/theme-config";
|
||||
import { useRoutesConfigStore } from "@/store/modules/route-config";
|
||||
const themeStore = useThemeConfig();
|
||||
let { refreshPage, isTabs, watermark, watermarkStyle, watermarkRotate, watermarkGap } = storeToRefs(themeStore);
|
||||
const routerStore = useRoutesConfigStore();
|
||||
const { cacheRoutes } = storeToRefs(routerStore);
|
||||
// 水印配置
|
||||
const watermarkConfig = computed(() => {
|
||||
return {
|
||||
font: watermarkStyle.value,
|
||||
rotate: watermarkRotate.value,
|
||||
gap: watermarkGap.value
|
||||
};
|
||||
});
|
||||
|
||||
watch(watermarkConfig, newv => {
|
||||
console.log(newv);
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.layout-main-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
// 修改左侧滚动条宽度-主要针对main窗口内的滚动条
|
||||
:deep(.arco-scrollbar-thumb-direction-vertical .arco-scrollbar-thumb-bar) {
|
||||
width: 4px;
|
||||
margin-left: 8px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -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?.());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user