Skip to content

Commit 347de00

Browse files
committed
doc: 更新示例
1 parent 39bd834 commit 347de00

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@
22

33
<h3>@Localizer["Html2ImageTitle"]</h3>
44

5-
<h4>@Localizer["Html2ImageDescription"]</h4>
6-
7-
<Tips>
8-
<div>@((MarkupString)Localizer["Html2ImageNote"].Value)</div>
9-
</Tips>
5+
<h4>@Localizer["Html2ImageIntro"]</h4>
106

117
<DemoBlock Title="@Localizer["Html2ImageElementTitle"]" Introduction="@Localizer["Html2ImageElementIntro"]" Name="Normal">
12-
<section ignore>
13-
<p>@((MarkupString)Localizer["Html2ImageElementDesc"].Value)</p>
14-
<Button OnClickWithoutRender="OnExportAsync" Text="@Localizer["ExportButtonText"]" Icon="@_exportIcon"></Button>
15-
</section>
8+
<Button OnClickWithoutRender="OnExportAsync" Text="@Localizer["Html2ImageButtonText"]" Icon="fa-solid fa-image"></Button>
169
<Table TItem="Foo" Items="@Items.Take(3)" Id="table-9527">
1710
<TableColumns>
1811
<TableColumn @bind-Field="@context.DateTime" Width="180" />
1912
<TableColumn @bind-Field="@context.Name" Sortable="true" Filterable="true" />
2013
<TableColumn @bind-Field="@context.Address" />
2114
</TableColumns>
2215
</Table>
16+
@if (!string.IsNullOrEmpty(_imageData))
17+
{
18+
<section ignore>
19+
<img src="@_imageData" class="w-100" />
20+
</section>
21+
}
2322
</DemoBlock>

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public partial class Html2Images
2727

2828
[Inject]
2929
[NotNull]
30-
private IStringLocalizer<Html2Pdfs>? Localizer { get; set; }
30+
private IStringLocalizer<Html2Images>? Localizer { get; set; }
3131

3232
[Inject]
3333
[NotNull]
@@ -36,7 +36,7 @@ public partial class Html2Images
3636
[NotNull]
3737
private List<Foo>? Items { get; set; }
3838

39-
private string? _exportIcon = "";
39+
private string? _imageData;
4040

4141
/// <summary>
4242
/// <inheritdoc/>
@@ -46,12 +46,11 @@ protected override void OnInitialized()
4646
base.OnInitialized();
4747

4848
Items = Foo.GenerateFoo(LocalizerFoo);
49-
50-
_exportIcon = IconTheme.GetIconByKey(ComponentIcons.TableExportPdfIcon);
5149
}
50+
5251
private async Task OnExportAsync()
5352
{
54-
var stream = await Html2ImageService.GetStreamAsync("#table-9527", new Html2ImageOptions()
53+
_imageData = await Html2ImageService.GetDataAsync("#table-9527", new Html2ImageOptions()
5554
{
5655
//IncludeStyleProperties = [
5756
// $"{NavigationManager.BaseUri}_content/BootstrapBlazor.FontAwesome/css/font-awesome.min.css",
@@ -60,11 +59,13 @@ private async Task OnExportAsync()
6059
// $"{NavigationManager.BaseUri}css/site.css"
6160
//]
6261
});
63-
if (stream != null)
64-
{
65-
var reader = new StreamReader(stream);
66-
var data = await reader.ReadToEndAsync();
67-
reader.Close();
68-
}
62+
StateHasChanged();
63+
64+
//if (stream != null)
65+
//{
66+
// var reader = new StreamReader(stream);
67+
// var data = await reader.ReadToEndAsync();
68+
// reader.Close();
69+
//}
6970
}
7071
}

0 commit comments

Comments
 (0)