Merge pull request #472 from chengzhongxue/main

页脚内容样式一和默认样式合并
This commit is contained in:
困困鱼 2023-09-05 01:20:27 +08:00 committed by GitHub
commit 0e1b8ecc53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 112 additions and 116 deletions

View File

@ -1079,36 +1079,43 @@ spec:
name: footerContent
label: 页脚内容
value:
footerStyle: default
style_one:
owner_enable: false
runtime_enable: true
work_img: "https://0206.ink/upload/%E5%9B%B0%E5%9B%B0%E9%B1%BC-%E4%B8%8B%E7%8F%AD%E5%95%A6-yellowgreen.svg"
work_description: "距离月入25k也就还差一个大佬带我~"
offduty_img: "https://0206.ink/upload/%E5%9B%B0%E5%9B%B0%E9%B1%BC-%E4%B8%8B%E7%8F%AD%E5%95%A6-yellowgreen.svg"
offduty_description: "下班了就该开开心心的玩耍,嘿嘿~"
bdageitem:
- link: "https://halo.run/"
shields: "https://npm.elemecdn.com/hao-theme-static@1.2.0/templates/images/Frame-Halo-blue.svg"
message: "博客框架为halo2.x"
default_enable: true
children:
- $formkit: select
name: footerStyle
id: footeStyle
key: footeStyle
label: 样式
value: default
- $formkit: radio
name: default_enable
label: 底部
options:
- value: default
label: 默认
- value: one
label: 样式一
- label: 显示
value: true
- label: 隐藏
value: false
- $formkit: group
if: $get(footeStyle).value == 'one'
name: style_one
label: 样式一
label: 中间
value:
runtime_enable:
work_img:
work_description:
offduty_img:
offduty_description:
bdageitem:
children:
- $formkit: radio
name: owner_enable
label: 网站所有者
options:
- label: 显示
value: true
- label: 隐藏
value: false
- $formkit: radio
name: runtime_enable
id: runtime_enable
key: runtime_enable
value: true
label: 运行时间
options:
- label: 显示
@ -1120,32 +1127,25 @@ spec:
name: work_img
label: 上班时间的徽标
placeholder: 请输入内容
value: "https://0206.ink/upload/%E5%9B%B0%E5%9B%B0%E9%B1%BC-%E4%B8%8B%E7%8F%AD%E5%95%A6-yellowgreen.svg"
- $formkit: text
if: $get(runtime_enable).value
name: work_description
label: 上班时间的 title 描述
placeholder: 请输入内容
value: "距离月入25k也就还差一个大佬带我~"
- $formkit: attachment
if: $get(runtime_enable).value
name: offduty_img
label: 下班时间的徽标
placeholder: 请输入内容
value: "https://0206.ink/upload/%E5%9B%B0%E5%9B%B0%E9%B1%BC-%E4%B8%8B%E7%8F%AD%E5%95%A6-yellowgreen.svg"
- $formkit: text
if: $get(runtime_enable).value
name: offduty_description
label: 下班时间的 title 描述
placeholder: 请输入内容
value: "下班了就该开开心心的玩耍,嘿嘿~"
- $formkit: repeater
name: bdageitem
label: 徽标配置项
value:
- link: "https://halo.run/"
shields: "https://npm.elemecdn.com/hao-theme-static@1.2.0/templates/images/Frame-Halo-blue.svg"
message: "博客框架为halo2.x"
children:
- $formkit: url
name: link

View File

