fix: 修复Pio手动换装首次加载默认图

This commit is contained in:
sunlei 2026-07-06 18:00:21 +08:00
parent e36fada219
commit 9f95504073
2 changed files with 15 additions and 2 deletions

View File

@ -8226,7 +8226,7 @@ function LAppModel() {
this.gl = null;
this.texPath = "";
this.modelPath = "";
this.countOfTexure = -1
this.countOfTexure = 0
}
LAppModel.prototype = new L2DBaseModel();
var motionModel;

View File

@ -1,4 +1,7 @@
import { flushPromises, mount } from '@vue/test-utils';
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
import { afterEach, describe, expect, it, vi } from 'vitest';
import BlogLive2D from '@/components/blog/BlogLive2D';
@ -277,6 +280,16 @@ describe('BlogLive2D', () => {
expect(document.querySelector('.waifu-tips')?.textContent).toContain('只有一套');
});
it('starts manual costume switching from the first variant and loops back to the default texture', () => {
const runtimeSource = readFileSync(resolve(process.cwd(), 'public/live2d/wordpress-moc/live2d.min.js'), 'utf-8');
expect(runtimeSource).toContain('this.countOfTexure = 0');
expect(runtimeSource).not.toContain('this.countOfTexure = -1');
expect(runtimeSource).toMatch(
/if \(no >= thisRef\.modelSetting\.getTextureNum\(\)\) \{\s*motionModel\.countOfTexure = 0;\s*no = 0\s*\}/,
);
});
it('reuses the page-level WordPress runtime after route component remounts', async () => {
vi.stubGlobal('innerWidth', 1280);
const initLive2D = vi.fn();