From 55dc52be376386d67e023500c754e7b46e9ac040 Mon Sep 17 00:00:00 2001 From: tianmo Date: Fri, 30 Oct 2026 16:31:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=9B=E5=BA=A6=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SpineThumbnailGenerateServer/index.html | 2 +- SpineThumbnailGenerateServer/js/plugin.js | 2 +- SpineThumbnailGenerateServer/progress.html | 2 +- SpineThumbnailGenerateServer/tests/progress-window.test.js | 7 +++++++ release/UNIVERSAL_SpineThumbnailGenerateServer/index.html | 2 +- .../UNIVERSAL_SpineThumbnailGenerateServer/js/plugin.js | 2 +- .../UNIVERSAL_SpineThumbnailGenerateServer/progress.html | 2 +- 7 files changed, 13 insertions(+), 6 deletions(-) diff --git a/SpineThumbnailGenerateServer/index.html b/SpineThumbnailGenerateServer/index.html index 64a7ccd..830e2d9 100644 --- a/SpineThumbnailGenerateServer/index.html +++ b/SpineThumbnailGenerateServer/index.html @@ -99,7 +99,7 @@ // Windows 上 pathname 形如 /C:/...,要去掉盘符前那个多余的斜杠; // macOS/Linux 是 /Users/...,前导斜杠必须留着,否则会变成相对路径。 const pathname = decodeURIComponent(new URL('.', location.href).pathname).replace(/\\/g, '/'); - window.SpinePluginRoot = pathname.replace(/^\/([A-Za-z]:)/, '$1'); + 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 8cabda7..3fe82b9 100644 --- a/SpineThumbnailGenerateServer/js/plugin.js +++ b/SpineThumbnailGenerateServer/js/plugin.js @@ -2,7 +2,7 @@ // 每次改动递增。Eagle 里的 service 插件是启动时加载并常驻的,改完代码必须重新加载插件 // 才会生效;状态栏会显示这个版本号,方便确认加载的到底是不是最新代码。 -const VERSION = 'v67'; +const VERSION = 'v68'; const SHOW_DEV_VERSION = true; const path = require('path'); diff --git a/SpineThumbnailGenerateServer/progress.html b/SpineThumbnailGenerateServer/progress.html index d33e4e6..1939a43 100644 --- a/SpineThumbnailGenerateServer/progress.html +++ b/SpineThumbnailGenerateServer/progress.html @@ -45,7 +45,7 @@ (function () { try { const pathname = decodeURIComponent(new URL('.', location.href).pathname).replace(/\\/g, '/'); - window.SpinePluginRoot = pathname.replace(/^\/([A-Za-z]:)/, '$1'); + window.SpinePluginRoot = pathname.replace(/^\/+([A-Za-z]:)/, '$1'); } catch (error) { window.SpinePluginRoot = ''; } diff --git a/SpineThumbnailGenerateServer/tests/progress-window.test.js b/SpineThumbnailGenerateServer/tests/progress-window.test.js index 43001ed..8aa0f11 100644 --- a/SpineThumbnailGenerateServer/tests/progress-window.test.js +++ b/SpineThumbnailGenerateServer/tests/progress-window.test.js @@ -6,13 +6,20 @@ const path = require('node:path'); const root = path.join(__dirname, '..'); const html = fs.readFileSync(path.join(root, 'progress.html'), 'utf8'); +const indexHtml = fs.readFileSync(path.join(root, 'index.html'), 'utf8'); const windowSource = fs.readFileSync(path.join(root, 'js', 'progress-window.js'), 'utf8'); const i18nSource = fs.readFileSync(path.join(root, 'js', 'i18n.js'), 'utf8'); +const normalizePluginRoot = (pathname) => pathname.replace(/^\/+([A-Za-z]:)/, '$1'); assert.match(windowSource, /minimizable: true/); assert.match(windowSource, /url: 'progress\.html',/); assert.doesNotMatch(windowSource, /url: 'progress\.html\?/); assert.match(i18nSource, /params\.get\('lang'\) \|\| params\.get\('locale'\)/); +for (const source of [html, indexHtml]) { + assert.match(source, /pathname\.replace\(\/\^\\\/\+\(\[A-Za-z\]:\)\/, '\$1'\)/); +} +assert.equal(normalizePluginRoot('//C:/Users/demo/plugin/'), 'C:/Users/demo/plugin/'); +assert.equal(normalizePluginRoot('/Users/demo/plugin/'), '/Users/demo/plugin/'); assert.match(html, /addEventListener\('beforeunload'/); assert.match(html, /function requestStop\(\)[\s\S]*writeControl\('pause'\)[\s\S]*resumeEl\.focus\(\)/); assert.match(html, /if \(allowClose \|\| finished\) return;[\s\S]*event\.returnValue = false;[\s\S]*requestStop\(\)/); diff --git a/release/UNIVERSAL_SpineThumbnailGenerateServer/index.html b/release/UNIVERSAL_SpineThumbnailGenerateServer/index.html index 64a7ccd..830e2d9 100644 --- a/release/UNIVERSAL_SpineThumbnailGenerateServer/index.html +++ b/release/UNIVERSAL_SpineThumbnailGenerateServer/index.html @@ -99,7 +99,7 @@ // Windows 上 pathname 形如 /C:/...,要去掉盘符前那个多余的斜杠; // macOS/Linux 是 /Users/...,前导斜杠必须留着,否则会变成相对路径。 const pathname = decodeURIComponent(new URL('.', location.href).pathname).replace(/\\/g, '/'); - window.SpinePluginRoot = pathname.replace(/^\/([A-Za-z]:)/, '$1'); + window.SpinePluginRoot = pathname.replace(/^\/+([A-Za-z]:)/, '$1'); } catch (error) { window.SpinePluginRoot = ''; } diff --git a/release/UNIVERSAL_SpineThumbnailGenerateServer/js/plugin.js b/release/UNIVERSAL_SpineThumbnailGenerateServer/js/plugin.js index bcbea10..54dabb9 100644 --- a/release/UNIVERSAL_SpineThumbnailGenerateServer/js/plugin.js +++ b/release/UNIVERSAL_SpineThumbnailGenerateServer/js/plugin.js @@ -2,7 +2,7 @@ // 每次改动递增。Eagle 里的 service 插件是启动时加载并常驻的,改完代码必须重新加载插件 // 才会生效;状态栏会显示这个版本号,方便确认加载的到底是不是最新代码。 -const VERSION = 'v67'; +const VERSION = 'v68'; const SHOW_DEV_VERSION = false; const path = require('path'); diff --git a/release/UNIVERSAL_SpineThumbnailGenerateServer/progress.html b/release/UNIVERSAL_SpineThumbnailGenerateServer/progress.html index d33e4e6..1939a43 100644 --- a/release/UNIVERSAL_SpineThumbnailGenerateServer/progress.html +++ b/release/UNIVERSAL_SpineThumbnailGenerateServer/progress.html @@ -45,7 +45,7 @@ (function () { try { const pathname = decodeURIComponent(new URL('.', location.href).pathname).replace(/\\/g, '/'); - window.SpinePluginRoot = pathname.replace(/^\/([A-Za-z]:)/, '$1'); + window.SpinePluginRoot = pathname.replace(/^\/+([A-Za-z]:)/, '$1'); } catch (error) { window.SpinePluginRoot = ''; }