').addClass('fullscreen-btn fullscreen-btn-left').html('<');
const $btnRight = $('
').addClass('fullscreen-btn fullscreen-btn-right').html('>');
$fullscreenMask.append($fullscreenImg, $btnLeft, $btnRight);
// 将遮罩层添加到 body
$('body').append($fullscreenMask);
setTimeout(function () {
$fullscreenMask.addClass('active');
}, 10);
// 点击遮罩层时关闭
$fullscreenMask.on('click', function (e) {
if (!$(e.target).is($btnLeft) && !$(e.target).is($btnRight)) {
$fullscreenMask.removeClass('active');
setTimeout(function () {
$fullscreenMask.remove();
}, 300);
}
});
// 点击左按钮显示上一张图片
$btnLeft.on('click', function () {
currentImageIndex--;
if (currentImageIndex < 0) {
currentImageIndex = imageSrcArray.length - 1;
}
$fullscreenImg.attr('src', imageSrcArray[currentImageIndex]);
});
// 点击右按钮显示下一张图片
$btnRight.on('click', function () {
currentImageIndex++;
if (currentImageIndex >= imageSrcArray.length) {
currentImageIndex = 0;
}
$fullscreenImg.attr('src', imageSrcArray[currentImageIndex]);
});
});
const $overlay = $('#overlay');
const $videoPlayer = $('#videoPlayer');
const $closeBtn = $('#closeBtn');
const $videoBtns = $('.video-btn');
// 点击播放按钮
$videoBtns.on('click', function() {
const videoSrc = $(this).data('src'); // 获取 data-src 属性
$videoPlayer.attr('src', videoSrc); // 设置视频源
$videoPlayer[0].autoplay = true; // 设置自动播放
$overlay.css('display', 'flex'); // 显示遮罩层
});
// 点击关闭按钮
$closeBtn.on('click', function() {
$videoPlayer[0].pause(); // 暂停视频
$videoPlayer.attr('src', ''); // 清空视频源
$overlay.hide(); // 隐藏遮罩层
});
// 点击遮罩层关闭
$overlay.on('click', function(event) {
if (event.target === $overlay[0]) { // 判断是否点击的是遮罩层本身
$videoPlayer[0].pause(); // 暂停视频
$videoPlayer.attr('src', ''); // 清空视频源
$overlay.hide(); // 隐藏遮罩层
}
});
// 为 .log-date 绑定点击事件
$('.log-date').on('click', function() {
// 找到当前 .log-date 的同级 .log-line 元素
$(this).siblings('.log-line').toggleClass('active');
});
//日志
// 检查 update-log 是否存在
if ($('.update-log').length > 0) {
// 定义一个函数来执行 AJAX 请求
function fetchUpdate() {
$.ajax({
url: '/next-log', // 替换为你的 API 端点
method: 'GET', // 根据你的需求选择 GET 或 POST
dataType: 'json', // 根据你的 API 返回的数据类型选择
success: function(response) {
// 假设 response 包含 timestamp 和 message
var created_at = response.data.created_at;
var action = response.data.action;
if (action == 'aa') {
action = '新增了';
} else {
action = '更新了';
}
var model = response.data.model + ' 的';
var content = response.data.content;
// 更新 timestamp 和 message
$('.update-log .update-time').text(created_at);
$('.update-log .action').text(action);
$('.update-log .model').text(model);
$('.update-log .log-content').text(content);
},
error: function(xhr, status, error) {
console.error('AJAX 请求失败:', status, error);
}
});
}
// 立即执行一次
fetchUpdate();
// 每 10 秒执行一次
setInterval(fetchUpdate, 20000); // 10000 毫秒 = 10 秒
}
// 监听 .download-all 的点击事件
$('.download-all').on('click', function() {
// 查找 .album-tab 中带有 is-active 类的
标签
let activeTab = $('.album-tab a.is-active').attr('href');
// 将 #album- 替换为空,得到 tab 变量
let tab = activeTab.replace('#album-', '');
// 获取当前 URL 中的 id 参数
let currentUrl = window.location.href;
let urlParams = new URLSearchParams(currentUrl.split('?')[1]);
let id = urlParams.get('id');
// 拼接新的 URL
let newUrl = `/download-all?id=${id}&tab=${tab}`;
// 跳转到新 URL
window.location.href = newUrl;
});
});