优化随机图重复

This commit is contained in:
1152958806@qq.com 2023-09-02 13:33:35 +08:00
parent ee690530f1
commit 463b5701e9
11 changed files with 26 additions and 24 deletions

View File

@ -13,7 +13,7 @@
<div id="archive">
<div class="article-sort-title">文章 - [[${siteStatsFinder.getStats().post}]]</div>
<div class="article-sort" th:each="archive : ${archives.items}"
th:with='postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,"?") ? theme.config.layout.postRandomImg+"," : theme.config.layout.postRandomImg+"?"}'>
th:with='postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,"?") ? theme.config.layout.postRandomImg+"&" : theme.config.layout.postRandomImg+"?"}'>
<div class="article-sort-item year" th:text="${archive.year}"></div>
<div class="article-sort" th:each="month : ${archive.months}">
<!-- 月份没有样式所以不显示 -->

View File

@ -1369,9 +1369,9 @@ blockquote footer cite::before {
transition: all 0.3s ease 0s;
}
@media screen and (max-width: 900px) {
.layout > div:first-child {
width: 100% !important;
@media screen and (max-width: 1200px) {
.layout>div:first-child {
width:100%!important
}
}
@ -6754,9 +6754,9 @@ a.console_switchbutton {
}
}
@media screen and (max-width: 900px) {
@media screen and (max-width: 1200px) {
#aside-content {
display: none;
display:none
}
}

View File

@ -35,7 +35,7 @@
<!-- TODO 按照年份分组 需要 halo 提供归档数据-->
<!--<div class="article-sort-item year">2022</div>-->
<div class="article-sort-item" th:each="post : ${posts.items}"
th:with='postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,"?") ? theme.config.layout.postRandomImg+"," : theme.config.layout.postRandomImg+"?"}'>
th:with='postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,"?") ? theme.config.layout.postRandomImg+"&" : theme.config.layout.postRandomImg+"?"}'>
<a class="article-sort-item-img" th:href="@{${post.status.permalink}}"
th:title="${post.spec.title}">
<img th:alt="${post.spec.title}"

View File

@ -30,12 +30,12 @@
<div class="aside-list">
<div class="aside-list-group"
th:with='topGroupPosts = ${postFinder.list(1,6)},
postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,"?") ? theme.config.layout.postRandomImg : theme.config.layout.postRandomImg+"?"}'>
postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,"?") ? theme.config.layout.postRandomImg+"&" : theme.config.layout.postRandomImg+"?"}'>
<div th:each="post : ${topGroupPosts}" class="aside-list-item"><a class="thumbnail"
th:href="@{${post.status.permalink}}"
th:title="${post.spec.title}"><img
loading="lazy"
th:src='${#strings.isEmpty(post.spec.cover) ? postRandomImg+","+post.spec.title : post.spec.cover}'
th:src='${#strings.isEmpty(post.spec.cover) ? postRandomImg+post.spec.title : post.spec.cover}'
th:alt="${post.spec.title}"></a>
<div class="content"><a class="title" th:href="@{${post.status.permalink}}"
th:title="${post.spec.title}"

View File

@ -30,12 +30,12 @@
<div class="aside-list">
<div class="aside-list-group"
th:with='topGroupPosts = ${postFinder.list(1,6)},
postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,"?") ? theme.config.layout.postRandomImg : theme.config.layout.postRandomImg+"?"}'>
postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,"?") ? theme.config.layout.postRandomImg+"&" : theme.config.layout.postRandomImg+"?"}'>
<div th:each="post : ${topGroupPosts}" class="aside-list-item"><a class="thumbnail"
th:href="@{${post.status.permalink}}"
th:title="${post.spec.title}"><img
loading="lazy"
th:src='${#strings.isEmpty(post.spec.cover) ? postRandomImg+","+post.spec.title : post.spec.cover}'
th:src='${#strings.isEmpty(post.spec.cover) ? postRandomImg+post.spec.title : post.spec.cover}'
th:alt="${post.spec.title}"></a>
<div class="content"><a class="title" th:href="@{${post.status.permalink}}"
th:title="${post.spec.title}"

View File

