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
43 lines
1.0 KiB
JavaScript
43 lines
1.0 KiB
JavaScript
"use strict";
|
|
|
|
/**
|
|
* 巡检模块 - 本地存储封装
|
|
*
|
|
* 使用 NetMesh 的 localStorageAdapter 机制存储巡检数据。
|
|
* 所有存储 key 统一加前缀 netcatty_inspection_。
|
|
*/
|
|
|
|
const { STORAGE_KEY_PREFIX } = require("./storageKeys.cjs");
|
|
|
|
/**
|
|
* 从 localStorage 读取数据(主进程侧通过 IPC 访问,这里提供 key 和默认值)
|
|
* @param {string} key - 存储键(不含前缀)
|
|
* @param {*} defaultValue - 默认值
|
|
* @returns {*}
|
|
*/
|
|
function getStore() {
|
|
// 主进程中,通过全局共享的 storage 方式
|
|
// 实际存储由 electron 的 localStorageAdapter 管理
|
|
// 这里提供纯函数式的读写接口,外层调用方负责实际 I/O
|
|
return {
|
|
getKey(key) {
|
|
return `${STORAGE_KEY_PREFIX}${key}`;
|
|
},
|
|
parse(raw, defaultValue) {
|
|
if (!raw) return defaultValue;
|
|
try {
|
|
return JSON.parse(raw);
|
|
} catch (e) {
|
|
return defaultValue;
|
|
}
|
|
},
|
|
stringify(value) {
|
|
return JSON.stringify(value);
|
|
},
|
|
};
|
|
}
|
|
|
|
module.exports = {
|
|
getStore,
|
|
};
|