1313using ColorMC . Gui . UI . Controls ;
1414using ColorMC . Gui . UIBinding ;
1515using ColorMC . Gui . Utils ;
16+ using Markdig ;
1617using CommunityToolkit . Mvvm . ComponentModel ;
1718using CommunityToolkit . Mvvm . Input ;
1819
@@ -87,9 +88,6 @@ public partial class FileItemModel : SelectItemModel
8788 /// </summary>
8889 public bool HaveMcmod { get ; init ; }
8990
90- public string SummaryHtml { get ; private set ; }
91- public string SummaryMarkdown { get ; private set ; }
92-
9391 /// <summary>
9492 /// 星的图标
9593 /// </summary>
@@ -177,12 +175,12 @@ public FileItemModel(CurseForgeListObj.CurseForgeListDataObj data, FileType type
177175 ID = data . Id . ToString ( ) ;
178176 Name = mcmod ? . McmodName ?? data . Name ;
179177 Summary = mcmod ? . McmodText ?? data . Summary ;
180- SummaryOld = data . Summary ;
178+ SummaryOld = Markdown . ToHtml ( data . Summary , new MarkdownPipelineBuilder ( ) . UseAdvancedExtensions ( ) . Build ( ) ) ;
181179 foreach ( var item in data . Authors )
182180 {
183- if ( Authors . Count > 10 )
181+ if ( Authors . Count > 5 )
184182 {
185- Authors . Add ( new AuthorModel ( string . Format ( LanguageUtils . Get ( "App.Text114" ) , data . Authors . Count - 10 ) , null ) ) ;
183+ Authors . Add ( new AuthorModel ( string . Format ( LanguageUtils . Get ( "App.Text114" ) , data . Authors . Count - 5 ) , null ) ) ;
186184 break ;
187185 }
188186 Authors . Add ( new AuthorModel ( item . Name , item . AvatarUrl ) ) ;
@@ -210,8 +208,6 @@ public FileItemModel(CurseForgeListObj.CurseForgeListDataObj data, FileType type
210208 {
211209 IsStar = CollectUtils . IsCollect ( SourceType , data . Id . ToString ( ) ) ;
212210 }
213-
214- LoadBody ( ) ;
215211 }
216212
217213 public FileItemModel ( ModrinthSearchObj . HitObj data , List < ModrinthTeamObj > ? team , ModrinthProjectObj ? project , FileType type , McModSearchItemObj ? mcmod )
@@ -226,7 +222,7 @@ public FileItemModel(ModrinthSearchObj.HitObj data, List<ModrinthTeamObj>? team,
226222 Summary = mcmod ? . McmodText ?? data . Description ;
227223 if ( project != null )
228224 {
229- SummaryOld = project . Body ;
225+ SummaryOld = Markdown . ToHtml ( project . Body , new MarkdownPipelineBuilder ( ) . UseAdvancedExtensions ( ) . Build ( ) ) ;
230226 }
231227 else
232228 {
@@ -236,9 +232,9 @@ public FileItemModel(ModrinthSearchObj.HitObj data, List<ModrinthTeamObj>? team,
236232 {
237233 foreach ( var item in team )
238234 {
239- if ( Authors . Count > 10 )
235+ if ( Authors . Count > 5 )
240236 {
241- Authors . Add ( new AuthorModel ( string . Format ( LanguageUtils . Get ( "App.Text114" ) , team . Count - 10 ) , null ) ) ;
237+ Authors . Add ( new AuthorModel ( string . Format ( LanguageUtils . Get ( "App.Text114" ) , team . Count - 5 ) , null ) ) ;
242238 break ;
243239 }
244240 Authors . Add ( new AuthorModel ( item . User . Username , item . User . AvatarUrl ) ) ;
@@ -263,8 +259,6 @@ public FileItemModel(ModrinthSearchObj.HitObj data, List<ModrinthTeamObj>? team,
263259 {
264260 IsStar = CollectUtils . IsCollect ( SourceType , data . ProjectId ) ;
265261 }
266-
267- LoadBody ( ) ;
268262 }
269263
270264 public FileItemModel ( ModrinthProjectObj data , FileType type , McModSearchItemObj ? mcmod )
@@ -291,8 +285,6 @@ public FileItemModel(ModrinthProjectObj data, FileType type, McModSearchItemObj?
291285 {
292286 IsStar = CollectUtils . IsCollect ( SourceType , data . Id ) ;
293287 }
294-
295- LoadBody ( ) ;
296288 }
297289
298290 public FileItemModel ( McModSearchItemObj data , FileType type )
@@ -302,28 +294,14 @@ public FileItemModel(McModSearchItemObj data, FileType type)
302294 Logo = data . McmodIcon . StartsWith ( "//" ) ? "https:" + data . McmodIcon : data . McmodIcon ;
303295 Name = data . McmodName ;
304296 Summary = data . McmodText ;
297+ SummaryOld = data . McmodText ;
305298 Authors . Add ( new AuthorModel ( data . McmodAuthor , null ) ) ;
306299 FileType = FileType . Mod ;
307300 SourceType = SourceType . McMod ;
308301 ModifiedDate = data . McmodUpdateTime ;
309302
310303 HaveDownload = data . CurseforgeId != null || data . ModrinthId != null ;
311304 IsModPack = type == FileType . ModPack ;
312-
313- LoadBody ( ) ;
314- }
315-
316- private void LoadBody ( )
317- {
318- if ( SummaryOld . StartsWith ( '#' ) )
319- {
320- IsMarkdown = true ;
321- SummaryMarkdown = SummaryOld ;
322- }
323- else
324- {
325- SummaryHtml = SummaryOld ;
326- }
327305 }
328306
329307 partial void OnIsStarChanged ( bool value )
0 commit comments