Browse Source

Update 2 files

- /_layouts/default.html
- /index.html
mayx 8 months ago
parent
commit
7785bc18c7
2 changed files with 7 additions and 2 deletions
  1. 6 1
      _layouts/default.html
  2. 1 1
      index.html

+ 6 - 1
_layouts/default.html

@@ -31,7 +31,12 @@
   function getSearchJSON(callback) {
     var searchData = JSON.parse(localStorage.getItem("blog_" + lastUpdated.valueOf()));
     if (!searchData) {
-      localStorage.clear();
+      for (var i = 0; i < localStorage.length; i++) {
+          var key = localStorage.key(i);
+          if (key.startsWith('blog_')) {
+              localStorage.removeItem(key);
+          }
+      }
       $.getJSON("/search.json", function (data) {
           localStorage.setItem("blog_" + lastUpdated.valueOf(), JSON.stringify(data));
           callback(data);

+ 1 - 1
index.html

@@ -3,7 +3,7 @@ layout: default
 title: 首页 - 我的文章
 ---
 
-<h1 style="display:inline"> 首页 - 我的文章 </h1><small><a href="/archives.html">Archives</a></small><br /><br />
+<h1 style="display:inline"> 首页 - 我的文章 </h1><small><a href="/archives.html">Archives</a> | <a href="javascript:getSearchJSON(function(data){window.location.href = data[Math.floor(Math.random()*data.length)].url})">Random</a></small><br /><br />
 
 <hr />