perf: add supports for showing multilingual plugin README

This commit is contained in:
Junyan Qin
2025-11-21 12:14:04 +08:00
parent b75ec9e989
commit 6c03a1dd31
3 changed files with 27 additions and 3 deletions
@@ -11,7 +11,7 @@ import { useTranslation } from 'react-i18next';
import { toast } from 'sonner';
import { PluginV4 } from '@/app/infra/entities/plugin';
import { getCloudServiceClientSync } from '@/app/infra/http';
import { extractI18nObject } from '@/i18n/I18nProvider';
import { extractI18nObject, getAPILanguageCode } from '@/i18n/I18nProvider';
import PluginComponentList from '@/app/home/plugins/components/plugin-installed/PluginComponentList';
interface PluginDetailDialogProps {
@@ -54,11 +54,16 @@ export default function PluginDetailDialog({
);
setPlugin(detailResponse.plugin);
// 获取README
// 获取README,根据当前语言设置传递language参数
setIsLoadingReadme(true);
try {
const languageCode = getAPILanguageCode();
const readmeResponse =
await getCloudServiceClientSync().getPluginREADME(author, pluginName);
await getCloudServiceClientSync().getPluginREADME(
author,
pluginName,
languageCode,
);
setReadme(readmeResponse.readme);
} catch (error) {
console.warn('Failed to load README:', error);
@@ -61,9 +61,11 @@ export class CloudServiceClient extends BaseHttpClient {
public getPluginREADME(
author: string,
pluginName: string,
language?: string,
): Promise<{ readme: string }> {
return this.get<{ readme: string }>(
`/api/v1/marketplace/plugins/${author}/${pluginName}/resources/README`,
language ? { language } : undefined,
);
}