重新整理了一下目录,更改了部分内容的实现方式
This commit is contained in:
浪子 2025-03-17 08:13:35 +08:00
parent 81af4b6590
commit 5c91195745
39 changed files with 461 additions and 297 deletions

View File

@ -1,5 +1,5 @@
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php $this->need('header.php'); ?>
<?php $this->need('module/header.php'); ?>
<main class="site--main">
<header class="archive--header"><?php if ($this->have()): ?>
<h2 class="post--single__title"><?php $this->archiveTitle(array(
@ -74,4 +74,4 @@
</header>
</main>
<?php endif; ?>
<?php $this->need('footer.php'); ?>
<?php $this->need('module/footer.php'); ?>

146
assets/css/donate.css Normal file
View File

@ -0,0 +1,146 @@
.donate-panel {
position: relative;
display: inline-block;
}
.button--like {
background: none;
border: none;
padding: 0;
cursor: pointer;
transition: transform 0.3s ease;
}
.button--like:hover {
transform: scale(1.1);
}
.icon--default {
fill: #666;
transition: fill 0.3s ease;
}
.button--like:hover .icon--default {
fill: #ff4081;
}
#qrcode-panel {
position: absolute;
bottom: 100%;
left: 50%;
transform: translateX(-50%);
background: white;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
padding: 15px;
margin-bottom: 10px;
display: none;
animation: fadeIn 0.3s ease;
min-width: 240px;
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translate(-50%, 10px);
}
to {
opacity: 1;
transform: translate(-50%, 0);
}
}
.qrcode-body {
text-align: center;
}
.donate-memo {
margin-bottom: 10px;
position: relative;
}
#donate-close {
position: absolute;
right: -5px;
top: -5px;
cursor: pointer;
font-size: 12px;
color: #666;
padding: 2px 5px;
border-radius: 3px;
}
#donate-close:hover {
color: #ff4081;
}
.donate-qrpay img {
max-width: 240px;
height: auto;
display: block;
margin: 0 auto;
transition: opacity 0.3s ease;
}
/* 支付方式切换按钮样式 */
.donate-methods {
display: flex;
justify-content: center;
margin-bottom: 15px;
gap: 10px;
}
.donate-method-btn {
padding: 5px 15px;
border: none;
border-radius: 15px;
cursor: pointer;
background: #f5f5f5;
color: #666;
font-size: 14px;
transition: all 0.3s ease;
}
.donate-method-btn.active {
background: #ff4081;
color: white;
}
.donate-method-btn:hover {
background: #ff4081;
color: white;
}
/* QR码容器样式 */
.qr-container {
position: relative;
height: 100%;
width: 100%;
margin: 0 auto;
}
.qr-image {
position: absolute;
top: 0;
left: 0;
opacity: 0;
visibility: hidden;
transition: opacity 0.3s ease, visibility 0.3s ease;
}
.qr-image.active {
opacity: 1;
visibility: visible;
}
/* 小三角形 */
#qrcode-panel:after {
content: '';
position: absolute;
bottom: -8px;
left: 50%;
transform: translateX(-50%);
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-top: 8px solid white;
}

BIN
assets/images/close.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

BIN
assets/images/loading.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

