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 = '';
}
+1 -1
View File
@@ -2,7 +2,7 @@
// 每次改动递增。Eagle 里的 service 插件是启动时加载并常驻的,改完代码必须重新加载插件
// 才会生效;状态栏会显示这个版本号,方便确认加载的到底是不是最新代码。
const VERSION = 'v59';
const VERSION = 'v60';
const path = require('path');
const os = require('os');
+3 -5
View File
@@ -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 堵死。 */
@@ -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');
}