'use client' import type { ReactNode } from 'react' import type { PluginDetail } from '../types' import { useTranslation } from 'react-i18next' import Loading from '@/app/components/base/loading' import { Markdown } from '@/app/components/base/markdown' import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks' import { usePluginReadme } from '@/service/use-plugins' import DetailHeader from '../plugin-detail-panel/detail-header' type ReadmePanelContentProps = { detail: PluginDetail title: ReactNode closeButton: ReactNode } export function ReadmePanelContent({ detail, title, closeButton, }: ReadmePanelContentProps) { const { t } = useTranslation() const language = useLanguage() const pluginUniqueIdentifier = detail.plugin_unique_identifier || '' const { data: readmeData, isLoading, error } = usePluginReadme({ plugin_unique_identifier: pluginUniqueIdentifier, language: language === 'zh-Hans' ? undefined : language, }) let readmeContent: ReactNode if (isLoading) { readmeContent = (
) } else if (error) { readmeContent = (

{t('readmeInfo.failedToFetch', { ns: 'plugin' })}

) } else if (readmeData?.readme) { readmeContent = ( ) } else { readmeContent = (

{t('readmeInfo.noReadmeAvailable', { ns: 'plugin' })}

) } return (
{closeButton}
{readmeContent}
) }