更新
This commit is contained in:
+60
-20
@@ -30,6 +30,16 @@ const pageDataCache = {
|
||||
timestamp: 0,
|
||||
data: null,
|
||||
expiry: 10 * 60 * 1000 // 10分钟过期
|
||||
},
|
||||
about: {
|
||||
timestamp: 0,
|
||||
data: null,
|
||||
expiry: 10 * 60 * 1000 // 10分钟过期
|
||||
},
|
||||
threats: {
|
||||
timestamp: 0,
|
||||
data: null,
|
||||
expiry: 5 * 60 * 1000 // 5分钟过期
|
||||
}
|
||||
},
|
||||
|
||||
@@ -90,8 +100,11 @@ function initPageByHash() {
|
||||
document.getElementById('hosts-content'),
|
||||
document.getElementById('gfwlist-content'),
|
||||
document.getElementById('query-content'),
|
||||
document.getElementById('domain-content'),
|
||||
document.getElementById('logs-content'),
|
||||
document.getElementById('config-content')
|
||||
document.getElementById('config-content'),
|
||||
document.getElementById('about-content'),
|
||||
document.getElementById('threats-content')
|
||||
];
|
||||
|
||||
contentSections.forEach(section => {
|
||||
@@ -109,17 +122,20 @@ function initPageByHash() {
|
||||
// 更新页面标题
|
||||
const pageTitle = document.getElementById('page-title');
|
||||
if (pageTitle) {
|
||||
const titles = {
|
||||
'dashboard': '仪表盘',
|
||||
'shield': '屏蔽管理',
|
||||
'hosts': 'Hosts管理',
|
||||
'gfwlist': 'GFWList管理',
|
||||
'query': 'DNS屏蔽查询',
|
||||
'logs': '查询日志',
|
||||
'config': '系统设置'
|
||||
};
|
||||
pageTitle.textContent = titles[hash] || '仪表盘';
|
||||
}
|
||||
const titles = {
|
||||
'dashboard': '仪表盘',
|
||||
'shield': '屏蔽管理',
|
||||
'hosts': 'Hosts管理',
|
||||
'gfwlist': 'GFWList管理',
|
||||
'query': 'DNS屏蔽查询',
|
||||
'domain': '域名查询',
|
||||
'logs': '查询日志',
|
||||
'config': '系统设置',
|
||||
'about': '关于',
|
||||
'threats': '威胁告警'
|
||||
};
|
||||
pageTitle.textContent = titles[hash] || '仪表盘';
|
||||
}
|
||||
|
||||
// 页面特定初始化 - 使用setTimeout延迟调用,确保所有脚本文件都已加载完成
|
||||
if (hash === 'shield') {
|
||||
@@ -172,23 +188,43 @@ function initPageByHash() {
|
||||
}
|
||||
}
|
||||
}, 0);
|
||||
} else if (hash === 'about') {
|
||||
setTimeout(() => {
|
||||
if (typeof initAboutPage === 'function') {
|
||||
// 检查页面是否已经初始化
|
||||
if (!pageDataCache.isPageInitialized('about') || !pageDataCache.isCacheValid('about')) {
|
||||
initAboutPage();
|
||||
pageDataCache.markPageInitialized('about');
|
||||
}
|
||||
}
|
||||
}, 0);
|
||||
} else if (hash === 'threats') {
|
||||
setTimeout(() => {
|
||||
if (typeof initThreatsPage === 'function') {
|
||||
// 检查页面是否已经初始化
|
||||
if (!pageDataCache.isPageInitialized('threats') || !pageDataCache.isCacheValid('threats')) {
|
||||
initThreatsPage();
|
||||
pageDataCache.markPageInitialized('threats');
|
||||
}
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// 格式化运行时间
|
||||
function formatUptime(milliseconds) {
|
||||
// 简化版的格式化,实际使用时需要根据API返回的数据格式调整
|
||||
const seconds = Math.floor(milliseconds / 1000);
|
||||
const minutes = Math.floor(seconds / 60);
|
||||
const hours = Math.floor(minutes / 60);
|
||||
const days = Math.floor(hours / 24);
|
||||
const totalSeconds = Math.floor(milliseconds / 1000);
|
||||
const days = Math.floor(totalSeconds / (24 * 60 * 60));
|
||||
const hours = Math.floor((totalSeconds % (24 * 60 * 60)) / (60 * 60));
|
||||
const minutes = Math.floor((totalSeconds % (60 * 60)) / 60);
|
||||
const seconds = totalSeconds % 60;
|
||||
|
||||
if (days > 0) {
|
||||
return `${days}天${hours % 24}小时`;
|
||||
return `${days}天${hours}小时${minutes}分钟`;
|
||||
} else if (hours > 0) {
|
||||
return `${hours}小时${minutes % 60}分钟`;
|
||||
return `${hours}小时${minutes}分钟${seconds}秒`;
|
||||
} else if (minutes > 0) {
|
||||
return `${minutes}分钟${seconds % 60}秒`;
|
||||
return `${minutes}分钟${seconds}秒`;
|
||||
} else {
|
||||
return `${seconds}秒`;
|
||||
}
|
||||
@@ -528,6 +564,10 @@ function handleVisibilityChange() {
|
||||
initShieldPage();
|
||||
} else if (hash === 'hosts' && typeof initHostsPage === 'function') {
|
||||
initHostsPage();
|
||||
} else if (hash === 'about' && typeof initAboutPage === 'function') {
|
||||
initAboutPage();
|
||||
} else if (hash === 'threats' && typeof initThreatsPage === 'function') {
|
||||
initThreatsPage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user