Skip to content

Commit 7e582b2

Browse files
committed
revert: 撤销更新
1 parent a719fcf commit 7e582b2

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</TableColumns>
2020
</Table>
2121
</section>
22-
<ExportPdfButton ElementId="table-9527-01" IsAsync="true" OnBeforeExport="OnBeforeExport" OnAfterDownload="OnAfterDownload" AutoDownload="true" StyleTags="_styleTags"></ExportPdfButton>
22+
<ExportPdfButton ElementId="table-9527-01" IsAsync="true" OnBeforeExport="OnBeforeExport" OnAfterDownload="OnAfterDownload" AutoDownload="true"></ExportPdfButton>
2323
</DemoBlock>
2424

2525
<DemoBlock Title="@Localizer["SelectorTitle"]" Introduction="@Localizer["SelectorIntro"]" Name="Selector">
@@ -41,7 +41,7 @@
4141
</div>
4242
</GroupBox>
4343
</section>
44-
<ExportPdfButton Selector=".table-9527-02" IsAsync="true" OnBeforeExport="OnBeforeExport" OnAfterDownload="OnAfterDownload" AutoDownload="true" FileName="@PdfFileName" StyleTags="_styleTags"></ExportPdfButton>
44+
<ExportPdfButton Selector=".table-9527-02" IsAsync="true" OnBeforeExport="OnBeforeExport" OnAfterDownload="OnAfterDownload" AutoDownload="true" FileName="@PdfFileName"></ExportPdfButton>
4545
</DemoBlock>
4646

4747
<AttributeTable Items="@GetAttributes()" />

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,12 @@ public partial class ExportPdfButtons
3232
[NotNull]
3333
private ToastService? ToastService { get; set; }
3434

35-
[Inject, NotNull]
36-
private NavigationManager? NavigationManager { get; set; }
37-
3835
private Task OnBeforeExport() => ToastService.Information(Localizer["ToastTitle"], Localizer["ToastContent"]);
3936

4037
private static string PdfFileName => $"Pdf-{DateTime.Now:HHmmss}.pdf";
4138

4239
private Task OnAfterDownload(string fileName) => ToastService.Success(Localizer["ToastDownloadTitle"], Localizer["ToastDownloadContent", fileName]);
4340

44-
private List<string> _styleTags = [];
45-
4641
/// <summary>
4742
/// <inheritdoc/>
4843
/// </summary>
@@ -51,11 +46,6 @@ protected override void OnInitialized()
5146
Items = Foo.GenerateFoo(FooLocalizer);
5247
Hobbies = Foo.GenerateHobbies(FooLocalizer);
5348
Model = Foo.Generate(FooLocalizer);
54-
55-
_styleTags.AddRange([
56-
$"{NavigationManager.BaseUri}_content/BootstrapBlazor.FontAwesome/css/font-awesome.min.css",
57-
$"{NavigationManager.BaseUri}_content/BootstrapBlazor/css/bootstrap.blazor.bundle.min.css"
58-
]);
5949
}
6050

6151
private AttributeItem[] GetAttributes() =>

src/BootstrapBlazor/Components/Button/ExportPdfButton.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ public class ExportPdfButton : Button
6767
[Inject, NotNull]
6868
private IHtml2Pdf? Html2PdfService { get; set; }
6969

70+
[Inject, NotNull]
71+
private NavigationManager? NavigationManager { get; set; }
72+
7073
[Inject, NotNull]
7174
private DownloadService? DownloadService { get; set; }
7275

@@ -114,8 +117,21 @@ protected override async Task HandlerClick()
114117
</html>
115118
""";
116119

120+
// 增加网页所需样式表文件
121+
List<string> styles = [
122+
$"{NavigationManager.BaseUri}_content/BootstrapBlazor.FontAwesome/css/font-awesome.min.css",
123+
$"{NavigationManager.BaseUri}_content/BootstrapBlazor/css/bootstrap.blazor.bundle.min.css"
124+
];
125+
if (StyleTags != null)
126+
{
127+
styles.AddRange(StyleTags);
128+
}
129+
130+
// 增加网页所需脚本文件
131+
var scripts = ScriptTags ?? [];
132+
117133
// 生成 Pdf 流
118-
using var stream = await Html2PdfService.PdfStreamFromHtmlAsync(htmlString, StyleTags, ScriptTags);
134+
using var stream = await Html2PdfService.PdfStreamFromHtmlAsync(htmlString, styles, scripts);
119135

120136
if (OnBeforeDownload != null)
121137
{

0 commit comments

Comments
 (0)