mirror of
https://github.com/real-zony/ZonyLrcToolsX.git
synced 2026-11-24 03:37:47 +08:00
歌词页原先只能扫本地目录。CLI 有三种来源 —— 本地、CSV、网易云歌单 —— 而 网易云那条路在界面上完全走不通。 现在页面有一个来源下拉,以及三行互斥的输入: 本地文件夹 —— 沿用目录选择器 CSV 文件 —— 选一个"歌名,歌手"两列的 .csv 网易云 —— 粘贴一个或多个歌单 ID,用分号分隔 因为网易云那条路需要已登录的会话,这个提交同时加上二维码登录对话框: - QrCodeLoginViewModel 用 QRCoder 把二维码内容渲染成真正的 PNG(CLI 是往日志里 画 ASCII 艺术,在窗口里没法用),下方显示登录状态:等待扫码、已扫码待确认、 成功。 - 关闭对话框即取消登录,而这次能真的停下来,因为扫描器已经接受 CancellationToken(上一个提交)。 - cookie 持久化到 netease.session.json,重启不必重新扫码。页面显示当前是否 已登录:未登录给"登录…"按钮,已登录给"退出登录",退出会同时清掉内存里的 cookie 和文件,下次解析歌单重新扫码。 - 非本地来源还需要指定 .lrc 的落盘目录,因此多一行输出目录,默认 <音乐>/DownloadedLrc。 扫描与下载拆成两步:"解析"把来源返回的歌曲填进表格,"开始下载"才写文件。 进度、逐行状态与取消按钮对三种来源一视同仁。
329 lines
16 KiB
XML
329 lines
16 KiB
XML
<UserControl xmlns="https://github.com/avaloniaui"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:vm="using:ZonyLrcTools.Desktop.ViewModels"
|
|
xmlns:loc="using:ZonyLrcTools.Desktop.Infrastructure.Localization"
|
|
x:Class="ZonyLrcTools.Desktop.Views.Pages.LyricsDownloadPage"
|
|
x:DataType="vm:LyricsDownloadViewModel">
|
|
|
|
<Grid RowDefinitions="Auto,Auto,*,Auto">
|
|
<!-- Title -->
|
|
<StackPanel Grid.Row="0" Margin="0,0,0,20">
|
|
<TextBlock Text="{Binding LyricsTitle}"
|
|
FontSize="24"
|
|
FontWeight="Bold" />
|
|
<TextBlock Text="{Binding LyricsDescription}"
|
|
FontSize="13"
|
|
Opacity="0.6"
|
|
Margin="0,4,0,0" />
|
|
</StackPanel>
|
|
|
|
<!-- Card 1: Form Controls -->
|
|
<Border Grid.Row="1"
|
|
Background="{DynamicResource CardBackgroundBrush}"
|
|
CornerRadius="8"
|
|
BoxShadow="0 2 8 0 #0D000000"
|
|
Padding="24,20"
|
|
Margin="0,0,0,16">
|
|
<StackPanel Spacing="0">
|
|
|
|
<!-- Source selector -->
|
|
<Grid ColumnDefinitions="Auto,*,Auto">
|
|
<TextBlock Grid.Column="0"
|
|
Text="{Binding LyricsScannerLabel}"
|
|
VerticalAlignment="Center"
|
|
FontSize="13"
|
|
FontWeight="Medium" />
|
|
<ComboBox Grid.Column="1"
|
|
ItemsSource="{Binding ScannerNames}"
|
|
SelectedIndex="{Binding SelectedScannerIndex}"
|
|
MinWidth="200"
|
|
HorizontalAlignment="Left"
|
|
Margin="16,0" />
|
|
<Button Grid.Column="2"
|
|
Content="{Binding LyricsScan}"
|
|
Command="{Binding StartScanCommand}"
|
|
IsEnabled="{Binding CanScan}"
|
|
MinWidth="88" />
|
|
</Grid>
|
|
|
|
<Border Height="1"
|
|
Background="{DynamicResource SeparatorBrush}"
|
|
Opacity="0.5"
|
|
Margin="0,16" />
|
|
|
|
<!-- Input row: switches with the selected scanner -->
|
|
<Grid ColumnDefinitions="Auto,*,Auto" IsVisible="{Binding IsLocalScanner}">
|
|
<TextBlock Grid.Column="0"
|
|
Text="{Binding LyricsFolderLabel}"
|
|
VerticalAlignment="Center"
|
|
FontSize="13"
|
|
FontWeight="Medium" />
|
|
<TextBox Grid.Column="1"
|
|
Text="{Binding SelectedFolderPath}"
|
|
Watermark="{Binding LyricsSelectFolder}"
|
|
IsReadOnly="True"
|
|
Margin="16,0" />
|
|
<Button Grid.Column="2"
|
|
Content="{Binding LyricsBrowse}"
|
|
Command="{Binding SelectFolderCommand}"
|
|
MinWidth="88"
|
|
HorizontalAlignment="Stretch" />
|
|
</Grid>
|
|
|
|
<Grid ColumnDefinitions="Auto,*,Auto" IsVisible="{Binding IsCsvScanner}">
|
|
<TextBlock Grid.Column="0"
|
|
Text="{Binding LyricsCsvLabel}"
|
|
VerticalAlignment="Center"
|
|
FontSize="13"
|
|
FontWeight="Medium" />
|
|
<TextBox Grid.Column="1"
|
|
Text="{Binding SelectedCsvFilePath}"
|
|
Watermark="{Binding LyricsCsvSelect}"
|
|
IsReadOnly="True"
|
|
Margin="16,0" />
|
|
<Button Grid.Column="2"
|
|
Content="{Binding LyricsCsvBrowse}"
|
|
Command="{Binding SelectCsvFileCommand}"
|
|
MinWidth="88"
|
|
HorizontalAlignment="Stretch" />
|
|
</Grid>
|
|
|
|
<StackPanel Spacing="8" IsVisible="{Binding IsNetEaseScanner}">
|
|
<Grid ColumnDefinitions="Auto,*,Auto">
|
|
<TextBlock Grid.Column="0"
|
|
Text="{Binding LyricsSongListLabel}"
|
|
VerticalAlignment="Center"
|
|
FontSize="13"
|
|
FontWeight="Medium" />
|
|
<TextBox Grid.Column="1"
|
|
Text="{Binding SongListIds}"
|
|
Watermark="{Binding LyricsSongListWatermark}"
|
|
Margin="16,0" />
|
|
<Button Grid.Column="2"
|
|
Classes="accent"
|
|
Content="{Binding NetEaseSignIn}"
|
|
Command="{Binding SignInNetEaseCommand}"
|
|
ToolTip.Tip="{Binding NetEaseSignInHint}"
|
|
IsVisible="{Binding !IsNetEaseLoggedIn}"
|
|
MinWidth="88" />
|
|
<Button Grid.Column="2"
|
|
Content="{Binding NetEaseSignOut}"
|
|
Command="{Binding SignOutNetEaseCommand}"
|
|
ToolTip.Tip="{Binding NetEaseSignOutHint}"
|
|
IsVisible="{Binding IsNetEaseLoggedIn}"
|
|
MinWidth="88" />
|
|
</Grid>
|
|
|
|
<!-- Account state stays visible even when this scanner is not selected, so the
|
|
sign-out entry is no longer hidden behind one dropdown value. -->
|
|
<Grid ColumnDefinitions="Auto,*,Auto">
|
|
<PathIcon Grid.Column="0"
|
|
Data="{StaticResource AccountIcon}"
|
|
Width="13"
|
|
Height="13"
|
|
VerticalAlignment="Center"
|
|
Opacity="0.55" />
|
|
<TextBlock Grid.Column="1"
|
|
Text="{Binding NetEaseAccountStatus}"
|
|
Margin="8,0,0,0"
|
|
FontSize="12"
|
|
Opacity="0.6"
|
|
TextWrapping="Wrap"
|
|
VerticalAlignment="Center" />
|
|
</Grid>
|
|
</StackPanel>
|
|
|
|
<!-- Output directory (only meaningful for csv / netease, but harmless for local) -->
|
|
<Grid ColumnDefinitions="Auto,*,Auto"
|
|
Margin="0,12,0,0"
|
|
IsVisible="{Binding !IsLocalScanner}">
|
|
<TextBlock Grid.Column="0"
|
|
Text="{Binding LyricsOutputLabel}"
|
|
VerticalAlignment="Center"
|
|
FontSize="13"
|
|
FontWeight="Medium" />
|
|
<TextBox Grid.Column="1"
|
|
Text="{Binding OutputDirectory}"
|
|
Watermark="{Binding LyricsOutputSelect}"
|
|
IsReadOnly="True"
|
|
Margin="16,0" />
|
|
<Button Grid.Column="2"
|
|
Content="{Binding LyricsOutputBrowse}"
|
|
Command="{Binding SelectOutputFolderCommand}"
|
|
MinWidth="88"
|
|
HorizontalAlignment="Stretch" />
|
|
</Grid>
|
|
|
|
<Border Height="1"
|
|
Background="{DynamicResource SeparatorBrush}"
|
|
Opacity="0.5"
|
|
Margin="0,16" />
|
|
|
|
<!-- Parallel count + download button -->
|
|
<Grid ColumnDefinitions="Auto,*,Auto">
|
|
<TextBlock Grid.Column="0"
|
|
Text="{Binding LyricsParallel}"
|
|
VerticalAlignment="Center"
|
|
FontSize="13"
|
|
FontWeight="Medium" />
|
|
<NumericUpDown Grid.Column="1"
|
|
Value="{Binding ParallelCount}"
|
|
Minimum="1"
|
|
Maximum="32"
|
|
Increment="1"
|
|
Width="100"
|
|
FormatString="0"
|
|
HorizontalAlignment="Left"
|
|
VerticalAlignment="Center"
|
|
Margin="16,0" />
|
|
<StackPanel Grid.Column="2"
|
|
Orientation="Horizontal" Spacing="8">
|
|
<Button Command="{Binding StartDownloadCommand}"
|
|
IsVisible="{Binding !IsDownloading}"
|
|
IsEnabled="{Binding CanStartDownload}"
|
|
Classes="accent"
|
|
MinWidth="132">
|
|
<StackPanel Orientation="Horizontal" Spacing="6">
|
|
<PathIcon Data="{StaticResource DownloadIcon}"
|
|
Width="14" Height="14" />
|
|
<TextBlock Text="{Binding LyricsStartDownload}"
|
|
VerticalAlignment="Center" />
|
|
</StackPanel>
|
|
</Button>
|
|
<Button Command="{Binding CancelDownloadCommand}"
|
|
Content="{Binding LyricsStopDownload}"
|
|
IsVisible="{Binding IsDownloading}"
|
|
MinWidth="108" />
|
|
</StackPanel>
|
|
</Grid>
|
|
|
|
<!-- Scan progress -->
|
|
<StackPanel IsVisible="{Binding IsScanning}"
|
|
Spacing="8" Margin="0,16,0,0">
|
|
<ProgressBar Value="{Binding ScanProgressPercentage}"
|
|
Maximum="100" Height="6" />
|
|
<TextBlock HorizontalAlignment="Center" FontSize="12" Opacity="0.7">
|
|
<Run Text="{Binding LyricsScanning}" />
|
|
<Run Text=" " />
|
|
<Run Text="{Binding ScanProgressCount}" />
|
|
<Run Text=" / " />
|
|
<Run Text="{Binding ScanTotalCount}" />
|
|
</TextBlock>
|
|
</StackPanel>
|
|
|
|
<!-- Download progress -->
|
|
<StackPanel IsVisible="{Binding IsDownloading}"
|
|
Spacing="8" Margin="0,16,0,0">
|
|
<ProgressBar Value="{Binding ProgressPercentage}"
|
|
Maximum="100" Height="6" />
|
|
<TextBlock HorizontalAlignment="Center" FontSize="12" Opacity="0.7">
|
|
<Run Text="{Binding CompletedCount}" />
|
|
<Run Text=" / " />
|
|
<Run Text="{Binding TotalCount}" />
|
|
</TextBlock>
|
|
</StackPanel>
|
|
</StackPanel>
|
|
</Border>
|
|
|
|
<!-- Card 2: File List with Empty State -->
|
|
<Panel Grid.Row="2">
|
|
<Border Background="{DynamicResource CardBackgroundBrush}"
|
|
CornerRadius="8"
|
|
BoxShadow="0 2 8 0 #0D000000"
|
|
ClipToBounds="True">
|
|
<DataGrid ItemsSource="{Binding MusicFiles}"
|
|
AutoGenerateColumns="False"
|
|
IsReadOnly="True"
|
|
GridLinesVisibility="Horizontal"
|
|
BorderThickness="0"
|
|
Background="Transparent">
|
|
<DataGrid.Columns>
|
|
<DataGridTextColumn x:DataType="vm:MusicFileViewModel"
|
|
Header="{loc:Localize Column_SongName}"
|
|
Binding="{Binding Name}"
|
|
Width="*" />
|
|
<DataGridTextColumn x:DataType="vm:MusicFileViewModel"
|
|
Header="{loc:Localize Column_Artist}"
|
|
Binding="{Binding Artist}"
|
|
Width="150" />
|
|
<DataGridTextColumn x:DataType="vm:MusicFileViewModel"
|
|
Header="{loc:Localize Column_FilePath}"
|
|
Binding="{Binding FilePath}"
|
|
Width="250" />
|
|
<DataGridTextColumn x:DataType="vm:MusicFileViewModel"
|
|
Header="{loc:Localize Column_Status}"
|
|
Binding="{Binding StatusMessage}"
|
|
Width="100" />
|
|
</DataGrid.Columns>
|
|
</DataGrid>
|
|
</Border>
|
|
|
|
<!-- Empty State Overlay (Margin top to preserve DataGrid header) -->
|
|
<Border Background="{DynamicResource CardBackgroundBrush}"
|
|
CornerRadius="0,0,8,8"
|
|
Margin="0,36,0,0"
|
|
IsVisible="{Binding HasNoFiles}"
|
|
IsHitTestVisible="False">
|
|
<StackPanel VerticalAlignment="Center"
|
|
HorizontalAlignment="Center"
|
|
Spacing="16">
|
|
<Border Background="{DynamicResource ContentAreaBrush}"
|
|
CornerRadius="4"
|
|
Width="50" Height="40"
|
|
HorizontalAlignment="Center">
|
|
<PathIcon Data="{StaticResource ImageIcon}"
|
|
Width="24" Height="24"
|
|
Opacity="0.3" />
|
|
</Border>
|
|
<TextBlock Text="{Binding EmptyStateText}"
|
|
Opacity="0.4"
|
|
FontSize="13"
|
|
HorizontalAlignment="Center" />
|
|
</StackPanel>
|
|
</Border>
|
|
</Panel>
|
|
|
|
<!-- Card 3: Status Bar -->
|
|
<Border Grid.Row="3"
|
|
Background="{DynamicResource CardBackgroundBrush}"
|
|
BoxShadow="0 2 8 0 #0D000000"
|
|
Padding="24,12"
|
|
Margin="0,16,0,0"
|
|
CornerRadius="8">
|
|
<Grid ColumnDefinitions="Auto,*,Auto,Auto">
|
|
<!-- Total -->
|
|
<StackPanel Grid.Column="0" Orientation="Horizontal" Spacing="4">
|
|
<TextBlock Text="{Binding CommonTotal}" FontSize="13" FontWeight="Medium" />
|
|
<TextBlock Text="{Binding TotalCount}" FontWeight="Bold" FontSize="13" />
|
|
<TextBlock Text="{Binding CommonFiles}" FontSize="13" Opacity="0.7" />
|
|
</StackPanel>
|
|
|
|
<Panel Grid.Column="1" />
|
|
|
|
<!-- Success -->
|
|
<StackPanel Grid.Column="2" Orientation="Horizontal" Spacing="6" Margin="0,0,24,0">
|
|
<Border Width="4" Height="16" CornerRadius="2"
|
|
Background="{DynamicResource SuccessColorBrush}"
|
|
VerticalAlignment="Center" />
|
|
<TextBlock Text="{Binding CommonSuccess}" FontSize="13" />
|
|
<TextBlock Text="{Binding CompletedCount}"
|
|
FontWeight="Bold" FontSize="13"
|
|
Foreground="{DynamicResource SuccessColorBrush}" />
|
|
</StackPanel>
|
|
|
|
<!-- Failed -->
|
|
<StackPanel Grid.Column="3" Orientation="Horizontal" Spacing="6">
|
|
<Border Width="4" Height="16" CornerRadius="2"
|
|
Background="{DynamicResource ErrorColorBrush}"
|
|
VerticalAlignment="Center" />
|
|
<TextBlock Text="{Binding CommonFailed}" FontSize="13" />
|
|
<TextBlock Text="{Binding FailedCount}"
|
|
FontWeight="Bold" FontSize="13"
|
|
Foreground="{DynamicResource ErrorColorBrush}" />
|
|
</StackPanel>
|
|
</Grid>
|
|
</Border>
|
|
</Grid>
|
|
|
|
</UserControl>
|