feat: 接入授权中心(安装/在线统计、公告推送、版本更新提示)+ 修复弹窗遮罩点击失效

This commit is contained in:
jinghui committed 2026-10-27 14:37:41 +08:00
1 parent 4ba470fc49
commit 192fe596d4
13 files changed
+510 -17

No files matched your search

+23 -1
View File
@@ -40,6 +40,7 @@ const DEFAULT_SETTINGS = {
notify: true,
debounceMinutes: 10,
links: { repo: '', nav: '' },
telemetry: true, // 安装/在线统计上报(关闭后不再上报,公告仍可拉取)
};
let settings = JSON.parse(JSON.stringify(DEFAULT_SETTINGS));
try {
@@ -937,8 +938,11 @@ app.post('/api/settings', (req, res) => {
notify: b.notify !== undefined ? !!b.notify : settings.notify,
debounceMinutes: b.debounceMinutes !== undefined ? (Number(b.debounceMinutes) || 10) : settings.debounceMinutes,
links: { ...(settings.links || {}), ...(b.links || {}) },
telemetry: b.telemetry !== undefined ? !!b.telemetry : settings.telemetry,
};
saveSettings();
// 开关变化后立即按新设置上报/停止上报
hub.refresh(true).catch(() => {});
res.json(settings);
});
app.post('/api/settings/test', async (req, res) => {
@@ -1681,6 +1685,20 @@ app.delete('/api/backup/:name', async (req, res) => {
});
/* ---------------- 启动 ---------------- */
const hub = require('./cloud');
const APP_VERSION = require('../package.json').version;
/* ---------------- 授权中心 / 版本 / 公告 ---------------- */
app.get('/api/version', (req, res) => res.json(hub.getSnapshot()));
app.post('/api/version/check', async (req, res) => {
try {
await hub.refresh(true);
res.json(hub.getSnapshot());
} catch (e) {
res.status(200).json({ ...hub.getSnapshot(), error: e.message });
}
});
setInterval(sampleOnce, SAMPLE_MS);
setInterval(tickApps, SAMPLE_MS);
setInterval(inspectAll, INSPECT_MS);
@@ -1689,4 +1707,8 @@ process.on('SIGTERM', () => { flushTraffic().finally(() => process.exit(0)); });
setInterval(tickUptime, UPTIME_MS);
setTimeout(() => { sampleOnce(); inspectAll(); tickApps(); }, 300);
app.listen(PORT, '0.0.0.0', () => console.log(`[docker-center] http://0.0.0.0:${PORT} sample=${SAMPLE_MS}ms inspect=${INSPECT_MS}ms`));
app.listen(PORT, '0.0.0.0', () => {
console.log(`[docker-center] http://0.0.0.0:${PORT} sample=${SAMPLE_MS}ms inspect=${INSPECT_MS}ms v${APP_VERSION}`);
// 授权中心上报(安装/在线/更新检测)+ 公告拉取,失败不影响面板
try { hub.start(APP_VERSION, () => settings); } catch (e) { console.error('[hub] 启动失败', e.message); }
});