@@ -3,6 +3,7 @@ import { theme as antdTheme, ConfigProvider } from 'antd';
33import type { ThemeConfig } from 'antd' ;
44import type { ThemeProviderProps } from 'antd-style' ;
55import { ThemeProvider } from 'antd-style' ;
6+ import { updateCSS } from 'rc-util/lib/Dom/dynamicCSS' ;
67
78import SiteContext from './slots/SiteContext' ;
89
@@ -41,6 +42,24 @@ const SiteThemeProvider: React.FC<ThemeProviderProps<any>> = ({ children, theme,
4142 ConfigProvider . config ( { theme : theme as ThemeConfig } ) ;
4243 } , [ theme ] ) ;
4344
45+ React . useEffect ( ( ) => {
46+ // iframe demo 生效
47+ if ( window . parent !== window ) {
48+ updateCSS (
49+ `
50+ [data-prefers-color='dark'] {
51+ color-scheme: dark !important;
52+ }
53+
54+ [data-prefers-color='light'] {
55+ color-scheme: light !important;
56+ }
57+ ` ,
58+ 'color-scheme' ,
59+ ) ;
60+ }
61+ } , [ theme ] ) ;
62+
4463 return (
4564 < ThemeProvider < NewToken >
4665 { ...rest }
@@ -51,7 +70,7 @@ const SiteThemeProvider: React.FC<ThemeProviderProps<any>> = ({ children, theme,
5170 menuItemBorder : 2 ,
5271 mobileMaxWidth : 767.99 ,
5372 siteMarkdownCodeBg : token . colorFillTertiary ,
54- siteMarkdownCodeBgDark : " #000" ,
73+ siteMarkdownCodeBgDark : ' #000' ,
5574 antCls : `.${ rootPrefixCls } ` ,
5675 iconCls : `.${ iconPrefixCls } ` ,
5776 /** 56 */
0 commit comments