import React, { useContext } from 'react'; import type { IApiComponentProps} from 'dumi/theme'; import { context, useApiData, AnchorLink } from 'dumi/theme'; const LOCALE_TEXTS = { 'zh-CN': { name: '属性名', description: '描述', type: '类型', default: '默认值', required: '(必选)', }, 'en-US': { name: 'Name', description: 'Description', type: 'Type', default: 'Default', required: '(required)', }, }; export default ({ identifier, export: expt }: IApiComponentProps) => { const data = useApiData(identifier); const { locale } = useContext(context); const texts = /^zh|cn$/i.test(locale) ? LOCALE_TEXTS['zh-CN'] : LOCALE_TEXTS['en-US']; return ( <> {data && ( {data[expt].map(row => ( ))}
{texts.name} {texts.description} {texts.type} {texts.default}
{row.identifier} {row.description || '--'} {row.type} {row.default || (row.required && texts.required) || '--'}
)} ); };