推进 INI 面板状态 report JSON 导出 helper

This commit is contained in:
2026-06-14 22:18:26 +08:00
parent 404cb1344c
commit 25268404cb
6 changed files with 186 additions and 0 deletions

View File

@@ -48,6 +48,7 @@ import {
import {
createMachineSessionStateSnapshot,
createMachineSessionStateReport,
createMachineSessionStateReportExport,
} from "./panel-state-summary.js";
const SAMPLE_PATH =
@@ -156,6 +157,10 @@ function getMachineSessionStateReport() {
return createMachineSessionStateReport(window.linuxCncIniPanelMachineSessionState);
}
function getMachineSessionStateReportExport() {
return createMachineSessionStateReportExport(window.linuxCncIniPanelMachineSessionState);
}
function updatePanelMachineSessionState(patch = {}) {
panelMachineSessionState = createMachineSessionStateSnapshot({
...panelMachineSessionState,
@@ -170,6 +175,7 @@ function updatePanelMachineSessionState(patch = {}) {
}
window.getMachineSessionStateReport = getMachineSessionStateReport;
window.getMachineSessionStateReportExport = getMachineSessionStateReportExport;
window.linuxCncIniPanelMachineSessionState = panelMachineSessionState;
function setBadge(node, text, className = "badge") {

View File

@@ -108,3 +108,13 @@ export function createMachineSessionStateReport(state = {}) {
},
};
}
export function createMachineSessionStateReportExport(state = {}, options = {}) {
const report = createMachineSessionStateReport(state);
return {
filename: options.filename ?? "machine-session-state-report.json",
mediaType: "application/json",
report,
text: `${JSON.stringify(report, null, 2)}\n`,
};
}