优化缩略图

This commit is contained in:
Yeomai committed 2026-09-20 02:31:07 +08:00
1 parent fe4997f913
commit c28adf9fae
21 files changed
+74 -24

No files matched your search

+16 -2
View File
@@ -95,6 +95,17 @@ assert.ok(
);
delete profilesModule.ANIMATED_PRIORITIES.__size;
// 「缩略图大小」默认值跟动画时长联动:每秒 25 KB,夹在 25–100 KB。
assert.deepEqual(profilesModule.SIZE_SUGGESTION_RANGE, [25, 100]);
assert.equal(profilesModule.suggestSize(0.5), 25, '短动画取最低值');
assert.equal(profilesModule.suggestSize(1), 25);
assert.equal(profilesModule.suggestSize(2), 50, '每秒 25 KB');
assert.equal(profilesModule.suggestSize(3.4), 85);
assert.equal(profilesModule.suggestSize(4), 100, '到顶后不再增加');
assert.equal(profilesModule.suggestSize(30), 100);
assert.equal(profilesModule.suggestSize(0), 25);
assert.equal(profilesModule.suggestSize(undefined), 25);
// 插值路径供按目标体积定位使用:比锚点更密,首尾与锚点一致。
// 配置允许分段(分辨率优先就是「400 系列 + 200 系列」),所以不要求整条路径单调。
for (const name of Object.keys(priorities)) {
@@ -124,6 +135,9 @@ for (const root of ['.', 'release/UNIVERSAL_SpineViewer']) {
assert.match(html, /id="animatedThumbCanvas"/);
assert.match(html, /<option value="200" selected>200 × 200<\/option>/);
assert.match(script, /canvasSize: Number\(canvasInput\.value\) \|\| animatedProfileConfig\.DEFAULT_OUTPUT_SIZE/);
// 画廊提示里的画布尺寸跟着输出尺寸走,不能写死。
assert.match(html, /id="animatedPickHint" class="thumb-dialog-note">/);
assert.match(script, /t\('viewer\.animatedPickHint', \{ size: size \+ '×' \+ size \}\)/);
assert.match(script, /async function renderAnimatedSourceFrames\(animation, options\)/);
assert.match(script, /async function pickAnimatedThumbnail\(sourceFrames, size, range, options\)/);
assert.match(script, /const targetBytes = options\.maxKilobytes \* 1024/);
@@ -168,11 +182,11 @@ for (const root of ['.', 'release/UNIVERSAL_SpineViewer']) {
assert.match(html, /id="animatedThumbStart" type="number" min="0" step="1"/);
assert.match(html, /id="animatedThumbEnd" type="number" min="0" step="1"/);
assert.match(html, /data-i18n="viewer\.framesUnit"/);
assert.match(html, /id="animatedThumbMaxSize" type="number" min="10" max="1024" step="10" value="30"/);
assert.match(html, /id="animatedThumbMaxSize" type="number" min="10" max="1024" step="10" value="25"/);
assert.match(html, /class="animated-thumb-danger" data-i18n="viewer\.animatedThumbnailDanger"/);
assert.match(html, /class="animated-thumb-warning-title" data-i18n="viewer\.animatedThumbnailAttention"/);
assert.match(css, /\.animated-thumb-warning-title \{ display: block; \}/);
assert.match(script, /maxSizeInput\.value = '30'/);
assert.match(script, /maxSizeInput\.value = String\(animatedProfileConfig\.suggestSize\(animationLength\)\)/);
assert.match(script, /maxKilobytes < 10 \|\| maxKilobytes > 1024/);
assert.doesNotMatch(script, /startInput\.(?:focus|select)\(\)/);
assert.match(script, /document\.activeElement\.blur\(\)/);