Skip to content

Commit

Permalink
新增百度统计插件功能,评论头像随机生成
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaoxiongDu committed Mar 26, 2021
1 parent d7a2647 commit a3f675f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
15 changes: 12 additions & 3 deletions .idea/workspace.xml

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

7 changes: 7 additions & 0 deletions src/main/java/com/lrm/service/CommentServiceImpl.java
Expand Up @@ -14,6 +14,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;

/**
* Created by limi on 2017/10/22.
Expand Down Expand Up @@ -59,6 +60,12 @@ public Comment saveComment(Comment comment) {
comment.setParentComment(null);
}
comment.setCreateTime(new Date());

String avatarRequestUrl = "https://picsum.photos/id/";
avatarRequestUrl += new Random().nextInt(1000) + 1;
avatarRequestUrl += "/200";

comment.setAvatar(avatarRequestUrl);
return commentRepository.save(comment);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application-dev.yml
@@ -1,7 +1,7 @@
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://rm-bp10dkvhokk30a8ae6oshaoxiongdu.mysql.rds.aliyuncs.com:3306/blog
url: jdbc:mysql://rm-bp10dkvhokk30a8ae6oshaoxiong.mysql.rds.aliyuncs.com:3306/blog
username: root
password: root
jpa:
Expand Down
19 changes: 19 additions & 0 deletions src/main/resources/templates/_fragments.html
Expand Up @@ -14,7 +14,22 @@
<link rel="stylesheet" href="../static/lib/prism/prism.css" th:href="@{/lib/prism/prism.css}">
<link rel="stylesheet" href="../static/lib/tocbot/tocbot.css" th:href="@{/lib/tocbot/tocbot.css}">
<link rel="stylesheet" href="../static/css/me.css" th:href="@{/css/me.css}">

<!--百度统计-->
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?ec67fe367b756f47737b99d404889527";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>

</head>



<body>


Expand Down Expand Up @@ -169,6 +184,10 @@ <h4 class="ui inverted header me-opacity-mini" >站长微信</h4>
setInterval(setTime, 1000);

</script>




</th:block>

</body>
Expand Down

0 comments on commit a3f675f

Please sign in to comment.