gpt4 book ai didi

electron - 如何在 Electron 应用程序中实现 ngxs 托管状态的存储

转载 作者:行者123 更新时间:2023-12-03 12:28:17 25 4
gpt4 key购买 nike

我在 Electron 应用程序中使用 Angular 和 ngxs 作为状态管理解决方案。现在我想将状态保存在用户主目录中(作为简单的 json 文件)。

有人知道怎么做这个吗。我必须编写自己的 ngxs 插件吗?

最佳答案

您可以使用@ngxs/storage-plugin 并编写自己的StorageEngine 接口(interface)实现。 (见 https://www.ngxs.io/plugins/storage#options)

但在这种情况下,需要异步行为。因为您必须使用 nodejs 文件 API 读取文件(例如 readFileSync 它返回一个 promise )

为此,还有一个可用的插件 (https://github.com/ngxs-labs/async-storage-plugin)。目前它仅处于 alpha 阶段,但似乎可以工作......

关于electron - 如何在 Electron 应用程序中实现 ngxs 托管状态的存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58414622/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com