Merge remote-tracking branch 'origin/main' into main

# Conflicts:
#	templates/modules/head.html
This commit is contained in:
1152958806@qq.com 2023-08-24 17:40:42 +08:00
commit 8c7cf5eb17
16 changed files with 223 additions and 77 deletions

View File

@ -47,7 +47,6 @@ spec:
label: 导航栏右侧
value:
travelling: true
travellingUrl: https://travellings.cn/go.html
article: true
darkMode: true
children:
@ -61,12 +60,6 @@ spec:
value: true
- label: 隐藏
value: false
- $formkit: url
if: $get(travelling).value
name: travellingUrl
label: 开往链接
placeholder: 请输入开往链接
help: 开往项目https://github.com/travellings-link/travellings
- $formkit: radio
name: article
label: 随机文章

View File

@ -41,6 +41,9 @@
</div>
<!-- 关于统计-->
<script th:src="${assets_link + '/libs/countup/countup.js' + theme_version}"></script>
<div class="author-content">
<div class="create-site-post author-content-item single" th:utext="${theme.config.about.xjlc}">

View File

@ -192,23 +192,22 @@ var btf = {
}
},
snackbarShow: (text, showAction, duration) => {
const sa = (typeof showAction !== 'undefined') ? showAction : false
const dur = (typeof duration !== 'undefined') ? duration : 5000
const position = GLOBAL_CONFIG.Snackbar.position
const bg = document.documentElement.getAttribute('data-theme') === 'light' ? GLOBAL_CONFIG.Snackbar.bgLight : GLOBAL_CONFIG.Snackbar.bgDark
const style = document.createElement('style');
document.head.appendChild(style);
const styleSheet = style.sheet;
styleSheet.insertRule(`:root{--heo-snackbar-time: ${dur}ms!important}`, styleSheet.cssRules.length);
snackbarShow: (text, showActionFunction = false, duration = 2000, actionText = false) => {
const { position, bgLight, bgDark } = GLOBAL_CONFIG.Snackbar;
const bg = document.documentElement.getAttribute("data-theme") === "light" ? bgLight : bgDark;
const root = document.querySelector(":root");
root.style.setProperty("--heo-snackbar-time", duration + "ms");
Snackbar.show({
text: text,
backgroundColor: bg,
showAction: sa,
duration: dur,
pos: position
})
onActionClick: showActionFunction,
actionText: actionText,
showAction: actionText,
duration: duration,
pos: position,
customClass: "snackbar-css",
});
},
initJustifiedGallery: function (selector) {

View File

@ -163,16 +163,19 @@ function HaoPostAI(AI_option) {
Referer: Referers
};
var url = window.location.href;
const title = document.title;
const truncateDescription = getTitleAndContent(num);
const queryParams = `key=${options.key}&content=${truncateDescription}&url=${url}&title=${title}`;
const requestBody = {
key: options.key,
content: truncateDescription,
url: location.href,
};
const requestOptions = {
method: "GET",
method: "POST",
headers: {
"Content-Type": "application/json",
Referer: options.Referer
},
body: JSON.stringify(requestBody),
};
try {
let animationInterval = null
@ -182,7 +185,7 @@ function HaoPostAI(AI_option) {
explanation.innerHTML = animationText;
j = (j % 3) + 1; // 在 1、2、3 之间循环
}, 500);
const response = await fetch(`https://summary.tianli0.top/?${queryParams}`, requestOptions);
const response = await fetch(`https://summary.tianli0.top/`, requestOptions);
let result;
if (response.status === 403) {
result = {
@ -199,11 +202,16 @@ function HaoPostAI(AI_option) {
setTimeout(() => {
aiTitleRefreshIcon.style.opacity = "1";
}, 300)
startAI(summary);
if (summary) {
startAI(summary);
} else {
startAI("摘要获取失败!!!请检查Tianli服务是否正常!!!");
}
clearInterval(animationInterval)
} catch (error) {
console.error(error);
explanation.innerHTML = "发生异常" + error;
}
} else {
const strArr = ai.split(",").map(item => item.trim()); // 将字符串转换为数组,去除每个字符串前后的空格
@ -425,4 +433,4 @@ function HaoPostAI(AI_option) {
aiAbstract();
showAiBtn()
}
}

View File

@ -435,11 +435,14 @@ function toforeverblog() {
}
//前往开往项目
function totraveling() {
btf.snackbarShow('即将跳转到「开往」项目的成员博客,不保证跳转网站的安全性和可用性', false, 5000);
setTimeout(function () {
window.open('https://travellings.link/');
}, "5000");
function totraveling () {
btf.snackbarShow("即将跳转到「开往」项目的成员博客,不保证跳转网站的安全性和可用性", function(element) {
element.style.opacity = 0,
travellingsTimer && clearTimeout(travellingsTimer)
}, 5000, "取消"),
travellingsTimer = setTimeout(function() {
window.open("https://www.travellings.cn/go.html", "_blank")
}, "5000")
}
// 移除加载动画
@ -651,24 +654,24 @@ function listenToPageInputPress() {
function initBlog() {
// 图片主色
GLOBAL_CONFIG.source.post.dynamicBackground && coverColor(),
percent(),
heo.topCategoriesBarScroll(),
heo.initIndexEssay(),
setBodyDataType(),
listenToPageInputPress(),
heo.topPostScroll(),
heo.sayhi(),
heo.qrcodeCreate(),
//右下角 snackbar 弹窗
percent(),
heo.topCategoriesBarScroll(),
heo.initIndexEssay(),
setBodyDataType(),
listenToPageInputPress(),
heo.topPostScroll(),
heo.sayhi(),
heo.qrcodeCreate(),
//右下角 snackbar 弹窗
GLOBAL_CONFIG.source.tool.switch && heo.hidecookie(),
heo.stopImgRightDrag(),
heo.onlyHome(),
heo.addNavBackgroundInit(),
heo.darkModeStatus(),
heo.initThemeColor(),
//隐藏加载动画
heo.stopImgRightDrag(),
heo.onlyHome(),
heo.addNavBackgroundInit(),
heo.darkModeStatus(),
heo.initThemeColor(),
//隐藏加载动画
GLOBAL_CONFIG.loadingBox && heo.hideLoading(),
checkUrlAndAddHideBanner()
checkUrlAndAddHideBanner()
}

View File

@ -29,6 +29,7 @@
--style-border-hover: 1px solid var(--heo-main);
--style-border-hover-always: 1px solid var(--heo-main);
--style-border-dashed: 1px dashed var(--heo-theme-op);
--heo-radius-full: 50px;
}
::selection {
@ -2644,6 +2645,115 @@ blockquote footer cite::before {
text-shadow: none;
}
#page-header.not-top-img #travellings_button::after {
background: var(--heo-main)!important;
}
#body-wrap .nav-fixed #travellings_button::after {
background: var(--heo-main)!important
}
#body-wrap #travellings_button {
display: -webkit-box;
display: -moz-box;
display: -webkit-flex;
display: -ms-flexbox;
display: box;
display: flex
}
#body-wrap #travellings_button:hover::after {
opacity: 1;
-ms-filter: none;
filter: none;
-webkit-transform: none;
-moz-transform: none;
-o-transform: none;
-ms-transform: none;
transform: none;
visibility: visible
}
#body-wrap #travellings_button:hover a {
background: var(--heo-main);
-webkit-box-shadow: var(--heo-shadow-main);
-webkit-box-shadow: var(--heo-shadow-main);
box-shadow: var(--heo-shadow-main)
}
#body-wrap #travellings_button:hover a i {
color: var(--heo-white)
}
#body-wrap #travellings_button::after {
--height: 1.8rem;
content: attr(title);
position: fixed;
display: -webkit-box;
display: -moz-box;
display: -webkit-flex;
display: -ms-flexbox;
display: box;
display: flex;
-webkit-box-pack: center;
-moz-box-pack: center;
-o-box-pack: center;
-ms-flex-pack: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-box-align: center;
-moz-box-align: center;
-o-box-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
color: var(--heo-white);
background: var(--heo-white-op)!important;
-webkit-box-shadow: var(--heo-shadow-nav);
box-shadow: var(--heo-shadow-nav);
border-radius: var(--heo-radius-full);
width: fit-content;
height: var(--height);
font-size: var(--global-font-size);
white-space: nowrap;
margin: auto;
padding: 0 4em;
top: calc((60px - var(--height))/ 2);
right: 0;
left: 0;
line-height: 0;
opacity: 0;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
z-index: 1;
visibility: hidden;
-webkit-transform: scaleX(1.1);
-moz-transform: scaleX(1.1);
-o-transform: scaleX(1.1);
-ms-transform: scaleX(1.1);
transform: scaleX(1.1);
pointer-events: none;
-webkit-transition: .5s;
-moz-transition: .5s;
-o-transition: .5s;
-ms-transition: .5s;
transition: .5s
}
@media screen and (max-width: 900px) {
#body-wrap #travellings_button::after {
padding:0 2em;
}
}
#body-wrap:has(#travellings_button:hover) #nav #menus,#body-wrap:has(#travellings_button:hover) #page-name {
display: none
}
#body-wrap .page #travellings_button:hover::after {
background: var(--heo-main)!important
}
#page-header.nav-fixed #nav {
position: fixed;
top: -60px;
@ -5587,6 +5697,9 @@ html {
#page-header.not-top-img:not(.nav-fixed) #nav {
background: var(--heo-background) !important;
}
div#travellings_button {
display: none!important
}
}
@ -6885,7 +6998,7 @@ img.footer_mini_logo:hover {
}
#rightMenu .rightMenu-line {
border-top: 1px dashed var(--heo-theme-op);
border-top: 2px dashed var(--heo-theme-op);
}
#rightMenu .rightMenu-group.rightMenu-small {

