Skip to content

Commit 558814d

Browse files
committed
版本号
1 parent dc05222 commit 558814d

File tree

5 files changed

+40
-60
lines changed

5 files changed

+40
-60
lines changed

assets/css/main.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2648,4 +2648,8 @@ span.tag-list a:hover {
26482648
.custom-textarea:focus {
26492649
border-color: #666 !important;
26502650
outline: none !important;
2651+
}
2652+
2653+
.poptrox-popup .pic img {
2654+
transition: opacity 0.3s ease-in-out;
26512655
}

functions.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,17 @@ function themeConfig($form)
5959
//输出导航
6060
function themeFields($layout)
6161
{
62-
$img = new Typecho_Widget_Helper_Form_Element_Textarea('img', NULL, NULL, _t('图片链接'), _t('请输入要展示的图片链接,每行一个链接'));
62+
$img = new Typecho_Widget_Helper_Form_Element_Textarea('img', NULL, NULL, _t('图片链接'), _t('请输入要展示的图片链接,每行一个链接。为了保证良好的体验,建议同一个文章下图片尺寸一致。'));
6363
$img->input->setAttribute('class', 'w-100 custom-textarea');
64+
$img->input->setAttribute('style', 'height: 200px');
6465
$layout->addItem($img);
6566

6667
$device = new Typecho_Widget_Helper_Form_Element_Text('device', NULL, NULL, _t('设备信息'), _t('请输入拍摄设备信息'));
68+
$device->input->setAttribute('class', 'w-100');
6769
$layout->addItem($device);
6870

6971
$location = new Typecho_Widget_Helper_Form_Element_Text('location', NULL, NULL, _t('拍摄地点'), _t('请输入拍摄地点信息'));
72+
$location->input->setAttribute('class', 'w-100');
7073
$layout->addItem($location);
7174
}
7275

index.php

Lines changed: 29 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* 一款简约的相册主题
44
* @package 洪墨时光
55
* @author zhheo
6-
* @version 2.13
6+
* @version 2.14
77
* @link https://zhheo.com/
88
*/
99
?>
@@ -105,12 +105,14 @@
105105
<span class="tag-list"><?php $this->tags('', true); ?></span>
106106
<?php endif; ?>
107107
</li>
108-
<!-- 添加所有图片数据到 data 属性 -->
108+
<!-- 只有当图片数量大于1时才显示面包屑导航 -->
109+
<?php if(count($images) > 1): ?>
109110
<div class="breadcrumb-nav" data-images='<?php echo json_encode($images); ?>'>
110111
<?php foreach($images as $index => $image): ?>
111112
<span class="nav-dot <?php echo $index === 0 ? 'active' : ''; ?>" data-index="<?php echo $index; ?>"></span>
112113
<?php endforeach; ?>
113114
</div>
115+
<?php endif; ?>
114116
</article>
115117
<?php endwhile; ?>
116118

@@ -246,11 +248,12 @@ function throttle(fn, mustRun = 10) {
246248
</script>
247249
<script>
248250
document.addEventListener('DOMContentLoaded', function() {
249-
let originalWidth, originalHeight;
250-
const imageCache = {}; // 用于缓存图片
251+
// 创建一个变量来跟踪是否正在切换图片
252+
let isTransitioning = false;
251253

252254
document.addEventListener('mouseover', function(e) {
253255
if (!e.target.classList.contains('nav-dot')) return;
256+
if (isTransitioning) return; // 如果正在切换则忽略新的切换请求
254257

255258
const nav = e.target.closest('.breadcrumb-nav');
256259
if (!nav) return;
@@ -262,68 +265,36 @@ function throttle(fn, mustRun = 10) {
262265

263266
if (!popup) return;
264267

265-
// 第一次记录原始尺寸
266-
if (!originalWidth || !originalHeight) {
267-
originalWidth = popup.offsetWidth + 'px';
268-
originalHeight = popup.offsetHeight + 'px';
269-
}
270-
271268
const img = popup.querySelector('.pic img');
272269
if (img) {
273-
// 仅在通过面包屑切换时显示加载动画并保持弹窗尺寸
274-
img.src = '<?php $this->options->themeUrl('assets/img/loading.gif'); ?>';
275-
img.style.objectFit = 'contain';
276-
img.style.margin = 'auto';
277-
img.style.width = originalWidth;
278-
img.style.height = originalHeight;
279-
}
280-
281-
// 检查图片是否已缓存
282-
if (!imageCache[images[index]]) {
283-
const newImg = new Image();
284-
newImg.onload = function() {
285-
imageCache[images[index]] = newImg; // 缓存图片
286-
updateImage(popup, newImg, images[index]);
287-
};
288-
newImg.src = images[index] + '<?php $this->options->zmki_sy() ?>';
289-
} else {
290-
// 如果已缓存,直接使用缓存的图片
291-
updateImage(popup, imageCache[images[index]], images[index]);
270+
isTransitioning = true;
271+
272+
// 确保当前图片有过渡效果
273+
img.style.transition = 'opacity 0.3s ease-in-out';
274+
img.style.opacity = '0';
275+
276+
// 等待淡出完成
277+
setTimeout(() => {
278+
// 切换图片源
279+
img.src = images[index] + '<?php $this->options->zmki_sy() ?>';
280+
281+
// 图片加载完成后显示
282+
img.onload = function() {
283+
img.style.opacity = '1';
284+
isTransitioning = false;
285+
};
286+
287+
// 如果图片加载失败,也要重置状态
288+
img.onerror = function() {
289+
isTransitioning = false;
290+
};
291+
}, 300);
292292
}
293293

294294
// 更新导航点状态
295295
dots.forEach(dot => dot.classList.remove('active'));
296296
e.target.classList.add('active');
297297
});
298-
299-
function updateImage(popup, imgElement, imageUrl) {
300-
const img = popup.querySelector('.pic img');
301-
if (img) {
302-
// 先设置弹窗尺寸为原始尺寸
303-
popup.style.width = originalWidth;
304-
popup.style.height = originalHeight;
305-
popup.style.maxWidth = originalWidth;
306-
popup.style.maxHeight = originalHeight;
307-
308-
// 设置图片容器样式
309-
const picContainer = popup.querySelector('.pic');
310-
if (picContainer) {
311-
picContainer.style.display = 'flex';
312-
picContainer.style.alignItems = 'center';
313-
picContainer.style.justifyContent = 'center';
314-
picContainer.style.height = '100%';
315-
}
316-
317-
// 设置图片
318-
img.src = imageUrl + '<?php $this->options->zmki_sy() ?>';
319-
img.style.maxWidth = '100%';
320-
img.style.maxHeight = '100%';
321-
img.style.width = 'auto';
322-
img.style.height = 'auto';
323-
img.style.objectFit = 'contain';
324-
img.style.margin = 'auto';
325-
}
326-
}
327298
});
328299
</script>
329300
</div>

releases.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"tag_name": "2.13"
2+
"tag_name": "2.14"
33
}

update.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ rsync -avz --progress --chmod=755 ./ [email protected]:/www/wwwroot/plog.zhheo
55
# 更新日志
66

77
## 2.14
8+
【壮举】支持一个文章插入多个图片 #20
9+
优化了设置自定义字段时,输入框的尺寸
810
当只有一页的时候,不显示分页器
911
看图时,只有悬浮状态才会显示两侧的阴影
1012
性能优化

0 commit comments

Comments
 (0)