Files
VRMify-Enhanced/ui/web/run.js
T
Black-Cyan 60cce66993
Tests / test (push) Has been cancelled
初始化 VRMify 增强版(VRMify Enhanced)
导入上游源码,为所有面向用户的品牌显示处添加「增强版 / Enhanced」标识;包含 unitypackage→VRM 的纯色 Toon 材质、兽耳 SpringBone、Unity 描边、UV 接缝白边补偿修复,以及默认不强制 T-pose。146 个单元测试通过。
2026-11-15 23:21:59 +08:00

64 lines
3.0 KiB
JavaScript

// Run bar (start / stop / progress) and the log.
import { $, S, api, pick, t, toast } from './core.js';
import { renderFiles } from './files.js';
import { flushOpts } from './options.js';
import { T, saveTune } from './tune.js';
$('start').onclick = async () => {
await flushOpts();
if (T.dirty && T.fid) await saveTune(T.edits); // unsaved tune edits go into this conversion
const r = await api('/api/convert', {});
if (!r.started) toast(t('nothing'));
S.result = null; S.logErrors = 0; renderBadge();
};
$('stop').onclick = () => api('/api/stop', {});
// after a run: show where the results went (the newest output, selected in the file manager)
const lastOutput = () => [...S.files].reverse().flatMap((f) => f.outputs.slice(-1))[0];
$('openOut').onclick = () => { const o = lastOutput(); if (o) api('/api/open', { path: o.path }); };
export function renderStatus() {
$('start').hidden = S.busy; $('stop').hidden = !S.busy;
let s = t('idle'), pct = 0;
if (S.busy && S.progress) {
s = t('converting', { i: S.progress.index + 1, n: S.progress.total, name: S.progress.name });
pct = S.progress.index / S.progress.total * 100;
} else if (S.result) { s = t(S.result.skipped ? 'finishedSkip' : 'finished', S.result); pct = 100; }
$('status').textContent = s;
$('openOut').hidden = S.busy || !lastOutput();
$('progressFill').style.width = pct + '%';
renderFiles();
}
let lastFile = null;
// fid: the file this line belongs to. When several files convert at once their lines interleave, so a short
// "· name" line marks each switch (a file's own first line "→ name" already says it)
// en: the English version of the line (null when there is none); both are kept so a language switch can redo the log
export function appendLog(msg, tag, fid, en) {
const log = $('log');
if (fid && fid !== lastFile && !msg.startsWith('→')) {
const f = S.files.find((x) => x.id === fid);
if (f) { const h = document.createElement('div'); h.className = 'file-mark'; h.textContent = '· ' + f.name; log.append(h); }
}
lastFile = fid || lastFile;
const line = document.createElement('div');
if (tag) line.className = tag;
line.dataset.zh = msg;
if (en) line.dataset.en = en;
line.textContent = pick(msg, en);
log.append(line);
while (log.childElementCount > 3000) log.firstElementChild.remove();
log.scrollTop = log.scrollHeight;
if (tag === 'err') { S.logErrors++; renderBadge(); }
}
// after a language switch
export function relocalizeLog() {
for (const line of $('log').children) if (line.dataset.zh !== undefined) line.textContent = pick(line.dataset.zh, line.dataset.en);
}
function renderBadge() { $('logBadge').hidden = !S.logErrors; $('logBadge').textContent = S.logErrors; }
$('logToggle').onclick = () => {
const open = $('log').hidden;
$('log').hidden = !open; $('logCard').classList.toggle('open', open);
$('logToggle').setAttribute('aria-expanded', open);
};
$('clearLog').onclick = () => { $('log').innerHTML = ''; S.logErrors = 0; renderBadge(); };