优化页脚样式一图片加载 (#367)

This commit is contained in:
Roozen 2023-08-04 00:51:23 +08:00 committed by GitHub
parent fea7a349c7
commit 0065cec8f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 17 deletions

View File

@ -39,28 +39,24 @@
n = (t / 1496e5).toFixed(6)
}
if (!(nowHour < 18 && nowHour >= 9)) {
// 如果是下班时间,插入"困困鱼-下班啦.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}]]";
}
// 更新网页中显示的网站运行时间
function updateHtml() {
const footer = document.getElementById("footer");
if (!footer) return
let currentTimeHtml = "";
let img = "";
let description = "";
if (nowHour < 18 && nowHour >= 9) {
// 如果是上班时间
img = "[(${theme.config.footer.footerContent.style_one.work_img})]";
description = "[(${theme.config.footer.footerContent.style_one.work_description})]";
} else {
// 如果是下班时间
img = "[(${theme.config.footer.footerContent.style_one.offduty_img})]";
description = "[(${theme.config.footer.footerContent.style_one.offduty_description})]";
}
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;
let currentTimeHtml = `本站居然运行了 ${dnum} 天<span id='runtime'> ${hnum} 小时 ${mnum} 分 ${snum} 秒 </span><i class='haofont hao-icon-heartbeat' style='color:red'></i> <br> 旅行者 1 号当前距离地球 ${t} 千米,约为 ${n} 个天文单位 🚀`;
if (document.getElementById("runtimeTextTip")) {
document.getElementById("runtimeTextTip").innerHTML = currentTimeHtml;
}
}
setInterval(() => {
updateTime();
updateHtml();

View File

@ -103,7 +103,13 @@
<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"></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>
<p id="ghbdages"
th:with="bdageitem = ${theme.config.footer.footerContent.style_one.bdageitem}">
<a class="github-badge" th:each="data : ${bdageitem}" target="_blank"