diff --git a/main/xiaozhi-server/test/js/ui/background-load.js b/main/xiaozhi-server/test/js/ui/background-load.js new file mode 100644 index 00000000..b956f731 --- /dev/null +++ b/main/xiaozhi-server/test/js/ui/background-load.js @@ -0,0 +1,27 @@ +// 背景图加载检测 +(function() { + const backgroundContainer = document.getElementById('backgroundContainer'); + + // 提取背景图片URL + let bgImageUrl = window.getComputedStyle(backgroundContainer).backgroundImage; + const urlMatch = bgImageUrl && bgImageUrl.match(/url\(["']?(.*?)["']?\)/); + + if (!urlMatch || !urlMatch[1]) { + console.warn('未提取到有效的背景图片URL'); + return; + } + + bgImageUrl = urlMatch[1]; + + const bgImage = new Image(); + bgImage.onerror = function() { + console.error('背景图片加载失败:', bgImageUrl); + }; + + // 加载成功显示模型加载 + bgImage.onload = function() { + modelLoading.style.display = 'flex'; + }; + + bgImage.src = bgImageUrl; +})(); \ No newline at end of file diff --git a/main/xiaozhi-server/test/js/ui/bg-image-load-detector.js b/main/xiaozhi-server/test/js/ui/bg-image-load-detector.js deleted file mode 100644 index 9ab3f16b..00000000 --- a/main/xiaozhi-server/test/js/ui/bg-image-load-detector.js +++ /dev/null @@ -1,15 +0,0 @@ -// 背景图加载检测 -const backgroundContainer = document.getElementById('backgroundContainer'); -// 提取背景图片URL -let bgImageUrl = window.getComputedStyle(backgroundContainer).backgroundImage; -const urlMatch = bgImageUrl.match(/url\(["']?(.*?)["']?\)/); -bgImageUrl = urlMatch[1]; -const bgImage = new Image(); -bgImage.src = bgImageUrl; -// 加载完成后显示模型加载 -bgImage.onload = function () { - const modelLoading = document.getElementById('modelLoading'); - if (modelLoading) { - modelLoading.style.display = 'flex'; - } -} \ No newline at end of file diff --git a/main/xiaozhi-server/test/test_page.html b/main/xiaozhi-server/test/test_page.html index d11d9d42..e92a3ea9 100644 --- a/main/xiaozhi-server/test/test_page.html +++ b/main/xiaozhi-server/test/test_page.html @@ -236,8 +236,8 @@ - - + +