用电子在本地保存文件 [英] Saving files locally with electron
问题描述
我有一些模板文件,每个文件都包含一些变量字符串,我想用Electron构建一个非常简单的输入表单( http://electron.atom.io/ ),我想将组合的输出文件保存在用户的计算机上。
是否有任何模块我可以使用让Electron将文件保存到本地吗?
如果您针对多个平台,我回答了这里有个类似的问题。基本上 app.getPath(name), app.setPath(name,path)和 app.getAppPath()在将文件保存到正确位置非常有用,无论操作系统如何。
您可能还想查看这些Nodejs包,这些包有助于简化将文件直接保存到主机的过程...
- fs-jetpack
- graceful-fs
-
if你打算让用户保存文件,你也可以看看 Dialog api ,您可以在其中专门调用保存对话框为此目的。
I have some template files that contain a few variable strings each, I'd like to build a very simple input form with Electron (http://electron.atom.io/) and I want to save the composed output file on the user's computer.
Is there any module I can use to let Electron save files locally?
解决方案If you are targeting multiple platforms, I answered a similar question here. Basically app.getPath(name), app.setPath(name, path), and app.getAppPath() are very useful in saving files to the the right place regardless of the OS.
You may also want to check out these Nodejs packages which help simplify saving files directly to the host machine...
If you intend for users to save files you might also have a look at the Dialog api where you can specifically invoke a save dialog for that purpose.
这篇关于用电子在本地保存文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!