Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
d40d22a4ce
|
@ -428,6 +428,96 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||
}
|
||||
);
|
||||
|
||||
|
||||
// flink 友链标签
|
||||
customElements.define(
|
||||
"hao-flink",
|
||||
class HaoGalleryGroup extends HTMLElement {
|
||||
constructor() {
|
||||
super();
|
||||
this.options = {
|
||||
name: this.getAttribute("name"),
|
||||
desc: this.getAttribute("desc"),
|
||||
style: this.getAttribute("style"),
|
||||
};
|
||||
const _temp = getChildren(this, "_tpl");
|
||||
let _innerHTML = _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, "");
|
||||
let style = this.options.style;
|
||||
let content = "";
|
||||
let contents = "";
|
||||
let class_desc = "";
|
||||
_innerHTML.replace(
|
||||
/{([^}]*)}/g,
|
||||
function ($0, $1) {
|
||||
var flink = $1.split(",",5);
|
||||
if(style=='beautify'){
|
||||
contents +=`
|
||||
<div class="site-card">
|
||||
<a class="img" target="_blank" href="${flink[1]}" title="${flink[0]}">
|
||||
<img class="flink-avatar entered loaded" style="pointer-events: none;" alt="${flink[0]}" ${GLOBAL_CONFIG.source.img.src}="${flink[4] || flink[2]}" >
|
||||
</a>
|
||||
|
||||
<a class="info cf-friends-link" target="_blank" href="${flink[1]}" title="${flink[0]}">
|
||||
<div class="site-card-avatar no-lightbox">
|
||||
<img class="flink-avatar cf-friends-avatar" alt="${flink[0]}" ${GLOBAL_CONFIG.source.img.src}="${flink[2]}">
|
||||
</div>
|
||||
<div class="site-card-text">
|
||||
<span class="title cf-friends-name">${flink[0]}</span>
|
||||
<span class="desc" title="${flink[3]}">${flink[3]}</span>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
if(style=='default'){
|
||||
contents +=`
|
||||
<div class="flink-list-item">
|
||||
<a class="cf-friends-link" rel="external nofollow" target="_blank" href="${flink[1]}" title="${flink[0]}">
|
||||
<img class="flink-avatar cf-friends-avatar" alt="${flink[0]}" ${GLOBAL_CONFIG.source.img.src}="${flink[2]}">
|
||||
<div class="flink-item-info no-lightbox">
|
||||
<span class="flink-item-name cf-friends-name">${flink[0]}</span>
|
||||
<span class="flink-item-desc" title="${flink[3]}">${flink[3]}</span>
|
||||
<img ${GLOBAL_CONFIG.source.img.src}="${flink[2]}">
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
}
|
||||
|
||||
);
|
||||
if(this.options.desc!=null && this.options.desc!=''){
|
||||
class_desc =`
|
||||
<div class="flink-desc">${this.options.desc}</div>
|
||||
`
|
||||
}
|
||||
if(this.options.style=='beautify'){
|
||||
content =`
|
||||
<div class="site-card-group">
|
||||
${contents}
|
||||
</div>
|
||||
`
|
||||
}
|
||||
if(this.options.style=='default'){
|
||||
content =`
|
||||
<div class="flink-list">
|
||||
${contents}
|
||||
</div>
|
||||
`
|
||||
}
|
||||
let htmlStr = `
|
||||
<div class="flink" id="article-container">
|
||||
<div class="flink-name">${this.options.name}</div>
|
||||
${class_desc}
|
||||
${content}
|
||||
</div>
|
||||
`;
|
||||
this.innerHTML = htmlStr;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
customElements.define(
|
||||
"hao-dplayer",
|
||||
class HaoDplayer extends HTMLElement {
|
||||
|
|
|
@ -147,6 +147,29 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* toc
|
||||
*/
|
||||
const tocFn = function () {
|
||||
const postContent = document.querySelector('.post-content');
|
||||
|
||||
if (postContent == null) return;
|
||||
|
||||
const headers = postContent.querySelectorAll('h1,h2,h3,h4,h5,h6');
|
||||
// 没有 toc 目录,则直接移除
|
||||
if (headers.length === 0) {
|
||||
document.getElementById("card-toc").remove();
|
||||
} else {
|
||||
tocbot.init({
|
||||
tocSelector: '.toc-content',
|
||||
contentSelector: '.post-content',
|
||||
headingSelector: 'h1,h2,h3,h4,h5,h6',
|
||||
hasInnerContainers: true
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 滾動處理
|
||||
*/
|
||||
|
@ -446,6 +469,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
|
||||
if (GLOBAL_CONFIG.isPost) {
|
||||
addRuntime();
|
||||
tocFn();
|
||||
} else {
|
||||
addLastPushDate()
|
||||
toggleCardCategory()
|
||||
|
|
|
@ -452,13 +452,6 @@ function removeLoading() {
|
|||
}, 3000)
|
||||
}
|
||||
|
||||
//移除pwa
|
||||
navigator.serviceWorker.getRegistrations().then(function (registrations) {
|
||||
for (let registration of registrations) {
|
||||
registration.unregister()
|
||||
}
|
||||
})
|
||||
|
||||
function addFriendLink() {
|
||||
var input = document.getElementsByClassName('el-textarea__inner')[0];
|
||||
let evt = document.createEvent('HTMLEvents');
|
||||
|
@ -672,7 +665,6 @@ function initBlog() {
|
|||
//隐藏加载动画
|
||||
GLOBAL_CONFIG.loadingBox && heo.hideLoading(),
|
||||
checkUrlAndAddHideBanner()
|
||||
|
||||
}
|
||||
|
||||
// 如果当前页有评论就执行函数
|
||||
|
|
|
@ -2102,4 +2102,13 @@ p.p.purple,span.p.purple {
|
|||
|
||||
p.p.gray,span.p.gray {
|
||||
color: #999
|
||||
}
|
||||
|
||||
.flink-name {
|
||||
margin-bottom: 5px;
|
||||
font-weight: 700;
|
||||
font-size: 1.5em
|
||||
}
|
||||
.flink-desc {
|
||||
margin: .2rem 0 .5rem
|
||||
}
|
|
@ -4,51 +4,5 @@
|
|||
<th:block th:fragment="toc-bot">
|
||||
<script th:src="${assets_link + '/libs/tocbot/4.18.2/tocbot.min.js'}"></script>
|
||||
<link th:href="${assets_link + '/libs/tocbot/4.18.2/tocbot.css'}" rel="stylesheet">
|
||||
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
|
||||
const postContent = document.querySelector('.post-content');
|
||||
|
||||
if (postContent == null) return;
|
||||
|
||||
const headers = postContent.querySelectorAll('h1,h2,h3,h4,h5,h6');
|
||||
// 没有 toc 目录,则直接移除
|
||||
if (headers.length === 0) {
|
||||
document.getElementById("card-toc").remove();
|
||||
} else {
|
||||
tocbot.init({
|
||||
tocSelector: '.toc-content',
|
||||
contentSelector: '.post-content',
|
||||
headingSelector: 'h1,h2,h3,h4,h5,h6',
|
||||
hasInnerContainers: true
|
||||
});
|
||||
|
||||
}
|
||||
})
|
||||
document.addEventListener('pjax:complete', function () {
|
||||
|
||||
const postContent = document.querySelector('.post-content');
|
||||
|
||||
if (postContent == null) return;
|
||||
|
||||
const headers = postContent.querySelectorAll('h1,h2,h3,h4,h5,h6');
|
||||
// 没有 toc 目录,则直接移除
|
||||
if (headers.length === 0) {
|
||||
document.getElementById("card-toc").remove();
|
||||
} else {
|
||||
tocbot.init({
|
||||
tocSelector: '.toc-content',
|
||||
contentSelector: '.post-content',
|
||||
headingSelector: 'h1,h2,h3,h4,h5,h6',
|
||||
hasInnerContainers: true
|
||||
});
|
||||
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</th:block>
|
||||
|
||||
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue