Skip to content

Commit 665c2a0

Browse files
authored
feat(EmbedPDF): add EmbedPDF component (#7572)
* doc: 增加 new 标签 * doc: 更新示例 * feat(EmbedPDF): add EmbedPDF component * refactor: 增加数据类型翻译
1 parent 56ff312 commit 665c2a0

5 files changed

Lines changed: 12 additions & 36 deletions

File tree

src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<PackageReference Include="BootstrapBlazor.Dom2Image" Version="10.0.1" />
3939
<PackageReference Include="BootstrapBlazor.DriverJs" Version="10.0.1" />
4040
<PackageReference Include="BootstrapBlazor.ElementIcon" Version="10.0.0" />
41-
<PackageReference Include="BootstrapBlazor.EmbedPDF" Version="10.0.0-beta04" />
41+
<PackageReference Include="BootstrapBlazor.EmbedPDF" Version="10.0.0" />
4242
<PackageReference Include="BootstrapBlazor.FileViewer" Version="10.0.0" />
4343
<PackageReference Include="BootstrapBlazor.FluentSystemIcon" Version="10.0.0" />
4444
<PackageReference Include="BootstrapBlazor.FontAwesome" Version="10.0.0" />

src/BootstrapBlazor.Server/Components/Samples/EmbedPdfs.razor

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@
2121
<Select @bind-Value="_language" Items="_languages"></Select>
2222
</BootstrapInputGroup>
2323
</div>
24-
<div class="col-12 col-sm-6">
25-
<BootstrapInputGroup>
26-
<BootstrapInputGroupLabel>TabBarMode</BootstrapInputGroupLabel>
27-
<Select @bind-Value="_tabBarMode"></Select>
28-
</BootstrapInputGroup>
29-
</div>
3024
<div class="col-12 col-sm-6">
3125
<BootstrapInputGroup>
3226
<BootstrapInputGroupLabel>Theme</BootstrapInputGroupLabel>
@@ -39,8 +33,14 @@
3933
<Select @bind-Value="_strategy"></Select>
4034
</BootstrapInputGroup>
4135
</div>
36+
<div class="col-12">
37+
<Button OnClick="@(() => OnSetUrl("sample.pdf"))" Text="Sample.Pdf"></Button>
38+
<Button OnClick="@(() => OnSetUrl("ebook.pdf"))" Text="EBook.Pdf" class="ms-3"></Button>
39+
</div>
4240
</div>
4341
</section>
4442
<EmbedPDF Url="@_url" ViewHeight="600px" Language="@_language"
45-
TabBarMode="_tabBarMode" Theme="_theme" ScrollStrategy="_strategy"></EmbedPDF>
43+
Theme="_theme" ScrollStrategy="_strategy"></EmbedPDF>
4644
</DemoBlock>
45+
46+
<AttributeTable Type="typeof(EmbedPDF)"></AttributeTable>

src/BootstrapBlazor.Server/Components/Samples/EmbedPdfs.razor.cs

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@ namespace BootstrapBlazor.Server.Components.Samples;
1010
/// </summary>
1111
public partial class EmbedPdfs
1212
{
13-
[Inject, NotNull]
14-
private IWebHostEnvironment? WebHostEnvironment { get; set; }
15-
16-
[Inject, NotNull]
17-
private DownloadService? DownloadService { get; set; }
18-
19-
private EmbedPDFTabBarMode _tabBarMode = EmbedPDFTabBarMode.Always;
2013
private EmbedPDFTheme _theme = EmbedPDFTheme.System;
2114
private EmbedPDFScrollStrategy _strategy = EmbedPDFScrollStrategy.Vertical;
2215
private string _url = "./samples/sample.pdf";
@@ -29,27 +22,8 @@ public partial class EmbedPdfs
2922
new SelectedItem("zh-CN", "zh-CN")
3023
};
3124

32-
private async Task<Stream> OnGetStreamAsync()
33-
{
34-
await Task.Yield();
35-
if (string.IsNullOrEmpty(_streamFileName))
36-
{
37-
return Stream.Null;
38-
}
39-
40-
var stream = File.OpenRead(Path.Combine(WebHostEnvironment.WebRootPath, "samples", _streamFileName));
41-
return stream;
42-
}
43-
44-
private void GetTestStream()
45-
{
46-
_url = "";
47-
_streamFileName = "ebook.pdf";
48-
}
49-
50-
private void GetSampleStream()
25+
private async Task OnSetUrl(string fileName)
5126
{
52-
_url = "";
53-
_streamFileName = "sample.pdf";
27+
_url = $"./samples/{fileName}";
5428
}
5529
}

src/BootstrapBlazor.Server/Extensions/MenusLocalizerExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,7 @@ void AddData(DemoMenuItem item)
800800
},
801801
new()
802802
{
803+
IsNew = true,
803804
Text = Localizer["EmbedPdf"],
804805
Url = "embed-pdf"
805806
},

src/BootstrapBlazor.Server/Services/ComponentAttributeCacheService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ private static string GetFriendlyTypeName(Type type)
146146

147147
return type.Name switch
148148
{
149+
"UInt32" => "uint",
149150
"Int32" => "int",
150151
"String" => "string",
151152
"Boolean" => "bool",

0 commit comments

Comments
 (0)