fix: correct local datetime display and remove false devtools detection

This commit is contained in:
2026-02-18 11:23:34 +08:00
parent 751428a29a
commit 3ea17db971
3 changed files with 104 additions and 159 deletions

View File

@@ -13,101 +13,32 @@
}
})();
</script>
<!-- 开发者工具检测 - 必须放在最前面,优先执行 -->
<!-- 安全快捷键拦截(避免误判开发者工具) -->
<script>
(function() {
'use strict';
// 检查调试模式
const isDebugMode = localStorage.getItem('debugMode') === 'true';
if (isDebugMode) return; // 调试模式下跳过检测
if (isDebugMode) return;
let devtoolsOpen = false;
let checkCount = 0; // 检测次数计数器
// 方法1: Console对象toString检测最可靠
const checkElement = /./;
checkElement.toString = function() {
devtoolsOpen = true;
};
// 方法2: debugger暂停检测可能误判需要多次确认
function detectDebugger() {
const start = performance.now();
debugger;
const end = performance.now();
return (end - start) > 100;
}
// 方法3: 窗口尺寸检测(辅助判断)
function detectWindowSize() {
const widthDiff = window.outerWidth - window.innerWidth;
const heightDiff = window.outerHeight - window.innerHeight;
// 提高阈值,避免误判
return widthDiff > 200 || heightDiff > 200;
}
// 综合检测(需要多个条件同时满足才判定)
function checkDevTools() {
devtoolsOpen = false;
console.log('%c', checkElement);
console.clear();
const consoleOpen = devtoolsOpen;
const debuggerPause = detectDebugger();
const windowSizeAbnormal = detectWindowSize();
// 严格判定console检测为主其他为辅助
// 只有console明确检测到才触发警告
return consoleOpen && (debuggerPause || windowSizeAbnormal);
}
// 立即检测(页面加载时)
const initialCheck = checkDevTools();
if (initialCheck) {
// 检测到开发者工具,显示警告
document.write('<style>body{margin:0;overflow:hidden;}</style>');
document.write('<div style="position:fixed;top:0;left:0;width:100%;height:100%;background:linear-gradient(135deg,#667eea 0%,#764ba2 100%);display:flex;align-items:center;justify-content:center;font-family:Arial,sans-serif;z-index:999999;">');
document.write('<div style="background:white;padding:60px;border-radius:20px;text-align:center;max-width:500px;box-shadow:0 20px 60px rgba(0,0,0,0.3);">');
document.write('<div style="font-size:80px;color:#667eea;margin-bottom:30px;">🛡️</div>');
document.write('<h1 style="color:#333;margin-bottom:20px;font-size:32px;">检测到开发者工具</h1>');
document.write('<p style="color:#666;font-size:18px;margin-bottom:30px;line-height:1.6;">为保护系统安全,请关闭浏览器开发者工具后访问</p>');
document.write('<button onclick="location.reload()" style="background:linear-gradient(135deg,#667eea 0%,#764ba2 100%);color:white;border:none;padding:15px 40px;font-size:16px;border-radius:10px;cursor:pointer;font-weight:600;box-shadow:0 4px 15px rgba(102,126,234,0.4);">🔄 刷新页面</button>');
document.write('<p style="color:#999;font-size:14px;margin-top:20px;">如需使用开发者工具,请联系管理员开启调试模式</p>');
document.write('</div></div>');
document.close();
throw new Error('DevTools detected');
}
// 禁用右键和快捷键
document.addEventListener('contextmenu', e => e.preventDefault());
document.addEventListener('keydown', function(e) {
// F12, Ctrl+Shift+I, Ctrl+Shift+J, Ctrl+U, Ctrl+Shift+C
if (e.keyCode === 123 ||
(e.ctrlKey && e.shiftKey && (e.keyCode === 73 || e.keyCode === 74 || e.keyCode === 67)) ||
(e.ctrlKey && e.keyCode === 85)) {
const key = String(e.key || '').toLowerCase();
const blocked = e.keyCode === 123
|| (e.ctrlKey && e.shiftKey && ['i', 'j', 'c'].includes(key))
|| (e.ctrlKey && key === 'u');
if (blocked) {
e.preventDefault();
return false;
}
});
// 持续监控每2秒检测一次避免频繁检测
setInterval(function() {
checkCount++;
// 每次检测都要确认
if (checkDevTools()) {
// 检测到开发者工具打开,刷新页面
location.reload();
}
}, 2000);
// 禁用console非localhost
if (window.location.hostname !== 'localhost' && window.location.hostname !== '127.0.0.1') {
const noop = function() {};
['log', 'info', 'warn', 'error', 'debug'].forEach(method => {
console[method] = noop;
try {
console[method] = noop;
} catch (_) {}
});
}
})();
@@ -7599,6 +7530,6 @@
}
</style>
<script src="app.js?v=20260218001"></script>
<script src="app.js?v=20260218002"></script>
</body>
</html>