win mac双平台修正

This commit is contained in:
Yeomai committed 2026-09-20 23:33:36 +08:00
1 parent 07c21f5954
commit 08456f26cf
4 files changed
+9 -9

No files matched your search

+4 -3
View File
@@ -105,9 +105,10 @@
// service 页面里的 require 不以插件目录为基准,本地资源要用绝对路径,这里先把根目录算出来。
(function () {
try {
// Windows 上 pathname 可能是 /C:/... 也可能是 \C:\...,统一成正斜杠并去掉前导分隔符。
const pathname = decodeURIComponent(new URL('.', location.href).pathname);
window.SpinePluginRoot = pathname.replace(/\\/g, '/').replace(/^\/+/, '');
// Windows 上 pathname 形如 /C:/...,要去掉盘符前那个多余的斜杠;
// macOS/Linux 是 /Users/...,前导斜杠必须留着,否则会变成相对路径。
const pathname = decodeURIComponent(new URL('.', location.href).pathname).replace(/\\/g, '/');
window.SpinePluginRoot = pathname.replace(/^\/([A-Za-z]:)/, '$1');
} catch (error) {
window.SpinePluginRoot = '';
}