Przeglądaj źródła

优化更新通知组件的版本内容提取逻辑,支持新的版本公告格式,并添加备用正则以处理匹配失败的情况。同时,更新文档中的版本公告格式以包含图标。

刘博博 1 miesiąc temu
rodzic
commit
6c09b1474b

+ 11 - 5
src/help/components/UpdateNotification/UpdateNotification.tsx

@@ -33,17 +33,23 @@ const UpdateNotification: React.FC<UpdateNotificationProps> = ({ version }) => {
       import('../../docs/update-history/index.md?raw')
         .then((module) => {
           const fullContent = module.default;
-          // 提取第一个版本的内容(从第一个 ## 📅 到下一个 --- 之间的内容)
-          const versionRegex = /##\s+📅.*?\n\n([\s\S]*?)(?=\n---)/;
+          // 提取第一个版本的内容(从第一个 ## <CalendarOutlined /> 到下一个 <hr 之间的内容)
+          const versionRegex = /##\s+<CalendarOutlined\s*\/>\s+\d{4}-\d{2}-\d{2}\s+版本公告\s+\([^)]+\)\s*\n([\s\S]*?)(?=<hr\s+style=|$)/;
           const match = fullContent.match(versionRegex);
           
           if (match && match[1]) {
             // 只取内容部分,不包括版本标题
             setContent(match[1].trim());
           } else {
-            // 如果匹配失败,显示整个文档
-            console.warn('无法提取最新版本内容,显示完整文档');
-            setContent(fullContent);
+            // 如果匹配失败,尝试备用正则
+            const fallbackRegex = /##\s+.*?\d{4}-\d{2}-\d{2}\s+版本公告.*?\n([\s\S]*?)(?=<hr\s+style=|##\s+|$)/;
+            const fallbackMatch = fullContent.match(fallbackRegex);
+            if (fallbackMatch && fallbackMatch[1]) {
+              setContent(fallbackMatch[1].trim());
+            } else {
+              console.warn('无法提取最新版本内容,显示完整文档');
+              setContent(fullContent);
+            }
           }
           
           setTimeout(() => {

+ 2 - 2
src/help/docs/update-history/index.md

@@ -3,7 +3,7 @@
 
 <hr style="margin: 48px 0; border-top: 1px solid #f5f5f5;"/>
 
-## 2025-12-11 版本公告 (v1.2)
+## <CalendarOutlined /> 2025-12-11 版本公告 (v1.2)
 本次更新涉及知识库中的一些功能改进,解决了使用过程中的一些体验问题。
 
 ### 【最新活动】
@@ -73,7 +73,7 @@
 
 <hr style="margin: 48px 0; border-top: 1px solid #f5f5f5;"/>
 
-## 2025-11-04 版本公告 (v1.1)
+## <CalendarOutlined /> 2025-11-04 版本公告 (v1.1)
 
 
 ### 【新增功能】