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(); const debugControl = new DebugControl();
watch( watch(
() => debugPrevention.value, () => debugPrevention.value,

View File

@ -1,52 +1,51 @@
<template> <template>
<a-watermark :content="watermark" v-bind="watermarkConfig"> <a-watermark :content="watermark" v-bind="watermarkConfig">
<a-layout-content class="layout-main-content"> <a-layout-content class="layout-main-content">
<Tabs v-if="isTabs" /> <Tabs v-if="isTabs" />
<router-view v-slot="{ Component, route }"> <router-view v-slot="{ Component, route }">
<MainTransition> <MainTransition>
<keep-alive :include="cacheRoutes"> <keep-alive :include="cacheRoutes">
<component :is="Component" :key="route.name" v-if="refreshPage" /> <component :is="Component" :key="route.name" v-if="refreshPage" />
</keep-alive> </keep-alive>
</MainTransition> </MainTransition>
</router-view> </router-view>
</a-layout-content> </a-layout-content>
</a-watermark> </a-watermark>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import Tabs from "@/layout/components/Tabs/index.vue"; import Tabs from "@/layout/components/Tabs/index.vue";
import { storeToRefs } from "pinia"; import { storeToRefs } from "pinia";
import { useThemeConfig } from "@/store/modules/theme-config"; import { useThemeConfig } from "@/store/modules/theme-config";
import { useRoutesConfigStore } from "@/store/modules/route-config"; import { useRoutesConfigStore } from "@/store/modules/route-config";
const themeStore = useThemeConfig(); 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 { font: watermarkStyle.value,
font: watermarkStyle.value, rotate: watermarkRotate.value,
rotate: watermarkRotate.value, gap: watermarkGap.value
gap: watermarkGap.value };
}; });
});
watch(watermarkConfig, newv => {
watch(watermarkConfig, newv => { console.log(newv);
console.log(newv); });
}); </script>
</script>
<style lang="scss" scoped>
<style lang="scss" scoped> .layout-main-content {
.layout-main-content { display: flex;
display: flex; flex-direction: column;
flex-direction: column; height: 100%;
height: 100%; }
}
// -main
// -main :deep(.arco-scrollbar-thumb-direction-vertical .arco-scrollbar-thumb-bar) {
:deep(.arco-scrollbar-thumb-direction-vertical .arco-scrollbar-thumb-bar) { width: 4px;
width: 4px; margin-left: 8px;
margin-left: 8px; }
} </style>
</style>

View File

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