22using Spectre . Console ;
33using Spectre . Console . Cli ;
44using System . ComponentModel ;
5+ using MaiChartManager . CLI . Utils ;
56
67namespace MaiChartManager . CLI . Commands ;
78
@@ -59,7 +60,9 @@ await AnsiConsole.Status()
5960 . Spinner ( Spinner . Known . Dots )
6061 . StartAsync ( "正在检测硬件加速..." , async ctx =>
6162 {
63+ TerminalProgress . Set ( TerminalProgress . Status . Indeterminate ) ;
6264 await VideoConvert . CheckHardwareAcceleration ( ) ;
65+ TerminalProgress . Clear ( ) ;
6366 } ) ;
6467
6568 AnsiConsole . MarkupLine ( $ "[green]硬件加速: { VideoConvert . HardwareAcceleration } [/]") ;
@@ -101,15 +104,20 @@ await AnsiConsole.Progress()
101104 {
102105 var task = ctx . AddTask ( $ "[green]转换 { Path . GetFileName ( source ) } [/]") ;
103106 task . MaxValue = 100 ;
107+ TerminalProgress . Set ( TerminalProgress . Status . Indeterminate ) ;
104108
105109 await VideoConvert . ConvertVideoToUsm (
106110 source ,
107111 output ,
108112 noScale : settings . NoScale ,
109113 yuv420p : settings . UseYuv420p ,
110- onProgress : percent => task . Value = percent
111- ) ;
114+ onProgress : percent =>
115+ {
116+ TerminalProgress . Set ( percent ) ;
117+ task . Value = percent ;
118+ } ) ;
112119
120+ TerminalProgress . Clear ( ) ;
113121 task . Value = 100 ;
114122 } ) ;
115123
@@ -129,12 +137,22 @@ await AnsiConsole.Progress()
129137 new SpinnerColumn ( ) )
130138 . StartAsync ( async ctx =>
131139 {
140+ int doneCount = 0 , errorCount = 0 ;
132141 foreach ( var source in settings . Sources )
133142 {
134143 var output = Path . ChangeExtension ( source , ".dat" ) ;
135144 var task = ctx . AddTask ( $ "[green]{ Path . GetFileName ( source ) } [/]") ;
136145 task . MaxValue = 100 ;
137146
147+ if ( errorCount > 0 )
148+ {
149+ TerminalProgress . Set ( TerminalProgress . Status . Warning , ( errorCount + doneCount ) * 100 / settings . Sources . Length ) ;
150+ }
151+ else
152+ {
153+ TerminalProgress . Set ( doneCount * 100 / settings . Sources . Length ) ;
154+ }
155+
138156 try
139157 {
140158 await VideoConvert . ConvertVideoToUsm (
@@ -145,17 +163,18 @@ await VideoConvert.ConvertVideoToUsm(
145163 onProgress : percent => task . Value = percent
146164 ) ;
147165
166+ doneCount ++ ;
148167 task . Value = 100 ;
149- AnsiConsole . MarkupLine ( $ "[green]✓ { Path . GetFileName ( source ) } → { Path . GetFileName ( output ) } [/]") ;
150168 }
151169 catch ( Exception ex )
152170 {
171+ errorCount ++ ;
153172 task . Description = $ "[red]{ Path . GetFileName ( source ) } - 失败[/]";
154173 task . Value = 100 ;
155174 task . StopTask ( ) ;
156- AnsiConsole . MarkupLine ( $ "[red]✗ 转换失败 { Path . GetFileName ( source ) } : { ex . Message } [/]") ;
157175 }
158176 }
177+ TerminalProgress . Clear ( ) ;
159178 } ) ;
160179 }
161180}
0 commit comments