在Electron(Atom Shell)应用程序中将用户设置存储在哪里? [英] Where to store user settings in Electron (Atom Shell) Application?

查看:118
本文介绍了在Electron(Atom Shell)应用程序中将用户设置存储在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎找不到用于存储用户设置的内置机制。我希望电子能提供一种在所有台式机平台上存储用户设置的标准方法。如果没有先例可以自己实现,那么我就是不想立即跳到自定义解决方案。在线研究在该领域非常稀疏。谢谢!

I can't seem to locate a built in mechanism to store user settings. I was hoping that electron provided a standard method for storing user settings across all desktop platforms. If there isn't a precedent for this I can implement it myself, I just didn't want to jump to a custom solution immediately. Research online is pretty sparse in this area. Thanks!

推荐答案

每个平台针对不同类型的数据都有不同的默认位置。因此,如果要基于平台将数据存储在默认位置,请检出 app。 getPath(name)

Each platform has different default locations for different kinds of data. So, if you want to store data in default locations based on platform, check out app.getPath(name)

它检索到与 name相关的特殊目录或文件的路径/ code>。

It retrieves a path to a special directory or file associated with name.

您还可以使用它来区分用户要保存的数据和应用程序要保存的数据,以免造成混乱

You can also use it to differentiate between data the user wants to save, and data your application saves that you don't want to clutter up users directories.

或者如果您只想存储指向特定路径的文件,则可以使用
app.setPath(name,path)

Or if you just want to store files reletive to a specific path you can use the app.setPath(name,path)

这篇关于在Electron(Atom Shell)应用程序中将用户设置存储在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