BIN
assets/images/next.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
assets/images/prev.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -17,7 +17,7 @@
is_single = false;
post_id = 0;
is_archive = false;
VERSION = "0.6.3";
VERSION = "0.7.0";
constructor() {
super();
this.initCopyright();

65
assets/js/donate.js Normal file
View File

@ -0,0 +1,65 @@
document.addEventListener('DOMContentLoaded', function() {
const donateBtn = document.getElementById('donate-btn');
const qrcodePanel = document.getElementById('qrcode-panel');
const donateClose = document.getElementById('donate-close');
const methodBtns = document.querySelectorAll('.donate-method-btn');
const qrImages = document.querySelectorAll('.qr-image');
let isVisible = false;
// 切换支付方式
function switchPayMethod(method) {
// 更新按钮状态
methodBtns.forEach(btn => {
btn.classList.remove('active');
if (btn.dataset.method === method) {
btn.classList.add('active');
}
});
// 更新二维码显示
qrImages.forEach(img => {
img.classList.remove('active');
if (img.dataset.method === method) {
img.classList.add('active');
}
});
}
// 点击打赏按钮切换二维码显示状态
function toggleQRCode(event) {
event.stopPropagation();
isVisible = !isVisible;
qrcodePanel.style.display = isVisible ? 'block' : 'none';
}
// 点击关闭按钮隐藏二维码
function hideQRCode(event) {
event.stopPropagation();
isVisible = false;
qrcodePanel.style.display = 'none';
}
// 点击二维码面板之外的地方隐藏二维码
function handleDocumentClick(event) {
if (isVisible && !qrcodePanel.contains(event.target) && !donateBtn.contains(event.target)) {
isVisible = false;
qrcodePanel.style.display = 'none';
}
}
// 绑定事件监听器
donateBtn.addEventListener('click', toggleQRCode);
donateClose.addEventListener('click', hideQRCode);
document.addEventListener('click', handleDocumentClick);
// 绑定支付方式切换按钮事件
methodBtns.forEach(btn => {
btn.addEventListener('click', (e) => {
const method = e.target.dataset.method;
switchPayMethod(method);
});
});
// 初始化显示第一个支付方式
switchPayMethod('wechat');
});

186
assets/js/post.js Normal file
View File

@ -0,0 +1,186 @@
document.addEventListener('DOMContentLoaded', function() {
const tooltip = document.getElementById('copyTooltip');
let timeoutId = null;
// 确保初始状态下提示框是隐藏的
tooltip.style.display = 'none';
// 复制函数
function copyToClipboard(text) {
navigator.clipboard.writeText(text).then(() => {
// 显示提示
tooltip.style.display = 'block';
tooltip.style.opacity = '1';
// 清除之前的定时器(如果存在)
if (timeoutId) clearTimeout(timeoutId);
// 设置新的定时器
timeoutId = setTimeout(() => {
tooltip.style.opacity = '0';
setTimeout(() => {
tooltip.style.display = 'none';
}, 300); // 等待淡出动画完成后再隐藏
}, 1500);
}).catch(err => {
tooltip.textContent = '复制失败,请重试';
tooltip.style.display = 'block';
tooltip.style.opacity = '1';
if (timeoutId) clearTimeout(timeoutId);
timeoutId = setTimeout(() => {
tooltip.style.opacity = '0';
setTimeout(() => {
tooltip.style.display = 'none';
tooltip.textContent = '复制成功!'; // 重置文本
}, 300);
}, 1500);
console.error('复制失败:', err);
});
}
// 给所有复制链接添加点击事件
document.querySelectorAll('.text').forEach(link => {
link.addEventListener('click', function(e) {
e.preventDefault();
const textToCopy = this.getAttribute('data-copy') || this.textContent;
copyToClipboard(textToCopy);
});
});
});
document.addEventListener('DOMContentLoaded', (event) => {
const targetClassElement = document.querySelector('.post--single__title');
const postContent = document.querySelector('.post--single__content');
if (!postContent) return;
let found = false;
for (let i = 1; i <= 6 &&!found; i++) {
if (postContent.querySelector(`h${i}`)) {
found = true;
}
}
if (!found) return;
const heads = postContent.querySelectorAll('h1, h2, h3, h4, h5, h6');
const toc = document.createElement('div');
toc.id = 'toc';
toc.innerHTML = '<details class="toc" open><summary class="toc-title">目录</summary><nav id="TableOfContents"><ul></ul></nav></details>';
// 插入到指定 class 元素之后
if (targetClassElement) {
targetClassElement.parentNode.insertBefore(toc, targetClassElement.nextSibling);
}
let currentLevel = 0;
let currentList = toc.querySelector('ul');
let levelCounts = [0];
heads.forEach((head, index) => {
const level = parseInt(head.tagName.substring(1));
if (levelCounts[level] === undefined) {
levelCounts[level] = 1;
} else {
levelCounts[level]++;
}
// 重置下级标题的计数器
levelCounts = levelCounts.slice(0, level + 1);
if (currentLevel === 0) {
currentLevel = level;
}
while (level > currentLevel) {
let newList = document.createElement('ul');
if (!currentList.lastElementChild) {
currentList.appendChild(newList);
} else {
currentList.lastElementChild.appendChild(newList);
}
currentList = newList;
currentLevel++;
levelCounts[currentLevel] = 1;
}
while (level < currentLevel) {
currentList = currentList.parentElement;
if (currentList.tagName.toLowerCase() === 'li') {
currentList = currentList.parentElement;
}
currentLevel--;
}
const anchor = head.textContent.trim().replace(/\s+/g, '-');
head.id = anchor;
const item = document.createElement('li');
const link = document.createElement('a');
link.href = `#${anchor}`;
link.textContent = `${head.textContent}`;
link.style.textDecoration = 'none';
item.appendChild(link);
currentList.appendChild(item);
});
});
function fetchWithRetry(url, retries = 3) {
return fetch(url)
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.text(); // 首先获取文本响应
})
.then(text => {
try {
return JSON.parse(text); // 尝试解析 JSON
} catch (e) {
console.error('Invalid JSON:', text);
throw new Error('Invalid JSON response');
}
})
.catch(error => {
if (retries > 0) {
console.log(`Retrying... (${retries} attempts left)`);
return new Promise(resolve => setTimeout(resolve, 1000)) // 等待1秒
.then(() => fetchWithRetry(url, retries - 1));
}
throw error;
});
}
document.addEventListener('DOMContentLoaded', function() {
const doubanLinks = document.querySelectorAll('a[href^="https://movie.douban.com/subject/"]');
doubanLinks.forEach(link => {
const url = link.href;
const movieId = url.match(/subject\/(\d+)/)[1];
link.innerHTML += ' <span class="loading">(加载中...)</span>';
fetchWithRetry(`https://api.loliko.cn/movies/${movieId}`)
.then(data => {
const movieInfo = createMovieInfoHTML(data, url);
const wrapper = document.createElement('div');
wrapper.innerHTML = movieInfo;
link.parentNode.replaceChild(wrapper, link);
})
.catch(error => {
console.error('Error fetching movie data:', error);
// 显示错误消息给用户
link.innerHTML = `<span style="color: red;">加载失败</span> <a href="${url}" target="_blank">查看豆瓣电影详情</a>`;
})
.finally(() => {
const loadingSpan = link.querySelector('.loading');
if (loadingSpan) {
loadingSpan.remove();
}
});
});
});
function createMovieInfoHTML(data, originalUrl) {
if (!data || data.error || Object.keys(data).length === 0) {
return `<a href="${originalUrl}" target="_blank">查看豆瓣电影详情</a>`;
}
return `
<div class=doulist-item>
<div class=doulist-subject>
<div class=doulist-post>
<img decoding=async referrerpolicy=no-referrer src=${data.img}>
</div>
<div class=doulist-content>
<div class=doulist-title>
<a href="${originalUrl}" class=cute target="_blank" rel="external nofollow"> ${data.name} </a>
</div>
<div class=rating>
<span class=rating_nums>豆瓣评分 : ${data.rating}</span>
</div>
<div class=abstract>
${data.year} · ${data.country} · ${data.genre} · 导演: ${data.director} · 演员 : ${data.actor}
</div>
</div>
</div>
</div>
`;
}

