/**
* 数字人直播系统 - Loading 加载组件
*/
(function() {
'use strict';
let overlay = null;
const Loading = {
show(message = '加载中...', targetId = null) {
// 全屏加载
if (!targetId) {
if (overlay) {
const msgEl = overlay.querySelector('.dh-loading-message');
if (msgEl) msgEl.textContent = message;
return;
}
overlay = document.createElement('div');
overlay.style.cssText = `
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
background: rgba(0,0,0,0.3);
display: flex;
align-items: center;
justify-content: center;
z-index: 99990;
`;
overlay.innerHTML = `
`;
document.body.appendChild(overlay);
} else {
// 区域加载
const target = document.getElementById(targetId);
if (!target) return;
target.style.position = 'relative';
const areaOverlay = document.createElement('div');
areaOverlay.className = 'dh-area-loading';
areaOverlay.style.cssText = `
position: absolute;
top: 0; left: 0; right: 0; bottom: 0;
background: rgba(255,255,255,0.7);
display: flex;
align-items: center;
justify-content: center;
z-index: 100;
border-radius: 8px;
`;
areaOverlay.innerHTML = `
`;
target.appendChild(areaOverlay);
}
},
hide(targetId = null) {
if (!targetId) {
if (overlay) {
overlay.remove();
overlay = null;
}
} else {
const target = document.getElementById(targetId);
if (target) {
const areaLoading = target.querySelector('.dh-area-loading');
if (areaLoading) areaLoading.remove();
}
}
}
};
// 添加旋转动画
const style = document.createElement('style');
style.textContent = '@keyframes dhSpin { to { transform: rotate(360deg); } }';
document.head.appendChild(style);
window.DigitalHumanLoading = Loading;
console.log('[数字人直播] Loading组件已加载');
})();