-
-
Notifications
You must be signed in to change notification settings - Fork 382
feat(EmbedPDF): add EmbedPDF component #7572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,13 +10,6 @@ namespace BootstrapBlazor.Server.Components.Samples; | |||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||
| public partial class EmbedPdfs | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| [Inject, NotNull] | ||||||||||||||||||||||||
| private IWebHostEnvironment? WebHostEnvironment { get; set; } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| [Inject, NotNull] | ||||||||||||||||||||||||
| private DownloadService? DownloadService { get; set; } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| private EmbedPDFTabBarMode _tabBarMode = EmbedPDFTabBarMode.Always; | ||||||||||||||||||||||||
| private EmbedPDFTheme _theme = EmbedPDFTheme.System; | ||||||||||||||||||||||||
| private EmbedPDFScrollStrategy _strategy = EmbedPDFScrollStrategy.Vertical; | ||||||||||||||||||||||||
| private string _url = "./samples/sample.pdf"; | ||||||||||||||||||||||||
|
|
@@ -29,27 +22,8 @@ public partial class EmbedPdfs | |||||||||||||||||||||||
| new SelectedItem("zh-CN", "zh-CN") | ||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| private async Task<Stream> OnGetStreamAsync() | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| await Task.Yield(); | ||||||||||||||||||||||||
| if (string.IsNullOrEmpty(_streamFileName)) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| return Stream.Null; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| var stream = File.OpenRead(Path.Combine(WebHostEnvironment.WebRootPath, "samples", _streamFileName)); | ||||||||||||||||||||||||
| return stream; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| private void GetTestStream() | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| _url = ""; | ||||||||||||||||||||||||
| _streamFileName = "ebook.pdf"; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| private void GetSampleStream() | ||||||||||||||||||||||||
| private async Task OnSetUrl(string fileName) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| _url = ""; | ||||||||||||||||||||||||
| _streamFileName = "sample.pdf"; | ||||||||||||||||||||||||
| _url = $"./samples/{fileName}"; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
Comment on lines
+25
to
28
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Avoid Since private Task OnSetUrl(string fileName)
{
_url = $"./samples/{fileName}";
return Task.CompletedTask;
}
Suggested change
|
||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,6 +146,7 @@ private static string GetFriendlyTypeName(Type type) | |
|
|
||
| return type.Name switch | ||
| { | ||
| "UInt32" => "uint", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Consider handling other unsigned primitive aliases for consistency. Specifically, consider also mapping |
||
| "Int32" => "int", | ||
| "String" => "string", | ||
| "Boolean" => "bool", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method OnSetUrl is marked as async but doesn't contain any await operations. This should be changed to a synchronous method by removing the async keyword and changing the return type from Task to void.