v0.16.1: 修复后台整体不可交互(node:fs 被客户端外置化报错,image-variant 改惰性获取)、字号再放大一号(15→16)、修复深色主题被烘焙 CSS 反盖(:where 降级变量块特异性)、antd v6 弃用 API 清理(Space direction→orientation/Drawer width→size)、仪表盘菜单标签改中文源串

This commit is contained in:
bigcode
2026-11-05 02:23:28 +08:00
parent a018019504
commit 1cefdecfe0
12 changed files with 30 additions and 21 deletions
+10 -4
View File
@@ -51,7 +51,7 @@ import { createCache, StyleProvider, extractStyle } from "@ant-design/cssinjs";
/** # 成员变量 与 admin.tsx 完全一致的主题配置(改动后必须重新烘焙)
* cssVar.key 固定为 "dusun":变量作用域类名确定,烘焙 CSS 与运行时 DOM 一致 **/
const THEME = { token: { colorPrimary: "#1677ff", fontSize: 15 }, cssVar: { key: "dusun" } };
const THEME = { token: { colorPrimary: "#1677ff", fontSize: 16 }, cssVar: { key: "dusun" } };
/** # 组件 覆盖后台全部 AntD 组件的样例树(每个组件至少渲染一次以注册其样式) **/
function Showcase() {
@@ -194,11 +194,17 @@ renderToString(
<Showcase />
</StyleProvider>,
);
const css = extractStyle(cache, { plain: true }) as string;
if (!css || css.length < 10000 || !css.includes(".ant-btn")) {
console.error("提取结果异常,中止写入。length:", css?.length);
const rawCss = extractStyle(cache, { plain: true }) as string;
if (!rawCss || rawCss.length < 10000 || !rawCss.includes(".ant-btn")) {
console.error("提取结果异常,中止写入。length:", rawCss?.length);
process.exit(1);
}
// 变量作用域块 .dusun{--ant-*} 降为零特异性 :where(.dusun):
// 运行时切深色时 cssinjs 重新注入的 .dusun 变量块(0,1,0)必须能覆盖烘焙 <link>
// 里的浅色变量(<link> 在 DOM 中晚于运行时 <style>,同特异性会反盖回去)。
// :where() 特异性为 0,仅剩烘焙块时(SSR 首屏)仍正常生效。
const css = rawCss.replace(/\.dusun\{/g, ":where(.dusun){");
console.log("var scope blocks downgraded:", (rawCss.match(/\.dusun\{/g) ?? []).length);
mkdirSync(new URL("../public/", import.meta.url), { recursive: true });
const out = new URL("../public/antd-baked.css", import.meta.url);
writeFileSync(out, `/* 本文件由 scripts/gen-antd-css.tsx 生成(AntD SSR 静态样式,防首屏闪烁),请勿手改 */\n${css}\n`);