iter(g250): 新增动效兜底门禁,补上转圈与不确定进度的减少动效降级
This commit is contained in:
@@ -7,6 +7,7 @@ import { spawnSync } from 'node:child_process';
|
||||
import { visualAudit } from '../lib/visual-audit.mjs';
|
||||
import { auditContrast, formatReport, PAIRS } from '../lib/contrast-audit.mjs';
|
||||
import { shellPalette } from '../lib/shell-palette.mjs';
|
||||
import { auditMotion, formatMotionReport } from '../lib/motion-audit.mjs';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
@@ -1625,6 +1626,25 @@ function cmdAuditContrast(args) {
|
||||
process.exit(result.failures.length === 0 ? 0 : 1);
|
||||
}
|
||||
|
||||
/*** 动效兜底审计:带 infinite 的动画必须在 prefers-reduced-motion 下被显式关掉(--json 出明细)
|
||||
* 只盯无限循环动画:有限时长的过渡不会持续刺激,把它也纳入只会让门禁变吵而没人看。
|
||||
*/
|
||||
function cmdAuditMotion(args) {
|
||||
let result;
|
||||
try {
|
||||
result = auditMotion(ROOT);
|
||||
} catch (err) {
|
||||
console.error(`audit:motion 失败:${err.message}`);
|
||||
process.exit(1);
|
||||
}
|
||||
if (args.includes('--json')) {
|
||||
console.log(JSON.stringify({ ok: result.gaps.length === 0, total: result.total, failing: result.gaps.length, entries: result.entries }, null, 2));
|
||||
} else {
|
||||
console.log(formatMotionReport(result));
|
||||
}
|
||||
process.exit(result.gaps.length === 0 ? 0 : 1);
|
||||
}
|
||||
|
||||
/*** 迭代留痕校验:.ua/iterations.log 每行 JSON 字段与格式必须符合 ITERATION.md 规范 ***/
|
||||
function cmdLintIterations() {
|
||||
const file = path.join(INDEX_DIR, 'iterations.log');
|
||||
@@ -1722,7 +1742,7 @@ function cmdDoctor() {
|
||||
detail: [missingInUsage.length ? `usage 缺 ${missingInUsage.join('/')}` : '', missingInCode.length ? `实现缺 ${missingInCode.join('/')}` : ''].filter(Boolean).join(';'),
|
||||
});
|
||||
// 门禁链自检:package.json 的 check 必须跑齐所有门禁步骤(新增门禁忘了接进链等于没加)
|
||||
const needSteps = ['build', 'demo', 'style', 'typecheck', 'smoke', 'index', 'verify', 'lint-iterations', 'audit:visual', 'audit:contrast'];
|
||||
const needSteps = ['build', 'demo', 'style', 'typecheck', 'smoke', 'index', 'verify', 'lint-iterations', 'audit:visual', 'audit:contrast', 'audit:motion'];
|
||||
const chain = String(JSON.parse(fs.readFileSync(path.join(ROOT, 'package.json'), 'utf8')).scripts?.check ?? '');
|
||||
const lacking = needSteps.filter((step) => !chain.includes(`npm run ${step}`));
|
||||
checks.push({ name: 'check 链覆盖全部门禁步骤', pass: !lacking.length, detail: lacking.length ? `缺 ${lacking.join(' / ')}` : '' });
|
||||
@@ -1798,10 +1818,13 @@ switch (cmd) {
|
||||
case 'audit:contrast':
|
||||
cmdAuditContrast(args);
|
||||
break;
|
||||
case 'audit:motion':
|
||||
cmdAuditMotion(args);
|
||||
break;
|
||||
case 'mcp':
|
||||
cmdMcp();
|
||||
break;
|
||||
default:
|
||||
console.log('usage: ua <index|list|search <kw>|info <name> [--json|--md]|recipes [编号] [--json]|docs|tokens [--json]|style|sync-counts|verify|doctor|commit-lint|lint-iterations|audit:visual [--json|--baseline]|audit:contrast [--json|--list]|changelog|mcp>');
|
||||
console.log('usage: ua <index|list|search <kw>|info <name> [--json|--md]|recipes [编号] [--json]|docs|tokens [--json]|style|sync-counts|verify|doctor|commit-lint|lint-iterations|audit:visual [--json|--baseline]|audit:contrast [--json|--list]|audit:motion [--json]|changelog|mcp>');
|
||||
process.exit(cmd ? 1 : 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user