diff --git a/frontend/app.html b/frontend/app.html index 0478136..198bc9a 100644 --- a/frontend/app.html +++ b/frontend/app.html @@ -2254,24 +2254,100 @@ (function() { const threshold = 160; let isDevToolsOpen = false; + let warningShown = false; - setInterval(function() { + // 增强型检测:结合窗口尺寸和debugger暂停 + function checkDevTools() { const widthThreshold = window.outerWidth - window.innerWidth > threshold; const heightThreshold = window.outerHeight - window.innerHeight > threshold; - const orientation = widthThreshold ? 'vertical' : 'horizontal'; - if (!(heightThreshold && widthThreshold) && - ((window.Firebug && window.Firebug.chrome && window.Firebug.chrome.isInitialized) || widthThreshold || heightThreshold)) { - if (!isDevToolsOpen) { - isDevToolsOpen = true; - // 检测到开发者工具打开,可以选择清空页面或重定向 - // document.body.innerHTML = '

请关闭开发者工具

'; + // 检测是否有开发者工具打开 + 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 { + } else if (!isOpen) { isDevToolsOpen = false; } - }, 500); + } + + // 立即检测一次(页面加载时就检查) + checkDevTools(); + + // 定期检测 + setInterval(checkDevTools, 500); + + // 使用debugger语句检测(更灵敏) + setInterval(function() { + const before = new Date().getTime(); + debugger; // 如果开发者工具打开,这里会暂停 + const after = new Date().getTime(); + + // 如果暂停时间超过100ms,说明开发者工具打开了 + if (after - before > 100) { + checkDevTools(); + } + }, 1000); })(); }