electron多窗口共享数据

4,659 阅读1分钟

使用localStorage共享数据出现的问题

  • 5M大小限制
  • 多窗口共享数据的前提是同源
  • 采用url search params传递数据 (2M以内)
    let value = encodeURIComponent(JSON.stringify(value))
    let url = http://xxx.zz.com/xx/?key=value
  • escape unescape
  • encodeURIComponent decodeURIComponent (参数使用)

encodeURIComponent不可以多次加密,dencodeURIComponent可以多次解密 -- encodeUrl decodeUrl (整个url使用)

  • 先是使用ascii编码,然后使用百分号编码

electron的webview加载的页面http与https混用不会出错

electron的h5标签下载文档、音频、视频会启动下载不会直接打开