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

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

问题描述

我似乎找不到存储用户设置的内置机制.我希望 Electron 提供了一种跨所有桌​​面平台存储用户设置的标准方法.如果没有先例,我可以自己实现它,我只是不想立即跳到自定义解决方案.这方面的在线研究非常稀少.谢谢!

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 关联的特殊目录或文件的路径.

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天全站免登陆