diff --git a/frontend/app.html b/frontend/app.html
index 198bc9a..adb879b 100644
--- a/frontend/app.html
+++ b/frontend/app.html
@@ -2251,104 +2251,119 @@
// 检测开发者工具是否打开(调试模式下不检测)
if (!isDebugMode) {
- (function() {
- const threshold = 160;
- let isDevToolsOpen = false;
- let warningShown = false;
+ let devtoolsDetected = false;
- // 增强型检测:结合窗口尺寸和debugger暂停
- function checkDevTools() {
- const widthThreshold = window.outerWidth - window.innerWidth > threshold;
- const heightThreshold = window.outerHeight - window.innerHeight > threshold;
+ // 方法1: 使用console对象检测
+ const devtools = /./;
+ devtools.toString = function() {
+ devtoolsDetected = true;
+ };
- // 检测是否有开发者工具打开
- const isOpen = widthThreshold || heightThreshold ||
- (window.Firebug && window.Firebug.chrome && window.Firebug.chrome.isInitialized);
-
- if (isOpen && !isDevToolsOpen) {
- isDevToolsOpen = true;
-
- if (!warningShown) {
- warningShown = true;
-
- // 清空控制台
- console.clear();
-
- // 显示警告页面
- const warningHTML = `
-
-
-
-
检测到开发者工具
-
- 为保护系统安全,请关闭浏览器开发者工具后刷新页面
-
-
-
- 如需使用开发者工具,请联系管理员开启调试模式
-
-
-
- `;
-
- // 替换页面内容
- document.body.innerHTML = warningHTML;
- }
- } else if (!isOpen) {
- isDevToolsOpen = false;
- }
+ // 方法2: debugger暂停时间检测
+ function detectByDebugger() {
+ const start = performance.now();
+ debugger;
+ const end = performance.now();
+ return (end - start) > 100; // 如果暂停超过100ms,说明开发者工具打开
}
- // 立即检测一次(页面加载时就检查)
- checkDevTools();
+ // 方法3: 窗口尺寸检测
+ function detectByWindowSize() {
+ const threshold = 160;
+ const widthDiff = window.outerWidth - window.innerWidth;
+ const heightDiff = window.outerHeight - window.innerHeight;
+ return widthDiff > threshold || heightDiff > threshold;
+ }
- // 定期检测
- setInterval(checkDevTools, 500);
+ // 方法4: 检测console.log是否被执行
+ function detectByConsole() {
+ devtoolsDetected = false;
+ console.log(devtools);
+ console.clear();
+ return devtoolsDetected;
+ }
- // 使用debugger语句检测(更灵敏)
+ // 显示警告页面
+ function showWarning() {
+ const warningHTML = `
+
+
+
+
检测到开发者工具
+
+ 为保护系统安全,请关闭浏览器开发者工具后刷新页面
+
+
+
+ 如需使用开发者工具,请联系管理员开启调试模式
+
+
+
+ `;
+ document.body.innerHTML = warningHTML;
+ }
+
+ // 综合检测函数
+ function checkDevTools() {
+ // 使用多种方法检测,任意一种检测到就触发
+ const method1 = detectByConsole();
+ const method2 = detectByDebugger();
+ const method3 = detectByWindowSize();
+
+ if (method1 || method2 || method3) {
+ showWarning();
+ return true;
+ }
+ return false;
+ }
+
+ // 页面加载完成后立即检测
+ if (document.readyState === 'loading') {
+ document.addEventListener('DOMContentLoaded', function() {
+ setTimeout(checkDevTools, 100);
+ });
+ } else {
+ setTimeout(checkDevTools, 100);
+ }
+
+ // 持续监控
setInterval(function() {
- const before = new Date().getTime();
- debugger; // 如果开发者工具打开,这里会暂停
- const after = new Date().getTime();
-
- // 如果暂停时间超过100ms,说明开发者工具打开了
- if (after - before > 100) {
+ if (!document.body.innerHTML.includes('检测到开发者工具')) {
checkDevTools();
}
}, 1000);
- })();
}
// 禁用console输出(调试模式下不禁用)