1
dist/css/donate.css vendored
View File

@ -1 +0,0 @@
#donate-btn,.donate-panel{position:relative;text-align:center}#donate-btn,#donate-close,input[name=pay]{cursor:pointer}#donate-btn{width:50px;height:50px;color:#fff;font-size:20px;font-weight:600;border-radius:50%;line-height:50px;display:inline-block}#qrcode-panel,.qrcode-body{background:#fff;border-radius:5px}#qrcode-panel{position:absolute;width:300px;height:320px;top:0;left:0;box-shadow:0 2px 4px rgba(0,0,0,.12),0 0 6px rgba(0,0,0,.04)}.qrcode-body{width:100%;height:100%;position:relative}.donate-memo{padding:10px;font-size:14px;color:#999;text-align:center}#donate-close{float:right;padding:0 5px;font-size:12px}#donate-close:hover{color:#bd4b4b}.donate-qrpay img{width:280px;height:280px}

File diff suppressed because one or more lines are too long

30
dist/js/donate.js vendored
View File

@ -1,30 +0,0 @@
setTimeout(function(){
initDonate()
}, 1000);
function initDonate(){
var donateBtn = document.getElementById('donate-btn');
var donatePopup = document.getElementById('qrcode-panel');
if(!donateBtn && !donatePopup){
return
}
var l = donateBtn.offsetLeft-125;
var t = donateBtn.offsetTop-330;
donatePopup.style.left=l+'px'
donatePopup.style.top=t+'px'
donateBtn.addEventListener('click',function(){
donatePopup.style.display='';
event.stopPropagation()
})
document.getElementById('donate-close').addEventListener('click',function(){
donatePopup.style.display='none';
event.stopPropagation()
})
document.querySelector('body').addEventListener('click',function() {
donatePopup.style.display='none';
event.stopPropagation()
});
donatePopup.addEventListener('click',function() {
event.stopPropagation()
});
}

