Compare commits

...

12 Commits
0.5.8 ... main

Author SHA1 Message Date
浪子 18bf403848 0.6.1 2024-10-08 17:01:31 +08:00
浪子 b0b20298b5
0.6.1 2024-09-28 23:51:56 +08:00
浪子 15b7523b18
0.6.1 2024-09-28 23:34:36 +08:00
浪子 59f1d27e27
0.6.1 2024-09-28 23:28:10 +08:00
浪子 b3c8ea001f
0.6.1 2024-09-28 23:25:27 +08:00
浪子 5c3fd36980 0.6.1
更改部分代码
2024-09-28 13:38:22 +08:00
浪子 c9be23aea0 去除fancybox 2024-09-28 13:38:00 +08:00
浪子 9c40556f6e 0.6.1
删除部分
2024-09-08 14:33:37 +08:00
浪子 8c9dd30c52 0.6.0 2024-08-31 10:57:54 +08:00
浪子 74b7bcecff 静态资源本地化
静态资源本地化
2024-08-29 18:26:30 +08:00
浪子 b4c55168b4 0.6.0
置顶不能为空
2024-08-13 10:33:58 +08:00
浪子 0e343d704f 0.6.0
略微调整页脚显示
2024-08-08 12:13:45 +08:00
12 changed files with 202 additions and 147 deletions

6
dist/js/bundle.js vendored
View File

