parent
2189a0ec68
commit
077bd0f720
|
@ -0,0 +1,48 @@
|
|||
// 加载更多文章
|
||||
$(document).on('click', '.post-read-more a', function(e){
|
||||
e.preventDefault();
|
||||
var $btn = $(this);
|
||||
var nextPage = $btn.attr('href');
|
||||
|
||||
if($btn.hasClass('loading')) return false;
|
||||
|
||||
$btn.addClass('loading').text('加载中...');
|
||||
|
||||
$.ajax({
|
||||
url: nextPage,
|
||||
type: 'GET',
|
||||
dataType: 'html',
|
||||
success: function(data){
|
||||
// 创建一个临时的DOM元素来解析返回的HTML
|
||||
var $html = $('<div></div>').html(data);
|
||||
|
||||
// 找到新的文章
|
||||
var $newPosts = $html.find('.post_loop');
|
||||
|
||||
// 找到新的"加载更多"按钮
|
||||
var $newBtn = $html.find('.post-read-more a');
|
||||
|
||||
// 将新文章添加到页面
|
||||
if ($newPosts.length > 0) {
|
||||
$('.post_box').append($newPosts);
|
||||
// 新文章淡入效果
|
||||
$newPosts.hide().fadeIn(500);
|
||||
}
|
||||
|
||||
// 更新"加载更多"按钮或移除它
|
||||
if($newBtn.length > 0){
|
||||
$btn.attr('href', $newBtn.attr('href'))
|
||||
.removeClass('loading')
|
||||
.text('加载更多');
|
||||
} else {
|
||||
$('.post-read-more').remove();
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error){
|
||||
console.error("AJAX Error:", status, error);
|
||||
$btn.removeClass('loading').text('加载失败,点击重试');
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
|
@ -13,7 +13,10 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
|||
'tag' => _t('标签 %s 下的文章'),
|
||||
'date' => _t('在<span> %s </span>发布的文章'),
|
||||
'author' => _t('%s 发布的文章')
|
||||
), '', ' - '); ?><?php if ($this->is('post')) $this->category(',', false);?><?php if ($this->is('post')) echo ' - ';?><?php $this->options->title(); ?><?php if ($this->is('index')) echo ' - '; ?><?php if ($this->is('index')) $this->options->description() ?></title>
|
||||
), '', ' - '); ?>
|
||||
<?php $this->options->title(); ?><?php if ($this->is('index')) echo ' - '; ?>
|
||||
<?php if ($this->is('index')) $this->options->description() ?>
|
||||
</title>
|
||||
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/style.min.css'); ?>">
|
||||
<?php if ($this->options->icoUrl): ?>
|
||||
<link rel='icon' href='<?php $this->options->icoUrl() ?>' type='image/x-icon' />
|
||||
|
|
Loading…
Reference in New Issue