File diff suppressed because one or more lines are too long

6
dist/js/vue.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -3,15 +3,15 @@
* 一款单栏主题. 移植自HUGO主题 Farallon 原作者 bigfa
* @package Farallon
* @author 老孙
* @version 0.6.3
* @version 0.7.0
* @link https://www.imsun.org
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
$this->need('header.php');
$this->need('module/header.php');
?>
<main class="site--main">
<div class="articleList">
<?php $this->need('postlist.php'); ?>
<?php $this->need('module/postlist.php'); ?>
</div>
</main>
<?php $this->need('footer.php'); ?>
<?php $this->need('module/footer.php'); ?>

View File

@ -2,7 +2,7 @@
<footer class="site--footer">
<div class="site--footer__content">
<div class=site--footer__sns>
<?php $this->need('sns.php'); ?>
<?php $this->need('./module/sns.php'); ?>
<?php //sitemap填入
if($this->options->sitemapurl): ?>
<a href="<?php $this->options->sitemapurl() ?>" target="_blank" aria-label="网站地图">💗</a>
@ -30,7 +30,7 @@
</path>
</svg>
</div>
<script src="<?php $this->options->themeUrl('/dist/js/bundle.js'); ?>"></script>
<script src="<?php $this->options->themeUrl('assets/js/bundle.js'); ?>"></script>
<?php $this->footer(); ?>
</div>
</body>

View File

@ -14,7 +14,7 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
'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>
<link rel="stylesheet" href="<?php $this->options->themeUrl('/dist/css/style.min.css'); ?>">
<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' />
<?php endif; ?>

View File

@ -8,6 +8,6 @@
<?php $this->options->description() ?>
</div>
<div class="author--sns">
<?php $this->need('sns.php'); ?>
<?php $this->need('./module/sns.php'); ?>
</div>
</div>

View File

@ -5,7 +5,7 @@
* @package custom
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php $this->need('header.php'); ?>
<?php $this->need('./module/header.php'); ?>
<section class="site--main">
<header class="archive--header">
<h1 class="post--single__title"><?php $this->title() ?></h1>
@ -57,4 +57,4 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
?>
</div>
</section>
<?php $this->need('footer.php'); ?>
<?php $this->need('./module/footer.php'); ?>

View File

@ -5,7 +5,7 @@
* @package custom
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php $this->need('header.php'); ?>
<?php $this->need('./module/header.php'); ?>
<div class="site--main">
<header class="archive--header">
<h1 class="post--single__title"><?php $this->title() ?></h1>
@ -33,4 +33,4 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php endwhile; ?>
</section>
</div>
<?php $this->need('footer.php'); ?>
<?php $this->need('./module/footer.php'); ?>

View File

