From 08456f26cf0783c19066fe660b8b2c6d9d86df61 Mon Sep 17 00:00:00 2001 From: YeomaiPC Date: Sun, 20 Sep 2026 23:33:36 +0800 Subject: [PATCH] =?UTF-8?q?win=20mac=E5=8F=8C=E5=B9=B3=E5=8F=B0=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SpineThumbnailGenerateServer/index.html | 7 ++++--- SpineThumbnailGenerateServer/js/plugin.js | 2 +- SpineThumbnailGenerateServer/js/renderer.js | 8 +++----- SpineThumbnailGenerateServer/progress.html | 1 + 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/SpineThumbnailGenerateServer/index.html b/SpineThumbnailGenerateServer/index.html index 836f1eb..6a6269b 100644 --- a/SpineThumbnailGenerateServer/index.html +++ b/SpineThumbnailGenerateServer/index.html @@ -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 = ''; } diff --git a/SpineThumbnailGenerateServer/js/plugin.js b/SpineThumbnailGenerateServer/js/plugin.js index a3122ec..4e81ad0 100644 --- a/SpineThumbnailGenerateServer/js/plugin.js +++ b/SpineThumbnailGenerateServer/js/plugin.js @@ -2,7 +2,7 @@ // 每次改动递增。Eagle 里的 service 插件是启动时加载并常驻的,改完代码必须重新加载插件 // 才会生效;状态栏会显示这个版本号,方便确认加载的到底是不是最新代码。 -const VERSION = 'v59'; +const VERSION = 'v60'; const path = require('path'); const os = require('os'); diff --git a/SpineThumbnailGenerateServer/js/renderer.js b/SpineThumbnailGenerateServer/js/renderer.js index e963eda..65864ce 100644 --- a/SpineThumbnailGenerateServer/js/renderer.js +++ b/SpineThumbnailGenerateServer/js/renderer.js @@ -9,6 +9,7 @@ const fs = require('fs'); const path = require('path'); +const { pathToFileURL } = require('url'); const runtimeCache = new Map(); // 长动画不截断时间轴,只降低采样密度:18 fps 采样,最多 240 帧。 @@ -69,12 +70,9 @@ function loadRuntime(runtimeDir) { return job; } -/** 本地绝对路径 → file:// URL(逐段编码,保留盘符)。 */ +/** 本地绝对路径 → file:// URL。交给 Node 的 pathToFileURL,Windows / macOS 都正确。 */ function fileUrl(filePath) { - const normalized = String(filePath).replace(/\\/g, '/'); - return 'file:///' + normalized.split('/') - .map((part, index) => (index === 0 ? part : encodeURIComponent(part))) - .join('/'); + return pathToFileURL(filePath).href; } /** 给可能挂起的异步操作套一层超时,避免队列被一个卡住的 Promise 堵死。 */ diff --git a/SpineThumbnailGenerateServer/progress.html b/SpineThumbnailGenerateServer/progress.html index 0b882be..0ee9fc3 100644 --- a/SpineThumbnailGenerateServer/progress.html +++ b/SpineThumbnailGenerateServer/progress.html @@ -68,6 +68,7 @@ /** Eagle 的 userData 目录;eagle.app.userDataPath 注入得比较晚,所以留一个兜底。 */ function userDataPath() { if (eagle.app && eagle.app.userDataPath) return eagle.app.userDataPath; + if (process.platform === 'darwin') return path.join(os.homedir(), 'Library', 'Application Support', 'Eagle'); return path.join(process.env.APPDATA || path.join(os.homedir(), 'AppData', 'Roaming'), 'Eagle'); }