Improve preview panel performance

This commit is contained in:
Jack251970 2025-06-05 11:18:07 +08:00
parent 4cd08917cf
commit e61151dc43
2 changed files with 14 additions and 3 deletions

View file

@ -117,7 +117,7 @@
HorizontalAlignment="Right"
VerticalAlignment="Top"
Style="{DynamicResource PreviewItemSubTitleStyle}"
Text="{Binding FileSize, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"
Text="{Binding FileSize, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Mode=OneWay}"
TextWrapping="Wrap"
Visibility="{Binding FileSizeVisibility, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" />

View file

@ -20,7 +20,7 @@ public partial class PreviewPanel : UserControl, INotifyPropertyChanged
private static readonly string ClassName = nameof(PreviewPanel);
private string FilePath { get; }
public string FileSize { get; } = "";
public string FileSize { get; private set; } = Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown");
public string CreatedAt { get; } = "";
public string LastModifiedAt { get; } = "";
private ImageSource _previewImage = new BitmapImage();
@ -63,7 +63,18 @@ public partial class PreviewPanel : UserControl, INotifyPropertyChanged
if (Settings.ShowFileSizeInPreviewPanel)
{
FileSize = type == ResultType.File ? GetFileSize(filePath) : GetFolderSize(filePath);
if (type == ResultType.File)
{
FileSize = GetFileSize(filePath);
}
else
{
_ = Task.Run(() =>
{
FileSize = GetFolderSize(filePath);
OnPropertyChanged(nameof(FileSize));
}).ConfigureAwait(false);
}
}
if (Settings.ShowCreatedDateInPreviewPanel)