fix: correct local datetime display and remove false devtools detection
This commit is contained in:
@@ -1369,17 +1369,36 @@
|
||||
return 'color: #9E9E9E;';
|
||||
},
|
||||
|
||||
formatDate(dateString) {
|
||||
if (!dateString) return '';
|
||||
|
||||
// SQLite 返回的是 UTC 时间字符串,需要显式处理
|
||||
let dateStr = dateString;
|
||||
if (!dateStr.includes('Z') && !dateStr.includes('+') && !dateStr.includes('T')) {
|
||||
// SQLite 格式: "2025-11-13 16:37:19" -> ISO格式: "2025-11-13T16:37:19Z"
|
||||
dateStr = dateStr.replace(' ', 'T') + 'Z';
|
||||
parseDateValue(value) {
|
||||
if (!value) return null;
|
||||
if (value instanceof Date) {
|
||||
return Number.isNaN(value.getTime()) ? null : value;
|
||||
}
|
||||
|
||||
const date = new Date(dateStr);
|
||||
const raw = String(value).trim();
|
||||
if (!raw) return null;
|
||||
|
||||
const localMatch = raw.match(/^(\d{4})-(\d{2})-(\d{2})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/);
|
||||
if (localMatch) {
|
||||
const year = Number(localMatch[1]);
|
||||
const month = Number(localMatch[2]);
|
||||
const day = Number(localMatch[3]);
|
||||
const hour = Number(localMatch[4] || 0);
|
||||
const minute = Number(localMatch[5] || 0);
|
||||
const second = Number(localMatch[6] || 0);
|
||||
const localDate = new Date(year, month - 1, day, hour, minute, second);
|
||||
return Number.isNaN(localDate.getTime()) ? null : localDate;
|
||||
}
|
||||
|
||||
const normalized = raw.includes('T') ? raw : raw.replace(' ', 'T');
|
||||
const parsed = new Date(normalized);
|
||||
return Number.isNaN(parsed.getTime()) ? null : parsed;
|
||||
},
|
||||
|
||||
formatDate(dateString) {
|
||||
if (!dateString) return '';
|
||||
const date = this.parseDateValue(dateString);
|
||||
if (!date) return String(dateString);
|
||||
return date.toLocaleString('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
@@ -1395,7 +1414,8 @@
|
||||
formatExpireTime(expiresAt) {
|
||||
if (!expiresAt) return '永久有效';
|
||||
|
||||
const expireDate = new Date(expiresAt);
|
||||
const expireDate = this.parseDateValue(expiresAt);
|
||||
if (!expireDate) return String(expiresAt);
|
||||
const now = new Date();
|
||||
const diffMs = expireDate - now;
|
||||
const diffMinutes = Math.floor(diffMs / (1000 * 60));
|
||||
@@ -1429,7 +1449,8 @@
|
||||
// 判断是否即将过期(3天内)
|
||||
isExpiringSoon(expiresAt) {
|
||||
if (!expiresAt) return false;
|
||||
const expireDate = new Date(expiresAt);
|
||||
const expireDate = this.parseDateValue(expiresAt);
|
||||
if (!expireDate) return false;
|
||||
const now = new Date();
|
||||
const diffMs = expireDate - now;
|
||||
const diffDays = diffMs / (1000 * 60 * 60 * 24);
|
||||
@@ -1439,7 +1460,8 @@
|
||||
// 判断是否已过期
|
||||
isExpired(expiresAt) {
|
||||
if (!expiresAt) return false;
|
||||
const expireDate = new Date(expiresAt);
|
||||
const expireDate = this.parseDateValue(expiresAt);
|
||||
if (!expireDate) return false;
|
||||
const now = new Date();
|
||||
return expireDate <= now;
|
||||
}
|
||||
@@ -1494,57 +1516,17 @@
|
||||
// 禁用F12和常见开发者工具快捷键(调试模式下不禁用)
|
||||
if (!isDebugMode) {
|
||||
document.addEventListener('keydown', function(e) {
|
||||
// F12
|
||||
if (e.key === 'F12' || e.keyCode === 123) {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
// Ctrl+Shift+I (开发者工具)
|
||||
if (e.ctrlKey && e.shiftKey && (e.key === 'I' || e.keyCode === 73)) {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
// Ctrl+Shift+J (控制台)
|
||||
if (e.ctrlKey && e.shiftKey && (e.key === 'J' || e.keyCode === 74)) {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
// Ctrl+U (查看源代码)
|
||||
if (e.ctrlKey && (e.key === 'U' || e.keyCode === 85)) {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
// Ctrl+Shift+C (元素选择器)
|
||||
if (e.ctrlKey && e.shiftKey && (e.key === 'C' || e.keyCode === 67)) {
|
||||
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;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 检测开发者工具是否打开(调试模式下不检测)
|
||||
if (!isDebugMode) {
|
||||
(function() {
|
||||
const threshold = 160;
|
||||
let isDevToolsOpen = false;
|
||||
|
||||
setInterval(function() {
|
||||
const widthThreshold = window.outerWidth - window.innerWidth > threshold;
|
||||
const heightThreshold = window.outerHeight - window.innerHeight > threshold;
|
||||
|
||||
if (!(heightThreshold && widthThreshold) &&
|
||||
((window.Firebug && window.Firebug.chrome && window.Firebug.chrome.isInitialized) || widthThreshold || heightThreshold)) {
|
||||
if (!isDevToolsOpen) {
|
||||
isDevToolsOpen = true;
|
||||
console.clear();
|
||||
}
|
||||
} else {
|
||||
isDevToolsOpen = false;
|
||||
}
|
||||
}, 500);
|
||||
})();
|
||||
}
|
||||
|
||||
// 禁用console输出(调试模式下不禁用)
|
||||
if (!isDebugMode && window.location.hostname !== 'localhost' && window.location.hostname !== '127.0.0.1') {
|
||||
console.log = function() {};
|
||||
|
||||
Reference in New Issue
Block a user