@@ -53,7 +53,7 @@ public override async Task<int> ExecuteAsync(CommandContext context, Settings se
5353 if ( settings . Sources . Length == 1 )
5454 {
5555 var source = settings . Sources [ 0 ] ;
56- var output = settings . Output ?? Path . ChangeExtension ( source , "" ) ;
56+ var output = settings . Output ?? Path . ChangeExtension ( source , null ) ;
5757 await ConvertSingleFile ( source , output , settings ) ;
5858 }
5959 else
@@ -96,39 +96,39 @@ private async Task ConvertMultipleFiles(Settings settings)
9696 {
9797 AnsiConsole . MarkupLine ( $ "[yellow]正在转换 { settings . Sources . Length } 个文件...[/]") ;
9898
99- var table = new Table ( ) ;
100- table . AddColumn ( "文件" ) ;
101- table . AddColumn ( "状态" ) ;
102-
103- foreach ( var source in settings . Sources )
104- {
105- var output = Path . ChangeExtension ( source , "" ) ;
106-
107- try
99+ await AnsiConsole . Progress ( )
100+ . AutoClear ( false )
101+ . Columns (
102+ new TaskDescriptionColumn ( ) ,
103+ new SpinnerColumn ( ) )
104+ . StartAsync ( async ctx =>
108105 {
109- await Task . Run ( ( ) =>
106+ foreach ( var source in settings . Sources )
110107 {
111- Audio . ConvertToMai (
112- srcPath : source ,
113- savePath : output ,
114- padding : settings . Padding
115- ) ;
116- } ) ;
117-
118- table . AddRow (
119- Path . GetFileName ( source ) ,
120- $ "[green]✓ → { Path . GetFileName ( output ) } .acb[/]"
121- ) ;
122- }
123- catch ( Exception ex )
124- {
125- table . AddRow (
126- Path . GetFileName ( source ) ,
127- $ "[red]✗ { ex . Message } [/]"
128- ) ;
129- }
130- }
131-
132- AnsiConsole . Write ( table ) ;
108+ var output = Path . ChangeExtension ( source , null ) ;
109+ var task = ctx . AddTask ( $ "[green]{ Path . GetFileName ( source ) } [/]") ;
110+ task . MaxValue = 100 ;
111+
112+ try
113+ {
114+ task . StartTask ( ) ;
115+ await Task . Run ( ( ) =>
116+ {
117+ Audio . ConvertToMai (
118+ srcPath : source ,
119+ savePath : output ,
120+ padding : settings . Padding
121+ ) ;
122+ } ) ;
123+
124+ task . StopTask ( ) ;
125+ }
126+ catch ( Exception ex )
127+ {
128+ task . Description = $ "[red]{ Path . GetFileName ( source ) } - 失败[/]";
129+ task . StopTask ( ) ;
130+ }
131+ }
132+ } ) ;
133133 }
134134}
0 commit comments