View File

@ -1,13 +1,13 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
th:replace="~{modules/layouts/layout :: layout(content = ~{::content}, htmlType = 'index', title = ${site.title})}">
th:replace="~{modules/layouts/layout :: layout(content = ~{::content}, htmlType = 'index', title = null)}">
<th:block th:fragment="content">
<div class="page" id="body-wrap">
<!-- 头部导航栏 -->
<header th:class="${theme.config.top.above.enable_above ? 'full_page' : 'not-top-img'}" id="page-header">
<nav th:replace="~{modules/nav :: nav(title = ${siteSubtitle})}"></nav>
<nav th:replace="~{modules/nav :: nav(title = ${siteTitle})}"></nav>
<!-- 问候语 -->
<th:block th:replace="~{modules/header/greeting :: greeting}"></th:block>
<!-- 第一屏 -->

View File

@ -5,7 +5,7 @@
th:if="${theme.config.other.diytitle.diytitleEnable}">
var leaveTitle = '[[${theme.config.other.diytitle.leaveTitle}]]';
var backTitle = '[[${theme.config.other.diytitle.backTitle}]]';
var OriginTitile = "[(${title})]"
var OriginTitile = "[(${siteTitle})]"
var titleTime
document.addEventListener('visibilitychange', function () {
if (document.hidden) {

View File

@ -13,7 +13,10 @@
</th:block>
<img th:if="${not #strings.isEmpty(theme.config.footer.social_media.centerImg)}" class="footer_mini_logo"
th:src="@{${theme.config.footer.social_media.centerImg}}" title="返回顶部" onclick="btf.scrollToDest(0, 500)">
th:with="img = @{${theme.config.footer.social_media.centerImg}}"
th:src="${isLazyload ? '' : img}"
th:data-lazy-src="${ isLazyload ? img : ''}"
title="返回顶部" onclick="btf.scrollToDest(0, 500)">
<th:block th:with="socialMedias = ${theme.config.footer.social_media.socialMediaRight}">
<a class="deal_link" rel="external nofollow" target="_blank" th:each="socialMedia : ${socialMedias}"
th:href="${socialMedia.url}" th:title="${socialMedia.name}">
@ -109,7 +112,9 @@
<a class="github-badge" th:each="data : ${bdageitem}" target="_blank"
th:href="@{${data.link}}" style="margin-inline:5px"
th:title="${data.message}">
<img th:src="@{${data.shields}}"
<img th:with=" img = @{${data.shields}}"
th:src="${isLazyload ? '' : img}"
th:data-lazy-src="${ isLazyload ? img : ''}"
th:alt="${data.message}" />
</a>
</p>

View File

@ -7,6 +7,7 @@
<meta content="width=device-width,initial-scale=1" name="viewport">
<meta content="telephone=no" name="format-detection">
<meta content="var(--heo-card-bg)" name="theme-color">
<title th:text="${siteTitle}"></title>
<link rel="shortcut icon"
th:href="@{${#strings.isEmpty(site.favicon) ? assets_link + '/images/hao-logo.jpg' : site.favicon}}"/>
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.6.0/jquery.min.js"></script>

View File

@ -5,13 +5,13 @@
theme.config.other.staticResource.use == 'custom' ? theme.config.other.staticResource.cdn_link : #theme.assets('/')},
theme_version = ${ theme.config.other.staticResource.use == 'local' ? '?v='+ theme.spec.version : ''},
isLazyload = ${theme.config.other.vanillaLazyload.enable},
loadingImg = ${theme.config.other.vanillaLazyload.loadingImg}">
loadingImg = ${theme.config.other.vanillaLazyload.loadingImg},
siteTitle = ${not #strings.isEmpty(title) ? title : #strings.isEmpty(site.subtitle) ? site.title : site.title +' - ' +site.subtitle }">
<!-- head 中自定义的 -->
<head>
<th:block th:replace="~{modules/head :: head(htmlType = ${htmlType})}"/>
<title th:text="${title}"></title>
</head>
<body>

View File

@ -99,6 +99,11 @@
<i class="iconfont icon-link"></i>
<span>复制地址</span>
</div>
<div class="rightMenu-item" id="menu-commentBarrage"
rel="external nofollow noreferrer" draggable="false" style="display: flex;">
<i class="haofont hao-icon-message"></i>
<span class="menu-commentBarrage-text">关闭热评</span>
</div>
<div class="rightMenu-item" id="menu-darkmode">
<i class="haofont hao-icon-circle-half-stroke"></i>
<span class="menu-darkmode-text">显示模式</span>

View File

@ -6,15 +6,20 @@
<div class="aside-list" id="newcomm">
<th:block th:if="${#strings.equals(theme.config.comments.use, 'commentWidget') }">
<div class="aside-list-item" th:each="comment,iterStat : ${commentFinder.list(null, 1, 20)}"
th:with="page = ${comment.spec.subjectRef.kind == 'Post' ? postFinder.getByName(comment.spec.subjectRef.name) : null}"
th:with="page = ${comment.spec.subjectRef.kind == 'Post' ? postFinder.getByName(comment.spec.subjectRef.name) :
comment.spec.subjectRef.kind == 'SinglePage' ? singlePageFinder.getByName(comment.spec.subjectRef.name) : null},
url = ${page == null? '/' : page.status.permalink + '#comment-' + comment.metadata.name}"
th:if="${iterStat.index < theme.config.sidebar.newcommentnumber}">
<span th:text="${commentIndex}"></span>
<a class="thumbnail" th:href="${page == null? '/' : page.status.permalink + '#comment-' + comment.metadata.name}" data-pjax-state="">
<img loading="lazy" alt="头像" th:src="${#strings.isEmpty(comment.owner.avatar)?'https://cravatar.cn/avatar/?d=mp':comment.owner.avatar}" data-ll-status="loading" class="entered loading">
<a class="thumbnail" th:href="${url}" data-pjax-state="">
<img alt="头像"
th:with=" img =${#strings.isEmpty(comment.owner.avatar)?'https://cravatar.cn/avatar/?d=mp':comment.owner.avatar}"
th:src="${isLazyload ? loadingImg : img}"
th:data-lazy-src="${ isLazyload ? img : ''}">
</a>
<div class="content" >
<a class="comment" style="display: -webkit-box;-webkit-line-clamp: 2;-webkit-box-orient: vertical;overflow: hidden;"
th:href="${page == null? '/' : page.status.permalink + '#comment-' + comment.metadata.name}" th:title="${comment.spec.content}" th:text="${comment.spec.content}" data-pjax-state="">
th:href="${url}" th:title="${comment.spec.content}" th:text="${comment.spec.content}" data-pjax-state="">
</a>
<div class="name">
@ -38,10 +43,14 @@
includeReply: false // 是否包括最新回复默认false
}).then(function (res) {
let commenthtml = '';
let name = 'src'
if([[${isLazyload}]]){
name = 'data-lazy-src'
}
res.forEach((items)=>{
commenthtml += `<div class="aside-list-item">
<a class="thumbnail" href="${items.url + '#' + items.id}">
<img loading="lazy" alt="dasda" src="${items.avatar}">
<img alt="dasda" ${name}="${items.avatar}">
</a>
<div class="content">
<a class="comment" style="display: -webkit-box;-webkit-line-clamp: 2;-webkit-box-orient: vertical;overflow: hidden;" href="${items.url + '#' + items.id}" title="test">

View File

@ -63,7 +63,10 @@
result += '<div class=\'aside-list-item\'>'
if (true) {
const name = 'src'
let name = 'src'
if([[${isLazyload}]]){
name = 'data-lazy-src'
}
result += `<a href='${array[i].url}' class='thumbnail'><img ${name}='${array[i].avatar}' alt='${array[i].nick}'><div class='name'><span>${array[i].nick}</span></div></a>`
}

View File

@ -17,18 +17,22 @@
<div class="aside-list">
<th:block th:if="${#strings.equals(theme.config.comments.use, 'commentWidget') }">
<!-- BUG由于当前的列出所有评论API无过滤功能非文章页的评论无法查询到页面信息所以非文章评论跳转至首页-->
<div class="aside-list-item" th:each="comment,iterStat : ${commentFinder.list(null, 1, 20)}"
th:with="page = ${comment.spec.subjectRef.kind == 'Post' ? postFinder.getByName(comment.spec.subjectRef.name) : null}"
th:if="${iterStat.index < 6}" >
<a th:href="${page == null? '/' : page.status.permalink + '#comment-' + comment.metadata.name}" class="thumbnail" data-pjax-state="">
<img th:src="${#strings.isEmpty(comment.owner.avatar)?'https://cravatar.cn/avatar/?d=mp':comment.owner.avatar}"
th:alt="${comment.owner.displayName}" data-ll-status="loaded" class="entered loaded">
<div class="aside-list-item" th:each="comment,iterStat : ${commentFinder.list(null, 1, 20)}"
th:with="page = ${comment.spec.subjectRef.kind == 'Post' ? postFinder.getByName(comment.spec.subjectRef.name) :
comment.spec.subjectRef.kind == 'SinglePage' ? singlePageFinder.getByName(comment.spec.subjectRef.name) : null},
url = ${page == null? '/' : page.status.permalink + '#comment-' + comment.metadata.name}"
th:if="${iterStat.index < 6}" >
<a th:href="${url}" class="thumbnail" data-pjax-state="">
<img th:with="img = ${#strings.isEmpty(comment.owner.avatar)?'https://cravatar.cn/avatar/?d=mp':comment.owner.avatar}"
th:src="${isLazyload ? loadingImg : img}"
th:data-lazy-src="${ isLazyload ? img : ''}"
th:alt="${comment.owner.displayName}">
<div class="name"><span>stonewu</span></div>
</a>
<div class="content">
<a class="comment" th:href="${page == null? '/' : page.status.permalink + '#comment-' + comment.metadata.name}" th:title="${comment.spec.content}" data-pjax-state="" th:text="${comment.spec.content}"></a>
<time th:datetime="${#dates.format(comment.metadata.creationTimestamp, 'yyyy-MM-dd HH:mm:ss')}"></time>
</div>
</a>
<div class="content">
<a class="comment" th:href="${url}" th:title="${comment.spec.content}" data-pjax-state="" th:text="${comment.spec.content}"></a>
<time th:datetime="${#dates.format(comment.metadata.creationTimestamp, 'yyyy-MM-dd HH:mm:ss')}"></time>
</div>
</div>
<script data-pjax>
window.addEventListener('load', () => {

View File

@ -7,14 +7,14 @@
<!-- 功能都需要添加开关 -->
<!-- 随机前往一个开往项目网站 -->
<div class="nav-button only-home" id="travellings_button" th:if="${theme.config.nav.right.travelling}">
<a class="site-page" th:href="@{${theme.config.nav.right.travellingUrl}}" target="_blank" rel="external nofollow"
<div class="nav-button" id="travellings_button" title="随机前往一个开往项目网站" th:if="${theme.config.nav.right.travelling}">
<a class="site-page" onclick="totraveling()" href="javascript:void(0);" rel="external nofollow"
title="随机前往一个开往项目网站">
<i class="haofont hao-icon-train" style="font-size: 1rem; font-weight: 700; "></i>
</a>
</div>
<div class="nav-button only-home" th:if="${theme.config.nav.right.article}">
<div class="nav-button" th:if="${theme.config.nav.right.article}">
<a class="site-page" href="javascript:void(0);" onclick="toRandomPost()" title="随机文章">
<i class="haofont hao-icon-dice" style="font-size: 1rem; font-weight: 700;"></i>
</a>