Some checks failed
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
巡检模块:巡检调度器改为轮询驱动,新增每日报告存储、告警规则独立 Store、设备 Store 解耦,_executeSnapshot 补齐 DEBUG 声明,巡检中心 与告警中心页增强。 拓扑大屏:MonitoringTopologyView 扩展分组/布局控制, useMonitoringData 重构数据流。 远程 HTTP:新增 electron/remoteHttpServer.cjs,preload/api.cjs 暴露 IPC,registerBridges 注册 netcatty:http:open 桥。 portable 绿色打包: - electron-builder.config.cjs 恢复原始白名单(61MB app.asar), 收集器自动追踪运行时依赖; - portableData.cjs 重写为 .portable 标记检测; - scripts/migratePortableLocalStorage.cjs 离线脚本把 Local Storage 的 http://localhost:5173 origin 批量迁移为 app://netcatty; - scripts/scanWorkspaceDeps.cjs 扫描 workspace 运行时依赖。
81 lines
2.4 KiB
JavaScript
81 lines
2.4 KiB
JavaScript
"use strict";
|
||
|
||
/**
|
||
* 巡检报告调度配置存储
|
||
*
|
||
* 存储内容(report-schedule.json):
|
||
* {
|
||
* enabled: true,
|
||
* defaultIntervalHours: 1, // 全局默认巡检周期(小时)
|
||
* dailyReportTime: "23:00", // 日运行报告定时触发时间 HH:MM
|
||
* enabledDeviceIds: null | string[], // null/undefined = 全部;[] = 一个都不选;["id1","id2"] = 指定
|
||
* perDeviceInterval: { host_a: 2 }, // 单设备周期覆盖(小时)
|
||
* aiSummaryEnabled: true // AI 汇总分析开关
|
||
* }
|
||
*/
|
||
|
||
const { STORAGE_KEY_REPORT_SCHEDULE } = require("./storageKeys.cjs");
|
||
|
||
const DEFAULTS = {
|
||
enabled: false,
|
||
defaultIntervalHours: 1,
|
||
dailyReportTime: "23:00",
|
||
enabledDeviceIds: null, // null = 全部设备(向后兼容旧的 empty array 也按全部处理)
|
||
perDeviceInterval: {},
|
||
aiSummaryEnabled: true,
|
||
};
|
||
|
||
function _safeParse(raw, def) {
|
||
if (raw === null || raw === undefined) return def;
|
||
if (typeof raw === "object") return raw;
|
||
try { return JSON.parse(raw); }
|
||
catch { return def; }
|
||
}
|
||
|
||
function _normalize(cfg) {
|
||
// 旧数据兼容:undefined enabledDeviceIds → null(全部)
|
||
// 新约定:null = 全部;[] = 一个都不选;[id1,id2] = 指定 —— 不主动改动
|
||
if (cfg.enabledDeviceIds === undefined) {
|
||
cfg.enabledDeviceIds = null;
|
||
}
|
||
return cfg;
|
||
}
|
||
|
||
function getSchedule(readFn) {
|
||
const raw = readFn(STORAGE_KEY_REPORT_SCHEDULE);
|
||
if (!raw) return _normalize({ ...DEFAULTS });
|
||
const parsed = _safeParse(raw, {});
|
||
return _normalize({ ...DEFAULTS, ...parsed });
|
||
}
|
||
|
||
function saveSchedule(writeFn, config) {
|
||
const merged = _normalize({ ...DEFAULTS, ...config });
|
||
writeFn(STORAGE_KEY_REPORT_SCHEDULE, JSON.stringify(merged, null, 2));
|
||
return merged;
|
||
}
|
||
|
||
function getIntervalHours(readFn, deviceId) {
|
||
const cfg = getSchedule(readFn);
|
||
if (cfg.perDeviceInterval && cfg.perDeviceInterval[deviceId]) {
|
||
return Number(cfg.perDeviceInterval[deviceId]) || cfg.defaultIntervalHours;
|
||
}
|
||
return cfg.defaultIntervalHours;
|
||
}
|
||
|
||
function isDeviceEnabled(readFn, deviceId) {
|
||
const cfg = getSchedule(readFn);
|
||
if (!cfg.enabled) return false;
|
||
// null/undefined = 全部;空数组 = 都不选;非空数组 = 白名单
|
||
if (!cfg.enabledDeviceIds) return true;
|
||
if (cfg.enabledDeviceIds.length === 0) return false;
|
||
return cfg.enabledDeviceIds.includes(deviceId);
|
||
}
|
||
|
||
module.exports = {
|
||
DEFAULTS,
|
||
getSchedule,
|
||
saveSchedule,
|
||
getIntervalHours,
|
||
isDeviceEnabled,
|
||
};
|