Browse Source

docs: fix ssr issue (#39825)

* docs: fix ssr issue

* docs: fix

* chore: code clean

* chore: update deps
pull/39930/head
MadCcc 2 years ago
committed by yoyo837
parent
commit
6056ba75b3
  1. 4
      .dumi/hooks/useMenu.tsx
  2. 2
      .dumi/loading.js
  3. 2
      .dumi/theme/common/Color/ColorPicker.tsx
  4. 11
      .dumi/theme/layouts/GlobalLayout.tsx
  5. 6
      docs/spec/data-list.en-US.md
  6. 3
      loading.js
  7. 2
      package.json

4
.dumi/hooks/useMenu.tsx

@ -59,7 +59,7 @@ const useMenu = (options: UseMenuOptions = {}): [MenuProps['items'], string] =>
}, {}); }, {});
const childItems = []; const childItems = [];
childItems.push( childItems.push(
...childrenGroup.default.map((item) => ({ ...(childrenGroup.default?.map((item) => ({
label: ( label: (
<Link to={`${item.link}${search}`}> <Link to={`${item.link}${search}`}>
{before} {before}
@ -68,7 +68,7 @@ const useMenu = (options: UseMenuOptions = {}): [MenuProps['items'], string] =>
</Link> </Link>
), ),
key: item.link.replace(/(-cn$)/g, ''), key: item.link.replace(/(-cn$)/g, ''),
})), })) ?? []),
); );
Object.entries(childrenGroup).forEach(([type, children]) => { Object.entries(childrenGroup).forEach(([type, children]) => {
if (type !== 'default') { if (type !== 'default') {

2
.dumi/loading.js

@ -0,0 +1,2 @@
// eslint-disable-next-line no-restricted-exports
export { default } from './theme/common/Loading';

2
.dumi/theme/common/Color/ColorPicker.tsx

@ -25,7 +25,7 @@ const ColorPicker: React.FC<ColorPickerProps> = (props) => {
const [displayColorPicker, setDisplayColorPicker] = useState<boolean>(false); const [displayColorPicker, setDisplayColorPicker] = useState<boolean>(false);
const handleClick = () => { const handleClick = () => {
setDisplayColorPicker(displayColorPicker); setDisplayColorPicker((prev) => !prev);
}; };
const handleClose = () => { const handleClose = () => {

11
.dumi/theme/layouts/GlobalLayout.tsx

@ -1,4 +1,4 @@
import React, { useCallback, useEffect, useMemo } from 'react'; import React, { startTransition, useCallback, useEffect, useMemo } from 'react';
import { createSearchParams, useOutlet, useSearchParams } from 'dumi'; import { createSearchParams, useOutlet, useSearchParams } from 'dumi';
import { ConfigProvider, theme as antdTheme } from 'antd'; import { ConfigProvider, theme as antdTheme } from 'antd';
import { createCache, StyleProvider } from '@ant-design/cssinjs'; import { createCache, StyleProvider } from '@ant-design/cssinjs';
@ -78,10 +78,13 @@ const GlobalLayout: React.FC = () => {
useEffect(() => { useEffect(() => {
const _theme = searchParams.getAll('theme') as ThemeName[]; const _theme = searchParams.getAll('theme') as ThemeName[];
const _direction = searchParams.get('direction') as DirectionType; const _direction = searchParams.get('direction') as DirectionType;
setSiteState({ theme: _theme, direction: _direction === 'rtl' ? 'rtl' : 'ltr' });
// Handle isMobile startTransition(() => {
updateMobileMode(); setSiteState({ theme: _theme, direction: _direction === 'rtl' ? 'rtl' : 'ltr' });
// Handle isMobile
updateMobileMode();
});
window.addEventListener('resize', updateMobileMode); window.addEventListener('resize', updateMobileMode);
return () => { return () => {
window.removeEventListener('resize', updateMobileMode); window.removeEventListener('resize', updateMobileMode);

6
docs/spec/data-list.en-US.md

@ -1,9 +1,9 @@
--- ---
group: 设计模式 group: Design Patterns
type: 全局规则 type: Global Rules
order: 7 order: 7
skip: true skip: true
title: 数据列表 title: Data List
--- ---
## 设计目标 ## 设计目标

3
loading.js

@ -1,3 +0,0 @@
// put it into `.dumi` folder when dumi ready
// eslint-disable-next-line no-restricted-exports
export { default } from './.dumi/theme/common/Loading';

2
package.json

@ -198,7 +198,7 @@
"cheerio": "1.0.0-rc.12", "cheerio": "1.0.0-rc.12",
"cross-env": "^7.0.0", "cross-env": "^7.0.0",
"dekko": "^0.2.1", "dekko": "^0.2.1",
"dumi": "^2.0.2", "dumi": "^2.0.17",
"duplicate-package-checker-webpack-plugin": "^3.0.0", "duplicate-package-checker-webpack-plugin": "^3.0.0",
"esbuild-loader": "^2.13.1", "esbuild-loader": "^2.13.1",
"eslint": "^8.0.0", "eslint": "^8.0.0",

Loading…
Cancel
Save