@fle-ui/next 1.0.5-alpha.0 → 1.0.5-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/.history/.dumi/theme/Link_20211224151001.tsx +0 -0
- package/.history/.dumi/theme/Link_20211224151003.tsx +0 -8
- package/.history/.dumi/theme/Link_20211224151013.tsx +0 -64
- package/.history/.dumi/theme/Link_20211224151019.tsx +0 -64
- package/.history/.dumi/theme/Link_20211224151048.tsx +0 -66
- package/.history/.dumi/theme/Link_20211224151051.tsx +0 -66
- package/.history/.dumi/theme/Link_20211224151057.tsx +0 -66
- package/.history/.dumi/theme/Link_20211224151820.tsx +0 -66
- package/.history/.dumi/theme/NavLink_20211224150935.tsx +0 -0
- package/.history/.dumi/theme/NavLink_20211224150937.tsx +0 -8
- package/.history/.dumi/theme/NavLink_20211224150942.tsx +0 -4
- package/.history/.dumi/theme/builtins/Link_20211224153113.tsx +0 -66
- package/.history/.dumi/theme/builtins/Link_20211224153117.tsx +0 -66
- package/.history/.dumi/theme/builtins/Link_20211224153821.tsx +0 -65
- package/.history/.dumi/theme/builtins/Link_20211224153823.tsx +0 -73
- package/.history/.dumi/theme/builtins/Link_20211224153825.tsx +0 -65
- package/.history/.dumi/theme/builtins/NavLink_20211224153113.tsx +0 -4
- package/.history/.dumi/theme/builtins/NavLink_20211224153856.tsx +0 -4
- package/.history/.dumi/theme/builtins/NavLink_20211224153857.tsx +0 -12
- package/.history/.dumi/theme/builtins/NavLink_20211224154244.tsx +0 -12
- package/.history/.dumi/theme/builtins/NavLink_20211224154245.tsx +0 -12
- package/.history/.dumi/theme/context_20211224155924.ts +0 -0
- package/.history/.dumi/theme/context_20211224155926.ts +0 -8
- package/.history/.dumi/theme/context_20211224155942.ts +0 -136
- package/.history/.dumi/theme/layout_20211224155840.tsx +0 -0
- package/.history/.dumi/theme/layout_20211224155841.tsx +0 -8
- package/.history/.dumi/theme/layout_20211224155903.tsx +0 -176
- package/.history/.dumi/theme/layout_20211227133806.tsx +0 -8
- package/.history/.dumi/theme/layout_20211227134054.tsx +0 -23
- package/.history/.dumi/theme/layout_20211227134056.tsx +0 -24
- package/.history/.dumi/theme/layout_20211227134246.tsx +0 -26
- package/.history/.dumi/theme/layout_20211227141142.tsx +0 -26
- package/.history/.dumi/theme/layout_20211227161540.tsx +0 -26
- package/.history/.dumi/theme/layouyt_20211224160056.ts +0 -0
- package/.history/.dumi/theme/layouyt_20211224160058.ts +0 -8
- package/.history/.gitignore_20210922213827 +0 -27
- package/.history/.gitignore_20211029154108 +0 -29
- package/.history/.gitignore_20211029154109 +0 -29
- package/.history/.gitignore_20211029173434 +0 -29
- package/.history/.umirc_20211224102827.ts +0 -155
- package/.history/.umirc_20211224103050.ts +0 -155
- package/.history/.umirc_20211224142413.ts +0 -163
- package/.history/.umirc_20211224142930.ts +0 -159
- package/.history/.umirc_20211224142939.ts +0 -159
- package/.history/.umirc_20211224142940.ts +0 -159
- package/.history/package_20220223140434.json +0 -147
- package/.history/package_20220223140435.json +0 -147
- package/.history/report_20211228211733.html +0 -45
- package/.history/report_20211228211748.html +0 -37
- package/.history/report_20211228211749.html +0 -45
@@ -1,73 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* @Author: your name
|
3
|
-
* @Date: 2021-12-24 15:10:02
|
4
|
-
* @LastEditTime: 2021-12-24 15:38:22
|
5
|
-
* @LastEditors: your name
|
6
|
-
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
7
|
-
* @FilePath: /fle-ui-next/.dumi/theme/builtins/Link.tsx
|
8
|
-
*/
|
9
|
-
import React from 'react';
|
10
|
-
import { Link } from '@umijs/runtime';
|
11
|
-
import type { LinkProps, NavLinkProps } from 'react-router-dom';
|
12
|
-
|
13
|
-
/**
|
14
|
-
* Link component wrapper for render external link
|
15
|
-
* @param Component original Link component
|
16
|
-
*/
|
17
|
-
export const LinkWrapper = (Component: React.FC<LinkProps | NavLinkProps>) => {
|
18
|
-
return ({ to, ...props }: LinkProps | NavLinkProps) => {
|
19
|
-
|
20
|
-
const isExternal = /^(\w+:)?\/\/|^(mailto|tel):/.test(to as string) || !to;
|
21
|
-
const hasComplexChildren = React.isValidElement(props.children);
|
22
|
-
|
23
|
-
return (
|
24
|
-
<Component
|
25
|
-
to={(to as any) || ''}
|
26
|
-
component={
|
27
|
-
isExternal
|
28
|
-
? () => (
|
29
|
-
<a target="_blank" rel="noopener noreferrer" href={to as string}>
|
30
|
-
{props.children}
|
31
|
-
{to && !hasComplexChildren && (
|
32
|
-
<svg
|
33
|
-
xmlns="http://www.w3.org/2000/svg"
|
34
|
-
aria-hidden="true"
|
35
|
-
x="0px"
|
36
|
-
y="0px"
|
37
|
-
viewBox="0 0 100 100"
|
38
|
-
width="15"
|
39
|
-
height="15"
|
40
|
-
className="__dumi-default-external-link-icon"
|
41
|
-
>
|
42
|
-
<path
|
43
|
-
fill="currentColor"
|
44
|
-
d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"
|
45
|
-
/>
|
46
|
-
<polygon
|
47
|
-
fill="currentColor"
|
48
|
-
points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"
|
49
|
-
/>
|
50
|
-
</svg>
|
51
|
-
)}
|
52
|
-
</a>
|
53
|
-
)
|
54
|
-
: undefined
|
55
|
-
}
|
56
|
-
{...props}
|
57
|
-
{...(isExternal
|
58
|
-
? {}
|
59
|
-
: {
|
60
|
-
// scroll to top while change url
|
61
|
-
onClick(...args) {
|
62
|
-
window.scrollTo({
|
63
|
-
top: 0,
|
64
|
-
});
|
65
|
-
props.onClick?.apply(this, args);
|
66
|
-
},
|
67
|
-
})}
|
68
|
-
/>
|
69
|
-
);
|
70
|
-
};
|
71
|
-
};
|
72
|
-
|
73
|
-
export default LinkWrapper(Link);
|
@@ -1,65 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { Link } from '@umijs/runtime';
|
3
|
-
import type { LinkProps, NavLinkProps } from 'react-router-dom';
|
4
|
-
|
5
|
-
/**
|
6
|
-
* Link component wrapper for render external link
|
7
|
-
* @param Component original Link component
|
8
|
-
*/
|
9
|
-
export const LinkWrapper = (Component: React.FC<LinkProps | NavLinkProps>) => {
|
10
|
-
return ({ to, ...props }: LinkProps | NavLinkProps) => {
|
11
|
-
|
12
|
-
const isExternal = /^(\w+:)?\/\/|^(mailto|tel):/.test(to as string) || !to;
|
13
|
-
const hasComplexChildren = React.isValidElement(props.children);
|
14
|
-
|
15
|
-
return (
|
16
|
-
<Component
|
17
|
-
to={(to as any) || ''}
|
18
|
-
component={
|
19
|
-
isExternal
|
20
|
-
? () => (
|
21
|
-
<a target="_blank" rel="noopener noreferrer" href={to as string}>
|
22
|
-
{props.children}
|
23
|
-
{to && !hasComplexChildren && (
|
24
|
-
<svg
|
25
|
-
xmlns="http://www.w3.org/2000/svg"
|
26
|
-
aria-hidden="true"
|
27
|
-
x="0px"
|
28
|
-
y="0px"
|
29
|
-
viewBox="0 0 100 100"
|
30
|
-
width="15"
|
31
|
-
height="15"
|
32
|
-
className="__dumi-default-external-link-icon"
|
33
|
-
>
|
34
|
-
<path
|
35
|
-
fill="currentColor"
|
36
|
-
d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"
|
37
|
-
/>
|
38
|
-
<polygon
|
39
|
-
fill="currentColor"
|
40
|
-
points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"
|
41
|
-
/>
|
42
|
-
</svg>
|
43
|
-
)}
|
44
|
-
</a>
|
45
|
-
)
|
46
|
-
: undefined
|
47
|
-
}
|
48
|
-
{...props}
|
49
|
-
{...(isExternal
|
50
|
-
? {}
|
51
|
-
: {
|
52
|
-
// scroll to top while change url
|
53
|
-
onClick(...args) {
|
54
|
-
window.scrollTo({
|
55
|
-
top: 0,
|
56
|
-
});
|
57
|
-
props.onClick?.apply(this, args);
|
58
|
-
},
|
59
|
-
})}
|
60
|
-
/>
|
61
|
-
);
|
62
|
-
};
|
63
|
-
};
|
64
|
-
|
65
|
-
export default LinkWrapper(Link);
|
@@ -1,12 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* @Author: your name
|
3
|
-
* @Date: 2021-12-24 15:09:36
|
4
|
-
* @LastEditTime: 2021-12-24 15:38:57
|
5
|
-
* @LastEditors: your name
|
6
|
-
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
7
|
-
* @FilePath: /fle-ui-next/.dumi/theme/builtins/NavLink.tsx
|
8
|
-
*/
|
9
|
-
import { NavLink } from '@umijs/runtime';
|
10
|
-
import { LinkWrapper } from './Links';
|
11
|
-
|
12
|
-
export default LinkWrapper(NavLink);
|
@@ -1,12 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* @Author: your name
|
3
|
-
* @Date: 2021-12-24 15:09:36
|
4
|
-
* @LastEditTime: 2021-12-24 15:42:44
|
5
|
-
* @LastEditors: Please set LastEditors
|
6
|
-
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
7
|
-
* @FilePath: /fle-ui-next/.dumi/theme/builtins/NavLink.tsx
|
8
|
-
*/
|
9
|
-
import { NavLink } from '@umijs/runtime';
|
10
|
-
import { LinkWrapper } from './Link';
|
11
|
-
|
12
|
-
export default LinkWrapper(NavLink);
|
@@ -1,12 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* @Author: your name
|
3
|
-
* @Date: 2021-12-24 15:09:36
|
4
|
-
* @LastEditTime: 2021-12-24 15:42:44
|
5
|
-
* @LastEditors: Please set LastEditors
|
6
|
-
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
7
|
-
* @FilePath: /fle-ui-next/.dumi/theme/builtins/NavLink.tsx
|
8
|
-
*/
|
9
|
-
import { NavLink } from '@umijs/runtime';
|
10
|
-
import { LinkWrapper } from './Link';
|
11
|
-
|
12
|
-
export default LinkWrapper(NavLink);
|
File without changes
|
@@ -1,8 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* @Author: your name
|
3
|
-
* @Date: 2021-12-24 15:59:25
|
4
|
-
* @LastEditTime: 2021-12-24 15:59:26
|
5
|
-
* @LastEditors: Please set LastEditors
|
6
|
-
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
7
|
-
* @FilePath: /fle-ui-next/.dumi/theme/context.ts
|
8
|
-
*/
|
@@ -1,136 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import type { IConfig, IRoute } from '@umijs/types';
|
3
|
-
import type { INav } from '../routes/getNavFromRoutes';
|
4
|
-
import type { IMenu } from '../routes/getMenuFromRoutes';
|
5
|
-
import type { ILocale } from '../routes/getLocaleFromRoutes';
|
6
|
-
import type { IApiDefinition } from '../api-parser';
|
7
|
-
import type { IDumiOpts } from '..';
|
8
|
-
import type { IPreviewerComponentProps } from '.';
|
9
|
-
|
10
|
-
export interface IThemeContext {
|
11
|
-
/**
|
12
|
-
* documentation config
|
13
|
-
*/
|
14
|
-
config: {
|
15
|
-
/**
|
16
|
-
* mode type
|
17
|
-
*/
|
18
|
-
mode: 'doc' | 'site';
|
19
|
-
/**
|
20
|
-
* site title
|
21
|
-
*/
|
22
|
-
title: IDumiOpts['title'];
|
23
|
-
/**
|
24
|
-
* site description
|
25
|
-
*/
|
26
|
-
description?: IDumiOpts['description'];
|
27
|
-
/**
|
28
|
-
* documentation repository URL
|
29
|
-
*/
|
30
|
-
repository: {
|
31
|
-
url?: string;
|
32
|
-
branch: string;
|
33
|
-
platform?: string;
|
34
|
-
};
|
35
|
-
/**
|
36
|
-
* logo image URL
|
37
|
-
*/
|
38
|
-
logo?: IDumiOpts['logo'];
|
39
|
-
/**
|
40
|
-
* navigation configurations
|
41
|
-
*/
|
42
|
-
navs: INav;
|
43
|
-
/**
|
44
|
-
* sidemenu configurations
|
45
|
-
*/
|
46
|
-
menus: IMenu;
|
47
|
-
/**
|
48
|
-
* locale configurations
|
49
|
-
*/
|
50
|
-
locales: ILocale[];
|
51
|
-
/**
|
52
|
-
* algolia configurations
|
53
|
-
*/
|
54
|
-
algolia?: IDumiOpts['algolia'];
|
55
|
-
/**
|
56
|
-
* theme config
|
57
|
-
*/
|
58
|
-
theme: IDumiOpts['theme'];
|
59
|
-
/**
|
60
|
-
* configure how html is output
|
61
|
-
*/
|
62
|
-
exportStatic?: IConfig['exportStatic'];
|
63
|
-
};
|
64
|
-
/**
|
65
|
-
* the meta information of current route
|
66
|
-
*/
|
67
|
-
meta: {
|
68
|
-
/**
|
69
|
-
* page title
|
70
|
-
*/
|
71
|
-
title: string;
|
72
|
-
/**
|
73
|
-
* control sidemenu display
|
74
|
-
*/
|
75
|
-
sidemenu?: boolean;
|
76
|
-
/**
|
77
|
-
* control toc position in page
|
78
|
-
*/
|
79
|
-
toc?: false | 'content' | 'menu';
|
80
|
-
// TODO: https://d.umijs.org/config/frontmatter#markdown-%E6%94%AF%E6%8C%81%E7%9A%84-frontmatter-%E9%85%8D%E7%BD%AE%E9%A1%B9
|
81
|
-
[key: string]: any;
|
82
|
-
};
|
83
|
-
/**
|
84
|
-
* current locale
|
85
|
-
*/
|
86
|
-
locale?: string;
|
87
|
-
/**
|
88
|
-
* current menu
|
89
|
-
*/
|
90
|
-
menu: IMenu['locale']['path'];
|
91
|
-
/**
|
92
|
-
* current nav
|
93
|
-
*/
|
94
|
-
nav: INav['locale'];
|
95
|
-
/**
|
96
|
-
* base path
|
97
|
-
*/
|
98
|
-
base: string;
|
99
|
-
/**
|
100
|
-
* documentation routes
|
101
|
-
*/
|
102
|
-
routes: (IRoute & { meta: any })[];
|
103
|
-
/**
|
104
|
-
* all demos data
|
105
|
-
*/
|
106
|
-
demos: Record<
|
107
|
-
string,
|
108
|
-
{
|
109
|
-
component: React.ComponentType;
|
110
|
-
previewerProps: IPreviewerComponentProps;
|
111
|
-
}
|
112
|
-
>;
|
113
|
-
/**
|
114
|
-
* all parsed api data
|
115
|
-
*/
|
116
|
-
apis: Record<string, IApiDefinition>;
|
117
|
-
}
|
118
|
-
|
119
|
-
export default React.createContext<IThemeContext>({
|
120
|
-
config: {
|
121
|
-
mode: 'doc',
|
122
|
-
title: '',
|
123
|
-
navs: {},
|
124
|
-
menus: {},
|
125
|
-
locales: [],
|
126
|
-
repository: { branch: 'master' },
|
127
|
-
theme: {},
|
128
|
-
},
|
129
|
-
meta: { title: '' },
|
130
|
-
menu: [],
|
131
|
-
nav: [],
|
132
|
-
base: '',
|
133
|
-
routes: [],
|
134
|
-
apis: {},
|
135
|
-
demos: {},
|
136
|
-
});
|
File without changes
|
@@ -1,8 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* @Author: your name
|
3
|
-
* @Date: 2021-12-24 15:58:41
|
4
|
-
* @LastEditTime: 2021-12-24 15:58:41
|
5
|
-
* @LastEditors: Please set LastEditors
|
6
|
-
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
7
|
-
* @FilePath: /fle-ui-next/.dumi/theme/layout.tsx
|
8
|
-
*/
|
@@ -1,176 +0,0 @@
|
|
1
|
-
import React, { useLayoutEffect, useState } from 'react';
|
2
|
-
import Context from './context';
|
3
|
-
import type { IRouteProps, IRouteComponentProps } from '@umijs/types';
|
4
|
-
import type { IThemeContext } from './context';
|
5
|
-
import type { IMenu } from '../routes/getMenuFromRoutes';
|
6
|
-
|
7
|
-
export interface IOuterLayoutProps {
|
8
|
-
routes: IThemeContext['routes'];
|
9
|
-
config: IThemeContext['config'];
|
10
|
-
apis: IThemeContext['apis'];
|
11
|
-
demos: IThemeContext['demos'];
|
12
|
-
}
|
13
|
-
|
14
|
-
/**
|
15
|
-
* hooks for get meta data of current route
|
16
|
-
* @param routes project route configurations
|
17
|
-
* @param pathname pathname of location
|
18
|
-
*/
|
19
|
-
const useCurrentRouteMeta = (routes: IOuterLayoutProps['routes'], pathname: string) => {
|
20
|
-
const handler = (...args: [IOuterLayoutProps['routes'], string]) => {
|
21
|
-
const pathWithoutSuffix = args[1].replace(/([^^])\/$/, '$1');
|
22
|
-
|
23
|
-
return {
|
24
|
-
...(args[0].find(({ path }) => path === pathWithoutSuffix)?.meta || {}),
|
25
|
-
__pathname: pathname,
|
26
|
-
};
|
27
|
-
};
|
28
|
-
const [meta, setMeta] = useState<IThemeContext['meta']>(handler(routes, pathname));
|
29
|
-
|
30
|
-
useLayoutEffect(() => {
|
31
|
-
setMeta(handler(routes, pathname));
|
32
|
-
}, [pathname]);
|
33
|
-
|
34
|
-
return meta;
|
35
|
-
};
|
36
|
-
|
37
|
-
/**
|
38
|
-
* hooks for get locale from current route
|
39
|
-
* @param locales project locale configurations
|
40
|
-
* @param pathname pathname of location
|
41
|
-
*/
|
42
|
-
const useCurrentLocale = (locales: IThemeContext['config']['locales'], pathname: string) => {
|
43
|
-
const handler = (...args: [IThemeContext['config']['locales'], string]) => {
|
44
|
-
// get locale by route prefix
|
45
|
-
return (
|
46
|
-
args[0].find(locale => new RegExp(`/${locale.name}(/|$)`).test(args[1]))?.name ||
|
47
|
-
locales[0].name
|
48
|
-
);
|
49
|
-
};
|
50
|
-
const [locale, setLocale] = useState<string>(handler(locales, pathname));
|
51
|
-
|
52
|
-
useLayoutEffect(() => {
|
53
|
-
setLocale(handler(locales, pathname));
|
54
|
-
}, [pathname]);
|
55
|
-
|
56
|
-
return locale;
|
57
|
-
};
|
58
|
-
|
59
|
-
/**
|
60
|
-
* hooks for get menu data of current route
|
61
|
-
* @param ctxConfig context config
|
62
|
-
* @param locale locale from current route
|
63
|
-
* @param pathname pathname of location
|
64
|
-
*/
|
65
|
-
const useCurrentMenu = (ctxConfig: IThemeContext['config'], locale: string, pathname: string) => {
|
66
|
-
const handler = (...args: [IThemeContext['config'], string, string]) => {
|
67
|
-
const navs = args[0].navs[args[1]] || [];
|
68
|
-
let navPath = '*';
|
69
|
-
|
70
|
-
// find nav in reverse way to fallback to the first nav
|
71
|
-
for (let i = navs.length - 1; i >= 0; i -= 1) {
|
72
|
-
const nav = navs[i];
|
73
|
-
const items = [nav].concat(nav.children).filter(Boolean);
|
74
|
-
const matched = items.find(
|
75
|
-
item =>
|
76
|
-
item.path && new RegExp(`^${item.path.replace(/\.html$/, '')}(/|\.|$)`).test(args[2]),
|
77
|
-
);
|
78
|
-
|
79
|
-
if (matched) {
|
80
|
-
navPath = matched.path;
|
81
|
-
break;
|
82
|
-
}
|
83
|
-
}
|
84
|
-
|
85
|
-
return args[0].menus[args[1]]?.[navPath] || [];
|
86
|
-
};
|
87
|
-
const [menu, setMenu] = useState<IMenu['locale']['path']>(handler(ctxConfig, locale, pathname));
|
88
|
-
|
89
|
-
useLayoutEffect(() => {
|
90
|
-
setMenu(handler(ctxConfig, locale, pathname));
|
91
|
-
}, [ctxConfig.navs, ctxConfig.menus, locale, pathname]);
|
92
|
-
|
93
|
-
return menu;
|
94
|
-
};
|
95
|
-
|
96
|
-
/**
|
97
|
-
* hooks for doc base route path
|
98
|
-
* @param locale current locale
|
99
|
-
* @param locales project locale configurations
|
100
|
-
* @param route layout route configurations
|
101
|
-
* @note handle these points:
|
102
|
-
* 1. locale prefix, such as empty or /zh-CN
|
103
|
-
* 2. integrate mode route prefix, such as /~docs or /~docs/zh-CN
|
104
|
-
*/
|
105
|
-
const useCurrentBase = (
|
106
|
-
locale: string,
|
107
|
-
locales: IThemeContext['config']['locales'],
|
108
|
-
route: IRouteProps,
|
109
|
-
) => {
|
110
|
-
const handler = (...args: [string, IThemeContext['config']['locales'], IRouteProps]) => {
|
111
|
-
if (args[0] === args[1][0].name) {
|
112
|
-
// use layout route path as base in default locale
|
113
|
-
return args[2].path;
|
114
|
-
}
|
115
|
-
|
116
|
-
// join layout route path & locale prefix in other locale
|
117
|
-
return `${route.path}/${locale}`.replace(/\/\//, '/');
|
118
|
-
};
|
119
|
-
const [base, setBase] = useState<string>(handler(locale, locales, route));
|
120
|
-
|
121
|
-
useLayoutEffect(() => {
|
122
|
-
setBase(handler(locale, locales, route));
|
123
|
-
}, [locale]);
|
124
|
-
|
125
|
-
return base;
|
126
|
-
};
|
127
|
-
|
128
|
-
const findDumiRoot = (routes: any): IThemeContext['routes'] => {
|
129
|
-
return routes.find(item => {
|
130
|
-
if (item.__dumiRoot) {
|
131
|
-
return true;
|
132
|
-
}
|
133
|
-
if (item.routes) {
|
134
|
-
return findDumiRoot(item.routes);
|
135
|
-
}
|
136
|
-
return false;
|
137
|
-
})?.routes;
|
138
|
-
};
|
139
|
-
|
140
|
-
/**
|
141
|
-
* outer theme layout
|
142
|
-
*/
|
143
|
-
const OuterLayout: React.FC<IOuterLayoutProps & IRouteComponentProps> = props => {
|
144
|
-
const { location, route, children, config, apis, demos } = props;
|
145
|
-
const pathWithoutPrefix = location.pathname.replace(
|
146
|
-
// to avoid stripped the first /
|
147
|
-
route.path.replace(/^\/$/, '//'),
|
148
|
-
'',
|
149
|
-
);
|
150
|
-
const routes = findDumiRoot(props.routes) || [];
|
151
|
-
const meta = useCurrentRouteMeta(routes, location.pathname);
|
152
|
-
// use non-prefix for detect current locale, such as /~docs/en-US -> /en-US
|
153
|
-
const locale = useCurrentLocale(config.locales, pathWithoutPrefix);
|
154
|
-
const menu = useCurrentMenu(config, locale, location.pathname);
|
155
|
-
const base = useCurrentBase(locale, config.locales, route);
|
156
|
-
|
157
|
-
return (
|
158
|
-
<Context.Provider
|
159
|
-
value={{
|
160
|
-
config,
|
161
|
-
meta: meta.__pathname === location.pathname ? meta : ({} as any),
|
162
|
-
locale,
|
163
|
-
nav: config.navs[locale] || [],
|
164
|
-
menu,
|
165
|
-
base,
|
166
|
-
routes,
|
167
|
-
apis,
|
168
|
-
demos,
|
169
|
-
}}
|
170
|
-
>
|
171
|
-
{children}
|
172
|
-
</Context.Provider>
|
173
|
-
);
|
174
|
-
};
|
175
|
-
|
176
|
-
export default OuterLayout;
|
@@ -1,8 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* @Author: your name
|
3
|
-
* @Date: 2021-12-27 13:38:05
|
4
|
-
* @LastEditTime: 2021-12-27 13:38:06
|
5
|
-
* @LastEditors: Please set LastEditors
|
6
|
-
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
7
|
-
* @FilePath: /fle-ui-next/.dumi/theme/layout.tsx
|
8
|
-
*/
|
@@ -1,23 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* @Author: your name
|
3
|
-
* @Date: 2021-12-27 13:38:05
|
4
|
-
* @LastEditTime: 2021-12-27 13:40:54
|
5
|
-
* @LastEditors: your name
|
6
|
-
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
7
|
-
* @FilePath: /fle-ui-next/.dumi/theme/layout.tsx
|
8
|
-
*/
|
9
|
-
import React from 'react';
|
10
|
-
import Layout from 'dumi-theme-default/src/layout';
|
11
|
-
|
12
|
-
const LayoutPage = ({ children, ...props }: any) => {
|
13
|
-
|
14
|
-
return (
|
15
|
-
<Layout {...props}>
|
16
|
-
<div>
|
17
|
-
<div key="children">{children}</div>
|
18
|
-
</div>
|
19
|
-
</Layout>
|
20
|
-
);
|
21
|
-
};
|
22
|
-
|
23
|
-
export default LayoutPage;
|
@@ -1,24 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* @Author: your name
|
3
|
-
* @Date: 2021-12-27 13:38:05
|
4
|
-
* @LastEditTime: 2021-12-27 13:40:54
|
5
|
-
* @LastEditors: your name
|
6
|
-
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
7
|
-
* @FilePath: /fle-ui-next/.dumi/theme/layout.tsx
|
8
|
-
*/
|
9
|
-
|
10
|
-
import React from 'react';
|
11
|
-
import Layout from 'dumi-theme-default/src/layout';
|
12
|
-
|
13
|
-
const LayoutPage = ({ children, ...props }: any) => {
|
14
|
-
|
15
|
-
return (
|
16
|
-
<Layout {...props}>
|
17
|
-
<div>
|
18
|
-
<div key="children">{children}</div>
|
19
|
-
</div>
|
20
|
-
</Layout>
|
21
|
-
);
|
22
|
-
};
|
23
|
-
|
24
|
-
export default LayoutPage;
|
@@ -1,26 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* @Author: your name
|
3
|
-
* @Date: 2021-12-27 13:38:05
|
4
|
-
* @LastEditTime: 2021-12-27 13:42:46
|
5
|
-
* @LastEditors: Please set LastEditors
|
6
|
-
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
7
|
-
* @FilePath: /fle-ui-next/.dumi/theme/layout.tsx
|
8
|
-
*/
|
9
|
-
|
10
|
-
import React from 'react';
|
11
|
-
import Layout from 'dumi-theme-default/src/layout';
|
12
|
-
|
13
|
-
const LayoutPage = ({ children, ...props }: any) => {
|
14
|
-
|
15
|
-
console.log('tet');
|
16
|
-
|
17
|
-
return (
|
18
|
-
<Layout {...props}>
|
19
|
-
<div>
|
20
|
-
<div key="children">{children}</div>
|
21
|
-
</div>
|
22
|
-
</Layout>
|
23
|
-
);
|
24
|
-
};
|
25
|
-
|
26
|
-
export default LayoutPage;
|
@@ -1,26 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* @Author: your name
|
3
|
-
* @Date: 2021-12-27 13:38:05
|
4
|
-
* @LastEditTime: 2021-12-27 14:11:42
|
5
|
-
* @LastEditors: Please set LastEditors
|
6
|
-
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
7
|
-
* @FilePath: /fle-ui-next/.dumi/theme/layout.tsx
|
8
|
-
*/
|
9
|
-
|
10
|
-
import React from 'react';
|
11
|
-
import Layout from 'dumi-theme-default/src/layout';
|
12
|
-
|
13
|
-
const LayoutPage = ({ children, ...props }: any) => {
|
14
|
-
|
15
|
-
console.log('tet11111');
|
16
|
-
|
17
|
-
return (
|
18
|
-
<Layout {...props}>
|
19
|
-
<div>
|
20
|
-
<div key="children">{children}</div>
|
21
|
-
</div>
|
22
|
-
</Layout>
|
23
|
-
);
|
24
|
-
};
|
25
|
-
|
26
|
-
export default LayoutPage;
|
@@ -1,26 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* @Author: your name
|
3
|
-
* @Date: 2021-12-27 13:38:05
|
4
|
-
* @LastEditTime: 2021-12-27 16:15:40
|
5
|
-
* @LastEditors: Please set LastEditors
|
6
|
-
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
7
|
-
* @FilePath: /fle-ui-next/.dumi/theme/layout.tsx
|
8
|
-
*/
|
9
|
-
|
10
|
-
import React from 'react';
|
11
|
-
import Layout from 'dumi-theme-default/src/layout';
|
12
|
-
|
13
|
-
const LayoutPage = ({ children, ...props }: any) => {
|
14
|
-
|
15
|
-
console.log('tet11111');
|
16
|
-
|
17
|
-
return (
|
18
|
-
<Layout {...props}>
|
19
|
-
<div>
|
20
|
-
<div key="children">{children}</div>
|
21
|
-
</div>
|
22
|
-
</Layout>
|
23
|
-
);
|
24
|
-
};
|
25
|
-
|
26
|
-
export default LayoutPage;
|
File without changes
|
@@ -1,8 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* @Author: your name
|
3
|
-
* @Date: 2021-12-24 16:00:57
|
4
|
-
* @LastEditTime: 2021-12-24 16:00:58
|
5
|
-
* @LastEditors: Please set LastEditors
|
6
|
-
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
7
|
-
* @FilePath: /fle-ui-next/.dumi/theme/layouyt.ts
|
8
|
-
*/
|