fix(web): improve version card content rendering with HTML support
- Add parseContent method to handle newline and HTML tag conversion - Update upgradePosition paragraph to use dangerouslySetInnerHTML for proper HTML rendering - Update coreUpgrades list items to render HTML content instead of plain text - Improve code formatting and readability with consistent className styling - Enable proper display of formatted content with line breaks and HTML elements in version information
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
* @Author: yujiangping
|
* @Author: yujiangping
|
||||||
* @Date: 2026-01-12 16:34:59
|
* @Date: 2026-01-12 16:34:59
|
||||||
* @LastEditors: yujiangping
|
* @LastEditors: yujiangping
|
||||||
* @LastEditTime: 2026-01-16 15:38:35
|
* @LastEditTime: 2026-01-23 19:07:36
|
||||||
*/
|
*/
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
@@ -23,6 +23,13 @@ const GuideCard: React.FC = () => {
|
|||||||
return currentLang === 'zh' ? versionInfo.introduction : (versionInfo.introduction_en || versionInfo.introduction);
|
return currentLang === 'zh' ? versionInfo.introduction : (versionInfo.introduction_en || versionInfo.introduction);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 解析换行符和HTML的方法
|
||||||
|
const parseContent = (text: string) => {
|
||||||
|
if (!text) return '';
|
||||||
|
// 将 \n 转换为 <br/> 标签
|
||||||
|
return text.replace(/\\n/g, '<br/>');
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchVersion = async () => {
|
const fetchVersion = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -58,13 +65,16 @@ const GuideCard: React.FC = () => {
|
|||||||
{t('version.name')}: {introduction.codeName}
|
{t('version.name')}: {introduction.codeName}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<p className='rb:text-sm rb:text-[#5B6167] rb:leading-5 rb:mt-2 '>
|
<p
|
||||||
{introduction.upgradePosition}
|
className='rb:text-sm rb:text-[#5B6167] rb:leading-5 rb:mt-2'
|
||||||
</p>
|
dangerouslySetInnerHTML={{ __html: introduction.upgradePosition }}
|
||||||
|
/>
|
||||||
{introduction.coreUpgrades?.map((item: string, index: number) => (
|
{introduction.coreUpgrades?.map((item: string, index: number) => (
|
||||||
<p key={index} className='rb:text-sm rb:text-[#5B6167] rb:leading-5'>
|
<p
|
||||||
{index + 1}. {item}
|
key={index}
|
||||||
</p>
|
className='rb:text-sm rb:text-[#5B6167] rb:leading-5'
|
||||||
|
dangerouslySetInnerHTML={{ __html: item }}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</>) : null;
|
</>) : null;
|
||||||
})()}
|
})()}
|
||||||
|
|||||||
Reference in New Issue
Block a user