From 3e7bc0606aaab5e528c8efd2c775e83eec8d9446 Mon Sep 17 00:00:00 2001 From: lww155 <756794909@qq.com> Date: Thu, 22 Jan 2026 16:16:09 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E4=BC=98=E5=8C=96=E8=83=8C=E6=99=AF?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/js/ui/background-load.js | 27 +++++++++++++++++++ .../test/js/ui/bg-image-load-detector.js | 15 ----------- main/xiaozhi-server/test/test_page.html | 4 +-- 3 files changed, 29 insertions(+), 17 deletions(-) create mode 100644 main/xiaozhi-server/test/js/ui/background-load.js delete mode 100644 main/xiaozhi-server/test/js/ui/bg-image-load-detector.js 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 @@ - - + +