chore(audit): admin 暗黑模式影响探针(决策点 1 取证)

- admin 12 个 tsx 零 bg-white、零硬编码灰黑,全部项目 token
- 登录页深/浅双版渲染干净、0 控制台报错
- 登录墙内工作台待有凭据后视觉 QA
This commit is contained in:
2026-09-20 11:50:58 +08:00
parent 0bd1e9a7e2
commit 7a9e4d56cd
+47
View File
@@ -0,0 +1,47 @@
// admin 暗黑模式影响探针:默认值改为「跟随系统」后,admin 区域(bg-white 密集)
// 会随 OS 偏好变暗 —— 这是悬置决策点「admin 是否参与暗黑模式」的新触发条件。
// 本探针只取证不修复:OS=dark 下 admin/login 与 admin 主框架的渲染状态。
//
// 用法:node scripts/audit/theme-admin-dark-probe.mjs (需 dev server 在 localhost:3000
import { chromium } from 'playwright';
import { mkdirSync, writeFileSync } from 'node:fs';
const BASE = 'http://localhost:3000';
const OUT = 'dogfood-output/theme-admin-dark-probe';
mkdirSync(OUT, { recursive: true });
const browser = await chromium.launch({ args: ['--no-proxy-server'] });
const findings = [];
for (const scheme of ['dark', 'light']) {
for (const route of ['/admin/login', '/admin']) {
const ctx = await browser.newContext({ colorScheme: scheme, viewport: { width: 1440, height: 900 } });
const page = await ctx.newPage();
const errors = [];
page.on('console', (m) => { if (m.type() === 'error') errors.push(m.text()); });
page.on('pageerror', (e) => errors.push('PAGEERROR: ' + e.message));
const resp = await page.goto(BASE + route, { waitUntil: 'networkidle', timeout: 30000 }).catch(() => null);
const status = resp ? resp.status() : 'goto-failed';
const probe = await page.evaluate(() => ({
dataTheme: document.documentElement.getAttribute('data-theme'),
bodyBg: getComputedStyle(document.body).backgroundColor,
title: document.title.slice(0, 40),
hasLoginForm: Boolean(document.querySelector('input[type="password"]')),
h1: document.querySelector('h1')?.textContent?.slice(0, 30) ?? null,
})).catch((e) => ({ probeError: String(e) }));
const file = `${OUT}/admin${route === '/admin' ? '-home' : '-login'}-${scheme}.png`;
await page.screenshot({ path: file }).catch(() => {});
await ctx.close();
findings.push({ scheme, route, status, ...probe, consoleErrors: errors, screenshot: file });
console.log(`OS=${scheme} ${route} → status=${status} data-theme=${probe.dataTheme} bodyBg=${probe.bodyBg} errors=${errors.length}`);
}
}
await browser.close();
writeFileSync(`${OUT}/admin-dark-probe.json`, JSON.stringify(findings, null, 2));
console.log(`\n产物:${OUT}/`);