@ -67,19 +67,23 @@ var heo = {
// 页脚友链
addFriendLinksInFooter: function () {
const fetchUrl = "/apis/api.plugin.halo.run/v1alpha1/plugins/PluginLinks/links?keyword=&sort=priority,asc"
const linksUrl = GLOBAL_CONFIG.source.links.linksUrl
const links = GLOBAL_CONFIG.source.links.linksData
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]
htmlText += `<a class='footer-item' href='${item.spec.url}' target="_blank" rel="noopener nofollow">${item.spec.displayName}</a>`;
}
htmlText += `<a class='footer-item' href='${linksUrl}'>更多</a>`
if(document.getElementById("friend-links-in-footer")){
document.getElementById("friend-links-in-footer").innerHTML = htmlText;
}
fetch(fetchUrl)
.then(res => res.json())
.then(json => {
var randomFriendLinks = getArrayItems(json.items, num);
var htmlText = '';
for (let i = 0; i < randomFriendLinks.length; ++i) {
var item = randomFriendLinks[i]
htmlText += `<a class='footer-item' href='${item.spec.url}' target="_blank" rel="noopener nofollow">${item.spec.displayName}</a>`;
}
htmlText += `<a class='footer-item' href='${linksUrl}'>更多</a>`
if(document.getElementById("friend-links-in-footer")){
document.getElementById("friend-links-in-footer").innerHTML = htmlText;
}
})
},
//禁止图片右键单击

View File

@ -390,32 +390,38 @@ document.addEventListener('scroll', btf.throttle(function () {
heo.initThemeColor()
}, 200))
//友链随机传送
//友链随机传送
function travelling() {
const links = GLOBAL_CONFIG.source.links.linksData
var name = ''
var link = ''
if(links.length>0){
var randomFriendLinks = getArrayItems(links, 1);
name = randomFriendLinks[0].spec.displayName;
link = randomFriendLinks[0].spec.url;
}
var msg = "点击前往按钮进入随机一个友链,不保证跳转网站的安全性和可用性。本次随机到的是本站友链:「" + name + "」";
const style = document.createElement('style');
document.head.appendChild(style);
const styleSheet = style.sheet;
styleSheet.insertRule(`:root{--heo-snackbar-time: 8000ms!important}`, styleSheet.cssRules.length);
Snackbar.show({
text: msg,
duration: 8000,
pos: 'top-center',
actionText: '前往',
onActionClick: function (element) {
//Set opacity of element to 0 to close Snackbar
$(element).css('opacity', 0);
window.open(link, '_blank');
}
});
const links = "/apis/api.plugin.halo.run/v1alpha1/plugins/PluginLinks/links?keyword=&sort=priority,asc"
fetch(links)
.then(res => res.json())
.then(json => {
var linksData = json.items
var name = ''
var link = ''
if(linksData.length>0){
var randomFriendLinks = getArrayItems(linksData, 1);
name = randomFriendLinks[0].spec.displayName;
link = randomFriendLinks[0].spec.url;
}
var msg = "点击前往按钮进入随机一个友链,不保证跳转网站的安全性和可用性。本次随机到的是本站友链:「" + name + "」";
const style = document.createElement('style');
document.head.appendChild(style);
const styleSheet = style.sheet;
styleSheet.insertRule(`:root{--heo-snackbar-time: 8000ms!important}`, styleSheet.cssRules.length);
Snackbar.show({
text: msg,
duration: 8000,
pos: 'top-center',
actionText: '前往',
onActionClick: function (element) {
//Set opacity of element to 0 to close Snackbar
$(element).css('opacity', 0);
window.open(link, '_blank');
}
});
})
}
//前往黑洞

View File

