更新时间:2023-02-02 21:35:45
如果您针对多个平台,我回答了这里有个类似的问题。基本上 app.getPath(name), app.setPath(name,path)和 app.getAppPath()在将文件保存到正确位置非常有用,无论操作系统如何。
您可能还想查看这些Nodejs包,这些包有助于简化将文件直接保存到主机的过程...
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.