fix: 优化文章首图
This commit is contained in:
parent
784c427251
commit
fdc65c125f
33
pom.xml
33
pom.xml
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>cn.allms</groupId>
|
<groupId>cn.allms</groupId>
|
||||||
<artifactId>blog</artifactId>
|
<artifactId>blog</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.2-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>blog</name>
|
<name>blog</name>
|
||||||
@ -18,6 +18,31 @@
|
|||||||
<relativePath/> <!-- lookup parent from repository -->
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>public</id>
|
||||||
|
<name>aliyun nexus</name>
|
||||||
|
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<pluginRepositories>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>public</id>
|
||||||
|
<name>aliyun nexus</name>
|
||||||
|
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</pluginRepository>
|
||||||
|
</pluginRepositories>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
@ -79,8 +104,12 @@
|
|||||||
<artifactId>commonmark-ext-gfm-tables</artifactId>
|
<artifactId>commonmark-ext-gfm-tables</artifactId>
|
||||||
<version>0.10.0</version>
|
<version>0.10.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|||||||
31
src/main/java/cn/allms/config/RandomPicturesConfig.java
Normal file
31
src/main/java/cn/allms/config/RandomPicturesConfig.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package cn.allms.config;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 随机图片配置类
|
||||||
|
*
|
||||||
|
* @author josxy
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class RandomPicturesConfig {
|
||||||
|
private List<String> pictures;
|
||||||
|
private final static String DEFAULT = "https://tva1.sinaimg.cn/large/0072Vf1pgy1foxk3rxvthj31kw0w0x3c";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO
|
||||||
|
* 随机获取一种图片
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getRandomPicAddr() {
|
||||||
|
Random random = new Random();
|
||||||
|
System.out.println(this.pictures);
|
||||||
|
System.out.println(this.pictures.get(random.nextInt(2)) + System.currentTimeMillis());
|
||||||
|
return this.pictures.size() > 0 ?
|
||||||
|
this.pictures.get(random.nextInt(2)) + System.currentTimeMillis() : DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
package cn.allms.controller.admin;
|
package cn.allms.controller.admin;
|
||||||
|
|
||||||
|
import cn.allms.config.RandomPicturesConfig;
|
||||||
import cn.allms.po.Blog;
|
import cn.allms.po.Blog;
|
||||||
import cn.allms.po.User;
|
import cn.allms.po.User;
|
||||||
import cn.allms.vo.BlogQuery;
|
import cn.allms.vo.BlogQuery;
|
||||||
@ -36,7 +37,8 @@ public class BlogController {
|
|||||||
* 博客发布页面url
|
* 博客发布页面url
|
||||||
*/
|
*/
|
||||||
private static final String INPUT="admin/blogs-input";
|
private static final String INPUT="admin/blogs-input";
|
||||||
|
private static final String HEAD_URL="https://api.rainss.cn/random.php?t=";
|
||||||
|
private static final String HEAD_URL_1="https://api.rainss.cn/acgimgurl/acgurl.php?t=";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 显示分页查询到的博客列表页面url
|
* 显示分页查询到的博客列表页面url
|
||||||
@ -92,6 +94,7 @@ public class BlogController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping("/blogs/input")
|
@GetMapping("/blogs/input")
|
||||||
public String inputBlog(Model model){
|
public String inputBlog(Model model){
|
||||||
|
model.addAttribute("firstPicture",HEAD_URL_1 + System.currentTimeMillis());
|
||||||
setTypeAadTag(model);
|
setTypeAadTag(model);
|
||||||
return INPUT;
|
return INPUT;
|
||||||
}
|
}
|
||||||
@ -150,6 +153,7 @@ public class BlogController {
|
|||||||
Blog blog = blogServiceImpl.getBlog(id);
|
Blog blog = blogServiceImpl.getBlog(id);
|
||||||
//处理tagIds
|
//处理tagIds
|
||||||
blog.init();
|
blog.init();
|
||||||
|
model.addAttribute("firstPicture",HEAD_URL_1 + System.currentTimeMillis());
|
||||||
model.addAttribute("blog",blog);
|
model.addAttribute("blog",blog);
|
||||||
return INPUT;
|
return INPUT;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,3 +11,9 @@ spring:
|
|||||||
comment:
|
comment:
|
||||||
v2exUrl: https://sdn.geekzu.org/avatar/
|
v2exUrl: https://sdn.geekzu.org/avatar/
|
||||||
avatar: /images/avatar.png
|
avatar: /images/avatar.png
|
||||||
|
|
||||||
|
# 随机图片
|
||||||
|
random:
|
||||||
|
pictures:
|
||||||
|
- "https://api.rainss.cn/random.php?t="
|
||||||
|
- "https://api.rainss.cn/acgimgurl/acgurl.php?t="
|
||||||
@ -57,10 +57,8 @@
|
|||||||
|
|
||||||
<!--底部footer-->
|
<!--底部footer-->
|
||||||
<footer th:fragment="footer" class="ui inverted vertical segment m-padded-tb-massive ">
|
<footer th:fragment="footer" class="ui inverted vertical segment m-padded-tb-massive ">
|
||||||
<div class="ui center aligned container ">
|
<div class="ui center aligned container " style="color: #4183c4">
|
||||||
<div id="yiyan" class="ui m-text-thin m-text-spaced m-opacity-tiny center aligned"></div>
|
<div id="yiyan" class="ui m-text-thin m-text-spaced m-opacity-tiny center aligned" style="padding-bottom: 5px"></div>
|
||||||
|
|
||||||
|
|
||||||
<!-- <div class="three wide column">-->
|
<!-- <div class="three wide column">-->
|
||||||
<!-- <div class="ui inverted link list">-->
|
<!-- <div class="ui inverted link list">-->
|
||||||
<!-- <h4 class="ui inverted header m-opacity-min">站长QQ</h4>-->
|
<!-- <h4 class="ui inverted header m-opacity-min">站长QQ</h4>-->
|
||||||
@ -100,7 +98,7 @@
|
|||||||
<p class="m-text-thin m-text-spaced m-opacity-tiny">©2021 浅枫沐雪</p>
|
<p class="m-text-thin m-text-spaced m-opacity-tiny">©2021 浅枫沐雪</p>
|
||||||
<a href="https://www.foreverblog.cn/" class="d-inline-block text-muted" target="_blank"><img src="https://resource.upcdn.rainss.cn/2019/11/3368312888.png" alt="" style="width:auto;height:16px;"> </a>
|
<a href="https://www.foreverblog.cn/" class="d-inline-block text-muted" target="_blank"><img src="https://resource.upcdn.rainss.cn/2019/11/3368312888.png" alt="" style="width:auto;height:16px;"> </a>
|
||||||
<p class="m-text-thin m-text-spaced m-opacity-tiny">
|
<p class="m-text-thin m-text-spaced m-opacity-tiny">
|
||||||
<p class="small"> Powered by <a href="http://spring.io" target="_blank">spring</a> · Theme is <a href="https://josxy.cn" target="_blank">mx</a></p>
|
Powered by <a href="http://spring.io" target="_blank">spring</a> · Theme is <a href="https://josxy.cn" target="_blank">mx</a>
|
||||||
</p>
|
</p>
|
||||||
<!--分割线-->
|
<!--分割线-->
|
||||||
<div class="ui inverted section divider"></div>
|
<div class="ui inverted section divider"></div>
|
||||||
@ -127,11 +125,11 @@
|
|||||||
$('#newblog-container').load(/*[[@{/footer/newblog}]]*/"/footer/newblog");
|
$('#newblog-container').load(/*[[@{/footer/newblog}]]*/"/footer/newblog");
|
||||||
</script>
|
</script>
|
||||||
<script >
|
<script >
|
||||||
/* let url = "https://v1.hitokoto.cn/?c=f&encode=text";
|
let yiyan_url = "https://v1.hitokoto.cn/?c=f&encode=text";
|
||||||
$.get(url,null,function (data){
|
$.get(yiyan_url,null,function (data){
|
||||||
$("#yiyan").text(data);
|
$("#yiyan").text(data);
|
||||||
console.log(data);
|
console.log(data);
|
||||||
})*/
|
})
|
||||||
</script>
|
</script>
|
||||||
</th:block>
|
</th:block>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@ -122,7 +122,7 @@
|
|||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="ui left labeled input">
|
<div class="ui left labeled input">
|
||||||
<label class="ui teal basic label">首图</label>
|
<label class="ui teal basic label">首图</label>
|
||||||
<input type="text" name="firstPicture" placeholder="首图引用地址" th:value="*{firstPicture}">
|
<input type="text" name="firstPicture" placeholder="首图引用地址" th:value="${firstPicture}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!--博客描述文本域-->
|
<!--博客描述文本域-->
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user