简体   繁体   English

Electron:Windows 上的 localStorage 无法正常工作

[英]Electron: localStorage on Windows is not working properly

Faced this situation: The application uses localStorage to save user settings.面临这种情况:应用程序使用 localStorage 来保存用户设置。 When saving, data is written to localStorage.保存时,将数据写入 localStorage。 I can even read them from there, everything is correct.我什至可以从那里阅读它们,一切都是正确的。

But at the same time, if you close the application window, and then open it again and log in as the same user, the data is not saved.但同时,如果您关闭应用程序 window,然后再次打开并以同一用户身份登录,则不会保存数据。 I see this error only on Windows (tested on Windows 10) and only when using Electron.我仅在 Windows 上看到此错误(在 Windows 10 上测试)并且仅在使用 Electron 时才看到。 If I open the same application in a regular browser, the app works fine (saves and loads without any issues).如果我在常规浏览器中打开相同的应用程序,该应用程序运行良好(保存和加载没有任何问题)。 Everything also works fine on a Mac (both Electron and a regular browser).在 Mac 上一切正常(Electron 和普通浏览器)。

Has anyone encountered similar behavior?有没有人遇到过类似的行为?

I would recommend treating an Electron app as a desktop application rather a web browser.我建议将 Electron 应用程序视为桌面应用程序,而不是 web 浏览器。 Explore using node's file system API fs to store user settings.探索使用节点的文件系统 API fs来存储用户设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM