Merge pull request #366 from chengzhongxue/main

优化页脚图片加载
This commit is contained in:
困困鱼 2023-08-03 23:46:15 +08:00 committed by GitHub
commit fea7a349c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 23 deletions

View File

@ -991,7 +991,7 @@ spec:
label: 页脚友链
value:
enable_footer_group:
fetchUrl:
num:
children:
- $formkit: radio
name: enable_footer_group
@ -1003,6 +1003,12 @@ spec:
value: true
- label: 禁用
value: false
- $formkit: number
if: $get(enable_footer_group).value
name: num
label: 友链数
value: 3
validation: required
- $formkit: group
name: footerContent
label: 页脚内容

View File

@ -139,7 +139,8 @@ var heo = {
addFriendLinksInFooter: function () {
const linksUrl = GLOBAL_CONFIG.source.links.linksUrl
const links = GLOBAL_CONFIG.source.links.linksData
var randomFriendLinks = getArrayItems(links, 3);
const num = GLOBAL_CONFIG.source.links.linksNum
var randomFriendLinks = getArrayItems(links, num);
var htmlText = '';
for (let i = 0; i < randomFriendLinks.length; ++i) {
var item = randomFriendLinks[i]

View File

@ -44,24 +44,23 @@
const footer = document.getElementById("footer");
if (!footer) return
let currentTimeHtml = "";
let img = "";
let description = "";
if (nowHour < 18 && nowHour >= 9) {
// 如果是上班时间,默认就是"困困鱼-上班摸鱼中.svg"图片,不需要更改
currentTimeHtml = `本站居然运行了 ${dnum} 天<span id='runtime'> ${hnum} 小时 ${mnum} 分 ${snum} 秒 </span><i class='haofont hao-icon-heartbeat' style='color:red'></i> <br> 旅行者 1 号当前距离地球 ${t} 千米,约为 ${n} 个天文单位 🚀`;
// 如果是上班时间
img = "[(${theme.config.footer.footerContent.style_one.work_img})]";
description = "[(${theme.config.footer.footerContent.style_one.work_description})]";
} else {
// 如果是下班时间,插入"困困鱼-下班啦.svg"图片
let img = document.querySelector("#workboard .workSituationImg");
img.src = "[[${theme.config.footer.footerContent.style_one.offduty_img}]]";
img.title = "[[${theme.config.footer.footerContent.style_one.offduty_description}]]";
img.alt = "[[${theme.config.footer.footerContent.style_one.offduty_description}]]";
currentTimeHtml = `本站居然运行了 ${dnum} 天<span id='runtime'> ${hnum} 小时 ${mnum} 分 ${snum} 秒 </span><i class='haofont hao-icon-heartbeat' style='color:red'></i> <br> 旅行者 1 号当前距离地球 ${t} 千米,约为 ${n} 个天文单位 🚀`;
// 如果是下班时间
img = "[(${theme.config.footer.footerContent.style_one.offduty_img})]";
description = "[(${theme.config.footer.footerContent.style_one.offduty_description})]";
}
if (document.getElementById("runtimeTextTip")) {
document.getElementById("runtimeTextTip").innerHTML = currentTimeHtml;
if (document.getElementById("workboard")) {
currentTimeHtml = `<img class="workSituationImg boardsign" src="${img}" alt="${description}" title="${description}">
<div id="runtimeTextTip"> 本站居然运行了 ${dnum} 天<span id='runtime'> ${hnum} 小时 ${mnum} 分 ${snum} 秒 </span><i class='haofont hao-icon-heartbeat' style='color:red'></i> <br> 旅行者 1 号当前距离地球 ${t} 千米,约为 ${n} 个天文单位 🚀 </div>`
document.getElementById("workboard").innerHTML = currentTimeHtml;
}
}
setInterval(() => {
updateTime();
updateHtml();

View File

@ -103,13 +103,7 @@
<div class="copyright" th:if="${#strings.isEmpty(theme.config.basics.siteStartTime)}">
©[[${#dates.format(new java.util.Date(), 'yyyy')}]] By [[${site.title}]]
</div>
<div th:if="${theme.config.footer.footerContent.style_one.runtime_enable}" id="workboard">
<img class="workSituationImg boardsign"
th:src="${theme.config.footer.footerContent.style_one.work_img}"
th:alt="${theme.config.footer.footerContent.style_one.work_description}"
th:title="${theme.config.footer.footerContent.style_one.work_description}" />
<div id="runtimeTextTip"></div>
</div>
<div th:if="${theme.config.footer.footerContent.style_one.runtime_enable}" id="workboard"></div>
<p id="ghbdages"
th:with="bdageitem = ${theme.config.footer.footerContent.style_one.bdageitem}">
<a class="github-badge" th:each="data : ${bdageitem}" target="_blank"

View File

@ -211,7 +211,8 @@
source: {
links: {
linksUrl: [[${ theme.config.link.linksUrl }]],
linksData: []
linksData: [],
linksNum: [[${theme.config.footer.footer_group.num}]],
},
jQuery: 'https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.6.0/jquery.min.js',
justifiedGallery: {