@ -3,7 +3,7 @@
<th:block th:fragment="post-list"
th:with='postItems=${posts.items},
postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,"?") ? theme.config.layout.postRandomImg : theme.config.layout.postRandomImg+"?"}'>
postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,"?") ? theme.config.layout.postRandomImg+"&" : theme.config.layout.postRandomImg+"?"}'>
<!-- card需要添加在没有图片时使用随机图片 -->
<div class="recent-post-item"
@ -16,7 +16,7 @@
<div class="post_cover left_radius">
<a th:attr="title=${post.spec.title}" th:href="@{${post.status.permalink}}">
<img class="post_bg"
th:with='img = ${#strings.isEmpty(post.spec.cover) ? postRandomImg+","+post.spec.title : post.spec.cover}'
th:with='img = ${#strings.isEmpty(post.spec.cover) ? postRandomImg+post.spec.title : post.spec.cover}'
th:alt="${post.spec.title}"
th:data-lazy-src="${ isLazyload ? img : ''}"
th:src="${isLazyload ? loadingImg : img}">

View File

@ -3,7 +3,8 @@
<!-- 阅读建议 -->
<th:block th:fragment="relatedPosts" th:if="${not #lists.isEmpty(post.categories)}" th:with="recommendQuantity = ${theme.config.post.recommendQuantity},
recommandPosts = ${postFinder.listByCategory(1,recommendQuantity == 'six' ? 7 : recommendQuantity == 'two' ? 3 : 1,post.categories.get(0).metadata.name)},
containsTitle = ${#strings.contains(recommandPosts,post.spec.title)}">
containsTitle = ${#strings.contains(recommandPosts,post.spec.title)},
postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,'?') ? theme.config.layout.postRandomImg+'&' : theme.config.layout.postRandomImg+'?'}">
<div class="relatedPosts" th:if="${recommandPosts.total>1}">
<div class="headline">
<i class="haofont hao-icon-cainixihuan" style="font-size: 1.1rem;"></i>
@ -17,7 +18,7 @@ containsTitle = ${#strings.contains(recommandPosts,post.spec.title)}">
<div th:if="${!containsTitle ? iterStat.index <6 : true}">
<a th:href="@{${recommandPost.status.permalink}}" th:title="${recommandPost.spec.title}">
<img alt="cover" class="cover" id="preimg"
th:with="img = ${#strings.isEmpty(recommandPost.spec.cover) ? theme.config.layout.postRandomImg : recommandPost.spec.cover}"
th:with="img = ${#strings.isEmpty(recommandPost.spec.cover) ? postRandomImg+recommandPost.spec.title : recommandPost.spec.cover}"
th:src="${isLazyload ? loadingImg : img}"
th:data-lazy-src="${ isLazyload ? img : ''}">
<div class="content is-center">
@ -37,7 +38,7 @@ containsTitle = ${#strings.contains(recommandPosts,post.spec.title)}">
<div th:if="${!containsTitle ? iterStat.index <2 : true}">
<a th:href="@{${recommandPost.status.permalink}}" th:title="${recommandPost.spec.title}">
<img class="cover" alt="cover"
th:with="img = ${#strings.isEmpty(recommandPost.spec.cover) ? theme.config.layout.postRandomImg : recommandPost.spec.cover}"
th:with="img = ${#strings.isEmpty(recommandPost.spec.cover) ? postRandomImg+recommandPost.spec.title : recommandPost.spec.cover}"
th:src="${isLazyload ? loadingImg : img}"
th:data-lazy-src="${ isLazyload ? img : ''}">

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<div class="card-widget card-recent-post" th:fragment="recent-posts" th:with='posts = ${postFinder.list(1,theme.config.sidebar.recentPost)},
postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,"?") ? theme.config.layout.postRandomImg+"," : theme.config.layout.postRandomImg+"?"}'>
postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,"?") ? theme.config.layout.postRandomImg+"&" : theme.config.layout.postRandomImg+"?"}'>
<div class="item-headline"><i class="haofont hao-icon-eicon_map-2-line1"></i><span>最近发布</span></div>
<div class="aside-list">
<!-- 最新文章,用户可以自定义展示数量 -->

View File

