From e93f9d711137cd94db2d29721097eb06d2412731 Mon Sep 17 00:00:00 2001 From: hrz <1710360675@qq.com> Date: Mon, 12 Jan 2026 18:05:39 +0800 Subject: [PATCH] =?UTF-8?q?update:=E4=BF=AE=E5=A4=8Dlive2d=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E5=8A=A0=E5=9C=A8=E8=B7=AF=E5=BE=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/test/js/live2d/live2d.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main/xiaozhi-server/test/js/live2d/live2d.js b/main/xiaozhi-server/test/js/live2d/live2d.js index f1ff45c7..8eafab16 100644 --- a/main/xiaozhi-server/test/js/live2d/live2d.js +++ b/main/xiaozhi-server/test/js/live2d/live2d.js @@ -62,8 +62,13 @@ class Live2DManager { backgroundAlpha: 0, }); - // 加载 Live2D 模型 - 使用正确的相对路径 - this.live2dModel = await PIXI.live2d.Live2DModel.from('../hiyori_pro_zh/runtime/hiyori_pro_t11.model3.json'); + // 加载 Live2D 模型 - 动态检测当前目录,适配不同环境 + // 获取当前HTML文件所在的目录路径 + const currentPath = window.location.pathname; + const lastSlashIndex = currentPath.lastIndexOf('/'); + const basePath = currentPath.substring(0, lastSlashIndex + 1); + const modelPath = basePath + 'hiyori_pro_zh/runtime/hiyori_pro_t11.model3.json'; + this.live2dModel = await PIXI.live2d.Live2DModel.from(modelPath); this.live2dApp.stage.addChild(this.live2dModel); // 设置模型属性