Skip to content

Commit

Permalink
🔧 “历史”使用lazyload,减轻服务端压力
Browse files Browse the repository at this point in the history
  • Loading branch information
adlered committed Jan 22, 2021
1 parent 16853f2 commit 1add847
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
27 changes: 15 additions & 12 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added src/main/resources/static/background/load.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions src/main/resources/static/js/history/histories.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,21 @@ $(function () {
.then(function (listRes) {
$.each(listRes.data, function (key, data) {
var list = data;
$("#" + year + "-" + month + "-" + day).append("<a href='" + data.path + "' target='_blank'><img src='" + list.path + "' style='width: auto; height: auto; max-width: 128px; max-height: 128px; margin: 8px 4px' class='img-thumbnail'></a>");
$("#" + year + "-" + month + "-" + day).append("<a href='" + data.path + "' target='_blank'><img class='lazyload img-thumbnail' src='background/load.gif' data-src='" + list.path + "' style='width: auto; height: auto; max-width: 128px; max-height: 128px; margin: 8px 4px'></a>");
if (i == 0) {
$("#histories").prepend("" +
"<h5>历史记录根据您的IP地址(" + data.ip + ")所生成,请及时保存,IP地址更改后历史记录将丢失。</h5>");
}
++i;
$("#picCount").text(i);
});

$(".lazyload").lazyload();
});
});
});
});
});
});
}
);
});
});
2 changes: 2 additions & 0 deletions src/main/resources/static/js/lazyload.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/main/resources/templates/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

<script src="js/axios.min.js"></script>
<script src="js/history/histories.js"></script>
<script src="js/lazyload.min.js"></script>

</body>
</html>

0 comments on commit 1add847

Please sign in to comment.