@ -17,7 +17,7 @@
is_single = false; is_single = false;
post_id = 0; post_id = 0;
is_archive = false; is_archive = false;
VERSION = "0.5.8"; VERSION = "0.6.1";
constructor() { constructor() {
super(); super();
this.initCopyright(); this.initCopyright();
@ -45,8 +45,8 @@
} }
} }
initCopyright() { initCopyright() {
const copyright = `<div class="site--footer__info"> const copyright = `<div class="site--footer__info">由<a href="https://www.typecho.org" target="_blank">Typecho</a> 驱动 <br>
Theme <a href="https://fatesinger.com/101971" target="_blank">farallon</a> by bigfa <a href="https://www.imsun.org" target="_blank">&nbsp;Made with Sun</a> / version ${this.VERSION} Theme <a href="https://fatesinger.com/101971" target="_blank">farallon</a> by bigfa &nbsp;<br>Made with<a href="https://www.imsun.org" target="_blank"> Sun</a> / version ${this.VERSION}
</div>`; </div>`;
document.querySelector(".site--footer__content").insertAdjacentHTML("afterend", copyright); document.querySelector(".site--footer__content").insertAdjacentHTML("afterend", copyright);
document.querySelector(".icon--copryrights").addEventListener("click", () => { document.querySelector(".icon--copryrights").addEventListener("click", () => {

1
dist/js/chart.js vendored Normal file

File diff suppressed because one or more lines are too long

6
dist/js/marked.min.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/js/tex-mml-chtml.js vendored Normal file

File diff suppressed because one or more lines are too long

13
dist/js/view-image.min.js vendored Normal file
View File

@ -0,0 +1,13 @@
/**
* ViewImage.min.js 2.0.2
* MIT License - http://www.opensource.org/licenses/mit-license.php
* https://tokinx.github.io/ViewImage/
*/
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.createTemplateTagFirstArg=function(b){return b.raw=b};$jscomp.createTemplateTagFirstArgWithRaw=function(b,a){b.raw=a;return b};$jscomp.arrayIteratorImpl=function(b){var a=0;return function(){return a<b.length?{done:!1,value:b[a++]}:{done:!0}}};$jscomp.arrayIterator=function(b){return{next:$jscomp.arrayIteratorImpl(b)}};$jscomp.makeIterator=function(b){var a="undefined"!=typeof Symbol&&Symbol.iterator&&b[Symbol.iterator];return a?a.call(b):$jscomp.arrayIterator(b)};
$jscomp.arrayFromIterator=function(b){for(var a,d=[];!(a=b.next()).done;)d.push(a.value);return d};$jscomp.arrayFromIterable=function(b){return b instanceof Array?b:$jscomp.arrayFromIterator($jscomp.makeIterator(b))};
(function(){window.ViewImage=new function(){var b=this;this.target="[view-image] img";this.listener=function(a){if(!(a.ctrlKey||a.metaKey||a.shiftKey||a.altKey)){var d=String(b.target.split(",").map(function(g){return g.trim()+":not([no-view])"})),c=a.target.closest(d);if(c){var e=c.closest("[view-image]")||document.body;d=[].concat($jscomp.arrayFromIterable(e.querySelectorAll(d))).map(function(g){return g.href||g.src});b.display(d,c.href||c.src);a.stopPropagation();a.preventDefault()}}};this.init=
function(a){a&&(b.target=a);["removeEventListener","addEventListener"].forEach(function(d){document[d]("click",b.listener,!1)})};this.display=function(a,d){var c=a.indexOf(d),e=(new DOMParser).parseFromString('\n <div class="view-image">\n <style>.view-image{position:fixed;inset:0;z-index:500;padding:1rem;display:flex;flex-direction:column;animation:view-image-in 300ms;backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px)}.view-image__out{animation:view-image-out 300ms}@keyframes view-image-in{0%{opacity:0}}@keyframes view-image-out{100%{opacity:0}}.view-image-btn{width:32px;height:32px;display:flex;justify-content:center;align-items:center;cursor:pointer;border-radius:3px;background-color:rgba(255,255,255,0.2)}.view-image-btn:hover{background-color:rgba(255,255,255,0.5)}.view-image-close__full{position:absolute;inset:0;background-color:rgba(48,55,66,0.3);z-index:unset;cursor:zoom-out;margin:0}.view-image-container{height:0;flex:1;display:flex;align-items:center;justify-content:center;}.view-image-lead{display:contents}.view-image-lead img{position:relative;z-index:1;max-width:100%;max-height:100%;object-fit:contain;border-radius:3px}.view-image-lead__in img{animation:view-image-lead-in 300ms}.view-image-lead__out img{animation:view-image-lead-out 300ms forwards}@keyframes view-image-lead-in{0%{opacity:0;transform:translateY(-20px)}}@keyframes view-image-lead-out{100%{opacity:0;transform:translateY(20px)}}[class*=__out] ~ .view-image-loading{display:block}.view-image-loading{position:absolute;inset:50%;width:8rem;height:2rem;color:#aab2bd;overflow:hidden;text-align:center;margin:-1rem -4rem;z-index:1;display:none}.view-image-loading::after{content:"";position:absolute;inset:50% 0;width:100%;height:3px;background:rgba(255,255,255,0.5);transform:translateX(-100%) translateY(-50%);animation:view-image-loading 800ms -100ms ease-in-out infinite}@keyframes view-image-loading{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}.view-image-tools{position:relative;display:flex;justify-content:space-between;align-content:center;color:#fff;max-width:600px;position: absolute; bottom: 5%; left: 1rem; right: 1rem; backdrop-filter: blur(10px);margin:0 auto;padding:10px;border-radius:5px;background:rgba(0,0,0,0.1);margin-bottom:constant(safe-area-inset-bottom);margin-bottom:env(safe-area-inset-bottom);z-index:1}.view-image-tools__count{width:60px;display:flex;align-items:center;justify-content:center}.view-image-tools__flip{display:flex;gap:10px}.view-image-tools [class*=-close]{margin:0 10px}</style>\n <div class="view-image-container">\n <div class="view-image-lead"></div>\n <div class="view-image-loading"></div>\n <div class="view-image-close view-image-close__full"></div>\n </div>\n <div class="view-image-tools">\n <div class="view-image-tools__count">\n <span><b class="view-image-index">'+
(c+1)+"</b>/"+a.length+'</span>\n </div>\n <div class="view-image-tools__flip">\n <div class="view-image-btn view-image-tools__flip-prev">\n <svg width="20" height="20" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="48" height="48" fill="white" fill-opacity="0.01"/><path d="M31 36L19 24L31 12" stroke="white" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></svg>\n </div>\n <div class="view-image-btn view-image-tools__flip-next">\n <svg width="20" height="20" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="48" height="48" fill="white" fill-opacity="0.01"/><path d="M19 12L31 24L19 36" stroke="white" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></svg>\n </div>\n </div>\n <div class="view-image-btn view-image-close">\n <svg width="16" height="16" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="48" height="48" fill="white" fill-opacity="0.01"/><path d="M8 8L40 40" stroke="white" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M8 40L40 8" stroke="white" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></svg>\n </div>\n </div>\n </div>\n ',
"text/html").body.firstChild,g=function(f){var h={Escape:"close",ArrowLeft:"tools__flip-prev",ArrowRight:"tools__flip-next"};h[f.key]&&e.querySelector(".view-image-"+h[f.key]).click()},l=function(f){var h=new Image,k=e.querySelector(".view-image-lead");k.className="view-image-lead view-image-lead__out";setTimeout(function(){k.innerHTML="";h.onload=function(){setTimeout(function(){k.innerHTML='<img src="'+h.src+'" alt="ViewImage" no-view/>';k.className="view-image-lead view-image-lead__in"},100)};
h.src=f},300)};document.body.appendChild(e);l(d);window.addEventListener("keydown",g);e.onclick=function(f){f.target.closest(".view-image-close")?(window.removeEventListener("keydown",g),e.onclick=null,e.classList.add("view-image__out"),setTimeout(function(){return e.remove()},290)):f.target.closest(".view-image-tools__flip")&&(c=f.target.closest(".view-image-tools__flip-prev")?0===c?a.length-1:c-1:c===a.length-1?0:c+1,l(a[c]),e.querySelector(".view-image-index").innerHTML=c+1)}}}})();

View File

@ -3,17 +3,18 @@
<div class="site--footer__content"> <div class="site--footer__content">
<div class=site--footer__sns> <div class=site--footer__sns>
<?php $this->need('sns.php'); ?> <?php $this->need('sns.php'); ?>
</div>
<?php //sitemap填入 <?php //sitemap填入
if($this->options->sitemapurl): ?> if($this->options->sitemapurl): ?>
<a href="<?php $this->options->sitemapurl() ?>" target="_blank">💗</a> <a href="<?php $this->options->sitemapurl() ?>" target="_blank">💗</a>
<?php endif; ?> <?php endif; ?>
</div>
<?php //添加加载时间控制 <?php //添加加载时间控制
if ($this->options->showtime): ?> if ($this->options->showtime): ?>
&nbsp;页面加载耗时<?php echo timer_stop();?> &nbsp;页面加载耗时<?php echo timer_stop();?>
<?php endif; ?> <?php endif; ?>
<?php $this->options->tongji(); ?>
<div class="copyright"> © <?php echo date('Y'); ?> <div class="copyright"> © <?php echo date('Y'); ?>
<?php $this->options->title(); ?>由<a href="https://www.typecho.org" target="_blank">Typecho</a> 驱动 <?php $this->options->title(); ?>
<svg class="icon icon--copryrights" viewBox="0 0 1040 1024" width="16" height="16"> <svg class="icon icon--copryrights" viewBox="0 0 1040 1024" width="16" height="16">
<path <path
d="M717.056236 383.936299l-51.226708 0c-28.2893 0-51.226708 22.936385-51.226708 51.225685l0 128.062678c0 28.2893 22.937408 51.225685 51.226708 51.225685l51.226708 0c28.2893 0 51.225685-22.936385 51.225685-51.225685L768.281921 435.161984C768.281921 406.872684 745.345536 383.936299 717.056236 383.936299zM717.056236 537.611308c0 14.158465-11.480472 25.612331-25.613354 25.612331-14.132882 0-25.612331-11.453866-25.612331-25.612331l0-76.835969c0-14.158465 11.480472-25.613354 25.612331-25.613354 14.133905 0 25.613354 11.453866 25.613354 25.613354L717.056236 537.611308zM1013.977739 426.580538 859.776751 165.30079c-8.888438-15.063067-22.294772-25.975605-37.57171-32.080649-32.708959-34.856879-79.187527-56.638975-130.762159-56.638975L332.862064 76.581166c-51.575656 0-98.0532 21.782096-130.761136 56.639998-15.276938 6.105045-28.683273 17.017582-37.572734 32.079626L10.327206 426.580538c-21.26021 36.069497-8.655124 82.217537 28.239158 103.028515l115.00836 64.967664 0 199.163015c0 99.024318 80.264045 153.678078 179.287339 153.678078l358.580818 0c99.024318 0 179.290409-80.266092 179.290409-179.290409L870.733291 594.575694l115.00836-64.966641C1022.63184 508.798075 1035.238972 462.650035 1013.977739 426.580538zM153.574724 536.518417l-67.058278-37.875632c-24.589025-13.907755-33.019021-44.647873-18.809391-68.684312l85.86767-145.555074L153.574724 536.518417zM646.620024 127.807874c0 56.5786-60.205197 102.45137-134.467551 102.45137-74.261331 0-134.466528-45.873794-134.466528-102.45137L646.620024 127.807874zM819.507606 742.515071c0 84.893482-68.810179 153.677055-153.678078 153.677055L358.475418 896.192126c-84.8679 0-153.675008-68.783573-153.675008-153.677055l0-461.030142c0-76.150354 55.402821-139.361001 128.093377-151.545508 1.332345 83.883479 81.06734 151.545508 179.258687 151.545508 98.19237 0 177.926342-67.662029 179.25971-151.545508 72.690556 12.183484 128.096447 75.394131 128.096447 151.545508L819.508629 742.515071zM937.791569 498.642784l-67.058278 37.875632 0-252.111948 85.86767 145.552004C970.807521 453.995935 962.377524 484.736053 937.791569 498.642784z" d="M717.056236 383.936299l-51.226708 0c-28.2893 0-51.226708 22.936385-51.226708 51.225685l0 128.062678c0 28.2893 22.937408 51.225685 51.226708 51.225685l51.226708 0c28.2893 0 51.225685-22.936385 51.225685-51.225685L768.281921 435.161984C768.281921 406.872684 745.345536 383.936299 717.056236 383.936299zM717.056236 537.611308c0 14.158465-11.480472 25.612331-25.613354 25.612331-14.132882 0-25.612331-11.453866-25.612331-25.612331l0-76.835969c0-14.158465 11.480472-25.613354 25.612331-25.613354 14.133905 0 25.613354 11.453866 25.613354 25.613354L717.056236 537.611308zM1013.977739 426.580538 859.776751 165.30079c-8.888438-15.063067-22.294772-25.975605-37.57171-32.080649-32.708959-34.856879-79.187527-56.638975-130.762159-56.638975L332.862064 76.581166c-51.575656 0-98.0532 21.782096-130.761136 56.639998-15.276938 6.105045-28.683273 17.017582-37.572734 32.079626L10.327206 426.580538c-21.26021 36.069497-8.655124 82.217537 28.239158 103.028515l115.00836 64.967664 0 199.163015c0 99.024318 80.264045 153.678078 179.287339 153.678078l358.580818 0c99.024318 0 179.290409-80.266092 179.290409-179.290409L870.733291 594.575694l115.00836-64.966641C1022.63184 508.798075 1035.238972 462.650035 1013.977739 426.580538zM153.574724 536.518417l-67.058278-37.875632c-24.589025-13.907755-33.019021-44.647873-18.809391-68.684312l85.86767-145.555074L153.574724 536.518417zM646.620024 127.807874c0 56.5786-60.205197 102.45137-134.467551 102.45137-74.261331 0-134.466528-45.873794-134.466528-102.45137L646.620024 127.807874zM819.507606 742.515071c0 84.893482-68.810179 153.677055-153.678078 153.677055L358.475418 896.192126c-84.8679 0-153.675008-68.783573-153.675008-153.677055l0-461.030142c0-76.150354 55.402821-139.361001 128.093377-151.545508 1.332345 83.883479 81.06734 151.545508 179.258687 151.545508 98.19237 0 177.926342-67.662029 179.25971-151.545508 72.690556 12.183484 128.096447 75.394131 128.096447 151.545508L819.508629 742.515071zM937.791569 498.642784l-67.058278 37.875632 0-252.111948 85.86767 145.552004C970.807521 453.995935 962.377524 484.736053 937.791569 498.642784z"
@ -21,7 +22,6 @@
</svg> </svg>
</div> </div>
</div> </div>
<?php $this->options->tongji(); ?>
</footer> </footer>
<div class="backToTop"> <div class="backToTop">
<svg xmlns="http://www.w3.org/2000/svg" class="svgIcon" viewBox="0 0 14 14" fill="currentColor" aria-hidden="true"> <svg xmlns="http://www.w3.org/2000/svg" class="svgIcon" viewBox="0 0 14 14" fill="currentColor" aria-hidden="true">

View File

@ -1,9 +1,9 @@
<?php <?php
/** /**
* 移植自HUGO主题 farallon 原作者 bigfa * 一款单栏主题. 移植自HUGO主题 Farallon 原作者 bigfa
* @package Farallon * @package Farallon
* @author 老孙 * @author 老孙
* @version 0.5.8 * @version 0.6.1
* @link https://www.imsun.org * @link https://www.imsun.org
*/ */
if (!defined('__TYPECHO_ROOT_DIR__')) exit; if (!defined('__TYPECHO_ROOT_DIR__')) exit;
@ -14,4 +14,4 @@ $this->need('header.php');
<?php $this->need('postlist.php'); ?> <?php $this->need('postlist.php'); ?>
</div> </div>
</main> </main>
<?php $this->need('footer.php'); ?> <?php $this->need('footer.php'); ?>

View File

@ -79,8 +79,8 @@ $this->need('header.php');
category: <?php echo json_encode(categoryPostCount()); ?> category: <?php echo json_encode(categoryPostCount()); ?>
}; };
</script> </script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/jkjoy/typecho-theme-farallon@0.5.0/dist/js/chart.js"></script> <script type="text/javascript" src="<?php $this->options->themeUrl('/dist/js/chart.js'); ?>"></script>
<script id="MathJax-script" async src="https://jsd.onmicrosoft.cn/npm/mathjax@3/es5/tex-mml-chtml.js"></script> <script id="MathJax-script" async src="<?php $this->options->themeUrl('/dist/js/tex-mml-chtml.js'); ?>"></script>
<script> <script>
// 配置 MathJax // 配置 MathJax
MathJax = { MathJax = {

View File

@ -11,9 +11,6 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<h1 class="post--single__title"><?php $this->title() ?></h1> <h1 class="post--single__title"><?php $this->title() ?></h1>
<h2 class="post--single__subtitle"><?php $this->content(); ?> </h2> <h2 class="post--single__subtitle"><?php $this->content(); ?> </h2>
</header> </header>
<div class="graph u-marginBottom30">
<?php $this->content(); ?>
</div>
<div class="template--linksWrap"> <div class="template--linksWrap">
<ul class="link-items"> <ul class="link-items">
<?php <?php

View File

@ -13,9 +13,8 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
</header> </header>
<article class="post--single"> <article class="post--single">
<?php $tooot = $this->fields->tooot ? $this->fields->tooot : 'https://bbapi.ima.cm'; ?> <?php $tooot = $this->fields->tooot ? $this->fields->tooot : 'https://bbapi.ima.cm'; ?>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script> <script src="<?php $this->options->themeUrl('/dist/js/marked.min.js'); ?>"></script>
<script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.umd.js"></script> <script src="<?php $this->options->themeUrl('/dist/js/view-image.min.js'); ?>"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.css" />
<div id="tooot"></div> <div id="tooot"></div>
<div class="nav-links" id="loadmore"> <div class="nav-links" id="loadmore">
<span class="loadmore">加载更多</span> <span class="loadmore">加载更多</span>
@ -34,7 +33,7 @@ window.onload = function() {
if (media_attachments.length > 0) { if (media_attachments.length > 0) {
media_attachments.forEach(attachment => { media_attachments.forEach(attachment => {
if (attachment.type === 'image') { if (attachment.type === 'image') {
mediaHTML += `<a href="${attachment.url}" target="_blank"><img src="${attachment.preview_url}" data-fancybox="img" class="thumbnail-image img"></a>`; mediaHTML += `<a href="${attachment.url}" target="_blank"><img src="${attachment.preview_url}" class="thumbnail-image img" ></a>`;
} }
}); });
} }
@ -45,7 +44,7 @@ window.onload = function() {
<article class='post--item post--item__status'> <article class='post--item post--item__status'>
<div class='content'> <div class='content'>
<header> <header>
<img src="${account.avatar}" class="avatar" width="48" height="48" /> <img src="${account.avatar}" class="avatar" width="48" height="48" no-view />
<a class="humane--time" href="${url}" target="_blank">${new Date(created_at).toLocaleString()}</a> <a class="humane--time" href="${url}" target="_blank">${new Date(created_at).toLocaleString()}</a>
</header> </header>
<div class="description" itemprop="about"> <div class="description" itemprop="about">
@ -82,9 +81,7 @@ window.onload = function() {
// 绑定“加载更多”按钮的点击事件 // 绑定“加载更多”按钮的点击事件
document.getElementById('loadmore').addEventListener('click', fetchAndDisplayToots); document.getElementById('loadmore').addEventListener('click', fetchAndDisplayToots);
}; };
Fancybox.bind("[data-fancybox]", { window.ViewImage && ViewImage.init('.content img');
// Your custom options
});
</script> </script>
<style> <style>
div pre code { div pre code {
@ -92,7 +89,6 @@ div pre code {
white-space: pre-wrap; /* CSS3 */ white-space: pre-wrap; /* CSS3 */
word-wrap: break-word; /* 老版本的浏览器 */ word-wrap: break-word; /* 老版本的浏览器 */
overflow-wrap: break-word; overflow-wrap: break-word;
/* 指定如何断行 */
word-break: break-all; word-break: break-all;
word-break: break-word; word-break: break-word;
} }
@ -172,4 +168,4 @@ img {
} }
</style> </style>
</div> </div>
<?php $this->need('footer.php'); ?> <?php $this->need('footer.php'); ?>

View File

@ -18,15 +18,22 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
$memosnum = $this->fields->memosnum ? $this->fields->memosnum : '20'; $memosnum = $this->fields->memosnum ? $this->fields->memosnum : '20';
?> ?>
<article class="post--single"> <article class="post--single">
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script> <script src="<?php $this->options->themeUrl('/dist/js/marked.min.js'); ?>"></script>
<script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.umd.js"></script> <script src="<?php $this->options->themeUrl('/dist/js/view-image.min.js'); ?>"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.css" />
<div id="talk"></div> <div id="talk"></div>
<div class="nav-links" id="loadmore">
<span class="loadmore">加载更多</span>
</div>
</article> </article>
<script> <script>
if (99) { let currentPage = 1; // 当前页码
let url = '<?php echo $memos; ?>'; const limit = 10; // 每页条数
fetch(url + '/api/v1/memo?creatorId=<?php echo $memosID; ?>&rowStatus=NORMAL&limit=<?php echo $memosnum; ?>') let url = '<?php echo $memos; ?>';
let memosID = '<?php echo $memosID; ?>';
let memosnum = '<?php echo $memosnum; ?>';
function loadMemos(page) {
fetch(`${url}/api/v1/memo?creatorId=${memosID}&rowStatus=NORMAL&limit=${limit}&offset=${(page - 1) * limit}`)
.then(res => res.json()) .then(res => res.json())
.then(data => { .then(data => {
let html = ''; let html = '';
@ -38,7 +45,7 @@ if (99) {
<article class='post--item post--item__status'> <article class='post--item post--item__status'>
<div class='content'> <div class='content'>
<header> <header>
<img src="<?php $this->options->logoUrl() ?>" class="avatar" width="48" height="48" /> <img src="<?php $this->options->logoUrl() ?>" class="avatar" width="48" height="48" no-view />
<a class="humane--time" href="${memoURL}" target="_blank">${data.date}</a> <a class="humane--time" href="${memoURL}" target="_blank">${data.date}</a>
</header> </header>
<div class="description" itemprop="about"> <div class="description" itemprop="about">
@ -49,57 +56,67 @@ if (99) {
</article> </article>
`; `;
}); });
document.getElementById('talk').innerHTML = html; document.getElementById('talk').innerHTML += html;
}) })
.catch(error => { .catch(error => {
console.error('Error:', error); console.error('Error:', error);
// 这里可以添加一些用户提示错误发生的 HTML 更新 // 这里可以添加一些用户提示错误发生的 HTML 更新
}); });
function Format(item) { }
let date = getTime(new Date(item.createdTs * 1000).toString()),
content = item.content, function Format(item) {
tag = item.content.match(/#([^\s#]+?) /g), let date = getTime(new Date(item.createdTs * 1000).toString()),
imgs = content.match(/!\[.*\]\(.*?\)/g), content = item.content,
text = '' tag = item.content.match(/#([^\s#]+?) /g),
if (imgs) imgs = imgs.map(item => { return item.replace(/!\[.*\]\((.*?)\)/, '$1') }) imgs = content.match(/!\[.*\]\(.*?\)/g),
if (item.resourceList.length) { text = ''
if (!imgs) imgs = [] if (imgs) imgs = imgs.map(item => { return item.replace(/!\[.*\]\((.*?)\)/, '$1') })
item.resourceList.forEach(t => { if (item.resourceList.length) {
if (t.externalLink) imgs.push(t.externalLink) if (!imgs) imgs = []
else imgs.push(`${url}/o/r/${t.id}/${t.publicId}/${t.filename}`) item.resourceList.forEach(t => {
}) if (t.externalLink) imgs.push(t.externalLink)
} else imgs.push(`${url}/o/r/${t.id}/${t.publicId}/${t.filename}`)
text = content.replace(/#(.*?)\s/g, '').replace(/\!?\[(.*?)\]\((.*?)\)/g, '').replace(/\{(.*?)\}/g, '') })
content = text.replace(/\[(.*?)\]\((.*?)\)/g, `<a href="$2" target="_blank">$1</a>`);
if (imgs) {
content += `<div class="resimg">`
imgs.forEach(e => content += `<a href="${e}" data-fancybox="gallery" class="fancybox img" data-thumb="${e}"><img class="no-lazyload thumbnail-image" src="${e}"></a>`
)
content += '</div>'
}
return {
content: content,
tag: tag ? tag[0].replace(/#([^\s#]+?) /,'$1') : '日常',
date: date,
text: text.replace(/\[(.*?)\]\((.*?)\)/g, '[链接]' + `${imgs?'[图片]':''}`)
}
} }
// 页面时间格式化 text = content.replace(/#(.*?)\s/g, '').replace(/\!?\[(.*?)\]\((.*?)\)/g, '').replace(/\{(.*?)\}/g, '')
function getTime(time) { content = text.replace(/\[(.*?)\]\((.*?)\)/g, `<a href="$2" target="_blank">$1</a>`);
let d = new Date(time), if (imgs) {
ls = [d.getFullYear(), d.getMonth() + 1, d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds()]; content += `<div class="resimg">`
for (let i = 0; i < ls.length; i++) { imgs.forEach(e => content += `<a href="${e}" class="img" data-thumb="${e}"><img class="no-lazyload thumbnail-image" src="${e}"></a>`
ls[i] = ls[i] <= 9 ? '0' + ls[i] : ls[i] + '' )
} content += '</div>'
if (new Date().getFullYear() == ls[0]) return ls[1] + '月' + ls[2] + '日 ' + ls[3] +':'+ ls[4] }
else return ls[0] + '年' + ls[1] + '月' + ls[2] + '日 ' + ls[3] +':'+ ls[4] return {
content: content,
tag: tag ? tag[0].replace(/#([^\s#]+?) /,'$1') : '日常',
date: date,
text: text.replace(/\[(.*?)\]\((.*?)\)/g, '[链接]' + `${imgs?'[图片]':''}`)
} }
} }
Fancybox.bind("[data-fancybox]", {
// Your custom options // 页面时间格式化
function getTime(time) {
let d = new Date(time),
ls = [d.getFullYear(), d.getMonth() + 1, d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds()];
for (let i = 0; i < ls.length; i++) {
ls[i] = ls[i] <= 9 ? '0' + ls[i] : ls[i] + ''
}
if (new Date().getFullYear() == ls[0]) return ls[1] + '月' + ls[2] + '日 ' + ls[3] +':'+ ls[4]
else return ls[0] + '年' + ls[1] + '月' + ls[2] + '日 ' + ls[3] +':'+ ls[4]
}
// 初始加载第一页
loadMemos(currentPage);
// 点击“加载更多”按钮时加载下一页
document.getElementById('loadmore').addEventListener('click', function() {
currentPage++;
loadMemos(currentPage);
}); });
window.ViewImage && ViewImage.init('.content img');
</script> </script>
<style> <style>
div pre code { div pre code {
/* 迫使文字断行 */ /* 迫使文字断行 */
white-space: pre-wrap; /* CSS3 */ white-space: pre-wrap; /* CSS3 */
@ -149,7 +166,34 @@ img {
.resimg { .resimg {
grid-template-columns: 1fr; /* 修改为一列 */ grid-template-columns: 1fr; /* 修改为一列 */
} }
} }
.load-more-btn {
display: block;
margin: 20px auto;
padding: 10px 20px;
background-color: #007bff;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
}
.load-more-btn:hover {
background-color: #0056b3;
}
.nav-links .loadmore {
border: 1px solid var(--farallon-border-color);
cursor: pointer;
position: relative;
padding: 5px 30px;
border-radius: 8px;
font-size: 14px;
color: var(--farallon-text-gray)
}
.nav-links .loadmore:hover {
border-color: var(--farallon-hover-color);
color: var(--farallon-hover-color)
}
</style> </style>
</div> </div>
<?php $this->need('footer.php'); ?> <?php $this->need('footer.php'); ?>

View File

@ -4,101 +4,98 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit;
/** 文章置顶 */ /** 文章置顶 */
$sticky = $this->options->sticky; // 置顶的文章id多个用|隔开 $sticky = $this->options->sticky; // 置顶的文章id多个用|隔开
$db = Typecho_Db::get();
$pageSize = $this->options->pageSize;
if ($sticky) { if ($sticky && !empty(trim($sticky))) {
$sticky_cids = array_filter(explode('|', $sticky)); // 分割文本并过滤空值 $sticky_cids = array_filter(explode('|', $sticky)); // 分割文本并过滤空值
$sticky_html = " <span class='sticky--post'> 置顶 </span> "; // 置顶标题的 html if (!empty($sticky_cids)) {
$db = Typecho_Db::get(); $sticky_html = " <span class='sticky--post'> 置顶 </span> "; // 置顶标题的 html
$pageSize = $this->options->pageSize;
// 清空原有文章的队列 // 清空原有文章的队列
$this->row = []; $this->row = [];
$this->stack = []; $this->stack = [];
$this->length = 0; $this->length = 0;
// 获取总数,并排除置顶文章数量 // 获取总数,并排除置顶文章数量
if (isset($this->currentPage) && $this->currentPage == 1) { if (isset($this->currentPage) && $this->currentPage == 1) {
$totalOriginal = $this->getTotal(); $totalOriginal = $this->getTotal();
$stickyCount = count($sticky_cids); $stickyCount = count($sticky_cids);
$this->setTotal(max($totalOriginal - $stickyCount, 0)); $this->setTotal(max($totalOriginal - $stickyCount, 0));
// 构建置顶文章的查询 // 构建置顶文章的查询
$selectSticky = $this->select()->where('type = ?', 'post'); $selectSticky = $this->select()->where('type = ?', 'post');
foreach ($sticky_cids as $i => $cid) { foreach ($sticky_cids as $i => $cid) {
if ($i == 0) if ($i == 0)
$selectSticky->where('cid = ?', $cid); $selectSticky->where('cid = ?', $cid);
else else
$selectSticky->orWhere('cid = ?', $cid); $selectSticky->orWhere('cid = ?', $cid);
}
// 获取置顶文章
$stickyPosts = $db->fetchAll($selectSticky);
// 压入置顶文章到文章队列
foreach ($stickyPosts as &$stickyPost) {
$stickyPost['title'] .= $sticky_html;
$this->push($stickyPost);
}
$standardPageSize = $pageSize - count($stickyPosts);
} else {
$standardPageSize = $pageSize;
} }
// 获取置顶文章 // 构建正常文章查询,排除置顶文章
$stickyPosts = $db->fetchAll($selectSticky); $selectNormal = $this->select()
->where('type = ?', 'post')
// 压入置顶文章到文章队列 ->where('status = ?', 'publish')
foreach ($stickyPosts as &$stickyPost) { ->where('created < ?', time())
$stickyPost['title'] .= $sticky_html; ->order('created', Typecho_Db::SORT_DESC)
$this->push($stickyPost); ->page(isset($this->currentPage) ? $this->currentPage : 1, $standardPageSize);
}
$standardPageSize = $pageSize - count($stickyPosts); foreach ($sticky_cids as $cid) {
$selectNormal->where('table.contents.cid != ?', $cid);
}
} else { } else {
$standardPageSize = $pageSize; // 如果sticky_cids为空使用默认查询
} $selectNormal = $this->select()
->where('type = ?', 'post')
// 构建正常文章查询,排除置顶文章 ->where('status = ?', 'publish')
$selectNormal = $this->select() ->where('created < ?', time())
->where('type = ?', 'post') ->order('created', Typecho_Db::SORT_DESC)
->where('status = ?', 'publish') ->page(isset($this->currentPage) ? $this->currentPage : 1, $pageSize);
->where('created < ?', time())
->order('created', Typecho_Db::SORT_DESC)
->page(isset($this->currentPage) ? $this->currentPage : 1, $standardPageSize);
foreach ($sticky_cids as $cid) {
$selectNormal->where('table.contents.cid != ?', $cid);
}
// 登录用户显示私密文章
if ($this->user->hasLogin()) {
$uid = $this->user->uid;
if ($uid) {
$selectNormal->orWhere('authorId = ? AND status = ?', $uid, 'private');
}
}
$normalPosts = $db->fetchAll($selectNormal);
// 压入正常文章到文章队列
foreach ($normalPosts as $normalPost) {
$this->push($normalPost);
} }
} else { } else {
// 如果没有置顶文章,正常分页 // 如果没有置顶文章,使用默认查询
$selectNormal = $this->select() $selectNormal = $this->select()
->where('type = ?', 'post') ->where('type = ?', 'post')
->where('status = ?', 'publish') ->where('status = ?', 'publish')
->where('created < ?', time()) ->where('created < ?', time())
->order('created', Typecho_Db::SORT_DESC) ->order('created', Typecho_Db::SORT_DESC)
->page(isset($this->currentPage) ? $this->currentPage : 1, $this->options->pageSize); ->page(isset($this->currentPage) ? $this->currentPage : 1, $pageSize);
}
// 登录用户显示私密文章 // 登录用户显示私密文章
if ($this->user->hasLogin()) { if ($this->user->hasLogin()) {
$uid = $this->user->uid; $uid = $this->user->uid;
if ($uid) { if ($uid) {
$selectNormal->orWhere('authorId = ? AND status = ?', $uid, 'private'); $selectNormal->orWhere('authorId = ? AND status = ?', $uid, 'private');
}
} }
}
$normalPosts = $db->fetchAll($selectNormal); $normalPosts = $db->fetchAll($selectNormal);
// 清空原有文章的队列 // 如果之前没有清空队列(没有置顶文章的情况),现在清空
if (empty($sticky) || empty(trim($sticky)) || empty($sticky_cids)) {
$this->row = []; $this->row = [];
$this->stack = []; $this->stack = [];
$this->length = 0; $this->length = 0;
}
// 压入正常文章到文章队列 // 压入正常文章到文章队列
foreach ($normalPosts as $normalPost) { foreach ($normalPosts as $normalPost) {
$this->push($normalPost); $this->push($normalPost);
}
} }
?> ?>
<?php while($this->next()): ?> <?php while($this->next()): ?>