@ -5,8 +5,8 @@
* @package custom
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php $this->need('header.php'); ?>
<script src="<?php $this->options->themeUrl('/dist/js/db.js'); ?>"></script>
<?php $this->need('./module/header.php'); ?>
<script src="<?php $this->options->themeUrl('assets/js/db.js'); ?>"></script>
<section class="site--main">
<header class="archive--header">
<h1 class="post--single__title"><?php $this->title() ?></h1>
@ -28,4 +28,4 @@ new Douban({
</script>
</div>
</section>
<?php $this->need('footer.php'); ?>
<?php $this->need('./module/footer.php'); ?>

View File

@ -5,7 +5,7 @@
* @package custom
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
$this->need('header.php');
$this->need('./module/header.php');
?>
<div class="site--main site--main__gears">
@ -114,5 +114,5 @@ function parseGoodsTable($content) {
return $goods;
}
$this->need('footer.php');
$this->need('./module/footer.php');
?>

View File

@ -5,7 +5,7 @@
* @package custom
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php $this->need('header.php'); ?>
<?php $this->need('./module/header.php'); ?>
<section class="site--main">
<header class="archive--header">
<h1 class="post--single__title"><?php $this->title() ?></h1>
@ -18,12 +18,12 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<span class="sitename"><strong>{name}</strong>{title}</span>
</a></li>');
?>
</ul>
</ul>
</div>
<article class="post--single">
<?php if ($this->allow('comment')): ?>
<?php $this->need('comments.php'); ?>
<?php endif; ?>
<?php if ($this->allow('comment')): ?>
<?php $this->need('./module/comments.php'); ?>
<?php endif; ?>
</article>
</section>
<?php $this->need('footer.php'); ?>
<?php $this->need('./module/footer.php'); ?>

View File

@ -5,7 +5,7 @@
* @package custom
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php $this->need('header.php'); ?>
<?php $this->need('./module/header.php'); ?>
<div class="site--main">
<header class="archive--header">
<h1 class="post--single__title"><?php $this->title() ?></h1>
@ -13,9 +13,9 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
</header>
<article class="post--single">
<?php $tooot = $this->fields->tooot ? $this->fields->tooot : 'https://bbapi.ima.cm'; ?>
<script src="<?php $this->options->themeUrl('/dist/js/marked.min.js'); ?>"></script>
<link rel="stylesheet" href="<?php $this->options->themeUrl('/dist/css/lightbox.min.css'); ?>">
<script src="<?php $this->options->themeUrl('/dist/js/lightbox-plus-jquery.min.js'); ?>"></script>
<script src="<?php $this->options->themeUrl('assets/js/marked.min.js'); ?>"></script>
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/lightbox.min.css'); ?>">
<script src="<?php $this->options->themeUrl('assets/js/lightbox-plus-jquery.min.js'); ?>"></script>
<div id="tooot"></div>
<div class="nav-links" id="loadmore">
<span class="loadmore">加载更多</span>
@ -175,4 +175,4 @@ img {
}
</style>
</div>
<?php $this->need('footer.php'); ?>
<?php $this->need('./module/footer.php'); ?>

View File

@ -5,7 +5,7 @@
* @package custom
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php $this->need('header.php'); ?>
<?php $this->need('./module/header.php'); ?>
<div class="site--main">
<header class="archive--header">
<h1 class="post--single__title"><?php $this->title() ?></h1>
@ -18,9 +18,9 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
$memosnum = $this->fields->memosnum ? $this->fields->memosnum : '20';
?>
<article class="post--single">
<script src="<?php $this->options->themeUrl('/dist/js/marked.min.js'); ?>"></script>
<link rel="stylesheet" href="<?php $this->options->themeUrl('/dist/css/lightbox.min.css'); ?>">
<script src="<?php $this->options->themeUrl('/dist/js/lightbox-plus-jquery.min.js'); ?>"></script>
<script src="<?php $this->options->themeUrl('assets/js/marked.min.js'); ?>"></script>
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/lightbox.min.css'); ?>">
<script src="<?php $this->options->themeUrl('assets/js/lightbox-plus-jquery.min.js'); ?>"></script>
<div id="talk"></div>
<div class="nav-links" id="loadmore">
<span class="loadmore">加载更多</span>
@ -196,4 +196,4 @@ img {
}
</style>
</div>
<?php $this->need('footer.php'); ?>
<?php $this->need('./module/footer.php'); ?>

View File

@ -5,9 +5,9 @@
* @package custom
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php $this->need('header.php'); ?>
<link rel="stylesheet" href="<?php $this->options->themeUrl('/dist/css/neodb.css'); ?>">
<script src="<?php $this->options->themeUrl('/dist/js/neodb.js'); ?>"></script>
<?php $this->need('./module/header.php'); ?>
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/neodb.css'); ?>">
<script src="<?php $this->options->themeUrl('assets/js/neodb.js'); ?>"></script>
<section class="site--main">
<header class="archive--header">
<h1 class="post--single__title"><?php $this->title() ?></h1>
@ -25,4 +25,4 @@ const neodb = new NeoDB({
</script>
</div>
</section>
<?php $this->need('footer.php'); ?>
<?php $this->need('./module/footer.php'); ?>

View File

@ -5,7 +5,7 @@
* @package custom
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php $this->need('header.php'); ?>
<?php $this->need('./module/header.php'); ?>
<section class="site--main">
<header class="archive--header">
<h1 class="post--single__title"><?php $this->title() ?></h1>
@ -28,4 +28,4 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php endif; ?>
</div>
</section>
<?php $this->need('footer.php'); ?>
<?php $this->need('./module/footer.php'); ?>

View File

@ -1,5 +1,5 @@
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php $this->need('header.php'); ?>
<?php $this->need('./module/header.php'); ?>
<section class="site--main">
<header class="archive--header">
<h1 class="post--single__title"><?php $this->title() ?></h1>
@ -16,5 +16,5 @@
<?php $this->options->twikoo(); ?>
</article>
</section>
<?php $this->need('footer.php'); ?>
<?php $this->need('module/footer.php'); ?>

228
post.php
View File

@ -1,5 +1,5 @@
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php $this->need('header.php'); ?>
<?php $this->need('module/header.php'); ?>
<style>
#toc {font-size:14px;padding:10px 15px;background-color:var(--farallon-background-gray);border-radius:10px;margin-bottom:20px}
#toc summary{cursor:pointer}
@ -48,8 +48,8 @@
<?php if($this->options->donate): ?>
<!--打赏 -->
<div class="post--single__action">
<link rel="stylesheet" href="<?php $this->options->themeUrl('/dist/css/donate.css'); ?>">
<script type="text/javascript" src="<?php $this->options->themeUrl('/dist/js/donate.js'); ?>"></script>
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/donate.css'); ?>">
<script type="text/javascript" src="<?php $this->options->themeUrl('assets/js/donate.js'); ?>"></script>
<div class="donate-panel">
<div id="donate-btn">
<button class="button--like">
@ -62,7 +62,7 @@
</div>
<div id="qrcode-panel" style="display: none;">
<div class="qrcode-body">
<div class="donate-memo">
<div class="hidden">
<span id="donate-close">关闭</span>
</div>
<div class="donate-qrpay">
@ -76,66 +76,20 @@
<!-- 复制链接 -->
<?php if($this->options->showshare): ?>
<div class="post--share">
<svg viewBox="0 0 24 24" aria-hidden="true">
<g>
<path d="M18.36 5.64c-1.95-1.96-5.11-1.96-7.07 0L9.88 7.05 8.46 5.64l1.42-1.42c2.73-2.73 7.16-2.73 9.9 0 2.73 2.74 2.73 7.17 0 9.9l-1.42 1.42-1.41-1.42 1.41-1.41c1.96-1.96 1.96-5.12 0-7.07zm-2.12 3.53l-7.07 7.07-1.41-1.41 7.07-7.07 1.41 1.41zm-12.02.71l1.42-1.42 1.41 1.42-1.41 1.41c-1.96 1.96-1.96 5.12 0 7.07 1.95 1.96 5.11 1.96 7.07 0l1.41-1.41 1.42 1.41-1.42 1.42c-2.73 2.73-7.16 2.73-9.9 0-2.73-2.74-2.73-7.17 0-9.9z"></path>
</g>
</svg>
<span class="text">复制链接</span>
<span class="link" @click="copy" data-link="<?php $this->permalink(); ?>"><?php $this->permalink(); ?></span>
<script src="<?php $this->options->themeUrl('/dist/js/vue.min.js'); ?>"></script>
<script src="<?php $this->options->themeUrl('/dist/js/clipboard.min.js'); ?>"></script>
<script>
var app = new Vue({
el: '.post--share',
data() {
return {
msg: "<?php $this->permalink(); ?>",
};
},
methods: {
//复制方法
copy: function () {
var that = this;
var clipboard = new ClipboardJS(".link",{
text: function (trigger) {
//返回字符串
return that.msg;
}});
clipboard.on("success", (e) => {
//复制成功,显示提示
this.showCopySuccessToast();
clipboard.destroy();
});
clipboard.on("error", (e) => {
//复制失败
clipboard.destroy();
});
},
showCopySuccessToast: function() {
const toast = document.createElement("div");
toast.textContent = "复制成功!";
toast.className = "notice--wrapper";
document.body.appendChild(toast);
setTimeout(() => {
document.body.removeChild(toast);
}, 3000);
}
}
});
</script>
</div>
<?php endif; ?>
<!-- TAG -->
<svg viewBox="0 0 24 24" aria-hidden="true"><g><path d="M18.36 5.64c-1.95-1.96-5.11-1.96-7.07 0L9.88 7.05 8.46 5.64l1.42-1.42c2.73-2.73 7.16-2.73 9.9 0 2.73 2.74 2.73 7.17 0 9.9l-1.42 1.42-1.41-1.42 1.41-1.41c1.96-1.96 1.96-5.12 0-7.07zm-2.12 3.53l-7.07 7.07-1.41-1.41 7.07-7.07 1.41 1.41zm-12.02.71l1.42-1.42 1.41 1.42-1.41 1.41c-1.96 1.96-1.96 5.12 0 7.07 1.95 1.96 5.11 1.96 7.07 0l1.41-1.41 1.42 1.41-1.42 1.42c-2.73 2.73-7.16 2.73-9.9 0-2.73-2.74-2.73-7.17 0-9.9z"></path></g></svg>
<span class="text" data-copy="<?php $this->permalink(); ?>">复制链接</span><span class="link text"><?php $this->permalink(); ?></span><div class="notice--wrapper" id="copyTooltip" style="display: none;">复制成功!</div>
</div>
<?php endif; ?>
<!-- TAG -->
<div class="tag--list artile--tag">
<?php $this->tags(' ', true, ' '); ?>
</div>
<!-- 个人信息-->
<?php if ($this->options->showProfile): ?>
<?php $this->need('profile.php'); ?>
<?php endif; ?>
<!-- 分类-->
<?php if ($this->options->showcate): ?>
<!-- 个人信息-->
<?php if ($this->options->showProfile): ?>
<?php $this->need('module/profile.php'); ?>
<?php endif; ?>
<!-- 分类-->
<?php if ($this->options->showcate): ?>
<?php
// 初始化分类图片地址为空
$categoryImage = '';
@ -169,7 +123,7 @@
<?php endif; ?>
<!-- 相关文章-->
<?php if ($this->options->showrelated): ?>
<?php $this->need('related.php'); ?>
<?php $this->need('module/related.php'); ?>
<?php endif; ?>
<!-- 如果设置了第三方评论系统则使用第三方评论 -->
<?php if($this->options->twikoo): ?>
@ -191,149 +145,7 @@
</ul>
</article>
</main>
<script>
document.addEventListener('DOMContentLoaded', (event) => {
const targetClassElement = document.querySelector('.post--single__title');
const postContent = document.querySelector('.post--single__content');
if (!postContent) return;
let found = false;
for (let i = 1; i <= 6 &&!found; i++) {
if (postContent.querySelector(`h${i}`)) {
found = true;
}
}
if (!found) return;
const heads = postContent.querySelectorAll('h1, h2, h3, h4, h5, h6');
const toc = document.createElement('div');
toc.id = 'toc';
toc.innerHTML = '<details class="toc" open><summary class="toc-title">目录</summary><nav id="TableOfContents"><ul></ul></nav></details>';
// 插入到指定 class 元素之后
if (targetClassElement) {
targetClassElement.parentNode.insertBefore(toc, targetClassElement.nextSibling);
}
let currentLevel = 0;
let currentList = toc.querySelector('ul');
let levelCounts = [0];
heads.forEach((head, index) => {
const level = parseInt(head.tagName.substring(1));
if (levelCounts[level] === undefined) {
levelCounts[level] = 1;
} else {
levelCounts[level]++;
}
// 重置下级标题的计数器
levelCounts = levelCounts.slice(0, level + 1);
if (currentLevel === 0) {
currentLevel = level;
}
while (level > currentLevel) {
let newList = document.createElement('ul');
if (!currentList.lastElementChild) {
currentList.appendChild(newList);
} else {
currentList.lastElementChild.appendChild(newList);
}
currentList = newList;
currentLevel++;
levelCounts[currentLevel] = 1;
}
while (level < currentLevel) {
currentList = currentList.parentElement;
if (currentList.tagName.toLowerCase() === 'li') {
currentList = currentList.parentElement;
}
currentLevel--;
}
const anchor = head.textContent.trim().replace(/\s+/g, '-');
head.id = anchor;
const item = document.createElement('li');
const link = document.createElement('a');
link.href = `#${anchor}`;
link.textContent = `${head.textContent}`;
link.style.textDecoration = 'none';
item.appendChild(link);
currentList.appendChild(item);
});
});
</script>
<script>
function fetchWithRetry(url, retries = 3) {
return fetch(url)
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.text(); // 首先获取文本响应
})
.then(text => {
try {
return JSON.parse(text); // 尝试解析 JSON
} catch (e) {
console.error('Invalid JSON:', text);
throw new Error('Invalid JSON response');
}
})
.catch(error => {
if (retries > 0) {
console.log(`Retrying... (${retries} attempts left)`);
return new Promise(resolve => setTimeout(resolve, 1000)) // 等待1秒
.then(() => fetchWithRetry(url, retries - 1));
}
throw error;
});
}
document.addEventListener('DOMContentLoaded', function() {
const doubanLinks = document.querySelectorAll('a[href^="https://movie.douban.com/subject/"]');
doubanLinks.forEach(link => {
const url = link.href;
const movieId = url.match(/subject\/(\d+)/)[1];
link.innerHTML += ' <span class="loading">(加载中...)</span>';
fetchWithRetry(`https://api.loliko.cn/movies/${movieId}`)
.then(data => {
const movieInfo = createMovieInfoHTML(data, url);
const wrapper = document.createElement('div');
wrapper.innerHTML = movieInfo;
link.parentNode.replaceChild(wrapper, link);
})
.catch(error => {
console.error('Error fetching movie data:', error);
// 显示错误消息给用户
link.innerHTML = `<span style="color: red;">加载失败</span> <a href="${url}" target="_blank">查看豆瓣电影详情</a>`;
})
.finally(() => {
const loadingSpan = link.querySelector('.loading');
if (loadingSpan) {
loadingSpan.remove();
}
});
});
});
function createMovieInfoHTML(data, originalUrl) {
if (!data || data.error || Object.keys(data).length === 0) {
return `<a href="${originalUrl}" target="_blank">查看豆瓣电影详情</a>`;
}
return `
<div class=doulist-item>
<div class=doulist-subject>
<div class=doulist-post>
<img decoding=async referrerpolicy=no-referrer src=${data.img}>
</div>
<div class=doulist-content>
<div class=doulist-title>
<a href="${originalUrl}" class=cute target="_blank" rel="external nofollow"> ${data.name} </a>
</div>
<div class=rating>
<span class=rating_nums>豆瓣评分 : ${data.rating}</span>
</div>
<div class=abstract>
${data.year} · ${data.country} · ${data.genre} · 导演: ${data.director} · 演员 : ${data.actor}
</div>
</div>
</div>
</div>
`;
}
</script>
<link rel="stylesheet" href="<?php $this->options->themeUrl('/dist/css/lightbox.min.css'); ?>">
<script src="<?php $this->options->themeUrl('/dist/js/lightbox-plus-jquery.min.js'); ?>"></script>
<?php $this->need('footer.php'); ?>
<script src="<?php $this->options->themeUrl('assets/js/post.js'); ?>"></script>
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/lightbox.min.css'); ?>">
<script src="<?php $this->options->themeUrl('assets/js/lightbox-plus-jquery.min.js'); ?>"></script>
<?php $this->need('module/footer.php'); ?>