nw.js的localStorage的物理储存位置

前言

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

储存位置

nw.js打包出来的应用的localStorage的储存目录为:
**C:\Users【用户名】\AppData\Local【nw应用名称】\User Data\Default\Local Storage\chrome-extension_【随机字符】_0.localstorage**

比如我的电脑上的位置是:
C:\Users\xxcanghai\AppData\Local\waimai_e_client_nw\User Data\Default\Local Storage\chrome-extension_blodpelipeilefodephhjbnidgkbghmj_0.localstorage

746158-20170627152358680-404650254.png

打开方式

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

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

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

火狐浏览器

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

火狐浏览器 (Windows Vista以上):
C:\Users<Windows login/user name>\AppData\Roaming\Mozilla\Firefox\Profiles<profile folder>\webappsstore.sqlite
or:
%APPDATA%\Mozilla\Firefox\Profiles<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%\Google\Chrome\User Data\Default\Local 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/

转载于:https://www.cnblogs.com/xxcanghai/p/7085424.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值