Fix #5191: trigger event when folder changed.

This commit is contained in:
Ben
2025-03-25 22:23:51 +08:00
parent 810a3e0171
commit 8376f98f21

View File

@ -163,6 +163,13 @@
[Parameter] [Parameter]
public EventCallback<int> OnUpload { get; set; } // optional - executes a method in the calling component when a file is uploaded public EventCallback<int> OnUpload { get; set; } // optional - executes a method in the calling component when a file is uploaded
[Parameter]
public EventCallback<int> OnSelectFolder { get; set; } // optional - executes a method in the calling component when a folder is selected
[Parameter]
public EventCallback<int> OnSelectFile { get; set; } // optional - executes a method in the calling component when a file is selected
[Obsolete("Use OnSelectFile instead.")]
[Parameter] [Parameter]
public EventCallback<int> OnSelect { get; set; } // optional - executes a method in the calling component when a file is selected public EventCallback<int> OnSelect { get; set; } // optional - executes a method in the calling component when a file is selected
@ -300,6 +307,8 @@
FileId = -1; FileId = -1;
_file = null; _file = null;
_image = string.Empty; _image = string.Empty;
await OnSelectFolder.InvokeAsync(FolderId);
StateHasChanged(); StateHasChanged();
} }
catch (Exception ex) catch (Exception ex)
@ -316,6 +325,7 @@
FileId = int.Parse((string)e.Value); FileId = int.Parse((string)e.Value);
await SetImage(); await SetImage();
await OnSelect.InvokeAsync(FileId); await OnSelect.InvokeAsync(FileId);
await OnSelectFile.InvokeAsync(FileId);
StateHasChanged(); StateHasChanged();
} }
@ -439,6 +449,7 @@
FileId = file.FileId; FileId = file.FileId;
await SetImage(); await SetImage();
await OnSelect.InvokeAsync(FileId); await OnSelect.InvokeAsync(FileId);
await OnSelectFile.InvokeAsync(FileId);
await OnUpload.InvokeAsync(FileId); await OnUpload.InvokeAsync(FileId);
} }
await GetFiles(); await GetFiles();
@ -490,6 +501,7 @@
FileId = -1; FileId = -1;
await SetImage(); await SetImage();
await OnSelect.InvokeAsync(FileId); await OnSelect.InvokeAsync(FileId);
await OnSelectFile.InvokeAsync(FileId);
StateHasChanged(); StateHasChanged();
} }
catch (Exception ex) catch (Exception ex)