This commit is contained in:
浪子 2025-08-05 10:04:56 +08:00
parent 57aeb81c62
commit a106080633
5 changed files with 50 additions and 79 deletions

View File

@ -1041,6 +1041,13 @@ class Puock {
const title = el.attr("title") || el.data("title") || '提示';
const url = el.data("url");
const onceLoad = el.data("once-load")
// 检查 url 是否存在,避免 SparkMD5 错误
if (!url) {
console.warn('Modal toggle: url is undefined');
return;
}
const id = SparkMD5.hash(url)
if (onceLoad && this.data.modalStorage[id]) {
this.modalLoadRender(id, this.data.modalStorage[id], title, noTitle, noPadding)

View File

@ -68,7 +68,7 @@
&copy; <?php echo date('Y'); ?> <a href="<?php $this->options->siteUrl(); ?>"><?php $this->options->title(); ?></a>
<div class="fs12 mt10 c-sub">
<span> &nbsp;Theme by
<a target="_blank" class="c-sub" title="Puock v1.2.2" href="https://github.com/jkjoy/typecho-theme-puock">Puock</a>
<a target="_blank" class="c-sub" title="Puock v1.2.3" href="https://github.com/jkjoy/typecho-theme-puock">Puock</a>
</span>
<span> &nbsp;Powered by
<a target="_blank" class="c-sub" title="Typecho" href="https://typecho.org">Typecho</a> <p><a target="_blank" class="c-sub" title="老孙博客" href="https://imsun.org">老孙博客</a>制作</p>

View File

@ -52,67 +52,14 @@ function getRandomPost() {
// 获取随机文章链接
$randomPostUrl = getRandomPost();
$this->need('header.php');
?>
<div id="breadcrumb" class="animated fadeInUp">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a class="a-link" href="<?php $this->options->siteUrl(); ?>">首页</a></li>
<li class="breadcrumb-item active" aria-current="page">随机阅读</li>
</ol>
</nav>
</div>
<div id="page-empty">
<div id="page" class="row row-cols-1">
<?php if ($this->options->showsidebar): ?>
<div id="post-main" class="col-lg-8 col-md-12 animated fadeInLeft">
<?php else: ?>
<div id="post-main" class="col-lg-12 col-md-12">
<?php endif; ?>
<div class="p-block">
<div>
<h1 id="post-title" class="mb-0 puock-text t-xxl">随机阅读</h1>
</div>
<div class="mt20 puock-text entry-content show-link-icon">
<div class="text-center">
<div class="mb-4">
<i class="fa fa-random fa-3x text-primary mb-3"></i>
<h3>正在为您随机选择一篇文章...</h3>
<p class="text-muted">请稍候,正在跳转中...</p>
</div>
<div class="spinner-border text-primary" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>
</div>
</div>
</div>
<?php if ($this->options->showsidebar): ?>
<?php $this->need('sidebar.php'); ?>
<?php endif; ?>
</div>
</div>
<script>
// 立即执行的跳转函数
function performRandomRedirect() {
setTimeout(function() {
<?php if ($randomPostUrl): ?>
// 跳转到随机文章
window.location.href = '<?php echo $randomPostUrl; ?>';
<?php else: ?>
// 如果没有文章,跳转到首页
window.location.href = '<?php $this->options->siteUrl(); ?>';
<?php endif; ?>
}, 1500);
// 直接重定向,实现无感跳转
if ($randomPostUrl) {
// 使用 302 临时重定向,避免缓存
header('Location: ' . $randomPostUrl, true, 302);
exit;
} else {
// 如果没有文章,重定向到首页
header('Location: ' . $this->options->siteUrl, true, 302);
exit;
}
// 在 DOMContentLoaded 和页面加载完成后都执行
document.addEventListener('DOMContentLoaded', performRandomRedirect);
window.addEventListener('load', performRandomRedirect);
// 立即执行一次,确保在 PJAX 模式下也能工作
performRandomRedirect();
</script>
<?php $this->need('footer.php'); ?>
?>

View File

@ -91,7 +91,7 @@ $this->need('header.php');
<div class="p-flex-sbc mt10">
<div class="form-foot">
<?php if($this->options->social): ?>
<button id="comment-insert-image" class="btn btn-outline-secondary btn-ssm pk-modal-toggle" type="button" title="插入图片">
<button id="comment-insert-image" class="btn btn-outline-secondary btn-ssm" type="button" title="插入图片">
<i class="fa-solid fa-image"></i>
</button>
<button id="comment-smiley" class="btn btn-outline-secondary btn-ssm pk-modal-toggle" type="button" title="表情" data-once-load="true"
@ -138,23 +138,40 @@ document.addEventListener('DOMContentLoaded', function() {
btn.addEventListener('click', function() {
let modal = document.createElement('div');
modal.innerHTML = `
<div id="img-insert-modal" style="position:fixed;z-index:9999;left:0;top:0;width:100vw;height:100vh;background:rgba(0,0,0,0.3);display:flex;align-items:center;justify-content:center;">
<div style="background:#fff;padding:24px 32px;border-radius:8px;min-width:320px;box-shadow:0 2px 16px rgba(0,0,0,0.15);">
<div style="font-size:18px;font-weight:bold;margin-bottom:12px;">插入图片</div>
<div style="margin-bottom:10px;">
<label style="display:block;font-size:14px;margin-bottom:4px;">标题(可选)</label>
<input id="img-insert-title" type="text" style="width:100%;padding:6px 8px;border:1px solid #ccc;border-radius:4px;">
<style>
.insert-image {
position: fixed;
z-index: 9999;
left: 0;
top: 0;
width: 100vw;
height: 100vh;
background: rgba(211, 134, 202, 0.9);
display: flex;
align-items: center;
justify-content: center;
}
</style>
<div id="img-insert-modal" class="insert-image">
<div class="min-width-modal" style="max-width: 290px">
<form>
<div class="form-label">插入图片</div>
<div class="mb15">
<label for="img-insert-title" class="form-label">标题(可选)</label>
<input id="img-insert-title" type="text" class="form-control form-control-sm">
</div>
<div style="margin-bottom:10px;">
<label style="display:block;font-size:14px;margin-bottom:4px;">图片地址 <span style="color:red">*</span></label>
<input id="img-insert-url" type="text" style="width:100%;padding:6px 8px;border:1px solid #ccc;border-radius:4px;" required>
<div class="mb15">
<label for="img-insert-url" class="form-label">图片地址 <span style="color:red">*</span></label>
<input id="img-insert-url" type="text" class="form-control form-control-sm" required>
</div>
<div style="text-align:right;">
<button id="img-insert-cancel" style="margin-right:10px;padding:6px 16px;">取消</button>
<button id="img-insert-confirm" style="background:#007bff;color:#fff;padding:6px 16px;border:none;border-radius:4px;">插入</button>
<div class="mb15 d-flex justify-content-center wh100">
<button id="img-insert-cancel" class="btn btn-ssm btn-primary mr5">取消</button>
<button id="img-insert-confirm" class="btn btn-ssm btn-primary mr5">插入</button>
</div>
</form>
</div>
</div>`;
</div>
`;
document.body.appendChild(modal);
document.getElementById('img-insert-cancel').onclick = function() {
document.body.removeChild(modal);

View File

@ -56,7 +56,7 @@ $wordCount = mb_strlen($content, 'UTF-8');
?>
<div class="mt20 entry-content-box">
<div class="entry-content show-link-icon content-main puock-text ">
<p class="fs12 c-sub no-indent"> <i class="fa-regular fa-clock"></i> 共计<?php echo $wordCount; ?>,预计需要花费 <?php echo ceil($wordCount / 800); ?>分钟才能阅读完成。 </p>
<p class="fs12 c-sub no-indent"> <i class="fa-regular fa-clock"></i> &nbsp;本文共计<?php echo $wordCount; ?>字,预计需要花费 <?php echo ceil($wordCount / 800); ?>分钟才能阅读完成。 </p>
<p class="fs12 c-sub">
<?php
$modified = $this->modified;