前言

因为在做美团外卖商家端的nw.js壳子项目,需要保证在壳子里面使用localStorage的数据可以持久化保存。
发现nw可以保存,即使删除应用重写打包也可以保存,所以解决了这个需求,但是还是需要知道具体储存在哪里,否则不清楚什么情况下数据会丢失。

储存位置

nw.js打包出来的应用的localStorage的储存目录为:
**C:Users【用户名】AppDataLocal【nw应用名称】User DataDefaultLocal Storagechrome-extension_【随机字符】_0.localstorage**

比如我的电脑上的位置是:
C:UsersxxcanghaiAppDataLocalwaimai_e_client_nwUser DataDefaultLocal Storagechrome-extension_blodpelipeilefodephhjbnidgkbghmj_0.localstorage

打开方式

此localStorage文件为二进制文件,不能直接使用文本编辑器打开,但是可以通过二进制文件查看器访问。
如我在nw应用中设置了一个localStorage的值:xxcanghai 123

然后用十六进制编辑器 WinHex打开 chrome-extension_blodpelipeilefodephhjbnidgkbghmj_0.localstorage 文件,就可以查看到里面的储存的xxcanghai123

附 其他浏览器localStorage的储存位置

火狐浏览器

Firefox将localstorage文件:webappsstore.sqlite 存储在配置文件文件夹中
火狐浏览器 (Windows XP):
C:Documents and Settings<Windows login/user name>Application DataMozillaFirefoxProfiles<profile folder>webappsstore.sqlite

火狐浏览器 (Windows Vista以上):
C:Users<Windows login/user name>AppDataRoamingMozillaFirefoxProfiles<profile folder>webappsstore.sqlite
or:
%APPDATA%MozillaFirefoxProfiles<profile folder>webappsstore.sqlite

火狐浏览器 on linux:
~/.mozilla/firefox//webappsstore.sqlite

火狐浏览器 on mac:
~/Library/Application Support/Firefox/Profiles//webappsstore.sqlite
or:
~/Library/Mozilla/Firefox/Profiles//webappsstore.sqlite

Chrome浏览器

Chrome浏览器将储存在localStorage储存在独立的 Local Storage 文件夹中
Chrome on windows:
%LocalAppData%GoogleChromeUser DataDefaultLocal Storage
Chrome on linux:
~/.config/google-chrome/Default/Local Storage/

Chrome on mac:
~/Library/Application Support/Google/Chrome//Local Storage/
一般情况:
~/Library/Application Support/Google/Chrome/Default/Local Storage/

内容来源于网络如有侵权请私信删除
你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!