|
|
@ -1,12 +1,25 @@
|
|
|
|
import React, { useMemo } from 'react';
|
|
|
|
import React, { useMemo } from 'react';
|
|
|
|
import type { MenuProps } from 'antd';
|
|
|
|
import type { MenuProps } from 'antd';
|
|
|
|
import { Tag, version } from 'antd';
|
|
|
|
import { Tag, version } from 'antd';
|
|
|
|
|
|
|
|
import { createStyles } from 'antd-style';
|
|
|
|
|
|
|
|
import classnames from 'classnames';
|
|
|
|
import { useFullSidebarData, useSidebarData } from 'dumi';
|
|
|
|
import { useFullSidebarData, useSidebarData } from 'dumi';
|
|
|
|
|
|
|
|
|
|
|
|
import Link from '../theme/common/Link';
|
|
|
|
import Link from '../theme/common/Link';
|
|
|
|
import useLocation from './useLocation';
|
|
|
|
import useLocation from './useLocation';
|
|
|
|
|
|
|
|
|
|
|
|
const MenuItemLabelWithTag: React.FC<{
|
|
|
|
const useStyle = createStyles(({ css }) => ({
|
|
|
|
|
|
|
|
link: css`
|
|
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
|
|
`,
|
|
|
|
|
|
|
|
tag: css`
|
|
|
|
|
|
|
|
margin-inline-end: 0;
|
|
|
|
|
|
|
|
`,
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface MenuItemLabelProps {
|
|
|
|
before?: React.ReactNode;
|
|
|
|
before?: React.ReactNode;
|
|
|
|
after?: React.ReactNode;
|
|
|
|
after?: React.ReactNode;
|
|
|
|
link: string;
|
|
|
|
link: string;
|
|
|
@ -15,18 +28,14 @@ const MenuItemLabelWithTag: React.FC<{
|
|
|
|
search?: string;
|
|
|
|
search?: string;
|
|
|
|
tag?: string;
|
|
|
|
tag?: string;
|
|
|
|
className?: string;
|
|
|
|
className?: string;
|
|
|
|
}> = ({ before, after, link, title, subtitle, search, tag = '', className }) => {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const MenuItemLabelWithTag: React.FC<MenuItemLabelProps> = (props) => {
|
|
|
|
|
|
|
|
const { styles } = useStyle();
|
|
|
|
|
|
|
|
const { before, after, link, title, subtitle, search, tag, className } = props;
|
|
|
|
if (!before && !after) {
|
|
|
|
if (!before && !after) {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Link
|
|
|
|
<Link to={`${link}${search}`} className={classnames(className, { [styles.link]: tag })}>
|
|
|
|
to={`${link}${search}`}
|
|
|
|
|
|
|
|
style={
|
|
|
|
|
|
|
|
tag
|
|
|
|
|
|
|
|
? { display: 'flex', alignItems: 'center', justifyContent: 'space-between' }
|
|
|
|
|
|
|
|
: undefined
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
className={className}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<span>
|
|
|
|
<span>
|
|
|
|
{title}
|
|
|
|
{title}
|
|
|
|
{subtitle && <span className="chinese">{subtitle}</span>}
|
|
|
|
{subtitle && <span className="chinese">{subtitle}</span>}
|
|
|
@ -34,8 +43,8 @@ const MenuItemLabelWithTag: React.FC<{
|
|
|
|
{tag && (
|
|
|
|
{tag && (
|
|
|
|
<Tag
|
|
|
|
<Tag
|
|
|
|
bordered={false}
|
|
|
|
bordered={false}
|
|
|
|
color={tag === 'New' ? 'success' : 'processing'}
|
|
|
|
className={classnames(styles.tag)}
|
|
|
|
style={{ marginBlockEnd: 0 }}
|
|
|
|
color={tag.startsWith('5.') || tag === 'New' ? 'success' : 'processing'}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
{tag.replace('VERSION', version)}
|
|
|
|
{tag.replace('VERSION', version)}
|
|
|
|
</Tag>
|
|
|
|
</Tag>
|
|
|
|