summary refs log tree commit diff
diff options
context:
space:
mode:
authormayx2025-03-30 13:47:42 +0000
committermayx2025-03-30 13:47:42 +0000
commit7785bc18c726c2757965874696fd0279cca57d2b (patch)
tree213dc83c3ff835b58d803d460b37755b8cf7230b
parent9a0af3f555a0b37e05bdf68a75b6eabb44c3b249 (diff)
Update 2 files
- /_layouts/default.html
- /index.html
-rw-r--r--_layouts/default.html7
-rw-r--r--index.html2
2 files changed, 7 insertions, 2 deletions
diff --git a/_layouts/default.html b/_layouts/default.html
index 3669255..ded6615 100644
--- a/_layouts/default.html
+++ b/_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);
diff --git a/index.html b/index.html
index 4248863..d9adde4 100644
--- a/index.html
+++ b/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 />