From 7c1d913f49d7a50c8c3b5f7bc1a562b8d154a960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E7=88=B1=E5=90=83=E7=99=BD=E8=90=9D?= =?UTF-8?q?=E5=8D=9C?= Date: Thu, 27 Jul 2023 16:22:53 +0800 Subject: [PATCH] docs: antd component export by page level (#43762) * chore: init for clean * docs: comment * chore: ping * fix: lint * chore: clean up --- .dumi/theme/layouts/GlobalLayout.tsx | 17 +++++++--- .dumi/theme/plugin.ts | 50 +++++++++++++++++++--------- CHANGELOG.en-US.md | 1 - 3 files changed, 48 insertions(+), 20 deletions(-) diff --git a/.dumi/theme/layouts/GlobalLayout.tsx b/.dumi/theme/layouts/GlobalLayout.tsx index 2b46f9f980..bb3c64f02f 100644 --- a/.dumi/theme/layouts/GlobalLayout.tsx +++ b/.dumi/theme/layouts/GlobalLayout.tsx @@ -4,10 +4,12 @@ import { logicalPropertiesLinter, parentSelectorLinter, StyleProvider, + extractStyle, } from '@ant-design/cssinjs'; import { App, theme as antdTheme } from 'antd'; import type { DirectionType } from 'antd/es/config-provider'; import { createSearchParams, useOutlet, useSearchParams } from 'dumi'; +import { useServerInsertedHTML } from 'umi'; import React, { useCallback, useEffect, useMemo } from 'react'; import useLayoutState from '../../hooks/useLayoutState'; import SiteThemeProvider from '../SiteThemeProvider'; @@ -22,10 +24,10 @@ type SiteState = Partial>; const RESPONSIVE_MOBILE = 768; -const styleCache = createCache(); -if (typeof global !== 'undefined') { - (global as any).styleCache = styleCache; -} +// const styleCache = createCache(); +// if (typeof global !== 'undefined') { +// (global as any).styleCache = styleCache; +// } const getAlgorithm = (themes: ThemeName[] = []) => themes.map((theme) => { @@ -107,6 +109,13 @@ const GlobalLayout: React.FC = () => { [isMobile, direction, updateSiteConfig, theme], ); + const [styleCache] = React.useState(() => createCache()); + + useServerInsertedHTML(() => { + const styleText = extractStyle(styleCache, true); + return