2025-10-19
流光快影 - 7张精选图片(按选择顺序)
2025-10-18
流光快影 - 2张精选图片(按选择顺序)
2025-10-17
流光快影 - 11张精选图片(按选择顺序)
2025-10-11
流光快影 - 1张精选图片(按选择顺序)
2025-10-10
流光快影 - 3张精选图片(按选择顺序)
2025-10-08
流光快影 - 3张精选图片(按选择顺序)
2025-10-07
流光快影 - 3张精选图片(按选择顺序)
2025-10-06
流光快影 - 3张精选图片(按选择顺序)
}
// 跨分组拖拽:将图片拖到其他日期卡片,调用后端更新 GroupDate(不删除旧功能)
(function(){
try{
// 仅本人可操作
var isOwner = false;
if (!isOwner) return;
// 为可拖拽的媒体设置 dragstart 事件
document.querySelectorAll('.grid a[data-media-id]').forEach(function(a){
a.addEventListener('dragstart', function(e){
e.dataTransfer.setData('text/plain', a.getAttribute('data-media-id') || '');
e.dataTransfer.effectAllowed = 'move';
// 拖拽时避免误触导航
e.preventDefault();
});
});
// 目标天卡片接收拖拽
document.querySelectorAll('section.day-section').forEach(function(sec){
sec.addEventListener('dragover', function(e){ e.preventDefault(); e.dataTransfer.dropEffect = 'move'; });
sec.addEventListener('drop', async function(e){
e.preventDefault();
var mediaId = e.dataTransfer.getData('text/plain');
if (!mediaId) return;
var day = sec.getAttribute('data-day'); // YYYY-MM-DD
try{
var res = await authFetch('/api/Media/' + mediaId + '/group-date', {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ groupDate: day })
});
var json = await res.json();
if (!json.success) throw new Error(json.message || '更新失败');
if (window.AppUtils && typeof window.AppUtils.showNotification === 'function'){
window.AppUtils.showNotification('分组调整成功', 'success');
}
// 将元素移动到目标分组的网格中
var dragged = document.querySelector('a[data-media-id="' + mediaId + '"]');
var targetGrid = sec.querySelector('.grid');
if (dragged && targetGrid){
targetGrid.appendChild(dragged);
}
}catch(err){
console.error(err);
if (window.AppUtils && typeof window.AppUtils.showNotification === 'function'){
window.AppUtils.showNotification('更新失败:' + (err.message || '未知错误'), 'error');
}
}
});
});
}catch(ex){ console.error(ex); }
})();