feat: add Monitor page for S2A dashboard statistics, pool management, and health checks.

This commit is contained in:
2026-02-01 07:55:10 +08:00
parent 995af8e19a
commit 6254e3781b

View File

@@ -258,6 +258,15 @@ export default function Monitor() {
// 从后端加载监控设置 // 从后端加载监控设置
const loadMonitorSettings = async () => { const loadMonitorSettings = async () => {
try { try {
// 加载全局代理配置(始终执行)
const configRes = await fetch('/api/config')
if (configRes.ok) {
const configJson = await configRes.json()
if (configJson.code === 0 && configJson.data) {
setGlobalProxy(configJson.data.default_proxy || '')
}
}
// 加载监控设置 // 加载监控设置
const res = await fetch('/api/monitor/settings') const res = await fetch('/api/monitor/settings')
if (res.ok) { if (res.ok) {
@@ -288,15 +297,6 @@ export default function Monitor() {
return { target, autoAdd: autoAddVal, minInterval: minIntervalVal, checkInterval: checkIntervalVal, pollingEnabled: pollingEnabledVal, pollingInterval: interval, replenishUseProxy: replenishUseProxyVal, browserType: browserTypeVal } return { target, autoAdd: autoAddVal, minInterval: minIntervalVal, checkInterval: checkIntervalVal, pollingEnabled: pollingEnabledVal, pollingInterval: interval, replenishUseProxy: replenishUseProxyVal, browserType: browserTypeVal }
} }
} }
// 加载全局代理配置
const configRes = await fetch('/api/config')
if (configRes.ok) {
const configJson = await configRes.json()
if (configJson.code === 0 && configJson.data) {
setGlobalProxy(configJson.data.default_proxy || '')
}
}
} catch (e) { } catch (e) {
console.error('加载监控设置失败:', e) console.error('加载监控设置失败:', e)
} }
@@ -537,12 +537,12 @@ export default function Monitor() {
disabled={!autoAdd || !globalProxy} disabled={!autoAdd || !globalProxy}
label="补号时使用代理" label="补号时使用代理"
description={ description={
globalProxy globalProxy
? `当前代理: ${globalProxy}` ? `当前代理: ${globalProxy}`
: '请先在系统配置中设置代理地址(支持 http://host:port、http://user:pass@host:port、host:port:user:pass' : '请先在系统配置中设置代理地址(支持 http://host:port、http://user:pass@host:port、host:port:user:pass'
} }
/> />
</div> </div>
{/* 浏览器选择器 */} {/* 浏览器选择器 */}
<div className="space-y-2"> <div className="space-y-2">
<label className="block text-sm font-medium text-slate-700 dark:text-slate-300"> <label className="block text-sm font-medium text-slate-700 dark:text-slate-300">
@@ -554,8 +554,8 @@ export default function Monitor() {
onClick={() => setBrowserType('chromedp')} onClick={() => setBrowserType('chromedp')}
disabled={!autoAdd} disabled={!autoAdd}
className={`flex-1 px-4 py-2.5 text-sm font-medium transition-all duration-200 ${browserType === 'chromedp' className={`flex-1 px-4 py-2.5 text-sm font-medium transition-all duration-200 ${browserType === 'chromedp'
? 'bg-blue-600 text-white' ? 'bg-blue-600 text-white'
: 'bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-400 hover:bg-slate-200 dark:hover:bg-slate-700' : 'bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-400 hover:bg-slate-200 dark:hover:bg-slate-700'
} ${!autoAdd ? 'opacity-50 cursor-not-allowed' : ''}`} } ${!autoAdd ? 'opacity-50 cursor-not-allowed' : ''}`}
> >
Chromedp Chromedp
@@ -565,8 +565,8 @@ export default function Monitor() {
onClick={() => setBrowserType('rod')} onClick={() => setBrowserType('rod')}
disabled={!autoAdd} disabled={!autoAdd}
className={`flex-1 px-4 py-2.5 text-sm font-medium transition-all duration-200 border-l border-slate-200 dark:border-slate-700 ${browserType === 'rod' className={`flex-1 px-4 py-2.5 text-sm font-medium transition-all duration-200 border-l border-slate-200 dark:border-slate-700 ${browserType === 'rod'
? 'bg-blue-600 text-white' ? 'bg-blue-600 text-white'
: 'bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-400 hover:bg-slate-200 dark:hover:bg-slate-700' : 'bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-400 hover:bg-slate-200 dark:hover:bg-slate-700'
} ${!autoAdd ? 'opacity-50 cursor-not-allowed' : ''}`} } ${!autoAdd ? 'opacity-50 cursor-not-allowed' : ''}`}
> >
Rod Rod