@ -3,7 +3,7 @@
<!-- 推荐文章 -->
<div class="topGroup" th:fragment="top-group" th:with='topGroupPosts = ${postFinder.list(1,6)},
postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,"?") ? theme.config.layout.postRandomImg : theme.config.layout.postRandomImg+"?"}'
postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,"?") ? theme.config.layout.postRandomImg+"&" : theme.config.layout.postRandomImg+"?"}'
>
<div class="recent-post-item"
th:each="post : ${topGroupPosts}"
@ -14,7 +14,7 @@
<span class="recent-post-top-text"
th:attr="onclick='pjax.loadUrl(\''+ @{${post.status.permalink}} +'\')'">荐</span>
<img class="post_bg"
th:with=' img = ${#strings.isEmpty(post.spec.cover) ? postRandomImg+","+post.spec.title : post.spec.cover}'
th:with=' img = ${#strings.isEmpty(post.spec.cover) ? postRandomImg+post.spec.title : post.spec.cover}'
th:alt="${post.spec.title}"
th:src="${isLazyload ? loadingImg : img}"
@ -41,7 +41,7 @@
<span class="recent-post-top-text"
th:attr="onclick='pjax.loadUrl(\''+ @{${post.status.permalink}} +'\')'">荐</span>
<img class="post_bg"
th:with='img = ${#strings.isEmpty(post.spec.cover) ? postRandomImg+","+post.spec.title : post.spec.cover}'
th:with='img = ${#strings.isEmpty(post.spec.cover) ? postRandomImg+post.spec.title : post.spec.cover}'
th:alt="${post.spec.title}"
th:src="${isLazyload ? loadingImg : img}"

View File

@ -129,11 +129,12 @@
<th:block th:replace="~{modules/post/copyright :: copyright}"></th:block>
<nav class="pagination-post" id="pagination"
th:with="postCursor = ${postFinder.cursor(post.metadata.name)}">
th:with="postCursor = ${postFinder.cursor(post.metadata.name)},
postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,'?') ? theme.config.layout.postRandomImg+'&' : theme.config.layout.postRandomImg+'?'}">
<div th:class="${postCursor.hasPrevious()==true && postCursor.hasNext()==false} ? 'prev-post2 pull-left postcarnepre' : 'prev-post pull-left'">
<a th:if="${postCursor.hasPrevious()}" th:href="@{${postCursor.previous.status.permalink}}">
<img alt="cover" id="preimg" class="nolazyload"
th:with="img = ${#strings.isEmpty(postCursor.previous.spec.cover) ? theme.config.layout.postRandomImg : postCursor.previous.spec.cover}"
th:with="img = ${#strings.isEmpty(postCursor.previous.spec.cover) ? postRandomImg+postCursor.previous.spec.title : postCursor.previous.spec.cover}"
th:src="${isLazyload ? loadingImg : img}"
th:data-lazy-src="${ isLazyload ? img : ''}">
@ -146,7 +147,7 @@
<div th:class="${postCursor.hasPrevious()==false && postCursor.hasNext()==true} ? 'next-post2 pull-right postcarnepre':'next-post pull-right'">
<a th:if="${postCursor.hasNext()}" th:href="@{${postCursor.next.status.permalink}}">
<img alt="cover" id="preimg" class="nolazyload"
th:with="img = ${#strings.isEmpty(postCursor.next.spec.cover) ? theme.config.layout.postRandomImg : postCursor.next.spec.cover}"
th:with="img = ${#strings.isEmpty(postCursor.next.spec.cover) ? postRandomImg+postCursor.next.spec.title : postCursor.next.spec.cover}"
th:src="${isLazyload ? loadingImg : img}"
th:data-lazy-src="${ isLazyload ? img : ''}">
<div class="pagination-info">

View File

@ -24,7 +24,7 @@
<div class="article-sort" th:with="postItems=${posts.items}">
<!--<div class="article-sort-item year">2022</div>-->
<div class="article-sort-item" th:each="post : ${postItems}"
th:with='postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,"?") ? theme.config.layout.postRandomImg+"," : theme.config.layout.postRandomImg+"?"}'>
th:with='postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,"?") ? theme.config.layout.postRandomImg+"&" : theme.config.layout.postRandomImg+"?"}'>
<a class="article-sort-item-img" th:href="@{${post.status.permalink}}"
th:title="${post.spec.title}">
<img loading="lazy" th:alt="${post.status.excerpt}"