github:即使重新加载浏览器,评论也将保留,为什么? [英] github: comment will be remaining even if reload browser, why?

查看:82
本文介绍了github:即使重新加载浏览器,评论也将保留,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在github的问题页面上写评论时,我注意到即使重新加载浏览器,评论正文仍然存在.

When I write a comment with github's issue page, I noticed that the comment body remains even if I reload the browser.

我已经检查了localStorage,sessionStorage,cacheStorage,IndexedDB,Cookie, 但是我找不到我写的句子的实例.

I have checked localStorage, sessionStorage, cacheStorage, IndexedDB, cookie, but I found no instance of the sentence that I wrote.

我还检查了Chrome Devtool的网络"标签,但找不到任何可疑的网络流量.

Also, I have checked the network tab of Chrome Devtool, but I could not find any suspicious network traffic.

github.com如何实现此恢复功能?

How does github.com achieve this recovery function?

推荐答案

他们正在使用SessionStorage来做到这一点:

They are using SessionStorage to do this:

页面离开:

  1. 使用.js-session-resumable作为选择器选择所有输入字段
  2. 将{id,value}对输入放入数组
  3. 将其作为session-resume:/current/page/path放入SessionStorage
  1. select all of the input fields with .js-session-resumable as selector
  2. put {id, value} pair of inputs in an array
  3. put it in SessionStorage as session-resume:/current/page/path

页面加载:

  1. 通过SessionStorage
  2. 中的session-resume:/current/page/path键检查是否有任何值
  3. 如果是,请更新输入值并从SessionStorage
  4. 中删除此记录
  1. check if there are any values with session-resume:/current/page/path key in SessionStorage
  2. if yes, update values of inputs and remove this record from SessionStorage

注意::如果您在页面中写评论(不提交)并转到另一页面,那么您可以看到您的评论保存在SessionStorage中.

Note: If you write a comment in a page (without submitting it) and go to another page, then you can see your comment saved in SessionStorage.

这篇关于github:即使重新加载浏览器,评论也将保留,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