diff --git a/web/src/app/home/plugins/components/plugin-market/plugin-detail-dialog/PluginDetailDialog.tsx b/web/src/app/home/plugins/components/plugin-market/plugin-detail-dialog/PluginDetailDialog.tsx index 4421d972..87d20d96 100644 --- a/web/src/app/home/plugins/components/plugin-market/plugin-detail-dialog/PluginDetailDialog.tsx +++ b/web/src/app/home/plugins/components/plugin-market/plugin-detail-dialog/PluginDetailDialog.tsx @@ -228,6 +228,30 @@ export default function PluginDetailDialog({ {...props} /> ), + h3: ({ ...props }) => ( +

+ ), + h4: ({ ...props }) => ( +

+ ), + h5: ({ ...props }) => ( +

+ ), + h6: ({ ...props }) => ( +
+ ), p: ({ ...props }) => (

), @@ -274,6 +298,57 @@ export default function PluginDetailDialog({ {...props} /> ), + // 图片组件 - 转换本地路径为API路径 + img: ({ src, alt, ...props }) => { + // 处理图片路径 + let imageSrc = src || ''; + + // 确保 src 是字符串类型 + if (typeof imageSrc !== 'string') { + return ( + {alt + ); + } + + // 如果是相对路径,转换为API路径 + if ( + imageSrc && + !imageSrc.startsWith('http://') && + !imageSrc.startsWith('https://') && + !imageSrc.startsWith('data:') + ) { + // 移除开头的 ./ 或 / (支持多个前缀) + imageSrc = imageSrc.replace(/^(\.\/|\/)+/, ''); + + // 如果路径以 assets/ 开头,直接使用 + // 否则假设它在 assets/ 目录下 + if (!imageSrc.startsWith('assets/')) { + imageSrc = `assets/${imageSrc}`; + } + + // 移除 assets/ 前缀以构建API URL + const assetPath = imageSrc.replace(/^assets\//, ''); + imageSrc = getCloudServiceClientSync().getPluginAssetURL( + author!, + pluginName!, + assetPath, + ); + } + + return ( + {alt + ); + }, }} > {readme} diff --git a/web/src/app/infra/http/CloudServiceClient.ts b/web/src/app/infra/http/CloudServiceClient.ts index f7491d5a..401f664a 100644 --- a/web/src/app/infra/http/CloudServiceClient.ts +++ b/web/src/app/infra/http/CloudServiceClient.ts @@ -69,6 +69,14 @@ export class CloudServiceClient extends BaseHttpClient { return `${this.baseURL}/api/v1/marketplace/plugins/${author}/${name}/resources/icon`; } + public getPluginAssetURL( + author: string, + pluginName: string, + filepath: string, + ): string { + return `${this.baseURL}/api/v1/marketplace/plugins/${author}/${pluginName}/resources/assets/${filepath}`; + } + public getPluginMarketplaceURL(author: string, name: string): string { return `${this.baseURL}/market?author=${author}&plugin=${name}`; }