@ -406,7 +406,7 @@ function addRightMenuClickEvent() {
});
$('#menu-copylink').on('click', rm.copyLink);
$('#menu-downloadimg').on('click', function () {
heo.downloadImage(domImgSrc, 'kunkunyu');
heo.downloadImage(domImgSrc, 'hao');
});
$('#menu-newwindowimg').on('click', function () {
window.open(domImgSrc, "_blank");

View File

@ -3,7 +3,7 @@
<th:block th:fragment="footer-style-one">
<script th:if="${theme.config.footer.footerContent.footerStyle == 'one'}" async="async">(function () {
<script th:if="${theme.config.footer.footerContent.style_one.runtime_enable}" async="async">(function () {
var grt = new Date("[[${#strings.arraySplit(theme.config.basics.siteStartTime, '-')[1]}]]/[[${#strings.arraySplit(theme.config.basics.siteStartTime, '-')[2]}]]/[[${#strings.arraySplit(theme.config.basics.siteStartTime, '-')[0]}]] 00:00:00"); //设置网站上线时间
var now = new Date();
var dnum;

View File

@ -53,10 +53,45 @@
</th:block>
<!-- 底部 banner -->
<halo:footer />
<div th:if="${theme.config.footer.footerContent.footerStyle == 'default'}" id="footer-banner">
<div class="copyright" th:if="${not #strings.isEmpty(theme.config.basics.siteStartTime) && theme.config.footer.footerContent.style_one.owner_enable}">
©[[${#strings.arraySplit(theme.config.basics.siteStartTime, '-')[0]}]] - [[${#dates.format(new
java.util.Date(), 'yyyy')}]] By [[${site.title}]]
</div>
<div class="copyright" th:if="${#strings.isEmpty(theme.config.basics.siteStartTime) && theme.config.footer.footerContent.style_one.owner_enable}">
©[[${#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>
<p id="ghbdages"
th:with="bdageitem = ${theme.config.footer.footerContent.style_one.bdageitem}">
<a class="github-badge" th:each="data : ${bdageitem}" target="_blank"
th:href="@{${data.link}}" style="margin-inline:5px"
th:title="${data.message}">
<img th:with=" img = @{${data.shields}}"
th:src="${isLazyload ? '' : img}"
th:data-lazy-src="${ isLazyload ? img : ''}"
th:alt="${data.message}" />
</a>
</p>
<span th:if="${!theme.config.footer.footerContent.default_enable}" style="padding: 20px 20px;">
</span>
<style>
.copyright,#ghbdages,#workboard {
text-align: center;
}
</style>
<style th:if="${(theme.config.footer.footerContent.style_one.owner_enable || not #lists.isEmpty(theme.config.footer.footerContent.style_one.bdageitem)) && theme.config.footer.footerContent.default_enable}">
#heo-footer {
margin-bottom: 1rem;
}
</style>
<div th:if="${theme.config.footer.footerContent.default_enable}" id="footer-banner">
<div class="footer-banner-links">
<div class="footer-banner-left">
<div id="footer-banner-tips">
@ -98,41 +133,6 @@
</div>
</div>
<th:block th:if="${theme.config.footer.footerContent.footerStyle == 'one'}">
<div class="copyright" th:if="${not #strings.isEmpty(theme.config.basics.siteStartTime)}">
©[[${#strings.arraySplit(theme.config.basics.siteStartTime, '-')[0]}]] - [[${#dates.format(new
java.util.Date(), 'yyyy')}]] By [[${site.title}]]
</div>
<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>
<p id="ghbdages"
th:with="bdageitem = ${theme.config.footer.footerContent.style_one.bdageitem}">
<a class="github-badge" th:each="data : ${bdageitem}" target="_blank"
th:href="@{${data.link}}" style="margin-inline:5px"
th:title="${data.message}">
<img th:with=" img = @{${data.shields}}"
th:src="${isLazyload ? '' : img}"
th:data-lazy-src="${ isLazyload ? img : ''}"
th:alt="${data.message}" />
</a>
</p>
<span style="padding: 20px 20px;">
</span>
<style>
[data-theme="light"] .copyright,#ghbdages,#workboard{
color: var(--font-color);
}
.copyright,#ghbdages,#workboard {
position: relative;
padding: 0px 20px;
text-align: center;
}
</style>
</th:block>
<!-- 右下角 snackbar 弹窗 -->
<div th:if="${theme.config.tool.snackbar.switch}" class="needEndHide" id="cookies-window">

View File

@ -199,7 +199,6 @@
source: {
links: {
linksUrl: [[${ theme.config.link.linksUrl }]],
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',
@ -280,22 +279,9 @@
};
</script>
<script data-pjax th:inline="javascript" th:if="${pluginFinder.available('PluginLinks')}">
var groupData = [[${ linkFinder.groupBy() }]]
if (groupData.length > 0) {
GLOBAL_CONFIG.source.links.linksData = groupData.flatMap((item) => {
return item.links
})
}
</script>
</th:block>
</html>