javascript - 如何在 Electron 中保存/加载菜单项的选中状态?
问题描述
我在电子应用程序中有一个菜单,项目看起来像这样:
const menuTemplate = [
// ... previous menu items
{
label: "Notifications",
submenu: [
{
label: "Enable reset notification",
type: "checkbox",
checked: true,
click: e => {
mainWindow.showResetNotification = e.checked;
}
},
{
label: "Reminder notifications",
submenu: [
{
label: "Never",
type: "radio",
click: e => {
if (e.checked) {
mainWindow.resetNotification = "never";
}
}
},
{
label: "Every 30 minutes",
type: "radio",
click: e => { /* ... */ }
},
{
label: "Every hour",
type: "radio",
checked: true,
click: e => { /* ... */ }
}
]
}
]
}
];
我希望能够检查某些内容并保存该状态,以便如果我重新打开应用程序,它会加载选中菜单项的先前状态(选中与未选中)。
我怎样才能在电子中做到这一点?我尝试了本地存储,但因为它是主进程,所以它无权访问它。
提前致谢!
解决方案
推荐阅读
- django - 安装了使用 Celery 和 Django Channels 运行时的 Scrapy 错误:OSError: [Errno 9] Bad file descriptor
- r - 删除 fviz_silhouette 中的网格?
- f# - F# 中的选择类型实现
- python - python在使用坐标计算2个地方之间的距离时得到ValueError
- r - 基于过滤条件的数据框标签列表
- javascript - 加载新网页而不重新加载加载脚本错误
- reactjs - nodejs,typescript 存储和处理 websocket 连接
- regex - PostgreSQL 为什么用正则表达式“\s+”不匹配几个空格
- python - 遵循使用 Django/Python 的教程:ModuleNotFoundError: No module named 'pages'
- python - 从两个音频文件中查找 smiliarites